From 29537504d01c8149b3f9b8173e9ea7b8dfb9303e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Wed, 8 May 2019 11:33:53 +0200 Subject: [PATCH] MOBILE-3014 block: Add Learning plans block feature --- scripts/langindex.json | 1 + src/addon/block/learningplans/lang/en.json | 3 ++ .../learningplans/learningplans.module.ts | 40 +++++++++++++++ .../learningplans/providers/block-handler.ts | 51 +++++++++++++++++++ src/app/app.module.ts | 4 +- src/assets/lang/en.json | 1 + 6 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 src/addon/block/learningplans/lang/en.json create mode 100644 src/addon/block/learningplans/learningplans.module.ts create mode 100644 src/addon/block/learningplans/providers/block-handler.ts diff --git a/scripts/langindex.json b/scripts/langindex.json index b286cb6b5..84401eb7f 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -29,6 +29,7 @@ "addon.block_activitymodules.pluginname": "block_activity_modules", "addon.block_calendarmonth.pluginname": "block_calendar_month", "addon.block_calendarupcoming.pluginname": "block_calendar_upcoming", + "addon.block_learningplans.pluginname": "block_lp", "addon.block_myoverview.all": "block_myoverview", "addon.block_myoverview.favourites": "block_myoverview", "addon.block_myoverview.future": "block_myoverview", diff --git a/src/addon/block/learningplans/lang/en.json b/src/addon/block/learningplans/lang/en.json new file mode 100644 index 000000000..0a7f81e22 --- /dev/null +++ b/src/addon/block/learningplans/lang/en.json @@ -0,0 +1,3 @@ +{ + "pluginname": "Learning plans" +} \ No newline at end of file diff --git a/src/addon/block/learningplans/learningplans.module.ts b/src/addon/block/learningplans/learningplans.module.ts new file mode 100644 index 000000000..167178d70 --- /dev/null +++ b/src/addon/block/learningplans/learningplans.module.ts @@ -0,0 +1,40 @@ +// (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 { AddonBlockLearningPlansHandler } from './providers/block-handler'; +import { CoreBlockComponentsModule } from '@core/block/components/components.module'; + +@NgModule({ + declarations: [ + ], + imports: [ + IonicModule, + CoreBlockComponentsModule, + TranslateModule.forChild() + ], + exports: [ + ], + providers: [ + AddonBlockLearningPlansHandler + ] +}) +export class AddonBlockLearningPlansModule { + constructor(blockDelegate: CoreBlockDelegate, blockHandler: AddonBlockLearningPlansHandler) { + blockDelegate.registerHandler(blockHandler); + } +} diff --git a/src/addon/block/learningplans/providers/block-handler.ts b/src/addon/block/learningplans/providers/block-handler.ts new file mode 100644 index 000000000..fa98be638 --- /dev/null +++ b/src/addon/block/learningplans/providers/block-handler.ts @@ -0,0 +1,51 @@ +// (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 { CoreBlockHandlerData } from '@core/block/providers/delegate'; +import { CoreBlockOnlyTitleComponent } from '@core/block/components/only-title-block/only-title-block'; +import { CoreBlockBaseHandler } from '@core/block/classes/base-block-handler'; + +/** + * Block handler. + */ +@Injectable() +export class AddonBlockLearningPlansHandler extends CoreBlockBaseHandler { + name = 'AddonBlockLearningPlans'; + blockName = 'lp'; + + constructor() { + 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: 'addon.block_learningplans.pluginname', + class: 'addon-block-learning-plans', + component: CoreBlockOnlyTitleComponent, + link: 'AddonCompetencyPlanListPage' + }; + } +} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 8fd2e06d1..6203c9b38 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -94,6 +94,7 @@ import { AddonBlockActivityModulesModule } from '@addon/block/activitymodules/ac import { AddonBlockCalendarMonthModule } from '@addon/block/calendarmonth/calendarmonth.module'; import { AddonBlockCalendarUpcomingModule } from '@addon/block/calendarupcoming/calendarupcoming.module'; import { AddonBlockMyOverviewModule } from '@addon/block/myoverview/myoverview.module'; +import { AddonBlockLearningPlansModule } from '@addon/block/learningplans/learningplans.module'; import { AddonBlockPrivateFilesModule } from '@addon/block/privatefiles/privatefiles.module'; import { AddonBlockSiteMainMenuModule } from '@addon/block/sitemainmenu/sitemainmenu.module'; import { AddonBlockTimelineModule } from '@addon/block/timeline/timeline.module'; @@ -218,8 +219,9 @@ export const CORE_PROVIDERS: any[] = [ AddonBlockActivityModulesModule, AddonBlockCalendarMonthModule, AddonBlockCalendarUpcomingModule, - AddonBlockPrivateFilesModule, + AddonBlockLearningPlansModule, AddonBlockMyOverviewModule, + AddonBlockPrivateFilesModule, AddonBlockSiteMainMenuModule, AddonBlockTimelineModule, AddonBlockRecentlyAccessedCoursesModule, diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index 93cf84463..0ac3f2045 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -29,6 +29,7 @@ "addon.block_activitymodules.pluginname": "Activities", "addon.block_calendarmonth.pluginname": "Calendar", "addon.block_calendarupcoming.pluginname": " Upcoming events", + "addon.block_learningplans.pluginname": "Learning plans", "addon.block_myoverview.all": "All", "addon.block_myoverview.favourites": "Starred", "addon.block_myoverview.future": "Future",