From f7eb8762ae93088a64712cb013b9189c95f0c08b Mon Sep 17 00:00:00 2001 From: dpalou Date: Thu, 27 Sep 2018 13:52:10 +0200 Subject: [PATCH] MOBILE-2636 siteplugins: Support preSets in new-content directives --- .../components/plugin-content/plugin-content.ts | 9 ++++++--- src/core/siteplugins/directives/call-ws-new-content.ts | 4 +++- src/core/siteplugins/directives/new-content.ts | 4 +++- src/core/siteplugins/pages/plugin-page/plugin-page.html | 2 +- src/core/siteplugins/pages/plugin-page/plugin-page.ts | 2 ++ 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/core/siteplugins/components/plugin-content/plugin-content.ts b/src/core/siteplugins/components/plugin-content/plugin-content.ts index ce8a59c6a..2342c6566 100644 --- a/src/core/siteplugins/components/plugin-content/plugin-content.ts +++ b/src/core/siteplugins/components/plugin-content/plugin-content.ts @@ -31,6 +31,7 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck { @Input() args: any; @Input() initResult: any; // Result of the init WS call of the handler. @Input() data: any; // Data to pass to the component. + @Input() preSets: any; // The preSets for the WS call. @Output() onContentLoaded?: EventEmitter; // Emits an event when the content is loaded. @Output() onLoadingContent?: EventEmitter; // Emits an event when starts to load the content. @@ -82,7 +83,7 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck { fetchContent(refresh?: boolean): Promise { this.onLoadingContent.emit(refresh); - return this.sitePluginsProvider.getContent(this.component, this.method, this.args).then((result) => { + return this.sitePluginsProvider.getContent(this.component, this.method, this.args, this.preSets).then((result) => { this.content = result.templates.length ? result.templates[0].html : ''; // Load first template. this.javascript = result.javascript; this.otherData = result.otherdata; @@ -112,8 +113,9 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck { * @param {string} [method] New method. If not provided, current method * @param {any} [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 {any} [preSets] The preSets for the WS call of the new content. */ - openContent(title: string, args: any, component?: string, method?: string, jsData?: any): void { + openContent(title: string, args: any, component?: string, method?: string, jsData?: any, preSets?: any): void { if (jsData === true) { jsData = this.data; } @@ -124,7 +126,8 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck { method: method || this.method, args: args, initResult: this.initResult, - jsData: jsData + jsData: jsData, + preSets: preSets }); } diff --git a/src/core/siteplugins/directives/call-ws-new-content.ts b/src/core/siteplugins/directives/call-ws-new-content.ts index 08b4a213e..a2d80d939 100644 --- a/src/core/siteplugins/directives/call-ws-new-content.ts +++ b/src/core/siteplugins/directives/call-ws-new-content.ts @@ -61,6 +61,7 @@ export class CoreSitePluginsCallWSNewContentDirective extends CoreSitePluginsCal @Input() useOtherData: any[]; // Whether to include other data in the args. @see CoreSitePluginsProvider.loadOtherDataInArgs. @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. constructor(element: ElementRef, translate: TranslateService, domUtils: CoreDomUtilsProvider, sitePluginsProvider: CoreSitePluginsProvider, @Optional() parentContent: CoreSitePluginsPluginContentComponent, @@ -100,7 +101,8 @@ export class CoreSitePluginsCallWSNewContentDirective extends CoreSitePluginsCal method: this.method || (this.parentContent && this.parentContent.method), args: args, initResult: this.parentContent && this.parentContent.initResult, - jsData: jsData + jsData: jsData, + preSets: this.newContentPreSets }); } } diff --git a/src/core/siteplugins/directives/new-content.ts b/src/core/siteplugins/directives/new-content.ts index 3bbd9504d..8f38ef1c0 100644 --- a/src/core/siteplugins/directives/new-content.ts +++ b/src/core/siteplugins/directives/new-content.ts @@ -53,6 +53,7 @@ export class CoreSitePluginsNewContentDirective implements OnInit { // If supplied and form is found, the form data will be retrieved and sent to the new content. @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. protected element: HTMLElement; @@ -97,7 +98,8 @@ export class CoreSitePluginsNewContentDirective implements OnInit { method: this.method || (this.parentContent && this.parentContent.method), args: args, initResult: this.parentContent && this.parentContent.initResult, - jsData: jsData + jsData: jsData, + preSets: this.preSets }); } }); diff --git a/src/core/siteplugins/pages/plugin-page/plugin-page.html b/src/core/siteplugins/pages/plugin-page/plugin-page.html index 6d2933b40..bb0676458 100644 --- a/src/core/siteplugins/pages/plugin-page/plugin-page.html +++ b/src/core/siteplugins/pages/plugin-page/plugin-page.html @@ -11,5 +11,5 @@ - + diff --git a/src/core/siteplugins/pages/plugin-page/plugin-page.ts b/src/core/siteplugins/pages/plugin-page/plugin-page.ts index 73e66b050..4e18eef73 100644 --- a/src/core/siteplugins/pages/plugin-page/plugin-page.ts +++ b/src/core/siteplugins/pages/plugin-page/plugin-page.ts @@ -34,6 +34,7 @@ export class CoreSitePluginsPluginPage { args: any; 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. constructor(params: NavParams) { this.title = params.get('title'); @@ -42,6 +43,7 @@ export class CoreSitePluginsPluginPage { this.args = params.get('args'); this.initResult = params.get('initResult'); this.jsData = params.get('jsData'); + this.preSets = params.get('preSets'); } /**