MOBILE-4362 activity: Show only description on list mod type page

main
Pau Ferrer Ocaña 2023-10-17 13:39:40 +02:00
parent 68f67ea4d5
commit f986937424
4 changed files with 52 additions and 19 deletions

View File

@ -80,14 +80,14 @@
<!-- Description and restrictions -->
<div *ngIf="module.description || module.availabilityinfo" id="activity-{{module.id}}-collapsible"
<div *ngIf="module.description || (showAvailability && module.availabilityinfo)" id="activity-{{module.id}}-collapsible"
class="ion-text-wrap activity-description-availabilityinfo activity-extra" [collapsible-item]="64">
<core-format-text class="core-module-description" *ngIf="module.description" [text]="module.description"
contextLevel="module" [contextInstanceId]="module.id" [courseId]="module.course">
</core-format-text>
<!-- Availability info -->
<div *ngIf="module.availabilityinfo" class="core-module-availabilityinfo">
<div *ngIf="showAvailability && module.availabilityinfo" class="core-module-availabilityinfo">
<ion-icon name="fas-lock" [attr.aria-label]="'core.restricted' | translate"></ion-icon>
<core-format-text [text]="module.availabilityinfo" contextLevel="module" [contextInstanceId]="module.id"
[courseId]="module.course">
@ -95,7 +95,7 @@
</div>
</div>
<div *ngIf="module.handlerData.extraBadge" class="ion-text-wrap activity-extrabadges activity-extra"
<div *ngIf="showExtra && module.handlerData.extraBadge" class="ion-text-wrap activity-extrabadges activity-extra"
[innerHTML]="module.handlerData.extraBadge"></div>
</ion-label>

View File

@ -50,6 +50,11 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy {
@Input() showActivityDates = false; // Whether to show activity dates.
@Input() showCompletionConditions = false; // Whether to show activity completion conditions.
@Input() showLegacyCompletion?: boolean; // Whether to show module completion in the old format.
@Input() showCompletion = true; // Whether to show module completion.
@Input() showAvailability = true; // Whether to show module availability.
@Input() showExtra = true; // Whether to show extra badges.
@Input() showDownloadStatus = true; // Whether to show download status.
@Input() showIndentation = true; // Whether to show indentation
@Input() isLastViewed = false; // Whether it's the last module viewed in a course.
@Output() completionChanged = new EventEmitter<CoreCourseModuleCompletionData>(); // Notify when module completion changes.
@HostBinding('class.indented') indented = false;
@ -70,14 +75,24 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy {
*/
async ngOnInit(): Promise<void> {
const site = CoreSites.getRequiredCurrentSite();
const enableIndentation = await CoreCourse.isCourseIndentationEnabled(site, this.module.course);
this.indented = enableIndentation && this.module.indent > 0;
if (this.showIndentation && this.module.indent > 0) {
this.indented = await CoreCourse.isCourseIndentationEnabled(site, this.module.course);
} else {
this.indented = false;
}
this.modNameTranslated = CoreCourse.translateModuleName(this.module.modname, this.module.modplural);
this.showLegacyCompletion = this.showLegacyCompletion ??
CoreConstants.CONFIG.uselegacycompletion ??
!site.isVersionGreaterEqualThan('3.11');
this.checkShowCompletion();
if (this.showCompletion) {
this.showLegacyCompletion = this.showLegacyCompletion ??
CoreConstants.CONFIG.uselegacycompletion ??
!site.isVersionGreaterEqualThan('3.11');
this.checkShowCompletion();
} else {
this.showLegacyCompletion = false;
this.showCompletionConditions = false;
this.showManualCompletion = false;
this.hasCompletion = false;
}
if (!this.module.handlerData) {
return;
@ -86,7 +101,7 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy {
this.module.handlerData.a11yTitle = this.module.handlerData.a11yTitle ?? this.module.handlerData.title;
this.moduleHasView = CoreCourse.moduleHasView(this.module);
if (this.module.handlerData?.showDownloadButton) {
if (this.showDownloadStatus && this.module.handlerData.showDownloadButton) {
const status = await CoreCourseModulePrefetchDelegate.getModuleStatus(this.module, this.module.course);
this.updateModuleStatus(status);

View File

@ -18,8 +18,17 @@
<ion-list class="core-course-module-list-wrapper">
<ng-container *ngFor="let section of sections">
<ion-item-divider class="course-section ion-text-wrap" *ngIf="section.name">
<ion-label>
<h2>
<core-format-text [text]="section.name" contextLevel="course" [contextInstanceId]="courseId">
</core-format-text>
</h2>
</ion-label>
</ion-item-divider>
<ng-container *ngFor="let module of section.modules">
<core-course-module *ngIf="module.visibleoncoursepage !== 0" [module]="module" [section]="section">
<core-course-module [module]="module" [section]="section" [showActivityDates]="false" [showAvailability]="false"
[showExtra]="false" [showDownloadStatus]="false" [showCompletion]="false" [showIndentation]="false">
</core-course-module>
</ng-container>
</ng-container>

View File

@ -37,7 +37,7 @@ export class CoreCourseListModTypePage implements OnInit {
sections: CoreCourseSection[] = [];
title = '';
loaded = false;
courseId?: number;
courseId = 0;
protected modName?: string;
protected archetypes: Record<string, number> = {}; // To speed up the check of modules.
@ -64,9 +64,16 @@ export class CoreCourseListModTypePage implements OnInit {
* @inheritdoc
*/
async ngOnInit(): Promise<void> {
this.title = CoreNavigator.getRouteParam('title') || '';
this.courseId = CoreNavigator.getRouteNumberParam('courseId');
this.modName = CoreNavigator.getRouteParam('modName');
try {
this.title = CoreNavigator.getRouteParam('title') || '';
this.courseId = CoreNavigator.getRequiredRouteParam('courseId');
this.modName = CoreNavigator.getRequiredRouteParam('modName');
} catch (error) {
CoreDomUtils.showErrorModal(error);
CoreNavigator.back();
return;
}
try {
await this.fetchData();
@ -95,7 +102,9 @@ export class CoreCourseListModTypePage implements OnInit {
}
section.modules = section.modules.filter((mod) => {
if (!CoreCourseHelper.canUserViewModule(mod, section) || !CoreCourse.moduleHasView(mod)) {
if (!CoreCourseHelper.canUserViewModule(mod, section) ||
!CoreCourse.moduleHasView(mod) ||
mod.visibleoncoursepage === 0) {
// Ignore this module.
return false;
}
@ -110,11 +119,11 @@ export class CoreCourseListModTypePage implements OnInit {
);
}
if (this.archetypes[mod.modname] == CoreConstants.MOD_ARCHETYPE_RESOURCE) {
if (this.archetypes[mod.modname] === CoreConstants.MOD_ARCHETYPE_RESOURCE) {
return true;
}
} else if (mod.modname == this.modName) {
} else if (mod.modname === this.modName) {
return true;
}
});
@ -137,7 +146,7 @@ export class CoreCourseListModTypePage implements OnInit {
* @returns Promise resolved when done.
*/
async refreshData(refresher: IonRefresher): Promise<void> {
await CoreUtils.ignoreErrors(CoreCourse.invalidateSections(this.courseId || 0));
await CoreUtils.ignoreErrors(CoreCourse.invalidateSections(this.courseId));
try {
await this.fetchData();