diff --git a/src/app/app.scss b/src/app/app.scss index 5dcc0a919..1dad14d49 100644 --- a/src/app/app.scss +++ b/src/app/app.scss @@ -370,7 +370,13 @@ ion-col ion-select { white-space: normal; text-align: right; } +} + +.core-button-select { + ion-icon:last-child { + margin-left: 5px; } +} // File uploader. // ------------------------- diff --git a/src/core/course/components/format/core-course-format.html b/src/core/course/components/format/core-course-format.html index 369c52c63..905800187 100644 --- a/src/core/course/components/format/core-course-format.html +++ b/src/core/course/components/format/core-course-format.html @@ -16,10 +16,10 @@
- - - {{section.formattedName || section.name}} - +
diff --git a/src/core/course/components/format/format.scss b/src/core/course/components/format/format.scss index 284fe6133..e0fb24ce2 100644 --- a/src/core/course/components/format/format.scss +++ b/src/core/course/components/format/format.scss @@ -22,4 +22,8 @@ core-course-format { width: 100%; } } -} \ No newline at end of file +} + +.core-section-select { + width: 100%; +} diff --git a/src/core/course/components/format/format.ts b/src/core/course/components/format/format.ts index 4e08d500a..9a2fd80b8 100644 --- a/src/core/course/components/format/format.ts +++ b/src/core/course/components/format/format.ts @@ -15,7 +15,7 @@ import { Component, Input, OnInit, OnChanges, OnDestroy, SimpleChange, Output, EventEmitter, ViewChildren, QueryList, Injector } from '@angular/core'; -import { Content } from 'ionic-angular'; +import { Content, ModalController } from 'ionic-angular'; import { TranslateService } from '@ngx-translate/core'; import { CoreEventsProvider } from '@providers/events'; import { CoreSitesProvider } from '@providers/sites'; @@ -72,7 +72,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { constructor(private cfDelegate: CoreCourseFormatDelegate, translate: TranslateService, private injector: Injector, private courseHelper: CoreCourseHelperProvider, private domUtils: CoreDomUtilsProvider, eventsProvider: CoreEventsProvider, private sitesProvider: CoreSitesProvider, private content: Content, - prefetchDelegate: CoreCourseModulePrefetchDelegate) { + prefetchDelegate: CoreCourseModulePrefetchDelegate, private modalCtrl: ModalController) { this.selectOptions.title = translate.instant('core.course.sections'); this.completionChanged = new EventEmitter(); @@ -221,6 +221,20 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { } } + /** + * Display the section selector modal. + */ + showSectionSelector(): void { + const modal = this.modalCtrl.create('CoreCourseSectionSelectorPage', + {sections: this.sections, selected: this.selectedSection}); + modal.onDidDismiss((newSection) => { + if (newSection) { + this.sectionChanged(newSection); + } + }); + modal.present(); + } + /** * Function called when selected section changes. * diff --git a/src/core/course/pages/section-selector/section-selector.html b/src/core/course/pages/section-selector/section-selector.html new file mode 100644 index 000000000..d96876437 --- /dev/null +++ b/src/core/course/pages/section-selector/section-selector.html @@ -0,0 +1,19 @@ + + + {{ 'core.course.sections' | translate }} + + + + + + + + +

+ {{ 'core.course.nocontentavailable' | translate }} + +
+
+
diff --git a/src/core/course/pages/section-selector/section-selector.module.ts b/src/core/course/pages/section-selector/section-selector.module.ts new file mode 100644 index 000000000..897696b62 --- /dev/null +++ b/src/core/course/pages/section-selector/section-selector.module.ts @@ -0,0 +1,33 @@ +// (C) Copyright 2015 Martin Dougiamas +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { NgModule } from '@angular/core'; +import { IonicPageModule } from 'ionic-angular'; +import { TranslateModule } from '@ngx-translate/core'; +import { CoreComponentsModule } from '@components/components.module'; +import { CoreDirectivesModule } from '@directives/directives.module'; +import { CoreCourseSectionSelectorPage } from './section-selector'; + +@NgModule({ + declarations: [ + CoreCourseSectionSelectorPage, + ], + imports: [ + CoreComponentsModule, + CoreDirectivesModule, + IonicPageModule.forChild(CoreCourseSectionSelectorPage), + TranslateModule.forChild() + ], +}) +export class CoreCourseSectionSelectorPageModule {} diff --git a/src/core/course/pages/section-selector/section-selector.ts b/src/core/course/pages/section-selector/section-selector.ts new file mode 100644 index 000000000..0f1f23933 --- /dev/null +++ b/src/core/course/pages/section-selector/section-selector.ts @@ -0,0 +1,57 @@ +// (C) Copyright 2015 Martin Dougiamas +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { Component } from '@angular/core'; +import { IonicPage, NavParams, ViewController } from 'ionic-angular'; +import { CoreCourseHelperProvider } from '../../providers/helper'; + +/** + * Page that displays course section selector. + */ +@IonicPage({ segment: 'core-course-section-selector' }) +@Component({ + selector: 'page-core-course-section-selector', + templateUrl: 'section-selector.html', +}) +export class CoreCourseSectionSelectorPage { + + sections: any; + selected: number; + sectionHasContent: any; + + constructor(navParams: NavParams, courseHelper: CoreCourseHelperProvider, private viewCtrl: ViewController) { + this.sections = navParams.get('sections'); + this.selected = navParams.get('selected'); + + this.sectionHasContent = courseHelper.sectionHasContent; + } + + /** + * Close the modal. + */ + closeModal(): void { + this.viewCtrl.dismiss(); + } + + /** + * Select a section. + * + * @param {any} section Selected section object. + */ + selectSection(section: any): void { + if (!(section.visible === 0 || section.uservisible === false)) { + this.viewCtrl.dismiss(section); + } + } +}