From 34061ad5abb76c2a06211a05e229e27802ecd97c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 9 May 2019 14:25:27 +0200 Subject: [PATCH 01/13] MOBILE-3002 block: Support for pre rendered block type --- .../block/components/components.module.ts | 4 ++ .../core-block-pre-rendered.html | 11 +++++ .../pre-rendered-block/pre-rendered-block.ts | 40 +++++++++++++++++++ .../block/providers/course-option-handler.ts | 4 +- src/core/course/providers/course.ts | 3 +- src/core/courses/providers/dashboard.ts | 1 + 6 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 src/core/block/components/pre-rendered-block/core-block-pre-rendered.html create mode 100644 src/core/block/components/pre-rendered-block/pre-rendered-block.ts diff --git a/src/core/block/components/components.module.ts b/src/core/block/components/components.module.ts index 33c80abcf..70627f6bf 100644 --- a/src/core/block/components/components.module.ts +++ b/src/core/block/components/components.module.ts @@ -19,6 +19,7 @@ import { TranslateModule } from '@ngx-translate/core'; import { CoreDirectivesModule } from '@directives/directives.module'; import { CoreBlockComponent } from './block/block'; import { CoreBlockOnlyTitleComponent } from './only-title-block/only-title-block'; +import { CoreBlockPreRenderedComponent } from './pre-rendered-block/pre-rendered-block'; import { CoreBlockCourseBlocksComponent } from './course-blocks/course-blocks'; import { CoreComponentsModule } from '@components/components.module'; @@ -26,6 +27,7 @@ import { CoreComponentsModule } from '@components/components.module'; declarations: [ CoreBlockComponent, CoreBlockOnlyTitleComponent, + CoreBlockPreRenderedComponent, CoreBlockCourseBlocksComponent ], imports: [ @@ -40,10 +42,12 @@ import { CoreComponentsModule } from '@components/components.module'; exports: [ CoreBlockComponent, CoreBlockOnlyTitleComponent, + CoreBlockPreRenderedComponent, CoreBlockCourseBlocksComponent ], entryComponents: [ CoreBlockOnlyTitleComponent, + CoreBlockPreRenderedComponent, CoreBlockCourseBlocksComponent ] }) diff --git a/src/core/block/components/pre-rendered-block/core-block-pre-rendered.html b/src/core/block/components/pre-rendered-block/core-block-pre-rendered.html new file mode 100644 index 000000000..84780cabb --- /dev/null +++ b/src/core/block/components/pre-rendered-block/core-block-pre-rendered.html @@ -0,0 +1,11 @@ + +

+
+ + + + + + + + diff --git a/src/core/block/components/pre-rendered-block/pre-rendered-block.ts b/src/core/block/components/pre-rendered-block/pre-rendered-block.ts new file mode 100644 index 000000000..0acd1712f --- /dev/null +++ b/src/core/block/components/pre-rendered-block/pre-rendered-block.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 { Injector, OnInit, Component } from '@angular/core'; +import { CoreBlockBaseComponent } from '../../classes/base-block-component'; + +/** + * Component to render blocks with pre-rendered HTML. + */ +@Component({ + selector: 'core-block-pre-rendered', + templateUrl: 'core-block-pre-rendered.html' +}) +export class CoreBlockPreRenderedComponent extends CoreBlockBaseComponent implements OnInit { + + constructor(injector: Injector) { + super(injector, 'CoreBlockPreRenderedComponent'); + } + + /** + * Component being initialized. + */ + ngOnInit(): void { + super.ngOnInit(); + + this.fetchContentDefaultError = 'Error getting ' + this.block.contents.title + ' data.'; + } + +} diff --git a/src/core/block/providers/course-option-handler.ts b/src/core/block/providers/course-option-handler.ts index c7e298c9c..7e38227f5 100644 --- a/src/core/block/providers/course-option-handler.ts +++ b/src/core/block/providers/course-option-handler.ts @@ -58,7 +58,9 @@ export class CoreBlockCourseBlocksCourseOptionHandler implements CoreCourseOptio * @return {boolean|Promise} True or promise resolved with true if enabled. */ isEnabledForCourse(courseId: number, accessData: any, navOptions?: any, admOptions?: any): boolean | Promise { - return true; + return this.courseProvider.getCourseBlocks(courseId).then((blocks) => { + return blocks && blocks.length > 0; + }); } /** diff --git a/src/core/course/providers/course.ts b/src/core/course/providers/course.ts index bb4a55c5a..3131fc869 100644 --- a/src/core/course/providers/course.ts +++ b/src/core/course/providers/course.ts @@ -255,7 +255,8 @@ export class CoreCourseProvider { getCourseBlocks(courseId: number, siteId?: string): Promise { return this.sitesProvider.getSite(siteId).then((site) => { const params = { - courseid: courseId + courseid: courseId, + returncontents: 1 }, preSets: CoreSiteWSPreSets = { cacheKey: this.getCourseBlocksCacheKey(courseId), diff --git a/src/core/courses/providers/dashboard.ts b/src/core/courses/providers/dashboard.ts index 24ac80e2c..beb6204d0 100644 --- a/src/core/courses/providers/dashboard.ts +++ b/src/core/courses/providers/dashboard.ts @@ -47,6 +47,7 @@ export class CoreCoursesDashboardProvider { getDashboardBlocks(userId?: number, siteId?: string): Promise { return this.sitesProvider.getSite(siteId).then((site) => { const params = { + returncontents: 1 }, preSets = { cacheKey: this.getDashboardBlocksCacheKey(userId), From 11eee9b8a8bec67eb26fddd30174457b60dfbbda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 7 May 2019 12:39:55 +0200 Subject: [PATCH 02/13] MOBILE-3002 block: Add HTML block feature --- src/addon/block/html/html.module.ts | 36 +++++++++++++ .../block/html/providers/block-handler.ts | 50 +++++++++++++++++++ src/app/app.module.ts | 2 + src/theme/format-text.scss | 3 +- 4 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 src/addon/block/html/html.module.ts create mode 100644 src/addon/block/html/providers/block-handler.ts diff --git a/src/addon/block/html/html.module.ts b/src/addon/block/html/html.module.ts new file mode 100644 index 000000000..1b81cf4ad --- /dev/null +++ b/src/addon/block/html/html.module.ts @@ -0,0 +1,36 @@ +// (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 { CoreBlockDelegate } from '@core/block/providers/delegate'; +import { AddonBlockHtmlHandler } from './providers/block-handler'; + +@NgModule({ + declarations: [ + ], + imports: [ + IonicModule + ], + exports: [ + ], + providers: [ + AddonBlockHtmlHandler + ] +}) +export class AddonBlockHtmlModule { + constructor(blockDelegate: CoreBlockDelegate, blockHandler: AddonBlockHtmlHandler) { + blockDelegate.registerHandler(blockHandler); + } +} diff --git a/src/addon/block/html/providers/block-handler.ts b/src/addon/block/html/providers/block-handler.ts new file mode 100644 index 000000000..a5603fb53 --- /dev/null +++ b/src/addon/block/html/providers/block-handler.ts @@ -0,0 +1,50 @@ +// (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 { 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 AddonBlockHtmlHandler extends CoreBlockBaseHandler { + name = 'AddonBlockHtml'; + blockName = 'html'; + + 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: block.contents.title, + class: 'addon-block-html', + component: CoreBlockPreRenderedComponent + }; + } +} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 3086286a1..fa19ec008 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -95,6 +95,7 @@ import { AddonBlockCalendarMonthModule } from '@addon/block/calendarmonth/calend import { AddonBlockCalendarUpcomingModule } from '@addon/block/calendarupcoming/calendarupcoming.module'; import { AddonBlockCommentsModule } from '@addon/block/comments/comments.module'; import { AddonBlockCompletionStatusModule } from '@addon/block/completionstatus/completionstatus.module'; +import { AddonBlockHtmlModule } from '@addon/block/html/html.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'; @@ -224,6 +225,7 @@ export const CORE_PROVIDERS: any[] = [ AddonBlockCalendarUpcomingModule, AddonBlockCommentsModule, AddonBlockCompletionStatusModule, + AddonBlockHtmlModule, AddonBlockLearningPlansModule, AddonBlockMyOverviewModule, AddonBlockPrivateFilesModule, diff --git a/src/theme/format-text.scss b/src/theme/format-text.scss index ad0a230fb..d14efd148 100644 --- a/src/theme/format-text.scss +++ b/src/theme/format-text.scss @@ -4,9 +4,8 @@ ion-app.app-root .item core-format-text, ion-app.app-root core-rich-text-editor .core-rte-editor { @include core-headings(); - font-size: 1.4rem; - p { + font-size: 1.4rem; margin-bottom: 1rem; } From 16d768d1876d48bdb8e99e4fa261261b476905af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 9 May 2019 14:31:08 +0200 Subject: [PATCH 03/13] MOBILE-3002 block: Add Online users block feature --- scripts/langindex.json | 1 + src/addon/block/onlineusers/lang/en.json | 3 ++ .../block/onlineusers/onlineusers.module.ts | 38 ++++++++++++++ src/addon/block/onlineusers/onlineusers.scss | 40 +++++++++++++++ .../onlineusers/providers/block-handler.ts | 50 +++++++++++++++++++ src/app/app.module.ts | 2 + src/assets/lang/en.json | 1 + 7 files changed, 135 insertions(+) create mode 100644 src/addon/block/onlineusers/lang/en.json create mode 100644 src/addon/block/onlineusers/onlineusers.module.ts create mode 100644 src/addon/block/onlineusers/onlineusers.scss create mode 100644 src/addon/block/onlineusers/providers/block-handler.ts diff --git a/scripts/langindex.json b/scripts/langindex.json index 1d142fd09..a700c40cd 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -43,6 +43,7 @@ "addon.block_myoverview.past": "block_myoverview", "addon.block_myoverview.pluginname": "block_myoverview", "addon.block_myoverview.title": "block_myoverview", + "addon.block_onlineusers.pluginname": "block_online_users", "addon.block_privatefiles.pluginname": "block_private_files", "addon.block_recentlyaccessedcourses.nocourses": "block_recentlyaccessedcourses", "addon.block_recentlyaccessedcourses.pluginname": "block_recentlyaccessedcourses", diff --git a/src/addon/block/onlineusers/lang/en.json b/src/addon/block/onlineusers/lang/en.json new file mode 100644 index 000000000..4bc6cd412 --- /dev/null +++ b/src/addon/block/onlineusers/lang/en.json @@ -0,0 +1,3 @@ +{ + "pluginname": "Online users" +} \ No newline at end of file diff --git a/src/addon/block/onlineusers/onlineusers.module.ts b/src/addon/block/onlineusers/onlineusers.module.ts new file mode 100644 index 000000000..0df61ad7a --- /dev/null +++ b/src/addon/block/onlineusers/onlineusers.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 { AddonBlockOnlineUsersHandler } from './providers/block-handler'; + +@NgModule({ + declarations: [ + ], + imports: [ + IonicModule, + TranslateModule.forChild() + ], + exports: [ + ], + providers: [ + AddonBlockOnlineUsersHandler + ] +}) +export class AddonBlockOnlineUsersModule { + constructor(blockDelegate: CoreBlockDelegate, blockHandler: AddonBlockOnlineUsersHandler) { + blockDelegate.registerHandler(blockHandler); + } +} diff --git a/src/addon/block/onlineusers/onlineusers.scss b/src/addon/block/onlineusers/onlineusers.scss new file mode 100644 index 000000000..eb05cef2e --- /dev/null +++ b/src/addon/block/onlineusers/onlineusers.scss @@ -0,0 +1,40 @@ +.addon-block-online-users core-block-pre-rendered .core-block-content { + .list { + @include margin-horizontal(0); + -webkit-padding-start: 0; + + li.listentry { + clear: both; + list-style-type: none; + + .user { + @include float(start); + position: relative; + padding-bottom: 16px; + + .core-adapted-img-container { + display: inline; + @include margin-horizontal(0, 8px); + } + + .userpicture { + vertical-align: text-bottom; + } + } + + .message { + @include float(end); + margin-top: 3px; + } + + .uservisibility { // No support on the app. + display: none; + } + } + } + + .info { + text-align: center; + } + +} \ No newline at end of file diff --git a/src/addon/block/onlineusers/providers/block-handler.ts b/src/addon/block/onlineusers/providers/block-handler.ts new file mode 100644 index 000000000..9967ad6f6 --- /dev/null +++ b/src/addon/block/onlineusers/providers/block-handler.ts @@ -0,0 +1,50 @@ +// (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 AddonBlockOnlineUsersHandler extends CoreBlockBaseHandler { + name = 'AddonBlockOnlineUsers'; + blockName = 'online_users'; + + 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_onlineusers.pluginname'), + class: 'addon-block-online-users', + component: CoreBlockPreRenderedComponent + }; + } +} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index fa19ec008..8ce3a1796 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -97,6 +97,7 @@ import { AddonBlockCommentsModule } from '@addon/block/comments/comments.module' import { AddonBlockCompletionStatusModule } from '@addon/block/completionstatus/completionstatus.module'; import { AddonBlockHtmlModule } from '@addon/block/html/html.module'; import { AddonBlockMyOverviewModule } from '@addon/block/myoverview/myoverview.module'; +import { AddonBlockOnlineUsersModule } from '@addon/block/onlineusers/onlineusers.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'; @@ -228,6 +229,7 @@ export const CORE_PROVIDERS: any[] = [ AddonBlockHtmlModule, AddonBlockLearningPlansModule, AddonBlockMyOverviewModule, + AddonBlockOnlineUsersModule, AddonBlockPrivateFilesModule, AddonBlockSiteMainMenuModule, AddonBlockTimelineModule, diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index c28b1240e..4d3f6b00e 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -43,6 +43,7 @@ "addon.block_myoverview.past": "Past", "addon.block_myoverview.pluginname": "Course overview", "addon.block_myoverview.title": "Course name", + "addon.block_onlineusers.pluginname": "Online users", "addon.block_privatefiles.pluginname": "Private files", "addon.block_recentlyaccessedcourses.nocourses": "No recent courses", "addon.block_recentlyaccessedcourses.pluginname": "Recently accessed courses", From 67be0a6c45640d97076f8aaea5f8c0c7c7568eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Fri, 10 May 2019 11:53:26 +0200 Subject: [PATCH 04/13] MOBILE-3002 block: Add Latest announcements block feature --- scripts/langindex.json | 1 + src/addon/block/newsitems/lang/en.json | 3 + src/addon/block/newsitems/newsitems.module.ts | 38 +++++++++ src/addon/block/newsitems/newsitems.scss | 26 ++++++ .../newsitems/providers/block-handler.ts | 50 +++++++++++ src/addon/mod/forum/forum.module.ts | 6 +- .../mod/forum/pages/discussion/discussion.ts | 3 + .../mod/forum/providers/index-link-handler.ts | 40 ++++++++- .../mod/forum/providers/post-link-handler.ts | 84 +++++++++++++++++++ src/app/app.module.ts | 2 + src/assets/lang/en.json | 1 + 11 files changed, 252 insertions(+), 2 deletions(-) create mode 100644 src/addon/block/newsitems/lang/en.json create mode 100644 src/addon/block/newsitems/newsitems.module.ts create mode 100644 src/addon/block/newsitems/newsitems.scss create mode 100644 src/addon/block/newsitems/providers/block-handler.ts create mode 100644 src/addon/mod/forum/providers/post-link-handler.ts diff --git a/scripts/langindex.json b/scripts/langindex.json index a700c40cd..20feed1fe 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -43,6 +43,7 @@ "addon.block_myoverview.past": "block_myoverview", "addon.block_myoverview.pluginname": "block_myoverview", "addon.block_myoverview.title": "block_myoverview", + "addon.block_newsitems.pluginname": "block_news_items", "addon.block_onlineusers.pluginname": "block_online_users", "addon.block_privatefiles.pluginname": "block_private_files", "addon.block_recentlyaccessedcourses.nocourses": "block_recentlyaccessedcourses", diff --git a/src/addon/block/newsitems/lang/en.json b/src/addon/block/newsitems/lang/en.json new file mode 100644 index 000000000..83b981297 --- /dev/null +++ b/src/addon/block/newsitems/lang/en.json @@ -0,0 +1,3 @@ +{ + "pluginname": "Latest announcements" +} \ No newline at end of file diff --git a/src/addon/block/newsitems/newsitems.module.ts b/src/addon/block/newsitems/newsitems.module.ts new file mode 100644 index 000000000..a3364ea5e --- /dev/null +++ b/src/addon/block/newsitems/newsitems.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 { AddonBlockNewsItemsHandler } from './providers/block-handler'; + +@NgModule({ + declarations: [ + ], + imports: [ + IonicModule, + TranslateModule.forChild() + ], + exports: [ + ], + providers: [ + AddonBlockNewsItemsHandler + ] +}) +export class AddonBlockNewsItemsModule { + constructor(blockDelegate: CoreBlockDelegate, blockHandler: AddonBlockNewsItemsHandler) { + blockDelegate.registerHandler(blockHandler); + } +} diff --git a/src/addon/block/newsitems/newsitems.scss b/src/addon/block/newsitems/newsitems.scss new file mode 100644 index 000000000..8b0c46287 --- /dev/null +++ b/src/addon/block/newsitems/newsitems.scss @@ -0,0 +1,26 @@ +.addon-block-news-items core-block-pre-rendered { + .core-block-content { + .unlist { + list-style-type: none; + @include margin-horizontal(0); + -webkit-padding-start: 0; + + li.post { + padding-bottom: 16px; + } + li.post:last-child { + padding-bottom: 0; + } + } + } + + // Hide RSS link. + .core-block-footer { + a { + display: none; + } + a:first-child { + display: inline; + } + } +} \ No newline at end of file diff --git a/src/addon/block/newsitems/providers/block-handler.ts b/src/addon/block/newsitems/providers/block-handler.ts new file mode 100644 index 000000000..9b6c15cb8 --- /dev/null +++ b/src/addon/block/newsitems/providers/block-handler.ts @@ -0,0 +1,50 @@ +// (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 AddonBlockNewsItemsHandler extends CoreBlockBaseHandler { + name = 'AddonBlockNewsItems'; + blockName = 'news_items'; + + 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_newsitems.pluginname'), + class: 'addon-block-news-items', + component: CoreBlockPreRenderedComponent + }; + } +} diff --git a/src/addon/mod/forum/forum.module.ts b/src/addon/mod/forum/forum.module.ts index 215c343e6..94fe30257 100644 --- a/src/addon/mod/forum/forum.module.ts +++ b/src/addon/mod/forum/forum.module.ts @@ -28,6 +28,7 @@ import { AddonModForumSyncCronHandler } from './providers/sync-cron-handler'; import { AddonModForumIndexLinkHandler } from './providers/index-link-handler'; import { AddonModForumDiscussionLinkHandler } from './providers/discussion-link-handler'; import { AddonModForumListLinkHandler } from './providers/list-link-handler'; +import { AddonModForumPostLinkHandler } from './providers/post-link-handler'; import { AddonModForumPushClickHandler } from './providers/push-click-handler'; import { AddonModForumComponentsModule } from './components/components.module'; import { CoreUpdateManagerProvider } from '@providers/update-manager'; @@ -56,6 +57,7 @@ export const ADDON_MOD_FORUM_PROVIDERS: any[] = [ AddonModForumSyncCronHandler, AddonModForumIndexLinkHandler, AddonModForumListLinkHandler, + AddonModForumPostLinkHandler, AddonModForumDiscussionLinkHandler, AddonModForumPushClickHandler ] @@ -66,7 +68,8 @@ export class AddonModForumModule { cronDelegate: CoreCronDelegate, syncHandler: AddonModForumSyncCronHandler, linksDelegate: CoreContentLinksDelegate, indexHandler: AddonModForumIndexLinkHandler, discussionHandler: AddonModForumDiscussionLinkHandler, updateManager: CoreUpdateManagerProvider, listLinkHandler: AddonModForumListLinkHandler, - pushNotificationsDelegate: CorePushNotificationsDelegate, pushClickHandler: AddonModForumPushClickHandler) { + pushNotificationsDelegate: CorePushNotificationsDelegate, pushClickHandler: AddonModForumPushClickHandler, + postLinkHandler: AddonModForumPostLinkHandler) { moduleDelegate.registerHandler(moduleHandler); prefetchDelegate.registerHandler(prefetchHandler); @@ -74,6 +77,7 @@ export class AddonModForumModule { linksDelegate.registerHandler(indexHandler); linksDelegate.registerHandler(discussionHandler); linksDelegate.registerHandler(listLinkHandler); + linksDelegate.registerHandler(postLinkHandler); pushNotificationsDelegate.registerClickHandler(pushClickHandler); // Allow migrating the tables from the old app to the new schema. diff --git a/src/addon/mod/forum/pages/discussion/discussion.ts b/src/addon/mod/forum/pages/discussion/discussion.ts index f8514dd5f..68598a18e 100644 --- a/src/addon/mod/forum/pages/discussion/discussion.ts +++ b/src/addon/mod/forum/pages/discussion/discussion.ts @@ -354,6 +354,9 @@ export class AddonModForumDiscussionPage implements OnDestroy { return Promise.reject('Invalid forum discussion.'); } + this.defaultSubject = this.translate.instant('addon.mod_forum.re') + ' ' + this.discussion.subject; + this.replyData.subject = this.defaultSubject; + if (this.discussion.userfullname && this.discussion.parent == 0 && this.forum.type == 'single') { // Hide author for first post and type single. this.discussion.userfullname = null; diff --git a/src/addon/mod/forum/providers/index-link-handler.ts b/src/addon/mod/forum/providers/index-link-handler.ts index 4beb1226f..b975f449c 100644 --- a/src/addon/mod/forum/providers/index-link-handler.ts +++ b/src/addon/mod/forum/providers/index-link-handler.ts @@ -16,6 +16,9 @@ import { Injectable } from '@angular/core'; import { CoreContentLinksModuleIndexHandler } from '@core/contentlinks/classes/module-index-handler'; import { CoreCourseHelperProvider } from '@core/course/providers/helper'; import { AddonModForumProvider } from './forum'; +import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate'; +import { CoreCourseProvider } from '@core/course/providers/course'; +import { CoreDomUtilsProvider } from '@providers/utils/dom'; /** * Handler to treat links to forum index. @@ -24,8 +27,12 @@ import { AddonModForumProvider } from './forum'; export class AddonModForumIndexLinkHandler extends CoreContentLinksModuleIndexHandler { name = 'AddonModForumIndexLinkHandler'; - constructor(courseHelper: CoreCourseHelperProvider, protected forumProvider: AddonModForumProvider) { + constructor(courseHelper: CoreCourseHelperProvider, protected forumProvider: AddonModForumProvider, + private courseProvider: CoreCourseProvider, private domUtils: CoreDomUtilsProvider) { super(courseHelper, 'AddonModForum', 'forum'); + + // Match the view.php URL with an id param. + this.pattern = new RegExp('\/mod\/forum\/view\.php.*([\&\?](f|id)=\\d+)'); } /** @@ -41,4 +48,35 @@ export class AddonModForumIndexLinkHandler extends CoreContentLinksModuleIndexHa isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise { return true; } + + /** + * Get the list of actions for a link (url). + * + * @param {string[]} siteIds List of sites the URL belongs to. + * @param {string} url The URL to treat. + * @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1} + * @param {number} [courseId] Course ID related to the URL. Optional but recommended. + * @return {CoreContentLinksAction[]|Promise} List of (or promise resolved with list of) actions. + */ + getActions(siteIds: string[], url: string, params: any, courseId?: number): + CoreContentLinksAction[] | Promise { + + if (typeof params.f != 'undefined') { + return [{ + action: (siteId, navCtrl?): void => { + const modal = this.domUtils.showModalLoading(), + forumId = parseInt(params.f, 10); + + this.courseProvider.getModuleBasicInfoByInstance(forumId, 'forum', siteId).then((module) => { + this.courseHelper.navigateToModule(parseInt(module.id, 10), siteId, module.course); + }).finally(() => { + // Just in case. In fact we need to dismiss the modal before showing a toast or error message. + modal.dismiss(); + }); + } + }]; + } + + return super.getActions(siteIds, url, params, courseId); + } } diff --git a/src/addon/mod/forum/providers/post-link-handler.ts b/src/addon/mod/forum/providers/post-link-handler.ts new file mode 100644 index 000000000..73d691dc1 --- /dev/null +++ b/src/addon/mod/forum/providers/post-link-handler.ts @@ -0,0 +1,84 @@ +// (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 } from '@angular/core'; +import { CoreContentLinksHandlerBase } from '@core/contentlinks/classes/base-handler'; +import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate'; +import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper'; +import { CoreCourseProvider } from '@core/course/providers/course'; +import { CoreDomUtilsProvider } from '@providers/utils/dom'; + +/** + * Content links handler for forum new discussion. + * Match mod/forum/post.php?forum=6 with a valid data. + */ +@Injectable() +export class AddonModForumPostLinkHandler extends CoreContentLinksHandlerBase { + name = 'AddonModForumPostLinkHandler'; + featureName = 'CoreCourseModuleDelegate_AddonModForum'; + pattern = /\/mod\/forum\/post\.php.*([\?\&](forum)=\d+)/; + + constructor(private linkHelper: CoreContentLinksHelperProvider, private courseProvider: CoreCourseProvider, + private domUtils: CoreDomUtilsProvider) { + super(); + } + + /** + * Get the list of actions for a link (url). + * + * @param {string[]} siteIds List of sites the URL belongs to. + * @param {string} url The URL to treat. + * @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1} + * @param {number} [courseId] Course ID related to the URL. Optional but recommended. + * @return {CoreContentLinksAction[]|Promise} List of (or promise resolved with list of) actions. + */ + getActions(siteIds: string[], url: string, params: any, courseId?: number): + CoreContentLinksAction[] | Promise { + + return [{ + action: (siteId, navCtrl?): void => { + const modal = this.domUtils.showModalLoading(), + forumId = parseInt(params.forum, 10); + + this.courseProvider.getModuleBasicInfoByInstance(forumId, 'forum', siteId).then((module) => { + const pageParams = { + courseId: module.course, + cmId: module.id, + forumId: module.instance, + timeCreated: 0, + }; + + return this.linkHelper.goInSite(navCtrl, 'AddonModForumNewDiscussionPage', pageParams, siteId); + }).finally(() => { + // Just in case. In fact we need to dismiss the modal before showing a toast or error message. + modal.dismiss(); + }); + } + }]; + } + + /** + * Check if the handler is enabled for a certain site (site + user) and a URL. + * If not defined, defaults to true. + * + * @param {string} siteId The site ID. + * @param {string} url The URL to treat. + * @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1} + * @param {number} [courseId] Course ID related to the URL. Optional but recommended. + * @return {boolean|Promise} Whether the handler is enabled for the URL and site. + */ + isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise { + return typeof params.forum != 'undefined'; + } +} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 8ce3a1796..4d4743294 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -97,6 +97,7 @@ import { AddonBlockCommentsModule } from '@addon/block/comments/comments.module' import { AddonBlockCompletionStatusModule } from '@addon/block/completionstatus/completionstatus.module'; import { AddonBlockHtmlModule } from '@addon/block/html/html.module'; import { AddonBlockMyOverviewModule } from '@addon/block/myoverview/myoverview.module'; +import { AddonBlockNewsItemsModule } from '@addon/block/newsitems/newsitems.module'; import { AddonBlockOnlineUsersModule } from '@addon/block/onlineusers/onlineusers.module'; import { AddonBlockLearningPlansModule } from '@addon/block/learningplans/learningplans.module'; import { AddonBlockPrivateFilesModule } from '@addon/block/privatefiles/privatefiles.module'; @@ -229,6 +230,7 @@ export const CORE_PROVIDERS: any[] = [ AddonBlockHtmlModule, AddonBlockLearningPlansModule, AddonBlockMyOverviewModule, + AddonBlockNewsItemsModule, AddonBlockOnlineUsersModule, AddonBlockPrivateFilesModule, AddonBlockSiteMainMenuModule, diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index 4d3f6b00e..88734646f 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -43,6 +43,7 @@ "addon.block_myoverview.past": "Past", "addon.block_myoverview.pluginname": "Course overview", "addon.block_myoverview.title": "Course name", + "addon.block_newsitems.pluginname": "Latest announcements", "addon.block_onlineusers.pluginname": "Online users", "addon.block_privatefiles.pluginname": "Private files", "addon.block_recentlyaccessedcourses.nocourses": "No recent courses", From 00993853956b5b8f17759bda36806f8696d06c51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Fri, 10 May 2019 15:15:07 +0200 Subject: [PATCH 05/13] MOBILE-3002 block: Add Glossary random block feature --- scripts/langindex.json | 1 + .../glossaryrandom/glossaryrandom.module.ts | 38 +++++++++ src/addon/block/glossaryrandom/lang/en.json | 3 + .../glossaryrandom/providers/block-handler.ts | 50 +++++++++++ src/addon/mod/glossary/glossary.module.ts | 8 +- .../glossary/providers/edit-link-handler.ts | 85 +++++++++++++++++++ src/app/app.module.ts | 2 + src/assets/lang/en.json | 1 + 8 files changed, 186 insertions(+), 2 deletions(-) create mode 100644 src/addon/block/glossaryrandom/glossaryrandom.module.ts create mode 100644 src/addon/block/glossaryrandom/lang/en.json create mode 100644 src/addon/block/glossaryrandom/providers/block-handler.ts create mode 100644 src/addon/mod/glossary/providers/edit-link-handler.ts diff --git a/scripts/langindex.json b/scripts/langindex.json index 20feed1fe..1c36c87ea 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -31,6 +31,7 @@ "addon.block_calendarupcoming.pluginname": "block_calendar_upcoming", "addon.block_comments.pluginname": "block_comments", "addon.block_completionstatus.pluginname": "block_completionstatus", + "addon.block_glossaryrandom.pluginname": "block_glossary_random", "addon.block_learningplans.pluginname": "block_lp", "addon.block_myoverview.all": "block_myoverview", "addon.block_myoverview.favourites": "block_myoverview", diff --git a/src/addon/block/glossaryrandom/glossaryrandom.module.ts b/src/addon/block/glossaryrandom/glossaryrandom.module.ts new file mode 100644 index 000000000..e6d238957 --- /dev/null +++ b/src/addon/block/glossaryrandom/glossaryrandom.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 { AddonBlockGlossaryRandomHandler } from './providers/block-handler'; + +@NgModule({ + declarations: [ + ], + imports: [ + IonicModule, + TranslateModule.forChild() + ], + exports: [ + ], + providers: [ + AddonBlockGlossaryRandomHandler + ] +}) +export class AddonBlockGlossaryRandomModule { + constructor(blockDelegate: CoreBlockDelegate, blockHandler: AddonBlockGlossaryRandomHandler) { + blockDelegate.registerHandler(blockHandler); + } +} diff --git a/src/addon/block/glossaryrandom/lang/en.json b/src/addon/block/glossaryrandom/lang/en.json new file mode 100644 index 000000000..1ae4de38c --- /dev/null +++ b/src/addon/block/glossaryrandom/lang/en.json @@ -0,0 +1,3 @@ +{ + "pluginname": "Random glossary entry" +} \ No newline at end of file diff --git a/src/addon/block/glossaryrandom/providers/block-handler.ts b/src/addon/block/glossaryrandom/providers/block-handler.ts new file mode 100644 index 000000000..48b97b5a1 --- /dev/null +++ b/src/addon/block/glossaryrandom/providers/block-handler.ts @@ -0,0 +1,50 @@ +// (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 AddonBlockGlossaryRandomHandler extends CoreBlockBaseHandler { + name = 'AddonBlockGlossaryRandom'; + blockName = 'glossary_random'; + + 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: block.contents.title || this.translate.instant('addon.block_glossaryrandom.pluginname'), + class: 'addon-block-glossary-random', + component: CoreBlockPreRenderedComponent + }; + } +} diff --git a/src/addon/mod/glossary/glossary.module.ts b/src/addon/mod/glossary/glossary.module.ts index ab114c54b..ac311c144 100644 --- a/src/addon/mod/glossary/glossary.module.ts +++ b/src/addon/mod/glossary/glossary.module.ts @@ -27,6 +27,7 @@ import { AddonModGlossarySyncCronHandler } from './providers/sync-cron-handler'; import { AddonModGlossaryIndexLinkHandler } from './providers/index-link-handler'; import { AddonModGlossaryEntryLinkHandler } from './providers/entry-link-handler'; import { AddonModGlossaryListLinkHandler } from './providers/list-link-handler'; +import { AddonModGlossaryEditLinkHandler } from './providers/edit-link-handler'; import { AddonModGlossaryComponentsModule } from './components/components.module'; import { CoreUpdateManagerProvider } from '@providers/update-manager'; @@ -54,7 +55,8 @@ export const ADDON_MOD_GLOSSARY_PROVIDERS: any[] = [ AddonModGlossarySyncCronHandler, AddonModGlossaryIndexLinkHandler, AddonModGlossaryEntryLinkHandler, - AddonModGlossaryListLinkHandler + AddonModGlossaryListLinkHandler, + AddonModGlossaryEditLinkHandler ] }) export class AddonModGlossaryModule { @@ -62,7 +64,8 @@ export class AddonModGlossaryModule { prefetchDelegate: CoreCourseModulePrefetchDelegate, prefetchHandler: AddonModGlossaryPrefetchHandler, cronDelegate: CoreCronDelegate, syncHandler: AddonModGlossarySyncCronHandler, linksDelegate: CoreContentLinksDelegate, indexHandler: AddonModGlossaryIndexLinkHandler, discussionHandler: AddonModGlossaryEntryLinkHandler, - updateManager: CoreUpdateManagerProvider, listLinkHandler: AddonModGlossaryListLinkHandler) { + updateManager: CoreUpdateManagerProvider, listLinkHandler: AddonModGlossaryListLinkHandler, + editLinkHandler: AddonModGlossaryEditLinkHandler) { moduleDelegate.registerHandler(moduleHandler); prefetchDelegate.registerHandler(prefetchHandler); @@ -70,6 +73,7 @@ export class AddonModGlossaryModule { linksDelegate.registerHandler(indexHandler); linksDelegate.registerHandler(discussionHandler); linksDelegate.registerHandler(listLinkHandler); + linksDelegate.registerHandler(editLinkHandler); // Allow migrating the tables from the old app to the new schema. updateManager.registerSiteTableMigration({ diff --git a/src/addon/mod/glossary/providers/edit-link-handler.ts b/src/addon/mod/glossary/providers/edit-link-handler.ts new file mode 100644 index 000000000..c2f34305c --- /dev/null +++ b/src/addon/mod/glossary/providers/edit-link-handler.ts @@ -0,0 +1,85 @@ +// (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 } from '@angular/core'; +import { CoreContentLinksHandlerBase } from '@core/contentlinks/classes/base-handler'; +import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate'; +import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper'; +import { CoreCourseProvider } from '@core/course/providers/course'; +import { CoreDomUtilsProvider } from '@providers/utils/dom'; + +/** + * Content links handler for glossary new entry. + * Match mod/glossary/edit.php?cmid=6 with a valid data. + * Currently it only supports new entry. + */ +@Injectable() +export class AddonModGlossaryEditLinkHandler extends CoreContentLinksHandlerBase { + name = 'AddonModGlossaryEditLinkHandler'; + featureName = 'CoreCourseModuleDelegate_AddonModGlossary'; + pattern = /\/mod\/glossary\/edit\.php.*([\?\&](cmid)=\d+)/; + + constructor(private linkHelper: CoreContentLinksHelperProvider, private courseProvider: CoreCourseProvider, + private domUtils: CoreDomUtilsProvider) { + super(); + } + + /** + * Get the list of actions for a link (url). + * + * @param {string[]} siteIds List of sites the URL belongs to. + * @param {string} url The URL to treat. + * @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1} + * @param {number} [courseId] Course ID related to the URL. Optional but recommended. + * @return {CoreContentLinksAction[]|Promise} List of (or promise resolved with list of) actions. + */ + getActions(siteIds: string[], url: string, params: any, courseId?: number): + CoreContentLinksAction[] | Promise { + + return [{ + action: (siteId, navCtrl?): void => { + const modal = this.domUtils.showModalLoading(), + cmId = parseInt(params.cmid, 10); + + this.courseProvider.getModuleBasicInfo(cmId, siteId).then((module) => { + const pageParams = { + courseId: module.course, + module: module, + glossary: module.module, + entry: null // It does not support entry editing. + }; + + return this.linkHelper.goInSite(navCtrl, 'AddonModGlossaryEditPage', pageParams, siteId); + }).finally(() => { + // Just in case. In fact we need to dismiss the modal before showing a toast or error message. + modal.dismiss(); + }); + } + }]; + } + + /** + * Check if the handler is enabled for a certain site (site + user) and a URL. + * If not defined, defaults to true. + * + * @param {string} siteId The site ID. + * @param {string} url The URL to treat. + * @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1} + * @param {number} [courseId] Course ID related to the URL. Optional but recommended. + * @return {boolean|Promise} Whether the handler is enabled for the URL and site. + */ + isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise { + return typeof params.cmid != 'undefined'; + } +} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 4d4743294..6069ee983 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -95,6 +95,7 @@ import { AddonBlockCalendarMonthModule } from '@addon/block/calendarmonth/calend import { AddonBlockCalendarUpcomingModule } from '@addon/block/calendarupcoming/calendarupcoming.module'; import { AddonBlockCommentsModule } from '@addon/block/comments/comments.module'; import { AddonBlockCompletionStatusModule } from '@addon/block/completionstatus/completionstatus.module'; +import { AddonBlockGlossaryRandomModule } from '@addon/block/glossaryrandom/glossaryrandom.module'; import { AddonBlockHtmlModule } from '@addon/block/html/html.module'; import { AddonBlockMyOverviewModule } from '@addon/block/myoverview/myoverview.module'; import { AddonBlockNewsItemsModule } from '@addon/block/newsitems/newsitems.module'; @@ -227,6 +228,7 @@ export const CORE_PROVIDERS: any[] = [ AddonBlockCalendarUpcomingModule, AddonBlockCommentsModule, AddonBlockCompletionStatusModule, + AddonBlockGlossaryRandomModule, AddonBlockHtmlModule, AddonBlockLearningPlansModule, AddonBlockMyOverviewModule, diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index 88734646f..cde20c4dc 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -31,6 +31,7 @@ "addon.block_calendarupcoming.pluginname": " Upcoming events", "addon.block_comments.pluginname": "Comments", "addon.block_completionstatus.pluginname": "Course completion status", + "addon.block_glossaryrandom.pluginname": "Random glossary entry", "addon.block_learningplans.pluginname": "Learning plans", "addon.block_myoverview.all": "All", "addon.block_myoverview.favourites": "Starred", From ebe4b0cf99452e665c99a7db10842c4fcde21d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Fri, 10 May 2019 15:34:31 +0200 Subject: [PATCH 06/13] MOBILE-3002 block: Add Latest badges block feature --- scripts/langindex.json | 1 + src/addon/block/badges/badges.module.ts | 38 ++++++++++++++ src/addon/block/badges/badges.scss | 23 ++++++++ src/addon/block/badges/lang/en.json | 3 ++ .../block/badges/providers/block-handler.ts | 52 +++++++++++++++++++ src/app/app.module.ts | 2 + src/assets/lang/en.json | 1 + 7 files changed, 120 insertions(+) create mode 100644 src/addon/block/badges/badges.module.ts create mode 100644 src/addon/block/badges/badges.scss create mode 100644 src/addon/block/badges/lang/en.json create mode 100644 src/addon/block/badges/providers/block-handler.ts diff --git a/scripts/langindex.json b/scripts/langindex.json index 1c36c87ea..b616afc3c 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -27,6 +27,7 @@ "addon.badges.version": "badges", "addon.badges.warnexpired": "badges", "addon.block_activitymodules.pluginname": "block_activity_modules", + "addon.block_badges.pluginname": "block_badges", "addon.block_calendarmonth.pluginname": "block_calendar_month", "addon.block_calendarupcoming.pluginname": "block_calendar_upcoming", "addon.block_comments.pluginname": "block_comments", diff --git a/src/addon/block/badges/badges.module.ts b/src/addon/block/badges/badges.module.ts new file mode 100644 index 000000000..ff9c450d2 --- /dev/null +++ b/src/addon/block/badges/badges.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 { AddonBlockBadgesHandler } from './providers/block-handler'; + +@NgModule({ + declarations: [ + ], + imports: [ + IonicModule, + TranslateModule.forChild() + ], + exports: [ + ], + providers: [ + AddonBlockBadgesHandler + ] +}) +export class AddonBlockBadgesModule { + constructor(blockDelegate: CoreBlockDelegate, blockHandler: AddonBlockBadgesHandler) { + blockDelegate.registerHandler(blockHandler); + } +} diff --git a/src/addon/block/badges/badges.scss b/src/addon/block/badges/badges.scss new file mode 100644 index 000000000..3f9d26d8b --- /dev/null +++ b/src/addon/block/badges/badges.scss @@ -0,0 +1,23 @@ +.addon-block-badges core-block-pre-rendered { + .core-block-content { + ul.badges { + list-style: none; + @include margin-horizontal(0); + -webkit-padding-start: 0; + + li { + position: relative; + display: inline-block; + padding-top: 1em; + text-align: center; + vertical-align: top; + width: 150px; + + .badge-name { + display: block; + padding: 5px; + } + } + } + } +} \ No newline at end of file diff --git a/src/addon/block/badges/lang/en.json b/src/addon/block/badges/lang/en.json new file mode 100644 index 000000000..dd957321f --- /dev/null +++ b/src/addon/block/badges/lang/en.json @@ -0,0 +1,3 @@ +{ + "pluginname": "Latest badges" +} \ No newline at end of file diff --git a/src/addon/block/badges/providers/block-handler.ts b/src/addon/block/badges/providers/block-handler.ts new file mode 100644 index 000000000..9cf9b3622 --- /dev/null +++ b/src/addon/block/badges/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 AddonBlockBadgesHandler extends CoreBlockBaseHandler { + name = 'AddonBlockBadges'; + blockName = 'badges'; + + 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_badges.pluginname'), + class: 'addon-block-badges', + component: CoreBlockPreRenderedComponent + }; + } +} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 6069ee983..1507b6921 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -91,6 +91,7 @@ import { AddonCourseCompletionModule } from '@addon/coursecompletion/coursecompl import { AddonUserProfileFieldModule } from '@addon/userprofilefield/userprofilefield.module'; import { AddonFilesModule } from '@addon/files/files.module'; import { AddonBlockActivityModulesModule } from '@addon/block/activitymodules/activitymodules.module'; +import { AddonBlockBadgesModule } from '@addon/block/badges/badges.module'; import { AddonBlockCalendarMonthModule } from '@addon/block/calendarmonth/calendarmonth.module'; import { AddonBlockCalendarUpcomingModule } from '@addon/block/calendarupcoming/calendarupcoming.module'; import { AddonBlockCommentsModule } from '@addon/block/comments/comments.module'; @@ -224,6 +225,7 @@ export const CORE_PROVIDERS: any[] = [ AddonUserProfileFieldModule, AddonFilesModule, AddonBlockActivityModulesModule, + AddonBlockBadgesModule, AddonBlockCalendarMonthModule, AddonBlockCalendarUpcomingModule, AddonBlockCommentsModule, diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index cde20c4dc..fff9c6689 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -27,6 +27,7 @@ "addon.badges.version": "Version", "addon.badges.warnexpired": "(This badge has expired!)", "addon.block_activitymodules.pluginname": "Activities", + "addon.block_badges.pluginname": "Latest badges", "addon.block_calendarmonth.pluginname": "Calendar", "addon.block_calendarupcoming.pluginname": " Upcoming events", "addon.block_comments.pluginname": "Comments", From 48303896b927f1228e78ecc4392076a3b1619dbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Fri, 10 May 2019 15:53:56 +0200 Subject: [PATCH 07/13] MOBILE-3002 block: Add Tags block feature --- scripts/langindex.json | 1 + src/addon/block/tags/lang/en.json | 3 + .../block/tags/providers/block-handler.ts | 52 +++++++++ src/addon/block/tags/tags.module.ts | 38 +++++++ src/addon/block/tags/tags.scss | 100 ++++++++++++++++++ src/app/app.module.ts | 2 + src/assets/lang/en.json | 1 + 7 files changed, 197 insertions(+) create mode 100644 src/addon/block/tags/lang/en.json create mode 100644 src/addon/block/tags/providers/block-handler.ts create mode 100644 src/addon/block/tags/tags.module.ts create mode 100644 src/addon/block/tags/tags.scss diff --git a/scripts/langindex.json b/scripts/langindex.json index b616afc3c..ceb8559a8 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -56,6 +56,7 @@ "addon.block_sitemainmenu.pluginname": "block_site_main_menu", "addon.block_starredcourses.nocourses": "block_starredcourses", "addon.block_starredcourses.pluginname": "block_starredcourses", + "addon.block_tags.pluginname": "block_tags", "addon.block_timeline.duedate": "block_timeline", "addon.block_timeline.next30days": "block_timeline", "addon.block_timeline.next3months": "block_timeline", diff --git a/src/addon/block/tags/lang/en.json b/src/addon/block/tags/lang/en.json new file mode 100644 index 000000000..a4080dd78 --- /dev/null +++ b/src/addon/block/tags/lang/en.json @@ -0,0 +1,3 @@ +{ + "pluginname": "Tags" +} \ No newline at end of file diff --git a/src/addon/block/tags/providers/block-handler.ts b/src/addon/block/tags/providers/block-handler.ts new file mode 100644 index 000000000..749188709 --- /dev/null +++ b/src/addon/block/tags/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 AddonBlockTagsHandler extends CoreBlockBaseHandler { + name = 'AddonBlockTags'; + blockName = 'tags'; + + 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_tags.pluginname'), + class: 'addon-block-tags', + component: CoreBlockPreRenderedComponent + }; + } +} diff --git a/src/addon/block/tags/tags.module.ts b/src/addon/block/tags/tags.module.ts new file mode 100644 index 000000000..4b57911c0 --- /dev/null +++ b/src/addon/block/tags/tags.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 { AddonBlockTagsHandler } from './providers/block-handler'; + +@NgModule({ + declarations: [ + ], + imports: [ + IonicModule, + TranslateModule.forChild() + ], + exports: [ + ], + providers: [ + AddonBlockTagsHandler + ] +}) +export class AddonBlockTagsModule { + constructor(blockDelegate: CoreBlockDelegate, blockHandler: AddonBlockTagsHandler) { + blockDelegate.registerHandler(blockHandler); + } +} diff --git a/src/addon/block/tags/tags.scss b/src/addon/block/tags/tags.scss new file mode 100644 index 000000000..cd3df32eb --- /dev/null +++ b/src/addon/block/tags/tags.scss @@ -0,0 +1,100 @@ +.addon-block-tags core-block-pre-rendered { + .core-block-content { + .tag_cloud { + text-align: center; + ul.inline-list { + list-style: none; + @include margin-horizontal(0); + -webkit-padding-start: 0; + + li { + padding: 0 .2em; + display: inline; + } + } + } + .tag_cloud .s20 { + font-size: 2.7em; + } + + .tag_cloud .s19 { + font-size: 2.6em; + } + + .tag_cloud .s18 { + font-size: 2.5em; + } + + .tag_cloud .s17 { + font-size: 2.4em; + } + + .tag_cloud .s16 { + font-size: 2.3em; + } + + .tag_cloud .s15 { + font-size: 2.2em; + } + + .tag_cloud .s14 { + font-size: 2.1em; + } + + .tag_cloud .s13 { + font-size: 2em; + } + + .tag_cloud .s12 { + font-size: 1.9em; + } + + .tag_cloud .s11 { + font-size: 1.8em; + } + + .tag_cloud .s10 { + font-size: 1.7em; + } + + .tag_cloud .s9 { + font-size: 1.6em; + } + + .tag_cloud .s8 { + font-size: 1.5em; + } + + .tag_cloud .s7 { + font-size: 1.4em; + } + + .tag_cloud .s6 { + font-size: 1.3em; + } + + .tag_cloud .s5 { + font-size: 1.2em; + } + + .tag_cloud .s4 { + font-size: 1.1em; + } + + .tag_cloud .s3 { + font-size: 1em; + } + + .tag_cloud .s2 { + font-size: 0.9em; + } + + .tag_cloud .s1 { + font-size: 0.8em; + } + + .tag_cloud .s0 { + font-size: 0.7em; + } + } +} \ No newline at end of file diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 1507b6921..9b4d75af7 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -109,6 +109,7 @@ import { AddonBlockRecentlyAccessedCoursesModule } from '@addon/block/recentlyac import { AddonBlockRecentlyAccessedItemsModule } from '@addon/block/recentlyaccesseditems/recentlyaccesseditems.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'; import { AddonModAssignModule } from '@addon/mod/assign/assign.module'; import { AddonModBookModule } from '@addon/mod/book/book.module'; import { AddonModChatModule } from '@addon/mod/chat/chat.module'; @@ -243,6 +244,7 @@ export const CORE_PROVIDERS: any[] = [ AddonBlockRecentlyAccessedItemsModule, AddonBlockStarredCoursesModule, AddonBlockSelfCompletionModule, + AddonBlockTagsModule, AddonModAssignModule, AddonModBookModule, AddonModChatModule, diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index fff9c6689..390eec79f 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -56,6 +56,7 @@ "addon.block_sitemainmenu.pluginname": "Main menu", "addon.block_starredcourses.nocourses": "No starred courses", "addon.block_starredcourses.pluginname": "Starred courses", + "addon.block_tags.pluginname": "Tags", "addon.block_timeline.duedate": "Due date", "addon.block_timeline.next30days": "Next 30 days", "addon.block_timeline.next3months": "Next 3 months", From 7398b0a662d25e5b542dcaeec4471b70f9e18ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Mon, 13 May 2019 13:30:02 +0200 Subject: [PATCH 08/13] MOBILE-3002 block: Add Blog Tags block feature --- scripts/langindex.json | 1 + src/addon/block/blogtags/blogtags.module.ts | 38 +++++++++ src/addon/block/blogtags/blogtags.scss | 82 +++++++++++++++++++ src/addon/block/blogtags/lang/en.json | 3 + .../block/blogtags/providers/block-handler.ts | 52 ++++++++++++ src/app/app.module.ts | 2 + src/assets/lang/en.json | 1 + 7 files changed, 179 insertions(+) create mode 100644 src/addon/block/blogtags/blogtags.module.ts create mode 100644 src/addon/block/blogtags/blogtags.scss create mode 100644 src/addon/block/blogtags/lang/en.json create mode 100644 src/addon/block/blogtags/providers/block-handler.ts diff --git a/scripts/langindex.json b/scripts/langindex.json index ceb8559a8..7ee470a71 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -28,6 +28,7 @@ "addon.badges.warnexpired": "badges", "addon.block_activitymodules.pluginname": "block_activity_modules", "addon.block_badges.pluginname": "block_badges", + "addon.block_blogtags.pluginname": "block_blog_tags", "addon.block_calendarmonth.pluginname": "block_calendar_month", "addon.block_calendarupcoming.pluginname": "block_calendar_upcoming", "addon.block_comments.pluginname": "block_comments", diff --git a/src/addon/block/blogtags/blogtags.module.ts b/src/addon/block/blogtags/blogtags.module.ts new file mode 100644 index 000000000..a9ed3a090 --- /dev/null +++ b/src/addon/block/blogtags/blogtags.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 { AddonBlockBlogTagsHandler } from './providers/block-handler'; + +@NgModule({ + declarations: [ + ], + imports: [ + IonicModule, + TranslateModule.forChild() + ], + exports: [ + ], + providers: [ + AddonBlockBlogTagsHandler + ] +}) +export class AddonBlockBlogTagsModule { + constructor(blockDelegate: CoreBlockDelegate, blockHandler: AddonBlockBlogTagsHandler) { + blockDelegate.registerHandler(blockHandler); + } +} diff --git a/src/addon/block/blogtags/blogtags.scss b/src/addon/block/blogtags/blogtags.scss new file mode 100644 index 000000000..859b876da --- /dev/null +++ b/src/addon/block/blogtags/blogtags.scss @@ -0,0 +1,82 @@ +.addon-block-blog-tags core-block-pre-rendered { + .core-block-content { + ul.inline-list { + list-style: none; + @include margin-horizontal(0); + -webkit-padding-start: 0; + + li { + padding: 0 .2em; + display: inline; + } + } + .s20 { + font-size: 1.5em; + font-weight: bold; + } + + .s19 { + font-size: 1.5em; + } + + .s18 { + font-size: 1.4em; + font-weight: bold; + } + + .s17 { + font-size: 1.4em; + } + + .s16 { + font-size: 1.3em; + font-weight: bold; + } + + .s15 { + font-size: 1.3em; + } + + .s14 { + font-size: 1.2em; + font-weight: bold; + } + + .s13 { + font-size: 1.2em; + } + + .s12, + .s11 { + font-size: 1.1em; + font-weight: bold; + } + + .s10, + .s9 { + font-size: 1.1em; + } + + .s8, + .s7 { + font-size: 1em; + font-weight: bold; + } + + .s6, + .s5 { + font-size: 1em; + } + + .s4, + .s3 { + font-size: 0.9em; + font-weight: bold; + } + + .s2, + .s1 { + font-size: 0.9em; + } + } +} \ No newline at end of file diff --git a/src/addon/block/blogtags/lang/en.json b/src/addon/block/blogtags/lang/en.json new file mode 100644 index 000000000..683c3aa90 --- /dev/null +++ b/src/addon/block/blogtags/lang/en.json @@ -0,0 +1,3 @@ +{ + "pluginname": "Blog tags" +} \ No newline at end of file diff --git a/src/addon/block/blogtags/providers/block-handler.ts b/src/addon/block/blogtags/providers/block-handler.ts new file mode 100644 index 000000000..cd6ae4c46 --- /dev/null +++ b/src/addon/block/blogtags/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 AddonBlockBlogTagsHandler extends CoreBlockBaseHandler { + name = 'AddonBlockBlogTags'; + blockName = 'blog_tags'; + + 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_blogtags.pluginname'), + class: 'addon-block-blog-tags', + component: CoreBlockPreRenderedComponent + }; + } +} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 9b4d75af7..6183c41f3 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -92,6 +92,7 @@ import { AddonUserProfileFieldModule } from '@addon/userprofilefield/userprofile import { AddonFilesModule } from '@addon/files/files.module'; import { AddonBlockActivityModulesModule } from '@addon/block/activitymodules/activitymodules.module'; import { AddonBlockBadgesModule } from '@addon/block/badges/badges.module'; +import { AddonBlockBlogTagsModule } from '@addon/block/blogtags/blogtags.module'; import { AddonBlockCalendarMonthModule } from '@addon/block/calendarmonth/calendarmonth.module'; import { AddonBlockCalendarUpcomingModule } from '@addon/block/calendarupcoming/calendarupcoming.module'; import { AddonBlockCommentsModule } from '@addon/block/comments/comments.module'; @@ -227,6 +228,7 @@ export const CORE_PROVIDERS: any[] = [ AddonFilesModule, AddonBlockActivityModulesModule, AddonBlockBadgesModule, + AddonBlockBlogTagsModule, AddonBlockCalendarMonthModule, AddonBlockCalendarUpcomingModule, AddonBlockCommentsModule, diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index 390eec79f..8eba39062 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -28,6 +28,7 @@ "addon.badges.warnexpired": "(This badge has expired!)", "addon.block_activitymodules.pluginname": "Activities", "addon.block_badges.pluginname": "Latest badges", + "addon.block_blogtags.pluginname": "Blog tags", "addon.block_calendarmonth.pluginname": "Calendar", "addon.block_calendarupcoming.pluginname": " Upcoming events", "addon.block_comments.pluginname": "Comments", From 83a899acd6bc66c34f9df0c68b5fc35504b51412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Mon, 13 May 2019 13:44:46 +0200 Subject: [PATCH 09/13] MOBILE-3002 block: Add Blog Menu block feature --- scripts/langindex.json | 1 + src/addon/block/blogmenu/blogmenu.module.ts | 38 ++++++++++++++ src/addon/block/blogmenu/blogmenu.scss | 16 ++++++ src/addon/block/blogmenu/lang/en.json | 3 ++ .../block/blogmenu/providers/block-handler.ts | 52 +++++++++++++++++++ src/app/app.module.ts | 2 + src/assets/lang/en.json | 1 + 7 files changed, 113 insertions(+) create mode 100644 src/addon/block/blogmenu/blogmenu.module.ts create mode 100644 src/addon/block/blogmenu/blogmenu.scss create mode 100644 src/addon/block/blogmenu/lang/en.json create mode 100644 src/addon/block/blogmenu/providers/block-handler.ts diff --git a/scripts/langindex.json b/scripts/langindex.json index 7ee470a71..b901aacbb 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -28,6 +28,7 @@ "addon.badges.warnexpired": "badges", "addon.block_activitymodules.pluginname": "block_activity_modules", "addon.block_badges.pluginname": "block_badges", + "addon.block_blogmenu.pluginname": "block_blog_menu", "addon.block_blogtags.pluginname": "block_blog_tags", "addon.block_calendarmonth.pluginname": "block_calendar_month", "addon.block_calendarupcoming.pluginname": "block_calendar_upcoming", diff --git a/src/addon/block/blogmenu/blogmenu.module.ts b/src/addon/block/blogmenu/blogmenu.module.ts new file mode 100644 index 000000000..cbca10200 --- /dev/null +++ b/src/addon/block/blogmenu/blogmenu.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 { AddonBlockBlogMenuHandler } from './providers/block-handler'; + +@NgModule({ + declarations: [ + ], + imports: [ + IonicModule, + TranslateModule.forChild() + ], + exports: [ + ], + providers: [ + AddonBlockBlogMenuHandler + ] +}) +export class AddonBlockBlogMenuModule { + constructor(blockDelegate: CoreBlockDelegate, blockHandler: AddonBlockBlogMenuHandler) { + blockDelegate.registerHandler(blockHandler); + } +} diff --git a/src/addon/block/blogmenu/blogmenu.scss b/src/addon/block/blogmenu/blogmenu.scss new file mode 100644 index 000000000..c649986ed --- /dev/null +++ b/src/addon/block/blogmenu/blogmenu.scss @@ -0,0 +1,16 @@ +.addon-block-blog-menu core-block-pre-rendered { + .core-block-content { + ul.list { + list-style: none; + @include margin-horizontal(0); + -webkit-padding-start: 0; + + li { + padding-bottom: 8px; + } + } + } + .core-block-footer { + display: none; + } +} \ No newline at end of file diff --git a/src/addon/block/blogmenu/lang/en.json b/src/addon/block/blogmenu/lang/en.json new file mode 100644 index 000000000..23541f7a0 --- /dev/null +++ b/src/addon/block/blogmenu/lang/en.json @@ -0,0 +1,3 @@ +{ + "pluginname": "Blog menu" +} \ No newline at end of file diff --git a/src/addon/block/blogmenu/providers/block-handler.ts b/src/addon/block/blogmenu/providers/block-handler.ts new file mode 100644 index 000000000..362b97899 --- /dev/null +++ b/src/addon/block/blogmenu/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 AddonBlockBlogMenuHandler extends CoreBlockBaseHandler { + name = 'AddonBlockBlogMenu'; + blockName = 'blog_menu'; + + 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_blogmenu.pluginname'), + class: 'addon-block-blog-menu', + component: CoreBlockPreRenderedComponent + }; + } +} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 6183c41f3..10a4b4b1a 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -92,6 +92,7 @@ import { AddonUserProfileFieldModule } from '@addon/userprofilefield/userprofile import { AddonFilesModule } from '@addon/files/files.module'; import { AddonBlockActivityModulesModule } from '@addon/block/activitymodules/activitymodules.module'; import { AddonBlockBadgesModule } from '@addon/block/badges/badges.module'; +import { AddonBlockBlogMenuModule } from '@addon/block/blogmenu/blogmenu.module'; import { AddonBlockBlogTagsModule } from '@addon/block/blogtags/blogtags.module'; import { AddonBlockCalendarMonthModule } from '@addon/block/calendarmonth/calendarmonth.module'; import { AddonBlockCalendarUpcomingModule } from '@addon/block/calendarupcoming/calendarupcoming.module'; @@ -228,6 +229,7 @@ export const CORE_PROVIDERS: any[] = [ AddonFilesModule, AddonBlockActivityModulesModule, AddonBlockBadgesModule, + AddonBlockBlogMenuModule, AddonBlockBlogTagsModule, AddonBlockCalendarMonthModule, AddonBlockCalendarUpcomingModule, diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index 8eba39062..b96c9a970 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -28,6 +28,7 @@ "addon.badges.warnexpired": "(This badge has expired!)", "addon.block_activitymodules.pluginname": "Activities", "addon.block_badges.pluginname": "Latest badges", + "addon.block_blogmenu.pluginname": "Blog menu", "addon.block_blogtags.pluginname": "Blog tags", "addon.block_calendarmonth.pluginname": "Calendar", "addon.block_calendarupcoming.pluginname": " Upcoming events", From 8ede493cef203b80b70ab5b037cd98a21f22ddc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 14 May 2019 13:51:26 +0200 Subject: [PATCH 10/13] MOBILE-3002 block: Add Recent activity block feature --- scripts/langindex.json | 3 +- src/addon/block/recentactivity/lang/en.json | 3 ++ .../recentactivity/providers/block-handler.ts | 52 +++++++++++++++++++ .../recentactivity/recentactivity.module.ts | 38 ++++++++++++++ .../block/recentactivity/recentactivity.scss | 20 +++++++ src/app/app.module.ts | 2 + src/assets/lang/en.json | 1 + 7 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 src/addon/block/recentactivity/lang/en.json create mode 100644 src/addon/block/recentactivity/providers/block-handler.ts create mode 100644 src/addon/block/recentactivity/recentactivity.module.ts create mode 100644 src/addon/block/recentactivity/recentactivity.scss 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", From cac7f0bc1255ca0cdd183ba70f4206f72e70b56a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 14 May 2019 14:01:08 +0200 Subject: [PATCH 11/13] MOBILE-3002 block: Add Recent blog entries block feature --- scripts/langindex.json | 1 + .../block/blogrecent/blogrecent.module.ts | 38 ++++++++++++++ src/addon/block/blogrecent/blogrecent.scss | 13 +++++ src/addon/block/blogrecent/lang/en.json | 3 ++ .../blogrecent/providers/block-handler.ts | 52 +++++++++++++++++++ src/app/app.module.ts | 2 + src/assets/lang/en.json | 1 + 7 files changed, 110 insertions(+) create mode 100644 src/addon/block/blogrecent/blogrecent.module.ts create mode 100644 src/addon/block/blogrecent/blogrecent.scss create mode 100644 src/addon/block/blogrecent/lang/en.json create mode 100644 src/addon/block/blogrecent/providers/block-handler.ts diff --git a/scripts/langindex.json b/scripts/langindex.json index b803d75bf..95f5d1ca6 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -29,6 +29,7 @@ "addon.block_activitymodules.pluginname": "block_activity_modules", "addon.block_badges.pluginname": "block_badges", "addon.block_blogmenu.pluginname": "block_blog_menu", + "addon.block_blogrecent.nocourses": "block_blog_recent", "addon.block_blogtags.pluginname": "block_blog_tags", "addon.block_calendarmonth.pluginname": "block_calendar_month", "addon.block_calendarupcoming.pluginname": "block_calendar_upcoming", diff --git a/src/addon/block/blogrecent/blogrecent.module.ts b/src/addon/block/blogrecent/blogrecent.module.ts new file mode 100644 index 000000000..1ecdf6f7b --- /dev/null +++ b/src/addon/block/blogrecent/blogrecent.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 { AddonBlockBlogRecentHandler } from './providers/block-handler'; + +@NgModule({ + declarations: [ + ], + imports: [ + IonicModule, + TranslateModule.forChild() + ], + exports: [ + ], + providers: [ + AddonBlockBlogRecentHandler + ] +}) +export class AddonBlockBlogRecentModule { + constructor(blockDelegate: CoreBlockDelegate, blockHandler: AddonBlockBlogRecentHandler) { + blockDelegate.registerHandler(blockHandler); + } +} diff --git a/src/addon/block/blogrecent/blogrecent.scss b/src/addon/block/blogrecent/blogrecent.scss new file mode 100644 index 000000000..81a03b227 --- /dev/null +++ b/src/addon/block/blogrecent/blogrecent.scss @@ -0,0 +1,13 @@ +.addon-block-blog-recent core-block-pre-rendered { + .core-block-content { + ul.list { + list-style: none; + @include margin-horizontal(0); + -webkit-padding-start: 0; + + li { + padding-bottom: 8px; + } + } + } +} \ No newline at end of file diff --git a/src/addon/block/blogrecent/lang/en.json b/src/addon/block/blogrecent/lang/en.json new file mode 100644 index 000000000..a92c0cce5 --- /dev/null +++ b/src/addon/block/blogrecent/lang/en.json @@ -0,0 +1,3 @@ +{ + "pluginname": "Recent blog entries" +} \ No newline at end of file diff --git a/src/addon/block/blogrecent/providers/block-handler.ts b/src/addon/block/blogrecent/providers/block-handler.ts new file mode 100644 index 000000000..69140e96d --- /dev/null +++ b/src/addon/block/blogrecent/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 AddonBlockBlogRecentHandler extends CoreBlockBaseHandler { + name = 'AddonBlockBlogRecent'; + blockName = 'blog_recent'; + + 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_blogrecent.pluginname'), + class: 'addon-block-blog-recent', + component: CoreBlockPreRenderedComponent + }; + } +} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index cc570b6b2..4c1b3f81f 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 { AddonBlockBadgesModule } from '@addon/block/badges/badges.module'; import { AddonBlockBlogMenuModule } from '@addon/block/blogmenu/blogmenu.module'; import { AddonBlockBlogTagsModule } from '@addon/block/blogtags/blogtags.module'; +import { AddonBlockBlogRecentModule } from '@addon/block/blogrecent/blogrecent.module'; import { AddonBlockCalendarMonthModule } from '@addon/block/calendarmonth/calendarmonth.module'; import { AddonBlockCalendarUpcomingModule } from '@addon/block/calendarupcoming/calendarupcoming.module'; import { AddonBlockCommentsModule } from '@addon/block/comments/comments.module'; @@ -231,6 +232,7 @@ export const CORE_PROVIDERS: any[] = [ AddonBlockActivityModulesModule, AddonBlockBadgesModule, AddonBlockBlogMenuModule, + AddonBlockBlogRecentModule, AddonBlockBlogTagsModule, AddonBlockCalendarMonthModule, AddonBlockCalendarUpcomingModule, diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index 69e66a2b3..a70d49554 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -29,6 +29,7 @@ "addon.block_activitymodules.pluginname": "Activities", "addon.block_badges.pluginname": "Latest badges", "addon.block_blogmenu.pluginname": "Blog menu", + "addon.block_blogrecent.pluginname": "Recent blog entries", "addon.block_blogtags.pluginname": "Blog tags", "addon.block_calendarmonth.pluginname": "Calendar", "addon.block_calendarupcoming.pluginname": " Upcoming events", From a549e70d5f49b5cb3baa7aa19987c7718c7ea6ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 14 May 2019 14:44:33 +0200 Subject: [PATCH 12/13] MOBILE-3002 block: Add Remote RSS block feature --- scripts/langindex.json | 1 + src/addon/block/rssclient/lang/en.json | 3 ++ .../rssclient/providers/block-handler.ts | 52 +++++++++++++++++++ src/addon/block/rssclient/rssclient.module.ts | 38 ++++++++++++++ src/addon/block/rssclient/rssclient.scss | 19 +++++++ src/app/app.module.ts | 2 + src/assets/lang/en.json | 1 + 7 files changed, 116 insertions(+) create mode 100644 src/addon/block/rssclient/lang/en.json create mode 100644 src/addon/block/rssclient/providers/block-handler.ts create mode 100644 src/addon/block/rssclient/rssclient.module.ts create mode 100644 src/addon/block/rssclient/rssclient.scss diff --git a/scripts/langindex.json b/scripts/langindex.json index 95f5d1ca6..e29d5b9d7 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -55,6 +55,7 @@ "addon.block_recentlyaccessedcourses.pluginname": "block_recentlyaccessedcourses", "addon.block_recentlyaccesseditems.noitems": "block_recentlyaccesseditems", "addon.block_recentactivity.pluginname": "block_recent_activity", + "addon.block_rssclient.pluginname": "block_rss_client", "addon.block_glossaryrandom.pluginname": "block_glossary_random", "addon.block_selfcompletion.pluginname": "block_selfcompletion", "addon.block_sitemainmenu.pluginname": "block_site_main_menu", diff --git a/src/addon/block/rssclient/lang/en.json b/src/addon/block/rssclient/lang/en.json new file mode 100644 index 000000000..18282971b --- /dev/null +++ b/src/addon/block/rssclient/lang/en.json @@ -0,0 +1,3 @@ +{ + "pluginname": "Remote RSS feeds" +} \ No newline at end of file diff --git a/src/addon/block/rssclient/providers/block-handler.ts b/src/addon/block/rssclient/providers/block-handler.ts new file mode 100644 index 000000000..ce26caba4 --- /dev/null +++ b/src/addon/block/rssclient/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 AddonBlockRssClientHandler extends CoreBlockBaseHandler { + name = 'AddonBlockRssClient'; + blockName = 'rss_client'; + + 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: block.contents.title || this.translate.instant('addon.block_rssclient.pluginname'), + class: 'addon-block-rss-client', + component: CoreBlockPreRenderedComponent + }; + } +} diff --git a/src/addon/block/rssclient/rssclient.module.ts b/src/addon/block/rssclient/rssclient.module.ts new file mode 100644 index 000000000..b98c39ae5 --- /dev/null +++ b/src/addon/block/rssclient/rssclient.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 { AddonBlockRssClientHandler } from './providers/block-handler'; + +@NgModule({ + declarations: [ + ], + imports: [ + IonicModule, + TranslateModule.forChild() + ], + exports: [ + ], + providers: [ + AddonBlockRssClientHandler + ] +}) +export class AddonBlockRssClientModule { + constructor(blockDelegate: CoreBlockDelegate, blockHandler: AddonBlockRssClientHandler) { + blockDelegate.registerHandler(blockHandler); + } +} diff --git a/src/addon/block/rssclient/rssclient.scss b/src/addon/block/rssclient/rssclient.scss new file mode 100644 index 000000000..33b37b0e7 --- /dev/null +++ b/src/addon/block/rssclient/rssclient.scss @@ -0,0 +1,19 @@ +.addon-block-rss-client core-block-pre-rendered { + .core-block-content { + .list { + list-style: none; + @include margin-horizontal(0); + -webkit-padding-start: 0; + + li { + border-top: 1px solid $gray; + padding: 5px; + padding-bottom: 8px; + } + + li:first-child { + border-top-width: 0; + } + } + } +} \ No newline at end of file diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 4c1b3f81f..6969e01bc 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -111,6 +111,7 @@ 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 { AddonBlockRssClientModule } from '@addon/block/rssclient/rssclient.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'; @@ -250,6 +251,7 @@ export const CORE_PROVIDERS: any[] = [ AddonBlockRecentlyAccessedCoursesModule, AddonBlockRecentlyAccessedItemsModule, AddonBlockRecentActivityModule, + AddonBlockRssClientModule, AddonBlockStarredCoursesModule, AddonBlockSelfCompletionModule, AddonBlockTagsModule, diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index a70d49554..f3f750318 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -56,6 +56,7 @@ "addon.block_recentlyaccessedcourses.pluginname": "Recently accessed courses", "addon.block_recentlyaccesseditems.noitems": "No recent items", "addon.block_recentlyaccesseditems.pluginname": "Recently accessed items", + "addon.block_rssclient.pluginname": "Remote RSS feeds", "addon.block_selfcompletion.pluginname": "Self completion", "addon.block_sitemainmenu.pluginname": "Main menu", "addon.block_starredcourses.nocourses": "No starred courses", From 03b305662e3c479127c4180847e277f0b7922a10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 16 May 2019 11:16:24 +0200 Subject: [PATCH 13/13] MOBILE-3002 block: Check if blocks are disabled in courses --- src/core/block/providers/course-option-handler.ts | 5 +++-- src/core/block/providers/delegate.ts | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/core/block/providers/course-option-handler.ts b/src/core/block/providers/course-option-handler.ts index 7e38227f5..893904ed8 100644 --- a/src/core/block/providers/course-option-handler.ts +++ b/src/core/block/providers/course-option-handler.ts @@ -16,6 +16,7 @@ import { Injectable, Injector } from '@angular/core'; import { CoreCourseOptionsHandler, CoreCourseOptionsHandlerData } from '@core/course/providers/options-delegate'; import { CoreCourseProvider } from '@core/course/providers/course'; import { CoreBlockCourseBlocksComponent } from '../components/course-blocks/course-blocks'; +import { CoreBlockDelegate } from './delegate'; /** * Course nav handler. @@ -25,7 +26,7 @@ export class CoreBlockCourseBlocksCourseOptionHandler implements CoreCourseOptio name = 'CoreCourseBlocks'; priority = 700; - constructor(private courseProvider: CoreCourseProvider) {} + constructor(private courseProvider: CoreCourseProvider, private blockDelegate: CoreBlockDelegate) {} /** * Should invalidate the data to determine if the handler is enabled for a certain course. @@ -45,7 +46,7 @@ export class CoreBlockCourseBlocksCourseOptionHandler implements CoreCourseOptio * @return {boolean} Whether or not the handler is enabled on a site level. */ isEnabled(): boolean | Promise { - return this.courseProvider.canGetCourseBlocks(); + return this.courseProvider.canGetCourseBlocks() && !this.blockDelegate.areBlocksDisabledInCourses(); } /** diff --git a/src/core/block/providers/delegate.ts b/src/core/block/providers/delegate.ts index b4e6fcf40..7f0f245f3 100644 --- a/src/core/block/providers/delegate.ts +++ b/src/core/block/providers/delegate.ts @@ -117,6 +117,18 @@ export class CoreBlockDelegate extends CoreDelegate { return site.isFeatureDisabled('NoDelegate_SiteBlocks'); } + /** + * Check if blocks are disabled in a certain site for courses. + * + * @param {CoreSite} [site] Site. If not defined, use current site. + * @return {boolean} Whether it's disabled. + */ + areBlocksDisabledInCourses(site?: CoreSite): boolean { + site = site || this.sitesProvider.getCurrentSite(); + + return site.isFeatureDisabled('NoDelegate_CourseBlocks'); + } + /** * Check if blocks are disabled in a certain site. *