feat: sort the event types in alphabetical order (#6400)

Co-authored-by: Max Peintner <max@caos.ch>
This commit is contained in:
Miguel Cabrerizo 2023-08-29 09:39:29 +02:00 committed by GitHub
parent fd00ac533a
commit 5dddbe7a8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -173,7 +173,43 @@ export class FilterEventsComponent implements OnInit {
return this.adminService return this.adminService
.listEventTypes(req) .listEventTypes(req)
.then((list) => { .then((list) => {
this.eventTypes = list.eventTypesList ?? []; this.eventTypes =
list.eventTypesList.sort((a, b) => {
if (b.localized && b.localized.localizedMessage) {
if (a.localized && a.localized.localizedMessage) {
if (a.localized.localizedMessage < b.localized.localizedMessage) {
return -1;
}
if (a.localized.localizedMessage > b.localized.localizedMessage) {
return 1;
}
} else {
if (a.type < b.localized.localizedMessage) {
return -1;
}
if (a.type > b.localized.localizedMessage) {
return 1;
}
}
} else {
if (a.localized && a.localized.localizedMessage) {
if (a.localized.localizedMessage < b.type) {
return -1;
}
if (a.localized.localizedMessage > b.type) {
return 1;
}
} else {
if (a.type < b.type) {
return -1;
}
if (a.type > b.type) {
return 1;
}
}
}
return 0;
}) ?? [];
}) })
.catch((error) => { .catch((error) => {
this.toast.showError(error); this.toast.showError(error);