forked from EVOgeek/Vmeda.Online
		
	MOBILE-3493 course: Don't display selector if course only has one section
This commit is contained in:
		
							parent
							
								
									fe91f7e602
								
							
						
					
					
						commit
						6b1e7b70d1
					
				@ -11,7 +11,7 @@
 | 
				
			|||||||
        <core-loading [hideUntil]="loaded">
 | 
					        <core-loading [hideUntil]="loaded">
 | 
				
			||||||
            <!-- Section selector. -->
 | 
					            <!-- Section selector. -->
 | 
				
			||||||
            <core-dynamic-component [component]="sectionSelectorComponent" [data]="data">
 | 
					            <core-dynamic-component [component]="sectionSelectorComponent" [data]="data">
 | 
				
			||||||
                <div text-wrap *ngIf="displaySectionSelector && sections && sections.length" padding class="clearfix" ion-row justify-content-between class="safe-padding-horizontal core-button-selector-row" [class.core-section-download]="downloadEnabled">
 | 
					                <div text-wrap *ngIf="displaySectionSelector && sections && hasSeveralSections" padding class="clearfix" ion-row justify-content-between class="safe-padding-horizontal core-button-selector-row" [class.core-section-download]="downloadEnabled">
 | 
				
			||||||
                    <button float-start ion-button icon-start icon-end (click)="showSectionSelector($event)" color="light" class="core-button-select button-no-uppercase" ion-col [attr.aria-label]="('core.course.sections' | translate) + ': ' + (selectedSection && (selectedSection.formattedName || selectedSection.name))" aria-haspopup="true" [attr.aria-expanded]="sectionSelectorExpanded" aria-controls="core-course-section-selector" id="core-course-section-button">
 | 
					                    <button float-start ion-button icon-start icon-end (click)="showSectionSelector($event)" color="light" class="core-button-select button-no-uppercase" ion-col [attr.aria-label]="('core.course.sections' | translate) + ': ' + (selectedSection && (selectedSection.formattedName || selectedSection.name))" aria-haspopup="true" [attr.aria-expanded]="sectionSelectorExpanded" aria-controls="core-course-section-selector" id="core-course-section-button">
 | 
				
			||||||
                        <core-icon name="fa-folder"></core-icon>
 | 
					                        <core-icon name="fa-folder"></core-icon>
 | 
				
			||||||
                        <span class="core-button-select-text">{{selectedSection && (selectedSection.formattedName || selectedSection.name) || 'core.course.sections' | translate }}</span>
 | 
					                        <span class="core-button-select-text">{{selectedSection && (selectedSection.formattedName || selectedSection.name) || 'core.course.sections' | translate }}</span>
 | 
				
			||||||
 | 
				
			|||||||
@ -76,6 +76,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
 | 
				
			|||||||
    stealthModulesSectionId: number = CoreCourseProvider.STEALTH_MODULES_SECTION_ID;
 | 
					    stealthModulesSectionId: number = CoreCourseProvider.STEALTH_MODULES_SECTION_ID;
 | 
				
			||||||
    selectOptions: any = {};
 | 
					    selectOptions: any = {};
 | 
				
			||||||
    loaded: boolean;
 | 
					    loaded: boolean;
 | 
				
			||||||
 | 
					    hasSeveralSections: boolean;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected sectionStatusObserver;
 | 
					    protected sectionStatusObserver;
 | 
				
			||||||
    protected selectTabObserver;
 | 
					    protected selectTabObserver;
 | 
				
			||||||
@ -171,9 +172,16 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (changes.sections && this.sections) {
 | 
					        if (changes.sections && this.sections) {
 | 
				
			||||||
 | 
					            const hasAllSections = this.sections[0].id == CoreCourseProvider.ALL_SECTIONS_ID;
 | 
				
			||||||
 | 
					            this.hasSeveralSections = this.sections.length > 2 || (this.sections.length == 2 && !hasAllSections);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (!this.selectedSection) {
 | 
					            if (!this.selectedSection) {
 | 
				
			||||||
                // There is no selected section yet, calculate which one to load.
 | 
					                // There is no selected section yet, calculate which one to load.
 | 
				
			||||||
                if (this.initialSectionId || this.initialSectionNumber) {
 | 
					                if (!this.hasSeveralSections) {
 | 
				
			||||||
 | 
					                    // Always load "All sections" to display the section title. If it isn't there just load the section.
 | 
				
			||||||
 | 
					                    this.loaded = true;
 | 
				
			||||||
 | 
					                    this.sectionChanged(this.sections[0]);
 | 
				
			||||||
 | 
					                } else if (this.initialSectionId || this.initialSectionNumber) {
 | 
				
			||||||
                    // We have an input indicating the section ID to load. Search the section.
 | 
					                    // We have an input indicating the section ID to load. Search the section.
 | 
				
			||||||
                    for (let i = 0; i < this.sections.length; i++) {
 | 
					                    for (let i = 0; i < this.sections.length; i++) {
 | 
				
			||||||
                        const section = this.sections[i];
 | 
					                        const section = this.sections[i];
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user