MOBILE-2479 siteplugins: Pass all inputs and outputs to components

main
Dani Palou 2018-07-24 10:53:33 +02:00
parent e6c5607463
commit 55682818ff
5 changed files with 19 additions and 5 deletions

View File

@ -186,6 +186,8 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
this.data.initialSectionId = this.initialSectionId;
this.data.initialSectionNumber = this.initialSectionNumber;
this.data.downloadEnabled = this.downloadEnabled;
this.data.moduleId = this.moduleId;
this.data.completionChanged = this.completionChanged;
}
/**

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { Component, Input, OnChanges, SimpleChange, ViewChild, Injector } from '@angular/core';
import { Component, Input, OnChanges, SimpleChange, ViewChild, Injector, Output, EventEmitter } from '@angular/core';
import { CoreCourseModuleDelegate } from '../../../providers/module-delegate';
import { CoreCourseUnsupportedModuleComponent } from '../../../components/unsupported-module/unsupported-module';
import { CoreDynamicComponent } from '../../../../../components/dynamic-component/dynamic-component';
@ -30,6 +30,10 @@ export class CoreCourseFormatSingleActivityComponent implements OnChanges {
@Input() course: any; // The course to render.
@Input() sections: any[]; // List of course sections.
@Input() downloadEnabled?: boolean; // Whether the download of sections and modules is enabled.
@Input() initialSectionId?: number; // The section to load first (by ID).
@Input() initialSectionNumber?: number; // The section to load first (by number).
@Input() moduleId?: number; // The module ID to scroll to. Must be inside the initial selected section.
@Output() completionChanged?: EventEmitter<void>; // Will emit an event when any module completion changes.
@ViewChild(CoreDynamicComponent) dynamicComponent: CoreDynamicComponent;

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { Component, OnChanges, Input, ViewChild } from '@angular/core';
import { Component, OnChanges, Input, ViewChild, Output, EventEmitter } from '@angular/core';
import { CoreSitePluginsProvider } from '../../providers/siteplugins';
import { CoreSitePluginsPluginContentComponent } from '../plugin-content/plugin-content';
@ -29,6 +29,8 @@ export class CoreSitePluginsCourseFormatComponent implements OnChanges {
@Input() downloadEnabled?: boolean; // Whether the download of sections and modules is enabled.
@Input() initialSectionId?: number; // The section to load first (by ID).
@Input() initialSectionNumber?: number; // The section to load first (by number).
@Input() moduleId?: number; // The module ID to scroll to. Must be inside the initial selected section.
@Output() completionChanged?: EventEmitter<void>; // Will emit an event when any module completion changes.
@ViewChild(CoreSitePluginsPluginContentComponent) content: CoreSitePluginsPluginContentComponent;
@ -65,7 +67,9 @@ export class CoreSitePluginsCourseFormatComponent implements OnChanges {
sections: this.sections,
downloadEnabled: this.downloadEnabled,
initialSectionId: this.initialSectionId,
initialSectionNumber: this.initialSectionNumber
initialSectionNumber: this.initialSectionNumber,
moduleId: this.moduleId,
completionChanged: this.completionChanged
};
}
}

View File

@ -15,6 +15,7 @@
import { Component, OnInit, Input } from '@angular/core';
import { CoreSitePluginsProvider } from '../../providers/siteplugins';
import { CoreSitePluginsCompileInitComponent } from '../../classes/compile-init-component';
import { FormGroup } from '@angular/forms';
/**
* Component that displays a user profile field created using a site plugin.
@ -25,9 +26,10 @@ import { CoreSitePluginsCompileInitComponent } from '../../classes/compile-init-
})
export class CoreSitePluginsUserProfileFieldComponent extends CoreSitePluginsCompileInitComponent implements OnInit {
@Input() field: any; // The profile field to be rendered.
@Input() signup = false; // True if editing the field in signup. Defaults to false.
@Input() edit = false; // True if editing the field. Defaults to false.
@Input() form?: any; // Form where to add the form control. Required if edit=true or signup=true.
@Input() disabled = false; // True if disabled. Defaults to false.
@Input() form?: FormGroup; // Form where to add the form control.
@Input() signup = false; // True if editing the field in signup. Defaults to false.
@Input() registerAuth?: string; // Register auth method. E.g. 'email'.
constructor(sitePluginsProvider: CoreSitePluginsProvider) {
@ -44,6 +46,7 @@ export class CoreSitePluginsUserProfileFieldComponent extends CoreSitePluginsCom
field: this.field,
signup: this.signup,
edit: this.edit,
disabled: this.disabled,
form: this.form,
registerAuth: this.registerAuth
};

View File

@ -50,6 +50,7 @@ export class CoreUserProfileFieldComponent implements OnInit {
this.data.signup = this.utilsProvider.isTrueOrOne(this.signup);
this.data.disabled = this.utilsProvider.isTrueOrOne(this.field.locked);
this.data.form = this.form;
this.data.registerAuth = this.registerAuth;
}
}
}