Merge pull request #1428 from dpalou/MOBILE-2479

Mobile 2479
main
Juan Leyva 2018-08-20 13:34:31 +01:00 committed by GitHub
commit d529812170
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 5 deletions

View File

@ -77,6 +77,9 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
this.selectOptions.title = translate.instant('core.course.sections');
this.completionChanged = new EventEmitter();
// Pass this instance to all components so they can use its methods and properties.
this.data.coreCourseFormatComponent = this;
// Listen for section status changes.
this.sectionStatusObserver = eventsProvider.on(CoreEventsProvider.SECTION_STATUS_CHANGED, (data) => {
if (this.downloadEnabled && this.sections && this.sections.length && this.course && data.sectionId &&
@ -186,6 +189,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,9 +12,10 @@
// 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';
import { CoreCourseFormatComponent } from '@core/course/components/format/format';
/**
* Component that displays the index of a course format site plugin.
@ -29,6 +30,13 @@ 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.
// Special input, allows access to the parent instance properties and methods.
// Please notice that all the other inputs/outputs are also accessible through this instance, so they could be removed.
// However, we decided to keep them to support ngOnChanges and to make templates easier to read.
@Input() coreCourseFormatComponent: CoreCourseFormatComponent;
@ViewChild(CoreSitePluginsPluginContentComponent) content: CoreSitePluginsPluginContentComponent;
@ -65,7 +73,10 @@ 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,
coreCourseFormatComponent: this.coreCourseFormatComponent
};
}
}

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;
}
}
}