From 16b7f8b696c2f2e00925977328bcfb0b1fc4fc39 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 2 Sep 2020 09:44:47 +0200 Subject: [PATCH] MOBILE-3188 siteplugins: Pass componentId using preSets --- .../module-index/core-siteplugins-module-index.html | 2 +- .../siteplugins/components/module-index/module-index.ts | 5 +++-- .../siteplugins/components/plugin-content/plugin-content.ts | 6 +----- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/core/siteplugins/components/module-index/core-siteplugins-module-index.html b/src/core/siteplugins/components/module-index/core-siteplugins-module-index.html index 1662b918c..a601f05c3 100644 --- a/src/core/siteplugins/components/module-index/core-siteplugins-module-index.html +++ b/src/core/siteplugins/components/module-index/core-siteplugins-module-index.html @@ -9,4 +9,4 @@ - + diff --git a/src/core/siteplugins/components/module-index/module-index.ts b/src/core/siteplugins/components/module-index/module-index.ts index 60347d9d4..ff85dc38f 100644 --- a/src/core/siteplugins/components/module-index/module-index.ts +++ b/src/core/siteplugins/components/module-index/module-index.ts @@ -21,6 +21,7 @@ import { CoreCourseModuleDelegate, CoreCourseModuleMainComponent } from '@core/c import { CoreCourseModulePrefetchDelegate } from '@core/course/providers/module-prefetch-delegate'; import { CoreCourseHelperProvider } from '@core/course/providers/helper'; import { CoreSitePluginsPluginContentComponent } from '../plugin-content/plugin-content'; +import { CoreSiteWSPreSets } from '@classes/site'; /** * Component that displays the index of a module site plugin. @@ -37,10 +38,10 @@ export class CoreSitePluginsModuleIndexComponent implements OnInit, OnDestroy, C @ViewChild(CoreSitePluginsPluginContentComponent) content: CoreSitePluginsPluginContentComponent; component: string; - componentId: number; method: string; args: any; initResult: any; + preSets: CoreSiteWSPreSets; // Data for context menu. externalUrl: string; @@ -78,7 +79,7 @@ export class CoreSitePluginsModuleIndexComponent implements OnInit, OnDestroy, C if (handler) { this.component = handler.plugin.component; - this.componentId = this.module.id; + this.preSets = {componentId: this.module.id}; this.method = handler.handlerSchema.method; this.args = { courseid: this.courseId, diff --git a/src/core/siteplugins/components/plugin-content/plugin-content.ts b/src/core/siteplugins/components/plugin-content/plugin-content.ts index cc3b74ff0..6f8768a9c 100644 --- a/src/core/siteplugins/components/plugin-content/plugin-content.ts +++ b/src/core/siteplugins/components/plugin-content/plugin-content.ts @@ -32,7 +32,6 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck { @ViewChild('compile') compileComponent: ElementRef; @Input() component: string; - @Input() componentId?: number; @Input() method: string; @Input() args: any; @Input() initResult: any; // Result of the init WS call of the handler. @@ -94,10 +93,7 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck { this.forceCompile = false; const preSets = Object.assign({}, this.preSets); - preSets.component = this.component; - if (this.componentId) { - preSets.componentId = this.componentId; - } + preSets.component = preSets.component || this.component; return this.sitePluginsProvider.getContent(this.component, this.method, this.args, preSets).then((result) => { this.content = result.templates.length ? result.templates[0].html : ''; // Load first template.