MOBILE-2945 course: Display course custom fields in preview page

main
Pau Ferrer Ocaña 2019-04-24 09:49:10 +02:00
parent c6e01bfa66
commit 0735453589
3 changed files with 29 additions and 0 deletions

View File

@ -32,6 +32,16 @@
</a>
<ion-item-divider></ion-item-divider>
</ng-container>
<ion-item text-wrap *ngIf="course.customfields" detail-none>
<ng-container *ngFor="let field of course.customfields">
<div *ngIf="field.value" class="core-customfield core-customfield_{{field.type}} core-customfield_{{field.shortname}}">
<span class="core-customfieldname"><core-format-text [text]="field.name"></core-format-text></span><span class="core-customfieldseparator">: </span>
<span class="core-customfieldvalue"><core-format-text [text]="field.value" maxHeight="120"></core-format-text></span>
</div>
</ng-container>
</ion-item>
<core-file *ngFor="let file of course.overviewfiles" [file]="file" [component]="component" [componentId]="course.id"></core-file>
<div *ngIf="!isEnrolled" detail-none>
<ion-item text-wrap *ngFor="let instance of selfEnrolInstances">

View File

@ -15,4 +15,8 @@ ion-app.app-root page-core-courses-course-preview {
width: 100%;
}
}
.core-customfieldvalue core-format-text {
display: inline;
}
}

View File

@ -233,6 +233,18 @@ export class CoreCoursesCoursePreviewPage implements OnDestroy {
this.canAccessCourse = false;
});
});
}).finally(() => {
if (!this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.7')) {
return this.coursesProvider.isGetCoursesByFieldAvailableInSite().then((available) => {
if (available) {
return this.coursesProvider.getCourseByField('id', this.course.id).then((course) => {
this.course.customfields = course.customfields;
});
}
}).catch(() => {
// Ignore errors.
});
}
}).finally(() => {
this.dataLoaded = true;
});
@ -386,6 +398,9 @@ export class CoreCoursesCoursePreviewPage implements OnDestroy {
promises.push(this.coursesProvider.invalidateCourse(this.course.id));
promises.push(this.coursesProvider.invalidateCourseEnrolmentMethods(this.course.id));
promises.push(this.courseOptionsDelegate.clearAndInvalidateCoursesOptions(this.course.id));
if (this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.7')) {
promises.push(this.coursesProvider.invalidateCoursesByField('id', this.course.id));
}
if (this.guestInstanceId) {
promises.push(this.coursesProvider.invalidateCourseGuestEnrolmentInfo(this.guestInstanceId));
}