diff --git a/src/core/siteplugins/classes/call-ws-directive.ts b/src/core/siteplugins/classes/call-ws-directive.ts index 8716afdd0..08dac6c7f 100644 --- a/src/core/siteplugins/classes/call-ws-directive.ts +++ b/src/core/siteplugins/classes/call-ws-directive.ts @@ -26,8 +26,8 @@ export class CoreSitePluginsCallWSBaseDirective implements OnInit, OnDestroy { @Input() name: string; // The name of the WS to call. @Input() params: any; // The params for the WS call. @Input() preSets: any; // The preSets for the WS call. - @Input() useOtherDataForWS: any[]; // Whether to include other data in the params for the WS. - // @see CoreSitePluginsProvider.loadOtherDataInArgs. + @Input() useOtherDataForWS: any; // Whether to include other data in the params for the WS. + // @see CoreSitePluginsProvider.loadOtherDataInArgs. @Input() form: string; // ID or name to identify a form. The form will be obtained from document.forms. // If supplied and form is found, the form data will be retrieved and sent to the WS. @Output() onSuccess: EventEmitter = new EventEmitter(); // Sends the result when the WS call succeeds. diff --git a/src/core/siteplugins/directives/new-content.ts b/src/core/siteplugins/directives/new-content.ts index 8f38ef1c0..1158b5dd6 100644 --- a/src/core/siteplugins/directives/new-content.ts +++ b/src/core/siteplugins/directives/new-content.ts @@ -48,7 +48,7 @@ export class CoreSitePluginsNewContentDirective implements OnInit { @Input() args: any; // The params to get the new content. @Input() title: string; // The title to display with the new content. Only if samePage=false. @Input() samePage: boolean | string; // Whether to display the content in same page or open a new one. Defaults to new page. - @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() form: string; // ID or name to identify a form. The form will be obtained from document.forms. // 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. diff --git a/src/core/siteplugins/providers/siteplugins.ts b/src/core/siteplugins/providers/siteplugins.ts index 8739e4722..7fa661716 100644 --- a/src/core/siteplugins/providers/siteplugins.ts +++ b/src/core/siteplugins/providers/siteplugins.ts @@ -421,15 +421,15 @@ export class CoreSitePluginsProvider { /** * Load other data into args as determined by useOtherData list. * If useOtherData is undefined, it won't add any data. - * If useOtherData is defined but empty (null, false or empty string) it will copy all the data from otherData to args. * If useOtherData is an array, it will only copy the properties whose names are in the array. + * If useOtherData is any other value, it will copy all the data from otherData to args. * * @param {any} args The current args. * @param {any} otherData All the other data. - * @param {any[]} useOtherData Names of the attributes to include. + * @param {any} useOtherData Names of the attributes to include. * @return {any} New args. */ - loadOtherDataInArgs(args: any, otherData: any, useOtherData: any[]): any { + loadOtherDataInArgs(args: any, otherData: any, useOtherData: any): any { if (!args) { args = {}; } else { @@ -441,14 +441,15 @@ export class CoreSitePluginsProvider { if (typeof useOtherData == 'undefined') { // No need to add other data, return args as they are. return args; - } else if (!useOtherData) { - // Use other data is defined but empty. Add all the data to args. - for (const name in otherData) { + } else if (Array.isArray(useOtherData)) { + // Include only the properties specified in the array. + for (const i in useOtherData) { + const name = useOtherData[i]; args[name] = otherData[name]; } } else { - for (const i in useOtherData) { - const name = useOtherData[i]; + // Add all the data to args. + for (const name in otherData) { args[name] = otherData[name]; } }