forked from CIT/Vmeda.Online
		
	
						commit
						8e14fb37de
					
				| @ -12,6 +12,7 @@ | |||||||
| // See the License for the specific language governing permissions and
 | // See the License for the specific language governing permissions and
 | ||||||
| // limitations under the License.
 | // limitations under the License.
 | ||||||
| 
 | 
 | ||||||
|  | import { CoreUtilsProvider } from '@providers/utils/utils'; | ||||||
| import { CoreSitePluginsProvider } from '../providers/siteplugins'; | import { CoreSitePluginsProvider } from '../providers/siteplugins'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
| @ -20,10 +21,10 @@ import { CoreSitePluginsProvider } from '../providers/siteplugins'; | |||||||
|  */ |  */ | ||||||
| export class CoreSitePluginsCompileInitComponent { | export class CoreSitePluginsCompileInitComponent { | ||||||
|     content = ''; // Content.
 |     content = ''; // Content.
 | ||||||
|     jsData: any; // Data to pass to the component.
 |     jsData: any = {}; // Data to pass to the component.
 | ||||||
|     protected handlerSchema: any; // The handler data.
 |     protected handlerSchema: any; // The handler data.
 | ||||||
| 
 | 
 | ||||||
|     constructor(protected sitePluginsProvider: CoreSitePluginsProvider) { } |     constructor(protected sitePluginsProvider: CoreSitePluginsProvider, protected utils: CoreUtilsProvider) { } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * Function called when the component is created. |      * Function called when the component is created. | ||||||
| @ -53,6 +54,16 @@ export class CoreSitePluginsCompileInitComponent { | |||||||
|             // Load first template.
 |             // Load first template.
 | ||||||
|             if (this.handlerSchema.methodTemplates && this.handlerSchema.methodTemplates.length) { |             if (this.handlerSchema.methodTemplates && this.handlerSchema.methodTemplates.length) { | ||||||
|                 this.content = handler.handlerSchema.methodTemplates[0].html; |                 this.content = handler.handlerSchema.methodTemplates[0].html; | ||||||
|  |                 this.jsData.CONTENT_TEMPLATES = this.utils.objectToKeyValueMap(handler.handlerSchema.methodTemplates, 'id', 'html'); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             // Pass data from the method result to the component.
 | ||||||
|  |             if (this.handlerSchema.methodOtherdata) { | ||||||
|  |                 this.jsData.CONTENT_OTHERDATA = this.handlerSchema.methodOtherdata; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             if (this.handlerSchema.methodJSResult) { | ||||||
|  |                 this.jsData.CONTENT_JS_RESULT = this.handlerSchema.methodJSResult; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -13,6 +13,7 @@ | |||||||
| // limitations under the License.
 | // limitations under the License.
 | ||||||
| 
 | 
 | ||||||
| import { Component, OnInit, Input } from '@angular/core'; | import { Component, OnInit, Input } from '@angular/core'; | ||||||
|  | import { CoreUtilsProvider } from '@providers/utils/utils'; | ||||||
| import { CoreSitePluginsProvider } from '../../providers/siteplugins'; | import { CoreSitePluginsProvider } from '../../providers/siteplugins'; | ||||||
| import { CoreSitePluginsCompileInitComponent } from '../../classes/compile-init-component'; | import { CoreSitePluginsCompileInitComponent } from '../../classes/compile-init-component'; | ||||||
| 
 | 
 | ||||||
| @ -32,8 +33,8 @@ export class CoreSitePluginsAssignFeedbackComponent extends CoreSitePluginsCompi | |||||||
|     @Input() canEdit: boolean; // Whether the user can edit.
 |     @Input() canEdit: boolean; // Whether the user can edit.
 | ||||||
|     @Input() edit: boolean; // Whether the user is editing.
 |     @Input() edit: boolean; // Whether the user is editing.
 | ||||||
| 
 | 
 | ||||||
|     constructor(sitePluginsProvider: CoreSitePluginsProvider) { |     constructor(sitePluginsProvider: CoreSitePluginsProvider, utils: CoreUtilsProvider) { | ||||||
|         super(sitePluginsProvider); |         super(sitePluginsProvider, utils); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -41,15 +42,13 @@ export class CoreSitePluginsAssignFeedbackComponent extends CoreSitePluginsCompi | |||||||
|      */ |      */ | ||||||
|     ngOnInit(): void { |     ngOnInit(): void { | ||||||
|         // Pass the input and output data to the component.
 |         // Pass the input and output data to the component.
 | ||||||
|         this.jsData = { |         this.jsData.assign = this.assign; | ||||||
|             assign: this.assign, |         this.jsData.submission = this.submission; | ||||||
|             submission: this.submission, |         this.jsData.plugin = this.plugin; | ||||||
|             plugin: this.plugin, |         this.jsData.userId = this.userId; | ||||||
|             userId: this.userId, |         this.jsData.configs = this.configs; | ||||||
|             configs: this.configs, |         this.jsData.edit = this.edit; | ||||||
|             edit: this.edit, |         this.jsData.canEdit = this.canEdit; | ||||||
|             canEdit: this.canEdit |  | ||||||
|         }; |  | ||||||
| 
 | 
 | ||||||
|         if (this.plugin) { |         if (this.plugin) { | ||||||
|             this.getHandlerData('assignfeedback_' + this.plugin.type); |             this.getHandlerData('assignfeedback_' + this.plugin.type); | ||||||
|  | |||||||
| @ -13,6 +13,7 @@ | |||||||
| // limitations under the License.
 | // limitations under the License.
 | ||||||
| 
 | 
 | ||||||
| import { Component, OnInit, Input } from '@angular/core'; | import { Component, OnInit, Input } from '@angular/core'; | ||||||
|  | import { CoreUtilsProvider } from '@providers/utils/utils'; | ||||||
| import { CoreSitePluginsProvider } from '../../providers/siteplugins'; | import { CoreSitePluginsProvider } from '../../providers/siteplugins'; | ||||||
| import { CoreSitePluginsCompileInitComponent } from '../../classes/compile-init-component'; | import { CoreSitePluginsCompileInitComponent } from '../../classes/compile-init-component'; | ||||||
| 
 | 
 | ||||||
| @ -31,8 +32,8 @@ export class CoreSitePluginsAssignSubmissionComponent extends CoreSitePluginsCom | |||||||
|     @Input() edit: boolean; // Whether the user is editing.
 |     @Input() edit: boolean; // Whether the user is editing.
 | ||||||
|     @Input() allowOffline: boolean; // Whether to allow offline.
 |     @Input() allowOffline: boolean; // Whether to allow offline.
 | ||||||
| 
 | 
 | ||||||
|     constructor(sitePluginsProvider: CoreSitePluginsProvider) { |     constructor(sitePluginsProvider: CoreSitePluginsProvider, utils: CoreUtilsProvider) { | ||||||
|         super(sitePluginsProvider); |         super(sitePluginsProvider, utils); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -40,14 +41,12 @@ export class CoreSitePluginsAssignSubmissionComponent extends CoreSitePluginsCom | |||||||
|      */ |      */ | ||||||
|     ngOnInit(): void { |     ngOnInit(): void { | ||||||
|         // Pass the input and output data to the component.
 |         // Pass the input and output data to the component.
 | ||||||
|         this.jsData = { |         this.jsData.assign = this.assign; | ||||||
|             assign: this.assign, |         this.jsData.submission = this.submission; | ||||||
|             submission: this.submission, |         this.jsData.plugin = this.plugin; | ||||||
|             plugin: this.plugin, |         this.jsData.configs = this.configs; | ||||||
|             configs: this.configs, |         this.jsData.edit = this.edit; | ||||||
|             edit: this.edit, |         this.jsData.allowOffline = this.allowOffline; | ||||||
|             allowOffline: this.allowOffline |  | ||||||
|         }; |  | ||||||
| 
 | 
 | ||||||
|         if (this.plugin) { |         if (this.plugin) { | ||||||
|             this.getHandlerData('assignsubmission_' + this.plugin.type); |             this.getHandlerData('assignsubmission_' + this.plugin.type); | ||||||
|  | |||||||
| @ -9,4 +9,4 @@ | |||||||
|     </core-context-menu> |     </core-context-menu> | ||||||
| </core-navbar-buttons> | </core-navbar-buttons> | ||||||
| 
 | 
 | ||||||
| <core-site-plugins-plugin-content *ngIf="component && method" [component]="component" [method]="method" [args]="args" [initResult]="initResult" (onContentLoaded)="contentLoaded($event)" (onLoadingContent)="contentLoading($event)"></core-site-plugins-plugin-content> | <core-site-plugins-plugin-content *ngIf="component && method" [component]="component" [method]="method" [args]="args" [initResult]="initResult" [data]="jsData" (onContentLoaded)="contentLoaded($event)" (onLoadingContent)="contentLoading($event)"></core-site-plugins-plugin-content> | ||||||
|  | |||||||
| @ -46,6 +46,7 @@ export class CoreSitePluginsModuleIndexComponent implements OnInit, OnDestroy, C | |||||||
|     prefetchStatusIcon: string; |     prefetchStatusIcon: string; | ||||||
|     prefetchText: string; |     prefetchText: string; | ||||||
|     size: string; |     size: string; | ||||||
|  |     jsData: any; // Data to pass to the component.
 | ||||||
| 
 | 
 | ||||||
|     protected isDestroyed = false; |     protected isDestroyed = false; | ||||||
|     protected statusObserver; |     protected statusObserver; | ||||||
| @ -70,6 +71,10 @@ export class CoreSitePluginsModuleIndexComponent implements OnInit, OnDestroy, C | |||||||
|                     cmid: this.module.id |                     cmid: this.module.id | ||||||
|                 }; |                 }; | ||||||
|                 this.initResult = handler.initResult; |                 this.initResult = handler.initResult; | ||||||
|  |                 this.jsData = { | ||||||
|  |                     module: this.module, | ||||||
|  |                     courseId: this.courseId | ||||||
|  |                 }; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             // Get the data for the context menu.
 |             // Get the data for the context menu.
 | ||||||
|  | |||||||
| @ -110,14 +110,21 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck { | |||||||
|      * @param {any} args New params. |      * @param {any} args New params. | ||||||
|      * @param {string} [component] New component. If not provided, current component |      * @param {string} [component] New component. If not provided, current component | ||||||
|      * @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. | ||||||
|  |      *                       If true is supplied instead of an object, all initial variables from current page will be copied. | ||||||
|      */ |      */ | ||||||
|     openContent(title: string, args: any, component?: string, method?: string): void { |     openContent(title: string, args: any, component?: string, method?: string, jsData?: any): void { | ||||||
|  |         if (jsData === true) { | ||||||
|  |             jsData = this.data; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         this.navCtrl.push('CoreSitePluginsPluginPage', { |         this.navCtrl.push('CoreSitePluginsPluginPage', { | ||||||
|             title: title, |             title: title, | ||||||
|             component: component || this.component, |             component: component || this.component, | ||||||
|             method: method || this.method, |             method: method || this.method, | ||||||
|             args: args, |             args: args, | ||||||
|             initResult: this.initResult |             initResult: this.initResult, | ||||||
|  |             jsData: jsData | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -144,12 +151,16 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck { | |||||||
|      * @param {any} args New params. |      * @param {any} args New params. | ||||||
|      * @param {string} [component] New component. If not provided, current component |      * @param {string} [component] New component. If not provided, current component | ||||||
|      * @param {string} [method] New method. If not provided, current method |      * @param {string} [method] New method. If not provided, current method | ||||||
|  |      * @param {string} [jsData] JS variables to pass to the new view so they can be used in the template or JS. | ||||||
|      */ |      */ | ||||||
|     updateContent(args: any, component?: string, method?: string): void { |     updateContent(args: any, component?: string, method?: string, jsData?: any): void { | ||||||
|         this.component = component || this.component; |         this.component = component || this.component; | ||||||
|         this.method = method || this.method; |         this.method = method || this.method; | ||||||
|         this.args = args; |         this.args = args; | ||||||
|         this.dataLoaded = false; |         this.dataLoaded = false; | ||||||
|  |         if (jsData) { | ||||||
|  |             Object.assign(this.data, jsData); | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|         this.fetchContent(); |         this.fetchContent(); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -13,6 +13,7 @@ | |||||||
| // limitations under the License.
 | // limitations under the License.
 | ||||||
| 
 | 
 | ||||||
| import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; | import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; | ||||||
|  | import { CoreUtilsProvider } from '@providers/utils/utils'; | ||||||
| import { CoreSitePluginsProvider } from '../../providers/siteplugins'; | import { CoreSitePluginsProvider } from '../../providers/siteplugins'; | ||||||
| import { CoreSitePluginsCompileInitComponent } from '../../classes/compile-init-component'; | import { CoreSitePluginsCompileInitComponent } from '../../classes/compile-init-component'; | ||||||
| 
 | 
 | ||||||
| @ -32,8 +33,8 @@ export class CoreSitePluginsQuestionBehaviourComponent extends CoreSitePluginsCo | |||||||
|     @Output() buttonClicked: EventEmitter<any>; // Should emit an event when a behaviour button is clicked.
 |     @Output() buttonClicked: EventEmitter<any>; // Should emit an event when a behaviour button is clicked.
 | ||||||
|     @Output() onAbort: EventEmitter<void>; // Should emit an event if the question should be aborted.
 |     @Output() onAbort: EventEmitter<void>; // Should emit an event if the question should be aborted.
 | ||||||
| 
 | 
 | ||||||
|     constructor(sitePluginsProvider: CoreSitePluginsProvider) { |     constructor(sitePluginsProvider: CoreSitePluginsProvider, utils: CoreUtilsProvider) { | ||||||
|         super(sitePluginsProvider); |         super(sitePluginsProvider, utils); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -41,15 +42,13 @@ export class CoreSitePluginsQuestionBehaviourComponent extends CoreSitePluginsCo | |||||||
|      */ |      */ | ||||||
|     ngOnInit(): void { |     ngOnInit(): void { | ||||||
|         // Pass the input and output data to the component.
 |         // Pass the input and output data to the component.
 | ||||||
|         this.jsData = { |         this.jsData.question = this.question; | ||||||
|             question: this.question, |         this.jsData.component = this.component; | ||||||
|             component: this.component, |         this.jsData.componentId = this.componentId; | ||||||
|             componentId: this.componentId, |         this.jsData.attemptId = this.attemptId; | ||||||
|             attemptId: this.attemptId, |         this.jsData.offlineEnabled = this.offlineEnabled; | ||||||
|             offlineEnabled: this.offlineEnabled, |         this.jsData.buttonClicked = this.buttonClicked; | ||||||
|             buttonClicked: this.buttonClicked, |         this.jsData.onAbort = this.onAbort; | ||||||
|             onAbort: this.onAbort |  | ||||||
|         }; |  | ||||||
| 
 | 
 | ||||||
|         if (this.question) { |         if (this.question) { | ||||||
|             this.getHandlerData('qbehaviour_' + this.question.preferredBehaviour); |             this.getHandlerData('qbehaviour_' + this.question.preferredBehaviour); | ||||||
|  | |||||||
| @ -13,6 +13,7 @@ | |||||||
| // limitations under the License.
 | // limitations under the License.
 | ||||||
| 
 | 
 | ||||||
| import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; | import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; | ||||||
|  | import { CoreUtilsProvider } from '@providers/utils/utils'; | ||||||
| import { CoreSitePluginsProvider } from '../../providers/siteplugins'; | import { CoreSitePluginsProvider } from '../../providers/siteplugins'; | ||||||
| import { CoreSitePluginsCompileInitComponent } from '../../classes/compile-init-component'; | import { CoreSitePluginsCompileInitComponent } from '../../classes/compile-init-component'; | ||||||
| 
 | 
 | ||||||
| @ -32,8 +33,8 @@ export class CoreSitePluginsQuestionComponent extends CoreSitePluginsCompileInit | |||||||
|     @Output() buttonClicked: EventEmitter<any>; // Should emit an event when a behaviour button is clicked.
 |     @Output() buttonClicked: EventEmitter<any>; // Should emit an event when a behaviour button is clicked.
 | ||||||
|     @Output() onAbort: EventEmitter<void>; // Should emit an event if the question should be aborted.
 |     @Output() onAbort: EventEmitter<void>; // Should emit an event if the question should be aborted.
 | ||||||
| 
 | 
 | ||||||
|     constructor(sitePluginsProvider: CoreSitePluginsProvider) { |     constructor(sitePluginsProvider: CoreSitePluginsProvider, utils: CoreUtilsProvider) { | ||||||
|         super(sitePluginsProvider); |         super(sitePluginsProvider, utils); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -41,15 +42,13 @@ export class CoreSitePluginsQuestionComponent extends CoreSitePluginsCompileInit | |||||||
|      */ |      */ | ||||||
|     ngOnInit(): void { |     ngOnInit(): void { | ||||||
|         // Pass the input and output data to the component.
 |         // Pass the input and output data to the component.
 | ||||||
|         this.jsData = { |         this.jsData.question = this.question; | ||||||
|             question: this.question, |         this.jsData.component = this.component; | ||||||
|             component: this.component, |         this.jsData.componentId = this.componentId; | ||||||
|             componentId: this.componentId, |         this.jsData.attemptId = this.attemptId; | ||||||
|             attemptId: this.attemptId, |         this.jsData.offlineEnabled = this.offlineEnabled; | ||||||
|             offlineEnabled: this.offlineEnabled, |         this.jsData.buttonClicked = this.buttonClicked; | ||||||
|             buttonClicked: this.buttonClicked, |         this.jsData.onAbort = this.onAbort; | ||||||
|             onAbort: this.onAbort |  | ||||||
|         }; |  | ||||||
| 
 | 
 | ||||||
|         if (this.question) { |         if (this.question) { | ||||||
|             this.getHandlerData('qtype_' + this.question.type); |             this.getHandlerData('qtype_' + this.question.type); | ||||||
|  | |||||||
| @ -13,6 +13,7 @@ | |||||||
| // limitations under the License.
 | // limitations under the License.
 | ||||||
| 
 | 
 | ||||||
| import { Component, OnInit, Input } from '@angular/core'; | import { Component, OnInit, Input } from '@angular/core'; | ||||||
|  | import { CoreUtilsProvider } from '@providers/utils/utils'; | ||||||
| import { CoreSitePluginsProvider } from '../../providers/siteplugins'; | import { CoreSitePluginsProvider } from '../../providers/siteplugins'; | ||||||
| import { CoreSitePluginsCompileInitComponent } from '../../classes/compile-init-component'; | import { CoreSitePluginsCompileInitComponent } from '../../classes/compile-init-component'; | ||||||
| import { FormGroup } from '@angular/forms'; | import { FormGroup } from '@angular/forms'; | ||||||
| @ -32,8 +33,8 @@ export class CoreSitePluginsQuizAccessRuleComponent extends CoreSitePluginsCompi | |||||||
|     @Input() siteId: string; // Site ID.
 |     @Input() siteId: string; // Site ID.
 | ||||||
|     @Input() form: FormGroup; // Form where to add the form control.
 |     @Input() form: FormGroup; // Form where to add the form control.
 | ||||||
| 
 | 
 | ||||||
|     constructor(sitePluginsProvider: CoreSitePluginsProvider) { |     constructor(sitePluginsProvider: CoreSitePluginsProvider, utils: CoreUtilsProvider) { | ||||||
|         super(sitePluginsProvider); |         super(sitePluginsProvider, utils); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -41,14 +42,12 @@ export class CoreSitePluginsQuizAccessRuleComponent extends CoreSitePluginsCompi | |||||||
|      */ |      */ | ||||||
|     ngOnInit(): void { |     ngOnInit(): void { | ||||||
|         // Pass the input and output data to the component.
 |         // Pass the input and output data to the component.
 | ||||||
|         this.jsData = { |         this.jsData.rule = this.rule; | ||||||
|             rule: this.rule, |         this.jsData.quiz = this.quiz; | ||||||
|             quiz: this.quiz, |         this.jsData.attempt = this.attempt; | ||||||
|             attempt: this.attempt, |         this.jsData.prefetch = this.prefetch; | ||||||
|             prefetch: this.prefetch, |         this.jsData.siteId = this.siteId; | ||||||
|             siteId: this.siteId, |         this.jsData.form = this.form; | ||||||
|             form: this.form |  | ||||||
|         }; |  | ||||||
| 
 | 
 | ||||||
|         if (this.rule) { |         if (this.rule) { | ||||||
|             this.getHandlerData(this.rule); |             this.getHandlerData(this.rule); | ||||||
|  | |||||||
| @ -13,6 +13,7 @@ | |||||||
| // limitations under the License.
 | // limitations under the License.
 | ||||||
| 
 | 
 | ||||||
| import { Component, OnInit, Input } from '@angular/core'; | import { Component, OnInit, Input } from '@angular/core'; | ||||||
|  | import { CoreUtilsProvider } from '@providers/utils/utils'; | ||||||
| import { CoreSitePluginsProvider } from '../../providers/siteplugins'; | import { CoreSitePluginsProvider } from '../../providers/siteplugins'; | ||||||
| import { CoreSitePluginsCompileInitComponent } from '../../classes/compile-init-component'; | import { CoreSitePluginsCompileInitComponent } from '../../classes/compile-init-component'; | ||||||
| import { FormGroup } from '@angular/forms'; | import { FormGroup } from '@angular/forms'; | ||||||
| @ -32,8 +33,8 @@ export class CoreSitePluginsUserProfileFieldComponent extends CoreSitePluginsCom | |||||||
|     @Input() signup = false; // True if editing the field in signup. Defaults to false.
 |     @Input() signup = false; // True if editing the field in signup. Defaults to false.
 | ||||||
|     @Input() registerAuth?: string; // Register auth method. E.g. 'email'.
 |     @Input() registerAuth?: string; // Register auth method. E.g. 'email'.
 | ||||||
| 
 | 
 | ||||||
|     constructor(sitePluginsProvider: CoreSitePluginsProvider) { |     constructor(sitePluginsProvider: CoreSitePluginsProvider, utils: CoreUtilsProvider) { | ||||||
|         super(sitePluginsProvider); |         super(sitePluginsProvider, utils); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -42,14 +43,12 @@ export class CoreSitePluginsUserProfileFieldComponent extends CoreSitePluginsCom | |||||||
|     ngOnInit(): void { |     ngOnInit(): void { | ||||||
| 
 | 
 | ||||||
|         // Pass the input data to the component.
 |         // Pass the input data to the component.
 | ||||||
|         this.jsData = { |         this.jsData.field = this.field; | ||||||
|             field: this.field, |         this.jsData.signup = this.signup; | ||||||
|             signup: this.signup, |         this.jsData.edit = this.edit; | ||||||
|             edit: this.edit, |         this.jsData.disabled = this.disabled; | ||||||
|             disabled: this.disabled, |         this.jsData.form = this.form; | ||||||
|             form: this.form, |         this.jsData.registerAuth = this.registerAuth; | ||||||
|             registerAuth: this.registerAuth |  | ||||||
|         }; |  | ||||||
| 
 | 
 | ||||||
|         if (this.field) { |         if (this.field) { | ||||||
|             this.getHandlerData('profilefield_' + (this.field.type || this.field.datatype)); |             this.getHandlerData('profilefield_' + (this.field.type || this.field.datatype)); | ||||||
|  | |||||||
| @ -13,6 +13,7 @@ | |||||||
| // limitations under the License.
 | // limitations under the License.
 | ||||||
| 
 | 
 | ||||||
| import { Component, OnInit, Input } from '@angular/core'; | import { Component, OnInit, Input } from '@angular/core'; | ||||||
|  | import { CoreUtilsProvider } from '@providers/utils/utils'; | ||||||
| import { CoreSitePluginsProvider } from '../../providers/siteplugins'; | import { CoreSitePluginsProvider } from '../../providers/siteplugins'; | ||||||
| import { CoreSitePluginsCompileInitComponent } from '../../classes/compile-init-component'; | import { CoreSitePluginsCompileInitComponent } from '../../classes/compile-init-component'; | ||||||
| 
 | 
 | ||||||
| @ -31,8 +32,8 @@ export class CoreSitePluginsWorkshopAssessmentStrategyComponent extends CoreSite | |||||||
|     @Input() fieldErrors: any; |     @Input() fieldErrors: any; | ||||||
|     @Input() strategy: string; |     @Input() strategy: string; | ||||||
| 
 | 
 | ||||||
|     constructor(sitePluginsProvider: CoreSitePluginsProvider) { |     constructor(sitePluginsProvider: CoreSitePluginsProvider, utils: CoreUtilsProvider) { | ||||||
|         super(sitePluginsProvider); |         super(sitePluginsProvider, utils); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -40,14 +41,12 @@ export class CoreSitePluginsWorkshopAssessmentStrategyComponent extends CoreSite | |||||||
|      */ |      */ | ||||||
|     ngOnInit(): void { |     ngOnInit(): void { | ||||||
|         // Pass the input and output data to the component.
 |         // Pass the input and output data to the component.
 | ||||||
|         this.jsData = { |         this.jsData.workshopId = this.workshopId; | ||||||
|             workshopId: this.workshopId, |         this.jsData.assessment = this.assessment; | ||||||
|             assessment: this.assessment, |         this.jsData.edit = this.edit; | ||||||
|             edit: this.edit, |         this.jsData.selectedValues = this.selectedValues; | ||||||
|             selectedValues: this.selectedValues, |         this.jsData.fieldErrors = this.fieldErrors; | ||||||
|             fieldErrors: this.fieldErrors, |         this.jsData.strategy = this.strategy; | ||||||
|             strategy: this.strategy |  | ||||||
|         }; |  | ||||||
| 
 | 
 | ||||||
|         this.getHandlerData('workshopform_' + this.strategy); |         this.getHandlerData('workshopform_' + this.strategy); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -59,6 +59,8 @@ export class CoreSitePluginsCallWSNewContentDirective extends CoreSitePluginsCal | |||||||
|     @Input() title: string; // The title to display with the new content. Only if samePage=false.
 |     @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() 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() 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.
 | ||||||
| 
 | 
 | ||||||
|     constructor(element: ElementRef, translate: TranslateService, domUtils: CoreDomUtilsProvider, |     constructor(element: ElementRef, translate: TranslateService, domUtils: CoreDomUtilsProvider, | ||||||
|             sitePluginsProvider: CoreSitePluginsProvider, @Optional() parentContent: CoreSitePluginsPluginContentComponent, |             sitePluginsProvider: CoreSitePluginsProvider, @Optional() parentContent: CoreSitePluginsPluginContentComponent, | ||||||
| @ -84,15 +86,21 @@ export class CoreSitePluginsCallWSNewContentDirective extends CoreSitePluginsCal | |||||||
|         if (this.utils.isTrueOrOne(this.samePage)) { |         if (this.utils.isTrueOrOne(this.samePage)) { | ||||||
|             // Update the parent content (if it exists).
 |             // Update the parent content (if it exists).
 | ||||||
|             if (this.parentContent) { |             if (this.parentContent) { | ||||||
|                 this.parentContent.updateContent(args, this.component, this.method); |                 this.parentContent.updateContent(args, this.component, this.method, this.jsData); | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|  |             let jsData = this.jsData; | ||||||
|  |             if (jsData === true && this.parentContent) { | ||||||
|  |                 jsData = this.parentContent.data; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|             this.navCtrl.push('CoreSitePluginsPluginPage', { |             this.navCtrl.push('CoreSitePluginsPluginPage', { | ||||||
|                 title: this.title, |                 title: this.title, | ||||||
|                 component: this.component || (this.parentContent && this.parentContent.component), |                 component: this.component || (this.parentContent && this.parentContent.component), | ||||||
|                 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 | ||||||
|             }); |             }); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -51,6 +51,8 @@ export class CoreSitePluginsNewContentDirective implements OnInit { | |||||||
|     @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.
 |     @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.
 |                            // 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.
 | ||||||
| 
 | 
 | ||||||
|     protected element: HTMLElement; |     protected element: HTMLElement; | ||||||
| 
 | 
 | ||||||
| @ -81,15 +83,21 @@ export class CoreSitePluginsNewContentDirective implements OnInit { | |||||||
|             if (this.utils.isTrueOrOne(this.samePage)) { |             if (this.utils.isTrueOrOne(this.samePage)) { | ||||||
|                 // Update the parent content (if it exists).
 |                 // Update the parent content (if it exists).
 | ||||||
|                 if (this.parentContent) { |                 if (this.parentContent) { | ||||||
|                     this.parentContent.updateContent(args, this.component, this.method); |                     this.parentContent.updateContent(args, this.component, this.method, this.jsData); | ||||||
|                 } |                 } | ||||||
|             } else { |             } else { | ||||||
|  |                 let jsData = this.jsData; | ||||||
|  |                 if (jsData === true) { | ||||||
|  |                     jsData = this.parentContent && this.parentContent.data || {}; | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|                 this.navCtrl.push('CoreSitePluginsPluginPage', { |                 this.navCtrl.push('CoreSitePluginsPluginPage', { | ||||||
|                     title: this.title, |                     title: this.title, | ||||||
|                     component: this.component || (this.parentContent && this.parentContent.component), |                     component: this.component || (this.parentContent && this.parentContent.component), | ||||||
|                     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 | ||||||
|                 }); |                 }); | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
|  | |||||||
| @ -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"></core-site-plugins-plugin-content> |     <core-site-plugins-plugin-content [component]="component" [method]="method" [args]="args" [initResult]="initResult" [data]="jsData"></core-site-plugins-plugin-content> | ||||||
| </ion-content> | </ion-content> | ||||||
|  | |||||||
| @ -33,6 +33,7 @@ export class CoreSitePluginsPluginPage { | |||||||
|     method: string; |     method: string; | ||||||
|     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.
 | ||||||
| 
 | 
 | ||||||
|     constructor(params: NavParams) { |     constructor(params: NavParams) { | ||||||
|         this.title = params.get('title'); |         this.title = params.get('title'); | ||||||
| @ -40,6 +41,7 @@ export class CoreSitePluginsPluginPage { | |||||||
|         this.method = params.get('method'); |         this.method = params.get('method'); | ||||||
|         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'); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | |||||||
| @ -547,6 +547,7 @@ export class CoreSitePluginsHelperProvider { | |||||||
|             // Store in handlerSchema some data required by the component.
 |             // Store in handlerSchema some data required by the component.
 | ||||||
|             handlerSchema.methodTemplates = result.templates; |             handlerSchema.methodTemplates = result.templates; | ||||||
|             handlerSchema.methodJSResult = result.jsResult; |             handlerSchema.methodJSResult = result.jsResult; | ||||||
|  |             handlerSchema.methodOtherdata = result.otherdata; | ||||||
| 
 | 
 | ||||||
|             if (result && result.jsResult) { |             if (result && result.jsResult) { | ||||||
|                 // Override default handler functions with the result of the method JS.
 |                 // Override default handler functions with the result of the method JS.
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user