forked from CIT/Vmeda.Online
		
	MOBILE-2636 siteplugins: Support preSets in new-content directives
This commit is contained in:
		
							parent
							
								
									8f99fab2e4
								
							
						
					
					
						commit
						f7eb8762ae
					
				@ -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<boolean>; // Emits an event when the content is loaded.
 | 
			
		||||
    @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> {
 | 
			
		||||
        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
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
@ -11,5 +11,5 @@
 | 
			
		||||
    <ion-refresher [enabled]="content && content.dataLoaded" (ionRefresh)="refreshData($event)">
 | 
			
		||||
        <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
 | 
			
		||||
    </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>
 | 
			
		||||
 | 
			
		||||
@ -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');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user