From 312a81f3ee19d45fd8e3590bab79037bad6f35c5 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 14 Jul 2020 12:32:45 +0200 Subject: [PATCH] MOBILE-3445 siteplugins: Let plugins disable PTR --- .../siteplugins/classes/handlers/course-option-handler.ts | 3 ++- src/core/siteplugins/classes/handlers/main-menu-handler.ts | 3 ++- .../siteplugins/classes/handlers/message-output-handler.ts | 3 ++- src/core/siteplugins/classes/handlers/settings-handler.ts | 3 ++- src/core/siteplugins/classes/handlers/user-handler.ts | 3 ++- .../course-option/core-siteplugins-course-option.html | 2 +- .../siteplugins/components/course-option/course-option.ts | 3 +++ .../siteplugins/components/module-index/module-index.ts | 2 ++ .../components/only-title-block/only-title-block.ts | 1 + .../components/plugin-content/plugin-content.ts | 7 +++++-- src/core/siteplugins/directives/call-ws-new-content.ts | 4 +++- src/core/siteplugins/directives/new-content.ts | 4 +++- src/core/siteplugins/pages/module-index/module-index.html | 2 +- src/core/siteplugins/pages/plugin-page/plugin-page.html | 2 +- src/core/siteplugins/pages/plugin-page/plugin-page.ts | 3 +++ 15 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/core/siteplugins/classes/handlers/course-option-handler.ts b/src/core/siteplugins/classes/handlers/course-option-handler.ts index 29800bbbf..e1a572172 100644 --- a/src/core/siteplugins/classes/handlers/course-option-handler.ts +++ b/src/core/siteplugins/classes/handlers/course-option-handler.ts @@ -98,7 +98,8 @@ export class CoreSitePluginsCourseOptionHandler extends CoreSitePluginsBaseHandl args: { courseid: course.id }, - initResult: this.initResult + initResult: this.initResult, + ptrEnabled: this.handlerSchema.ptrenabled, } }; } diff --git a/src/core/siteplugins/classes/handlers/main-menu-handler.ts b/src/core/siteplugins/classes/handlers/main-menu-handler.ts index 431164e07..5ff904abf 100644 --- a/src/core/siteplugins/classes/handlers/main-menu-handler.ts +++ b/src/core/siteplugins/classes/handlers/main-menu-handler.ts @@ -43,7 +43,8 @@ export class CoreSitePluginsMainMenuHandler extends CoreSitePluginsBaseHandler i title: this.title, component: this.plugin.component, method: this.handlerSchema.method, - initResult: this.initResult + initResult: this.initResult, + ptrEnabled: this.handlerSchema.ptrenabled, }, onlyInMore: true }; diff --git a/src/core/siteplugins/classes/handlers/message-output-handler.ts b/src/core/siteplugins/classes/handlers/message-output-handler.ts index 3c8d9b996..1e0985ccc 100644 --- a/src/core/siteplugins/classes/handlers/message-output-handler.ts +++ b/src/core/siteplugins/classes/handlers/message-output-handler.ts @@ -40,7 +40,8 @@ export class CoreSitePluginsMessageOutputHandler extends CoreSitePluginsBaseHand title: this.title, component: this.plugin.component, method: this.handlerSchema.method, - initResult: this.initResult + initResult: this.initResult, + ptrEnabled: this.handlerSchema.ptrenabled, } }; } diff --git a/src/core/siteplugins/classes/handlers/settings-handler.ts b/src/core/siteplugins/classes/handlers/settings-handler.ts index d3de29f45..1267faa07 100644 --- a/src/core/siteplugins/classes/handlers/settings-handler.ts +++ b/src/core/siteplugins/classes/handlers/settings-handler.ts @@ -43,7 +43,8 @@ export class CoreSitePluginsSettingsHandler extends CoreSitePluginsBaseHandler i title: this.title, component: this.plugin.component, method: this.handlerSchema.method, - initResult: this.initResult + initResult: this.initResult, + ptrEnabled: this.handlerSchema.ptrenabled, } }; } diff --git a/src/core/siteplugins/classes/handlers/user-handler.ts b/src/core/siteplugins/classes/handlers/user-handler.ts index 29266d048..ae381c477 100644 --- a/src/core/siteplugins/classes/handlers/user-handler.ts +++ b/src/core/siteplugins/classes/handlers/user-handler.ts @@ -94,7 +94,8 @@ export class CoreSitePluginsUserProfileHandler extends CoreSitePluginsBaseHandle courseid: courseId, userid: user.id }, - initResult: this.initResult + initResult: this.initResult, + ptrEnabled: this.handlerSchema.ptrenabled, }); } }; diff --git a/src/core/siteplugins/components/course-option/core-siteplugins-course-option.html b/src/core/siteplugins/components/course-option/core-siteplugins-course-option.html index b2191c305..782649125 100644 --- a/src/core/siteplugins/components/course-option/core-siteplugins-course-option.html +++ b/src/core/siteplugins/components/course-option/core-siteplugins-course-option.html @@ -1,5 +1,5 @@ - + diff --git a/src/core/siteplugins/components/course-option/course-option.ts b/src/core/siteplugins/components/course-option/course-option.ts index 26adaf219..22753f553 100644 --- a/src/core/siteplugins/components/course-option/course-option.ts +++ b/src/core/siteplugins/components/course-option/course-option.ts @@ -13,6 +13,7 @@ // limitations under the License. import { Component, OnInit, Input, ViewChild } from '@angular/core'; +import { CoreUtils } from '@providers/utils/utils'; import { CoreSitePluginsProvider } from '../../providers/siteplugins'; import { CoreSitePluginsPluginContentComponent } from '../plugin-content/plugin-content'; @@ -33,6 +34,7 @@ export class CoreSitePluginsCourseOptionComponent implements OnInit { method: string; args: any; initResult: any; + ptrEnabled = true; constructor(protected sitePluginsProvider: CoreSitePluginsProvider) { } @@ -49,6 +51,7 @@ export class CoreSitePluginsCourseOptionComponent implements OnInit { courseid: this.courseId, }; this.initResult = handler.initResult; + this.ptrEnabled = !CoreUtils.instance.isFalseOrZero(handler.handlerSchema.ptrenabled); } } } diff --git a/src/core/siteplugins/components/module-index/module-index.ts b/src/core/siteplugins/components/module-index/module-index.ts index 94f1dcc75..48a6621e8 100644 --- a/src/core/siteplugins/components/module-index/module-index.ts +++ b/src/core/siteplugins/components/module-index/module-index.ts @@ -53,6 +53,7 @@ export class CoreSitePluginsModuleIndexComponent implements OnInit, OnDestroy, C displayRefresh = true; displayPrefetch = true; displaySize = true; + ptrEnabled = true; jsData: any; // Data to pass to the component. @@ -92,6 +93,7 @@ export class CoreSitePluginsModuleIndexComponent implements OnInit, OnDestroy, C this.displayRefresh = !this.utils.isFalseOrZero(handler.handlerSchema.displayrefresh); this.displayPrefetch = !this.utils.isFalseOrZero(handler.handlerSchema.displayprefetch); this.displaySize = !this.utils.isFalseOrZero(handler.handlerSchema.displaysize); + this.ptrEnabled = !this.utils.isFalseOrZero(handler.handlerSchema.ptrenabled); } // Get the data for the context menu. diff --git a/src/core/siteplugins/components/only-title-block/only-title-block.ts b/src/core/siteplugins/components/only-title-block/only-title-block.ts index 8b1a3987f..fc89a6440 100644 --- a/src/core/siteplugins/components/only-title-block/only-title-block.ts +++ b/src/core/siteplugins/components/only-title-block/only-title-block.ts @@ -63,6 +63,7 @@ export class CoreSitePluginsOnlyTitleBlockComponent extends CoreBlockBaseCompon contextlevel: this.contextLevel, instanceid: this.instanceId, }, + ptrEnabled: handler.handlerSchema.ptrenabled, }); } } diff --git a/src/core/siteplugins/components/plugin-content/plugin-content.ts b/src/core/siteplugins/components/plugin-content/plugin-content.ts index 3a0b491c7..632a64222 100644 --- a/src/core/siteplugins/components/plugin-content/plugin-content.ts +++ b/src/core/siteplugins/components/plugin-content/plugin-content.ts @@ -129,8 +129,10 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck { * @param jsData JS variables to pass to the new view so they can be used in the template or JS. * If true is supplied instead of an object, all initial variables from current page will be copied. * @param preSets The preSets for the WS call of the new content. + * @param ptrEnabled Whether PTR should be enabled in the new page. Defaults to true. */ - openContent(title: string, args: any, component?: string, method?: string, jsData?: any, preSets?: any): void { + openContent(title: string, args: any, component?: string, method?: string, jsData?: any, preSets?: any, + ptrEnabled?: boolean): void { if (jsData === true) { jsData = this.data; } @@ -142,7 +144,8 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck { args: args, initResult: this.initResult, jsData: jsData, - preSets: preSets + preSets: preSets, + ptrEnabled: ptrEnabled, }); } diff --git a/src/core/siteplugins/directives/call-ws-new-content.ts b/src/core/siteplugins/directives/call-ws-new-content.ts index b6c1bdea0..03c7d2ee4 100644 --- a/src/core/siteplugins/directives/call-ws-new-content.ts +++ b/src/core/siteplugins/directives/call-ws-new-content.ts @@ -62,6 +62,7 @@ export class CoreSitePluginsCallWSNewContentDirective extends CoreSitePluginsCal @Input() jsData: any; // JS variables to pass to the new page so they can be used in the template or JS. // If true is supplied instead of an object, all initial variables from current page will be copied. @Input() newContentPreSets: any; // The preSets for the WS call of the new content. + @Input() ptrEnabled: boolean | string; // Whether PTR should be enabled in the new page. Defaults to true. constructor(element: ElementRef, translate: TranslateService, domUtils: CoreDomUtilsProvider, sitePluginsProvider: CoreSitePluginsProvider, @Optional() parentContent: CoreSitePluginsPluginContentComponent, @@ -102,7 +103,8 @@ export class CoreSitePluginsCallWSNewContentDirective extends CoreSitePluginsCal args: args, initResult: this.parentContent && this.parentContent.initResult, jsData: jsData, - preSets: this.newContentPreSets + preSets: this.newContentPreSets, + ptrEnabled: this.ptrEnabled, }); } } diff --git a/src/core/siteplugins/directives/new-content.ts b/src/core/siteplugins/directives/new-content.ts index a373a55ee..cf9a183a5 100644 --- a/src/core/siteplugins/directives/new-content.ts +++ b/src/core/siteplugins/directives/new-content.ts @@ -54,6 +54,7 @@ export class CoreSitePluginsNewContentDirective implements OnInit { @Input() jsData: any; // JS variables to pass to the new page so they can be used in the template or JS. // If true is supplied instead of an object, all initial variables from current page will be copied. @Input() preSets: any; // The preSets for the WS call of the new content. + @Input() ptrEnabled: boolean | string; // Whether PTR should be enabled in the new page. Defaults to true. protected element: HTMLElement; @@ -99,7 +100,8 @@ export class CoreSitePluginsNewContentDirective implements OnInit { args: args, initResult: this.parentContent && this.parentContent.initResult, jsData: jsData, - preSets: this.preSets + preSets: this.preSets, + ptrEnabled: this.ptrEnabled, }); } }); diff --git a/src/core/siteplugins/pages/module-index/module-index.html b/src/core/siteplugins/pages/module-index/module-index.html index 8d83a46b7..f82c0f72e 100644 --- a/src/core/siteplugins/pages/module-index/module-index.html +++ b/src/core/siteplugins/pages/module-index/module-index.html @@ -8,7 +8,7 @@ - + diff --git a/src/core/siteplugins/pages/plugin-page/plugin-page.html b/src/core/siteplugins/pages/plugin-page/plugin-page.html index be1566304..35ea3950a 100644 --- a/src/core/siteplugins/pages/plugin-page/plugin-page.html +++ b/src/core/siteplugins/pages/plugin-page/plugin-page.html @@ -8,7 +8,7 @@ - + diff --git a/src/core/siteplugins/pages/plugin-page/plugin-page.ts b/src/core/siteplugins/pages/plugin-page/plugin-page.ts index 75c81bc53..ec5a97ad4 100644 --- a/src/core/siteplugins/pages/plugin-page/plugin-page.ts +++ b/src/core/siteplugins/pages/plugin-page/plugin-page.ts @@ -14,6 +14,7 @@ import { Component, ViewChild } from '@angular/core'; import { IonicPage, NavParams } from 'ionic-angular'; +import { CoreUtils } from '@providers/utils/utils'; import { CoreSitePluginsPluginContentComponent } from '../../components/plugin-content/plugin-content'; /** @@ -35,6 +36,7 @@ export class CoreSitePluginsPluginPage { initResult: any; jsData: any; // JS variables to pass to the plugin so they can be used in the template or JS. preSets: any; // The preSets for the WS call. + ptrEnabled: boolean; constructor(params: NavParams) { this.title = params.get('title'); @@ -44,6 +46,7 @@ export class CoreSitePluginsPluginPage { this.initResult = params.get('initResult'); this.jsData = params.get('jsData'); this.preSets = params.get('preSets'); + this.ptrEnabled = !CoreUtils.instance.isFalseOrZero(params.get('ptrEnabled')); } /**