diff --git a/src/addons/calendar/components/filter/filter.html b/src/addons/calendar/components/filter/filter.html index 0a344811a..65dee4fd4 100644 --- a/src/addons/calendar/components/filter/filter.html +++ b/src/addons/calendar/components/filter/filter.html @@ -17,9 +17,9 @@ - + - + diff --git a/src/addons/calendar/components/filter/filter.ts b/src/addons/calendar/components/filter/filter.ts index 9d25721b2..c13e6e372 100644 --- a/src/addons/calendar/components/filter/filter.ts +++ b/src/addons/calendar/components/filter/filter.ts @@ -30,6 +30,7 @@ import { AddonCalendarFilter, AddonCalendarEventIcons } from '../../services/cal }) export class AddonCalendarFilterComponent implements OnInit { + @Input() courses: Partial[] = []; @Input() filter: AddonCalendarFilter = { filtered: false, courseId: undefined, @@ -42,10 +43,9 @@ export class AddonCalendarFilterComponent implements OnInit { }; courseId = -1; - - @Input() courses: Partial[] = []; typeIcons: AddonCalendarEventIcons[] = []; types: string[] = []; + sortedCourses: Partial[] = []; 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() ?? '')); } /**