Merge pull request #1542 from dpalou/MOBILE-2636
MOBILE-2636 siteplugins: Support preSets in new-content directivesmain
commit
ae60746e40
|
@ -31,6 +31,7 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck {
|
||||||
@Input() args: any;
|
@Input() args: any;
|
||||||
@Input() initResult: any; // Result of the init WS call of the handler.
|
@Input() initResult: any; // Result of the init WS call of the handler.
|
||||||
@Input() data: any; // Data to pass to the component.
|
@Input() data: any; // Data to pass to the component.
|
||||||
|
@Input() preSets: any; // The preSets for the WS call.
|
||||||
@Output() onContentLoaded?: EventEmitter<boolean>; // Emits an event when the content is loaded.
|
@Output() onContentLoaded?: EventEmitter<boolean>; // Emits an event when the content is loaded.
|
||||||
@Output() onLoadingContent?: EventEmitter<boolean>; // Emits an event when starts to load the content.
|
@Output() onLoadingContent?: EventEmitter<boolean>; // Emits an event when starts to load the content.
|
||||||
|
|
||||||
|
@ -82,7 +83,7 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck {
|
||||||
fetchContent(refresh?: boolean): Promise<any> {
|
fetchContent(refresh?: boolean): Promise<any> {
|
||||||
this.onLoadingContent.emit(refresh);
|
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.content = result.templates.length ? result.templates[0].html : ''; // Load first template.
|
||||||
this.javascript = result.javascript;
|
this.javascript = result.javascript;
|
||||||
this.otherData = result.otherdata;
|
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 {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.
|
* @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.
|
* 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) {
|
if (jsData === true) {
|
||||||
jsData = this.data;
|
jsData = this.data;
|
||||||
}
|
}
|
||||||
|
@ -124,7 +126,8 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck {
|
||||||
method: method || this.method,
|
method: method || this.method,
|
||||||
args: args,
|
args: args,
|
||||||
initResult: this.initResult,
|
initResult: this.initResult,
|
||||||
jsData: jsData
|
jsData: jsData,
|
||||||
|
preSets: preSets
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ export class CoreSitePluginsCallWSNewContentDirective extends CoreSitePluginsCal
|
||||||
@Input() useOtherData: any[]; // Whether to include other data in the args. @see CoreSitePluginsProvider.loadOtherDataInArgs.
|
@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.
|
@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.
|
// 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,
|
constructor(element: ElementRef, translate: TranslateService, domUtils: CoreDomUtilsProvider,
|
||||||
sitePluginsProvider: CoreSitePluginsProvider, @Optional() parentContent: CoreSitePluginsPluginContentComponent,
|
sitePluginsProvider: CoreSitePluginsProvider, @Optional() parentContent: CoreSitePluginsPluginContentComponent,
|
||||||
|
@ -100,7 +101,8 @@ export class CoreSitePluginsCallWSNewContentDirective extends CoreSitePluginsCal
|
||||||
method: this.method || (this.parentContent && this.parentContent.method),
|
method: this.method || (this.parentContent && this.parentContent.method),
|
||||||
args: args,
|
args: args,
|
||||||
initResult: this.parentContent && this.parentContent.initResult,
|
initResult: this.parentContent && this.parentContent.initResult,
|
||||||
jsData: jsData
|
jsData: jsData,
|
||||||
|
preSets: this.newContentPreSets
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
// 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.
|
@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.
|
// 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;
|
protected element: HTMLElement;
|
||||||
|
|
||||||
|
@ -97,7 +98,8 @@ export class CoreSitePluginsNewContentDirective implements OnInit {
|
||||||
method: this.method || (this.parentContent && this.parentContent.method),
|
method: this.method || (this.parentContent && this.parentContent.method),
|
||||||
args: args,
|
args: args,
|
||||||
initResult: this.parentContent && this.parentContent.initResult,
|
initResult: this.parentContent && this.parentContent.initResult,
|
||||||
jsData: jsData
|
jsData: jsData,
|
||||||
|
preSets: this.preSets
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,5 +11,5 @@
|
||||||
<ion-refresher [enabled]="content && content.dataLoaded" (ionRefresh)="refreshData($event)">
|
<ion-refresher [enabled]="content && content.dataLoaded" (ionRefresh)="refreshData($event)">
|
||||||
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
|
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
|
||||||
</ion-refresher>
|
</ion-refresher>
|
||||||
<core-site-plugins-plugin-content [component]="component" [method]="method" [args]="args" [initResult]="initResult" [data]="jsData"></core-site-plugins-plugin-content>
|
<core-site-plugins-plugin-content [component]="component" [method]="method" [args]="args" [preSets]="preSets" [initResult]="initResult" [data]="jsData"></core-site-plugins-plugin-content>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
|
|
@ -34,6 +34,7 @@ export class CoreSitePluginsPluginPage {
|
||||||
args: any;
|
args: any;
|
||||||
initResult: any;
|
initResult: any;
|
||||||
jsData: any; // JS variables to pass to the plugin so they can be used in the template or JS.
|
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) {
|
constructor(params: NavParams) {
|
||||||
this.title = params.get('title');
|
this.title = params.get('title');
|
||||||
|
@ -42,6 +43,7 @@ export class CoreSitePluginsPluginPage {
|
||||||
this.args = params.get('args');
|
this.args = params.get('args');
|
||||||
this.initResult = params.get('initResult');
|
this.initResult = params.get('initResult');
|
||||||
this.jsData = params.get('jsData');
|
this.jsData = params.get('jsData');
|
||||||
|
this.preSets = params.get('preSets');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue