diff --git a/scripts/langindex.json b/scripts/langindex.json index b901aacbb..b803d75bf 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -53,7 +53,8 @@ "addon.block_recentlyaccessedcourses.nocourses": "block_recentlyaccessedcourses", "addon.block_recentlyaccessedcourses.pluginname": "block_recentlyaccessedcourses", "addon.block_recentlyaccesseditems.noitems": "block_recentlyaccesseditems", - "addon.block_recentlyaccesseditems.pluginname": "block_recentlyaccesseditems", + "addon.block_recentactivity.pluginname": "block_recent_activity", + "addon.block_glossaryrandom.pluginname": "block_glossary_random", "addon.block_selfcompletion.pluginname": "block_selfcompletion", "addon.block_sitemainmenu.pluginname": "block_site_main_menu", "addon.block_starredcourses.nocourses": "block_starredcourses", diff --git a/src/addon/block/recentactivity/lang/en.json b/src/addon/block/recentactivity/lang/en.json new file mode 100644 index 000000000..29f7996e2 --- /dev/null +++ b/src/addon/block/recentactivity/lang/en.json @@ -0,0 +1,3 @@ +{ + "pluginname": "Recent activity" +} \ No newline at end of file diff --git a/src/addon/block/recentactivity/providers/block-handler.ts b/src/addon/block/recentactivity/providers/block-handler.ts new file mode 100644 index 000000000..043acd495 --- /dev/null +++ b/src/addon/block/recentactivity/providers/block-handler.ts @@ -0,0 +1,52 @@ +// (C) Copyright 2015 Martin Dougiamas +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { Injectable, Injector } from '@angular/core'; +import { TranslateService } from '@ngx-translate/core'; + +import { CoreBlockHandlerData } from '@core/block/providers/delegate'; +import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block'; +import { CoreBlockBaseHandler } from '@core/block/classes/base-block-handler'; + +/** + * Block handler. + */ +@Injectable() +export class AddonBlockRecentActivityHandler extends CoreBlockBaseHandler { + name = 'AddonBlockRecentActivity'; + blockName = 'recent_activity'; + + constructor(private translate: TranslateService) { + super(); + } + + /** + * Returns the data needed to render the block. + * + * @param {Injector} injector Injector. + * @param {any} block The block to render. + * @param {string} contextLevel The context where the block will be used. + * @param {number} instanceId The instance ID associated with the context level. + * @return {CoreBlockHandlerData|Promise} Data or promise resolved with the data. + */ + getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number) + : CoreBlockHandlerData | Promise { + + return { + title: this.translate.instant('addon.block_recentactivity.pluginname'), + class: 'addon-block-recent-activity', + component: CoreBlockPreRenderedComponent + }; + } +} diff --git a/src/addon/block/recentactivity/recentactivity.module.ts b/src/addon/block/recentactivity/recentactivity.module.ts new file mode 100644 index 000000000..cd0136763 --- /dev/null +++ b/src/addon/block/recentactivity/recentactivity.module.ts @@ -0,0 +1,38 @@ +// (C) Copyright 2015 Martin Dougiamas +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { NgModule } from '@angular/core'; +import { IonicModule } from 'ionic-angular'; +import { TranslateModule } from '@ngx-translate/core'; +import { CoreBlockDelegate } from '@core/block/providers/delegate'; +import { AddonBlockRecentActivityHandler } from './providers/block-handler'; + +@NgModule({ + declarations: [ + ], + imports: [ + IonicModule, + TranslateModule.forChild() + ], + exports: [ + ], + providers: [ + AddonBlockRecentActivityHandler + ] +}) +export class AddonBlockRecentActivityModule { + constructor(blockDelegate: CoreBlockDelegate, blockHandler: AddonBlockRecentActivityHandler) { + blockDelegate.registerHandler(blockHandler); + } +} diff --git a/src/addon/block/recentactivity/recentactivity.scss b/src/addon/block/recentactivity/recentactivity.scss new file mode 100644 index 000000000..0eb73e102 --- /dev/null +++ b/src/addon/block/recentactivity/recentactivity.scss @@ -0,0 +1,20 @@ +.addon-block-recent-activity core-block-pre-rendered { + .core-block-content { + .activitydate, .activityhead { + text-align: center; + } + + .unlist { + list-style: none; + @include margin-horizontal(0); + -webkit-padding-start: 0; + li { + margin-bottom: 1em; + + .head .date { + @include float(end); + } + } + } + } +} \ No newline at end of file diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 10a4b4b1a..cc570b6b2 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -109,6 +109,7 @@ import { AddonBlockSiteMainMenuModule } from '@addon/block/sitemainmenu/sitemain import { AddonBlockTimelineModule } from '@addon/block/timeline/timeline.module'; import { AddonBlockRecentlyAccessedCoursesModule } from '@addon/block/recentlyaccessedcourses/recentlyaccessedcourses.module'; import { AddonBlockRecentlyAccessedItemsModule } from '@addon/block/recentlyaccesseditems/recentlyaccesseditems.module'; +import { AddonBlockRecentActivityModule } from '@addon/block/recentactivity/recentactivity.module'; import { AddonBlockStarredCoursesModule } from '@addon/block/starredcourses/starredcourses.module'; import { AddonBlockSelfCompletionModule } from '@addon/block/selfcompletion/selfcompletion.module'; import { AddonBlockTagsModule } from '@addon/block/tags/tags.module'; @@ -246,6 +247,7 @@ export const CORE_PROVIDERS: any[] = [ AddonBlockTimelineModule, AddonBlockRecentlyAccessedCoursesModule, AddonBlockRecentlyAccessedItemsModule, + AddonBlockRecentActivityModule, AddonBlockStarredCoursesModule, AddonBlockSelfCompletionModule, AddonBlockTagsModule, diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index b96c9a970..69e66a2b3 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -50,6 +50,7 @@ "addon.block_newsitems.pluginname": "Latest announcements", "addon.block_onlineusers.pluginname": "Online users", "addon.block_privatefiles.pluginname": "Private files", + "addon.block_recentactivity.pluginname": "Recent activity", "addon.block_recentlyaccessedcourses.nocourses": "No recent courses", "addon.block_recentlyaccessedcourses.pluginname": "Recently accessed courses", "addon.block_recentlyaccesseditems.noitems": "No recent items",