MOBILE-4270 calendar: Make course filter list consistent with LMS

main
Dani Palou 2023-05-04 09:49:01 +02:00
parent c030fed670
commit 8ce5414980
2 changed files with 7 additions and 4 deletions

View File

@ -17,9 +17,9 @@
<core-spacer *ngIf="filter.course || filter.category || filter.group"></core-spacer>
<ng-container *ngIf="filter.course || filter.category || filter.group">
<ion-radio-group [(ngModel)]="courseId" (ionChange)="onChange()">
<ion-item class="ion-text-wrap" *ngFor="let course of courses">
<ion-item class="ion-text-wrap" *ngFor="let course of sortedCourses">
<ion-label>
<core-format-text [text]="course.fullname"></core-format-text>
<core-format-text [text]="course.shortname"></core-format-text>
</ion-label>
<ion-radio slot="end" [value]="course.id"></ion-radio>
</ion-item>

View File

@ -30,6 +30,7 @@ import { AddonCalendarFilter, AddonCalendarEventIcons } from '../../services/cal
})
export class AddonCalendarFilterComponent implements OnInit {
@Input() courses: Partial<CoreEnrolledCourseData>[] = [];
@Input() filter: AddonCalendarFilter = {
filtered: false,
courseId: undefined,
@ -42,10 +43,9 @@ export class AddonCalendarFilterComponent implements OnInit {
};
courseId = -1;
@Input() courses: Partial<CoreEnrolledCourseData>[] = [];
typeIcons: AddonCalendarEventIcons[] = [];
types: string[] = [];
sortedCourses: Partial<CoreEnrolledCourseData>[] = [];
constructor() {
CoreUtils.enumKeys(AddonCalendarEventType).forEach((name) => {
@ -61,6 +61,9 @@ export class AddonCalendarFilterComponent implements OnInit {
*/
ngOnInit(): void {
this.courseId = this.filter.courseId || -1;
this.sortedCourses = Array.from(this.courses)
.sort((a, b) => (a.shortname?.toLowerCase() ?? '').localeCompare(b.shortname?.toLowerCase() ?? ''));
}
/**