Merge pull request #4019 from dpalou/MOBILE-4487

Mobile 4487
main
Pau Ferrer Ocaña 2024-04-24 14:54:52 +02:00 committed by GitHub
commit 03879074ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 2 deletions

View File

@ -34,6 +34,7 @@ export class CoreSitePluginsBlockComponent extends CoreBlockBaseComponent implem
@HostBinding('class') component?: string; @HostBinding('class') component?: string;
method?: string; method?: string;
args?: Record<string, unknown>; args?: Record<string, unknown>;
jsData?: Record<string, unknown>; // Data to pass to the component.
initResult?: CoreSitePluginsContent | null; initResult?: CoreSitePluginsContent | null;
constructor() { constructor() {
@ -62,6 +63,9 @@ export class CoreSitePluginsBlockComponent extends CoreBlockBaseComponent implem
instanceid: this.instanceId, instanceid: this.instanceId,
blockid: this.block.instanceid, blockid: this.block.instanceid,
}; };
this.jsData = {
block: this.block,
};
this.initResult = handler.initResult; this.initResult = handler.initResult;
} }

View File

@ -1,2 +1,2 @@
<core-site-plugins-plugin-content *ngIf="component && method" [component]="component" [method]="method" [args]="args" <core-site-plugins-plugin-content *ngIf="component && method" [component]="component" [method]="method" [args]="args"
[initResult]="initResult" /> [initResult]="initResult" [data]="jsData" />

View File

@ -118,7 +118,11 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck {
this.data = this.data || {}; this.data = this.data || {};
this.forceCompile = true; this.forceCompile = true;
this.jsData = Object.assign(this.data, CoreSitePlugins.createDataForJS(this.initResult, result)); this.jsData = {
...this.args,
...this.data,
...CoreSitePlugins.createDataForJS(this.initResult, result),
};
// Pass some methods as jsData so they can be called from the template too. // Pass some methods as jsData so they can be called from the template too.
this.jsData.fetchContent = (refresh?: boolean) => this.fetchContent(refresh); this.jsData.fetchContent = (refresh?: boolean) => this.fetchContent(refresh);