From 7126c449174a8cdf2e42a796976d437271474528 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 30 Aug 2018 16:17:20 +0200 Subject: [PATCH] MOBILE-2567 course: Don't show next/previous in all sections --- src/core/course/components/format/format.ts | 33 ++++++++++++--------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/core/course/components/format/format.ts b/src/core/course/components/format/format.ts index b6ec4c1de..cd9a0bd00 100644 --- a/src/core/course/components/format/format.ts +++ b/src/core/course/components/format/format.ts @@ -250,25 +250,30 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { this.selectedSection = newSection; this.data.section = this.selectedSection; - // Select next and previous sections to show the arrows. - const i = this.sections.findIndex((value, index) => { - return this.compareSections(value, this.selectedSection); - }); + if (newSection.id != this.allSectionsId) { + // Select next and previous sections to show the arrows. + const i = this.sections.findIndex((value, index) => { + return this.compareSections(value, this.selectedSection); + }); - let j; - for (j = i - 1; j >= 1; j--) { - if (this.sections[j].uservisible !== false && this.sections[j].hasContent) { - break; + let j; + for (j = i - 1; j >= 1; j--) { + if (this.sections[j].uservisible !== false && this.sections[j].hasContent) { + break; + } } - } - this.previousSection = j >= 1 ? this.sections[j] : null; + this.previousSection = j >= 1 ? this.sections[j] : null; - for (j = i + 1; j < this.sections.length; j++) { - if (this.sections[j].uservisible !== false && this.sections[j].hasContent) { - break; + for (j = i + 1; j < this.sections.length; j++) { + if (this.sections[j].uservisible !== false && this.sections[j].hasContent) { + break; + } } + this.nextSection = j < this.sections.length ? this.sections[j] : null; + } else { + this.previousSection = null; + this.nextSection = null; } - this.nextSection = j < this.sections.length ? this.sections[j] : null; if (this.moduleId && typeof previousValue == 'undefined') { setTimeout(() => {