Skip to content

Commit

Permalink
Merge pull request #3769 from dpalou/MOBILE-4370
Browse files Browse the repository at this point in the history
Mobile 4370
  • Loading branch information
alfonso-salces authored Aug 10, 2023
2 parents 81ac023 + e35909d commit 813f731
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h2 *ngIf="section.name" class="big" [id]="'core-section-name-' + section.id">
</ion-badge>
</div>
<div *ngIf="section.availabilityinfo">
<ion-chip>
<ion-chip class="clickable">
<ion-icon name="fas-lock" [attr.aria-label]="'core.restricted' | translate"></ion-icon>
<ion-label>
<core-format-text [text]=" section.availabilityinfo" contextLevel="course" [contextInstanceId]="course.id">
Expand Down
17 changes: 17 additions & 0 deletions src/core/features/course/services/course.ts
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@ export class CoreCourseProvider {
course: courseId,
section: sectionId,
completiondata: completionData,
availabilityinfo: this.treatAvailablityInfo(module.availabilityinfo),
};
}

Expand Down Expand Up @@ -998,6 +999,7 @@ export class CoreCourseProvider {
// Add course to all modules.
return sections.map((section) => ({
...section,
availabilityinfo: this.treatAvailablityInfo(section.availabilityinfo),
modules: section.modules.map((module) => this.addAdditionalModuleData(module, courseId, section.id)),
}));
}),
Expand Down Expand Up @@ -1555,6 +1557,21 @@ export class CoreCourseProvider {
}, siteId);
}

/**
* Treat availability info HTML.
*
* @param availabilityInfo HTML to treat.
* @returns Treated HTML.
*/
protected treatAvailablityInfo(availabilityInfo?: string): string | undefined {
if (!availabilityInfo) {
return availabilityInfo;
}

// Remove "Show more" option in 4.2 or older sites.
return CoreDomUtils.removeElementFromHtml(availabilityInfo, 'li[data-action="showmore"]');
}

}

export const CoreCourse = makeSingleton(CoreCourseProvider);
Expand Down

0 comments on commit 813f731

Please sign in to comment.