From da286a80e7cd772d0a4320eaa502ea64e64cc5e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Mon, 7 Dec 2020 17:02:30 +0100 Subject: [PATCH] MOBILE-3608 blocks: Add all only title blocks --- src/addons/addons.module.ts | 14 +++++ .../calendarmonth/calendarmonth.module.ts | 36 +++++++++++ src/addons/block/calendarmonth/lang.json | 3 + .../calendarmonth/services/block-handler.ts | 61 ++++++++++++++++++ .../calendarupcoming.module.ts | 36 +++++++++++ src/addons/block/calendarupcoming/lang.json | 3 + .../services/block-handler.ts | 62 +++++++++++++++++++ src/addons/block/comments/comments.module.ts | 36 +++++++++++ src/addons/block/comments/lang.json | 3 + .../block/comments/services/block-handler.ts | 59 ++++++++++++++++++ .../completionstatus.module.ts | 36 +++++++++++ src/addons/block/completionstatus/lang.json | 3 + .../services/block-handler.ts | 55 ++++++++++++++++ src/addons/block/learningplans/lang.json | 3 + .../learningplans/learningplans.module.ts | 38 ++++++++++++ .../learningplans/services/block-handler.ts | 48 ++++++++++++++ src/addons/block/privatefiles/lang.json | 3 + .../block/privatefiles/privatefiles.module.ts | 36 +++++++++++ .../privatefiles/services/block-handler.ts | 49 +++++++++++++++ src/addons/block/selfcompletion/lang.json | 3 + .../selfcompletion/selfcompletion.module.ts | 36 +++++++++++ .../selfcompletion/services/block-handler.ts | 53 ++++++++++++++++ 22 files changed, 676 insertions(+) create mode 100644 src/addons/block/calendarmonth/calendarmonth.module.ts create mode 100644 src/addons/block/calendarmonth/lang.json create mode 100644 src/addons/block/calendarmonth/services/block-handler.ts create mode 100644 src/addons/block/calendarupcoming/calendarupcoming.module.ts create mode 100644 src/addons/block/calendarupcoming/lang.json create mode 100644 src/addons/block/calendarupcoming/services/block-handler.ts create mode 100644 src/addons/block/comments/comments.module.ts create mode 100644 src/addons/block/comments/lang.json create mode 100644 src/addons/block/comments/services/block-handler.ts create mode 100644 src/addons/block/completionstatus/completionstatus.module.ts create mode 100644 src/addons/block/completionstatus/lang.json create mode 100644 src/addons/block/completionstatus/services/block-handler.ts create mode 100644 src/addons/block/learningplans/lang.json create mode 100644 src/addons/block/learningplans/learningplans.module.ts create mode 100644 src/addons/block/learningplans/services/block-handler.ts create mode 100644 src/addons/block/privatefiles/lang.json create mode 100644 src/addons/block/privatefiles/privatefiles.module.ts create mode 100644 src/addons/block/privatefiles/services/block-handler.ts create mode 100644 src/addons/block/selfcompletion/lang.json create mode 100644 src/addons/block/selfcompletion/selfcompletion.module.ts create mode 100644 src/addons/block/selfcompletion/services/block-handler.ts diff --git a/src/addons/addons.module.ts b/src/addons/addons.module.ts index 9379c35c7..680edb1dd 100644 --- a/src/addons/addons.module.ts +++ b/src/addons/addons.module.ts @@ -19,11 +19,18 @@ import { AddonBlockBadgesModule } from './block/badges/badges.module'; import { AddonBlockBlogMenuModule } from './block/blogmenu/blogmenu.module'; import { AddonBlockBlogRecentModule } from './block/blogrecent/blogrecent.module'; import { AddonBlockBlogTagsModule } from './block/blogtags/blogtags.module'; +import { AddonBlockCalendarMonthModule } from './block/calendarmonth/calendarmonth.module'; +import { AddonBlockCalendarUpcomingModule } from './block/calendarupcoming/calendarupcoming.module'; +import { AddonBlockCommentsModule } from './block/comments/comments.module'; +import { AddonBlockCompletionStatusModule } from './block/completionstatus/completionstatus.module'; import { AddonBlockGlossaryRandomModule } from './block/glossaryrandom/glossaryrandom.module'; import { AddonBlockHtmlModule } from './block/html/html.module'; +import { AddonBlockLearningPlansModule } from './block/learningplans/learningplans.module'; import { AddonBlockNewsItemsModule } from './block/newsitems/newsitems.module'; import { AddonBlockOnlineUsersModule } from './block/onlineusers/onlineusers.module'; +import { AddonBlockPrivateFilesModule } from './block/privatefiles/privatefiles.module'; import { AddonBlockRssClientModule } from './block/rssclient/rssclient.module'; +import { AddonBlockSelfCompletionModule } from './block/selfcompletion/selfcompletion.module'; import { AddonBlockTagsModule } from './block/tags/tags.module'; import { AddonPrivateFilesModule } from './privatefiles/privatefiles.module'; import { AddonFilterModule } from './filter/filter.module'; @@ -38,11 +45,18 @@ import { AddonUserProfileFieldModule } from './userprofilefield/userprofilefield AddonBlockBlogMenuModule, AddonBlockBlogRecentModule, AddonBlockBlogTagsModule, + AddonBlockCalendarMonthModule, + AddonBlockCalendarUpcomingModule, + AddonBlockCommentsModule, + AddonBlockCompletionStatusModule, AddonBlockGlossaryRandomModule, AddonBlockHtmlModule, + AddonBlockLearningPlansModule, AddonBlockNewsItemsModule, AddonBlockOnlineUsersModule, + AddonBlockPrivateFilesModule, AddonBlockRssClientModule, + AddonBlockSelfCompletionModule, AddonBlockTagsModule, AddonUserProfileFieldModule, ], diff --git a/src/addons/block/calendarmonth/calendarmonth.module.ts b/src/addons/block/calendarmonth/calendarmonth.module.ts new file mode 100644 index 000000000..c432e4d0e --- /dev/null +++ b/src/addons/block/calendarmonth/calendarmonth.module.ts @@ -0,0 +1,36 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// 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 { APP_INITIALIZER, NgModule } from '@angular/core'; +import { IonicModule } from '@ionic/angular'; +import { TranslateModule } from '@ngx-translate/core'; +import { CoreBlockDelegate } from '@features/block/services/block-delegate'; +import { AddonBlockCalendarMonthHandler } from './services/block-handler'; + +@NgModule({ + imports: [ + IonicModule, + TranslateModule.forChild(), + ], + providers: [ + { + provide: APP_INITIALIZER, + multi: true, + useValue: () => { + CoreBlockDelegate.instance.registerHandler(AddonBlockCalendarMonthHandler.instance); + }, + }, + ], +}) +export class AddonBlockCalendarMonthModule {} diff --git a/src/addons/block/calendarmonth/lang.json b/src/addons/block/calendarmonth/lang.json new file mode 100644 index 000000000..86a476c29 --- /dev/null +++ b/src/addons/block/calendarmonth/lang.json @@ -0,0 +1,3 @@ +{ + "pluginname": "Calendar" +} \ No newline at end of file diff --git a/src/addons/block/calendarmonth/services/block-handler.ts b/src/addons/block/calendarmonth/services/block-handler.ts new file mode 100644 index 000000000..ed08c724d --- /dev/null +++ b/src/addons/block/calendarmonth/services/block-handler.ts @@ -0,0 +1,61 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// 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 } from '@angular/core'; +import { CoreBlockHandlerData } from '@features/block/services/block-delegate'; +import { CoreBlockOnlyTitleComponent } from '@features/block/components/only-title-block/only-title-block'; +import { CoreBlockBaseHandler } from '@features/block/classes/base-block-handler'; +// import { AddonCalendar } from '@addon/calendar/services/calendar'; +import { CoreCourseBlock } from '@features/course/services/course'; +import { Params } from '@angular/router'; +import { makeSingleton } from '@singletons'; + +/** + * Block handler. + */ +@Injectable({ providedIn: 'root' }) +export class AddonBlockCalendarMonthHandlerService extends CoreBlockBaseHandler { + + name = 'AddonBlockCalendarMonth'; + blockName = 'calendar_month'; + + /** + * Returns the data needed to render the block. + * + * @param block The block to render. + * @param contextLevel The context where the block will be used. + * @param instanceId The instance ID associated with the context level. + * @return Data or promise resolved with the data. + */ + getDisplayData(block: CoreCourseBlock, contextLevel: string, instanceId: number): CoreBlockHandlerData { + // @todo + const link = 'AddonCalendarListPage'; + const linkParams: Params = contextLevel == 'course' ? { courseId: instanceId } : {}; + + /* if (AddonCalendar.instance.canViewMonthInSite()) { + link = 'AddonCalendarIndexPage'; + }*/ + + return { + title: 'addon.block_calendarmonth.pluginname', + class: 'addon-block-calendar-month', + component: CoreBlockOnlyTitleComponent, + link: link, + linkParams: linkParams, + }; + } + +} + +export class AddonBlockCalendarMonthHandler extends makeSingleton(AddonBlockCalendarMonthHandlerService) {} diff --git a/src/addons/block/calendarupcoming/calendarupcoming.module.ts b/src/addons/block/calendarupcoming/calendarupcoming.module.ts new file mode 100644 index 000000000..08884ab7a --- /dev/null +++ b/src/addons/block/calendarupcoming/calendarupcoming.module.ts @@ -0,0 +1,36 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// 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 { APP_INITIALIZER, NgModule } from '@angular/core'; +import { IonicModule } from '@ionic/angular'; +import { TranslateModule } from '@ngx-translate/core'; +import { CoreBlockDelegate } from '@features/block/services/block-delegate'; +import { AddonBlockCalendarUpcomingHandler } from './services/block-handler'; + +@NgModule({ + imports: [ + IonicModule, + TranslateModule.forChild(), + ], + providers: [ + { + provide: APP_INITIALIZER, + multi: true, + useValue: () => { + CoreBlockDelegate.instance.registerHandler(AddonBlockCalendarUpcomingHandler.instance); + }, + }, + ], +}) +export class AddonBlockCalendarUpcomingModule {} diff --git a/src/addons/block/calendarupcoming/lang.json b/src/addons/block/calendarupcoming/lang.json new file mode 100644 index 000000000..4d73d8f67 --- /dev/null +++ b/src/addons/block/calendarupcoming/lang.json @@ -0,0 +1,3 @@ +{ + "pluginname": "Upcoming events" +} \ No newline at end of file diff --git a/src/addons/block/calendarupcoming/services/block-handler.ts b/src/addons/block/calendarupcoming/services/block-handler.ts new file mode 100644 index 000000000..6a5d0bda6 --- /dev/null +++ b/src/addons/block/calendarupcoming/services/block-handler.ts @@ -0,0 +1,62 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// 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 } from '@angular/core'; +import { CoreBlockHandlerData } from '@features/block/services/block-delegate'; +import { CoreBlockOnlyTitleComponent } from '@features/block/components/only-title-block/only-title-block'; +import { CoreBlockBaseHandler } from '@features/block/classes/base-block-handler'; +// import { AddonCalendar } from '@addon/calendar/services/calendar'; +import { CoreCourseBlock } from '@features/course/services/course'; +import { Params } from '@angular/router'; +import { makeSingleton } from '@singletons'; + +/** + * Block handler. + */ +@Injectable({ providedIn: 'root' }) +export class AddonBlockCalendarUpcomingHandlerService extends CoreBlockBaseHandler { + + name = 'AddonBlockCalendarUpcoming'; + blockName = 'calendar_upcoming'; + + /** + * Returns the data needed to render the block. + * + * @param block The block to render. + * @param contextLevel The context where the block will be used. + * @param instanceId The instance ID associated with the context level. + * @return Data or promise resolved with the data. + */ + getDisplayData(block: CoreCourseBlock, contextLevel: string, instanceId: number): CoreBlockHandlerData { + // @todo + const link = 'AddonCalendarListPage'; + const linkParams: Params = contextLevel == 'course' ? { courseId: instanceId } : {}; + + /* if (AddonCalendar.instance.canViewMonthInSite()) { + link = 'AddonCalendarIndexPage'; + linkParams.upcoming = true; + }*/ + + return { + title: 'addon.block_calendarupcoming.pluginname', + class: 'addon-block-calendar-upcoming', + component: CoreBlockOnlyTitleComponent, + link: link, + linkParams: linkParams, + }; + } + +} + +export class AddonBlockCalendarUpcomingHandler extends makeSingleton(AddonBlockCalendarUpcomingHandlerService) {} diff --git a/src/addons/block/comments/comments.module.ts b/src/addons/block/comments/comments.module.ts new file mode 100644 index 000000000..678abdbbb --- /dev/null +++ b/src/addons/block/comments/comments.module.ts @@ -0,0 +1,36 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// 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 { APP_INITIALIZER, NgModule } from '@angular/core'; +import { IonicModule } from '@ionic/angular'; +import { TranslateModule } from '@ngx-translate/core'; +import { CoreBlockDelegate } from '@features/block/services/block-delegate'; +import { AddonBlockCommentsHandler } from './services/block-handler'; + +@NgModule({ + imports: [ + IonicModule, + TranslateModule.forChild(), + ], + providers: [ + { + provide: APP_INITIALIZER, + multi: true, + useValue: () => { + CoreBlockDelegate.instance.registerHandler(AddonBlockCommentsHandler.instance); + }, + }, + ], +}) +export class AddonBlockCommentsModule {} diff --git a/src/addons/block/comments/lang.json b/src/addons/block/comments/lang.json new file mode 100644 index 000000000..adcbcabae --- /dev/null +++ b/src/addons/block/comments/lang.json @@ -0,0 +1,3 @@ +{ + "pluginname": "Comments" +} \ No newline at end of file diff --git a/src/addons/block/comments/services/block-handler.ts b/src/addons/block/comments/services/block-handler.ts new file mode 100644 index 000000000..0a72b3360 --- /dev/null +++ b/src/addons/block/comments/services/block-handler.ts @@ -0,0 +1,59 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// 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 } from '@angular/core'; +import { CoreBlockHandlerData } from '@features/block/services/block-delegate'; +import { CoreBlockOnlyTitleComponent } from '@features/block/components/only-title-block/only-title-block'; +import { CoreBlockBaseHandler } from '@features/block/classes/base-block-handler'; +import { CoreCourseBlock } from '@features/course/services/course'; +import { makeSingleton } from '@singletons'; + +/** + * Block handler. + */ +@Injectable({ providedIn: 'root' }) +export class AddonBlockCommentsHandlerService extends CoreBlockBaseHandler { + + name = 'AddonBlockComments'; + blockName = 'comments'; + + /** + * Returns the data needed to render the block. + * + * @param block The block to render. + * @param contextLevel The context where the block will be used. + * @param instanceId The instance ID associated with the context level. + * @return Data or promise resolved with the data. + */ + getDisplayData(block: CoreCourseBlock, contextLevel: string, instanceId: number): CoreBlockHandlerData { + // @todo + + return { + title: 'addon.block_comments.pluginname', + class: 'addon-block-comments', + component: CoreBlockOnlyTitleComponent, + link: 'CoreCommentsViewerPage', + linkParams: { + contextLevel: contextLevel, + instanceId: instanceId, + componentName: 'block_comments', + area: 'page_comments', + itemId: 0, + }, + }; + } + +} + +export class AddonBlockCommentsHandler extends makeSingleton(AddonBlockCommentsHandlerService) {} diff --git a/src/addons/block/completionstatus/completionstatus.module.ts b/src/addons/block/completionstatus/completionstatus.module.ts new file mode 100644 index 000000000..a57bc8fcc --- /dev/null +++ b/src/addons/block/completionstatus/completionstatus.module.ts @@ -0,0 +1,36 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// 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 { APP_INITIALIZER, NgModule } from '@angular/core'; +import { IonicModule } from '@ionic/angular'; +import { TranslateModule } from '@ngx-translate/core'; +import { CoreBlockDelegate } from '@features/block/services/block-delegate'; +import { AddonBlockCompletionStatusHandler } from './services/block-handler'; + +@NgModule({ + imports: [ + IonicModule, + TranslateModule.forChild(), + ], + providers: [ + { + provide: APP_INITIALIZER, + multi: true, + useValue: () => { + CoreBlockDelegate.instance.registerHandler(AddonBlockCompletionStatusHandler.instance); + }, + }, + ], +}) +export class AddonBlockCompletionStatusModule {} diff --git a/src/addons/block/completionstatus/lang.json b/src/addons/block/completionstatus/lang.json new file mode 100644 index 000000000..fe57356da --- /dev/null +++ b/src/addons/block/completionstatus/lang.json @@ -0,0 +1,3 @@ +{ + "pluginname": "Course completion status" +} \ No newline at end of file diff --git a/src/addons/block/completionstatus/services/block-handler.ts b/src/addons/block/completionstatus/services/block-handler.ts new file mode 100644 index 000000000..00458928d --- /dev/null +++ b/src/addons/block/completionstatus/services/block-handler.ts @@ -0,0 +1,55 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// 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 } from '@angular/core'; +import { CoreBlockHandlerData } from '@features/block/services/block-delegate'; +import { CoreBlockOnlyTitleComponent } from '@features/block/components/only-title-block/only-title-block'; +import { CoreBlockBaseHandler } from '@features/block/classes/base-block-handler'; +import { CoreCourseBlock } from '@features/course/services/course'; +import { makeSingleton } from '@singletons'; + +/** + * Block handler. + */ +@Injectable({ providedIn: 'root' }) +export class AddonBlockCompletionStatusHandlerService extends CoreBlockBaseHandler { + + name = 'AddonBlockCompletionStatus'; + blockName = 'completionstatus'; + + /** + * Returns the data needed to render the block. + * + * @param block The block to render. + * @param contextLevel The context where the block will be used. + * @param instanceId The instance ID associated with the context level. + * @return Data or promise resolved with the data. + */ + getDisplayData(block: CoreCourseBlock, contextLevel: string, instanceId: number): CoreBlockHandlerData { + // @todo + + return { + title: 'addon.block_completionstatus.pluginname', + class: 'addon-block-completion-status', + component: CoreBlockOnlyTitleComponent, + link: 'AddonCourseCompletionReportPage', + linkParams: { + courseId: instanceId, + }, + }; + } + +} + +export class AddonBlockCompletionStatusHandler extends makeSingleton(AddonBlockCompletionStatusHandlerService) {} diff --git a/src/addons/block/learningplans/lang.json b/src/addons/block/learningplans/lang.json new file mode 100644 index 000000000..0a7f81e22 --- /dev/null +++ b/src/addons/block/learningplans/lang.json @@ -0,0 +1,3 @@ +{ + "pluginname": "Learning plans" +} \ No newline at end of file diff --git a/src/addons/block/learningplans/learningplans.module.ts b/src/addons/block/learningplans/learningplans.module.ts new file mode 100644 index 000000000..acf5d32e7 --- /dev/null +++ b/src/addons/block/learningplans/learningplans.module.ts @@ -0,0 +1,38 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// 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 { APP_INITIALIZER, NgModule } from '@angular/core'; +import { IonicModule } from '@ionic/angular'; +import { TranslateModule } from '@ngx-translate/core'; +import { CoreBlockDelegate } from '@features/block/services/block-delegate'; +import { AddonBlockLearningPlansHandler } from './services/block-handler'; +import { CoreBlockComponentsModule } from '@features/block/components/components.module'; + +@NgModule({ + imports: [ + IonicModule, + CoreBlockComponentsModule, + TranslateModule.forChild(), + ], + providers: [ + { + provide: APP_INITIALIZER, + multi: true, + useValue: () => { + CoreBlockDelegate.instance.registerHandler(AddonBlockLearningPlansHandler.instance); + }, + }, + ], +}) +export class AddonBlockLearningPlansModule {} diff --git a/src/addons/block/learningplans/services/block-handler.ts b/src/addons/block/learningplans/services/block-handler.ts new file mode 100644 index 000000000..3340be569 --- /dev/null +++ b/src/addons/block/learningplans/services/block-handler.ts @@ -0,0 +1,48 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// 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 } from '@angular/core'; +import { CoreBlockHandlerData } from '@features/block/services/block-delegate'; +import { CoreBlockOnlyTitleComponent } from '@features/block/components/only-title-block/only-title-block'; +import { CoreBlockBaseHandler } from '@features/block/classes/base-block-handler'; +import { makeSingleton } from '@singletons'; + +/** + * Block handler. + */ +@Injectable({ providedIn: 'root' }) +export class AddonBlockLearningPlansHandlerService extends CoreBlockBaseHandler { + + name = 'AddonBlockLearningPlans'; + blockName = 'lp'; + + /** + * Returns the data needed to render the block. + * + * @return Data or promise resolved with the data. + */ + getDisplayData(): CoreBlockHandlerData { + // @todo + + return { + title: 'addon.block_learningplans.pluginname', + class: 'addon-block-learning-plans', + component: CoreBlockOnlyTitleComponent, + link: 'AddonCompetencyPlanListPage', + }; + } + +} + +export class AddonBlockLearningPlansHandler extends makeSingleton(AddonBlockLearningPlansHandlerService) {} diff --git a/src/addons/block/privatefiles/lang.json b/src/addons/block/privatefiles/lang.json new file mode 100644 index 000000000..bba9d4bc0 --- /dev/null +++ b/src/addons/block/privatefiles/lang.json @@ -0,0 +1,3 @@ +{ + "pluginname": "Private files" +} \ No newline at end of file diff --git a/src/addons/block/privatefiles/privatefiles.module.ts b/src/addons/block/privatefiles/privatefiles.module.ts new file mode 100644 index 000000000..a19075e8f --- /dev/null +++ b/src/addons/block/privatefiles/privatefiles.module.ts @@ -0,0 +1,36 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// 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 { APP_INITIALIZER, NgModule } from '@angular/core'; +import { IonicModule } from '@ionic/angular'; +import { TranslateModule } from '@ngx-translate/core'; +import { CoreBlockDelegate } from '@features/block/services/block-delegate'; +import { AddonBlockPrivateFilesHandler } from './services/block-handler'; + +@NgModule({ + imports: [ + IonicModule, + TranslateModule.forChild(), + ], + providers: [ + { + provide: APP_INITIALIZER, + multi: true, + useValue: () => { + CoreBlockDelegate.instance.registerHandler(AddonBlockPrivateFilesHandler.instance); + }, + }, + ], +}) +export class AddonBlockPrivateFilesModule {} diff --git a/src/addons/block/privatefiles/services/block-handler.ts b/src/addons/block/privatefiles/services/block-handler.ts new file mode 100644 index 000000000..8b2071b7b --- /dev/null +++ b/src/addons/block/privatefiles/services/block-handler.ts @@ -0,0 +1,49 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// 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 } from '@angular/core'; +import { CoreBlockHandlerData } from '@features/block/services/block-delegate'; +import { CoreBlockOnlyTitleComponent } from '@features/block/components/only-title-block/only-title-block'; +import { CoreBlockBaseHandler } from '@features/block/classes/base-block-handler'; +import { AddonPrivateFilesMainMenuHandlerService } from '@/addons/privatefiles/services/handlers/mainmenu'; +import { makeSingleton } from '@singletons'; + +/** + * Block handler. + */ +@Injectable({ providedIn: 'root' }) +export class AddonBlockPrivateFilesHandlerService extends CoreBlockBaseHandler { + + name = 'AddonBlockPrivateFiles'; + blockName = 'private_files'; + + /** + * Returns the data needed to render the block. + * + * @return Data or promise resolved with the data. + */ + getDisplayData(): CoreBlockHandlerData { + + return { + title: 'addon.block_privatefiles.pluginname', + class: 'addon-block-private-files', + component: CoreBlockOnlyTitleComponent, + link: '/main/' + AddonPrivateFilesMainMenuHandlerService.PAGE_NAME, + linkParams: { root: 'my' }, + }; + } + +} + +export class AddonBlockPrivateFilesHandler extends makeSingleton(AddonBlockPrivateFilesHandlerService) {} diff --git a/src/addons/block/selfcompletion/lang.json b/src/addons/block/selfcompletion/lang.json new file mode 100644 index 000000000..32521695a --- /dev/null +++ b/src/addons/block/selfcompletion/lang.json @@ -0,0 +1,3 @@ +{ + "pluginname": "Self completion" +} \ No newline at end of file diff --git a/src/addons/block/selfcompletion/selfcompletion.module.ts b/src/addons/block/selfcompletion/selfcompletion.module.ts new file mode 100644 index 000000000..13d8e0712 --- /dev/null +++ b/src/addons/block/selfcompletion/selfcompletion.module.ts @@ -0,0 +1,36 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// 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 { APP_INITIALIZER, NgModule } from '@angular/core'; +import { IonicModule } from '@ionic/angular'; +import { TranslateModule } from '@ngx-translate/core'; +import { CoreBlockDelegate } from '@features/block/services/block-delegate'; +import { AddonBlockSelfCompletionHandler } from './services/block-handler'; + +@NgModule({ + imports: [ + IonicModule, + TranslateModule.forChild(), + ], + providers: [ + { + provide: APP_INITIALIZER, + multi: true, + useValue: () => { + CoreBlockDelegate.instance.registerHandler(AddonBlockSelfCompletionHandler.instance); + }, + }, + ], +}) +export class AddonBlockSelfCompletionModule {} diff --git a/src/addons/block/selfcompletion/services/block-handler.ts b/src/addons/block/selfcompletion/services/block-handler.ts new file mode 100644 index 000000000..ff046df7b --- /dev/null +++ b/src/addons/block/selfcompletion/services/block-handler.ts @@ -0,0 +1,53 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// 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 } from '@angular/core'; +import { CoreBlockHandlerData } from '@features/block/services/block-delegate'; +import { CoreBlockOnlyTitleComponent } from '@features/block/components/only-title-block/only-title-block'; +import { CoreBlockBaseHandler } from '@features/block/classes/base-block-handler'; +import { CoreCourseBlock } from '@features/course/services/course'; +import { makeSingleton } from '@singletons'; + +/** + * Block handler. + */ +@Injectable({ providedIn: 'root' }) +export class AddonBlockSelfCompletionHandlerService extends CoreBlockBaseHandler { + + name = 'AddonBlockSelfCompletion'; + blockName = 'selfcompletion'; + + /** + * Returns the data needed to render the block. + * + * @param block The block to render. + * @param contextLevel The context where the block will be used. + * @param instanceId The instance ID associated with the context level. + * @return Data or promise resolved with the data. + */ + getDisplayData(block: CoreCourseBlock, contextLevel: string, instanceId: number): CoreBlockHandlerData { + // @todo + + return { + title: 'addon.block_selfcompletion.pluginname', + class: 'addon-block-self-completion', + component: CoreBlockOnlyTitleComponent, + link: 'AddonCourseCompletionReportPage', + linkParams: { courseId: instanceId }, + }; + } + +} + +export class AddonBlockSelfCompletionHandler extends makeSingleton(AddonBlockSelfCompletionHandlerService) {}