-
- {{ 'core.discard' | translate }}
-
{{ 'core.save' | translate }}
diff --git a/src/addons/calendar/pages/edit-event/edit-event.ts b/src/addons/calendar/pages/edit-event/edit-event.ts
index 8b8ffe230..eb1bca439 100644
--- a/src/addons/calendar/pages/edit-event/edit-event.ts
+++ b/src/addons/calendar/pages/edit-event/edit-event.ts
@@ -563,7 +563,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave {
*
* @param event Event.
*/
- protected returnToList(event?: AddonCalendarEvent | AddonCalendarOfflineEventDBRecord): void {
+ protected returnToList(event: AddonCalendarEvent | AddonCalendarOfflineEventDBRecord): void {
// Unblock the sync because the view will be destroyed and the sync process could be triggered before ngOnDestroy.
this.unblockSync();
@@ -575,50 +575,20 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave {
this.currentSite.getId(),
);
} else {
- if (event) {
- CoreEvents.trigger(
- AddonCalendarProvider.NEW_EVENT_EVENT,
- {
- eventId: event.id,
- oldEventId: this.eventId,
- },
- this.currentSite.getId(),
- );
- } else {
- CoreEvents.trigger(AddonCalendarProvider.NEW_EVENT_DISCARDED_EVENT, {}, this.currentSite.getId());
- }
+ CoreEvents.trigger(
+ AddonCalendarProvider.NEW_EVENT_EVENT,
+ {
+ eventId: event.id,
+ oldEventId: this.eventId,
+ },
+ this.currentSite.getId(),
+ );
}
this.originalData = undefined; // Avoid asking for confirmation.
CoreNavigator.back();
}
- /**
- * Discard an offline saved discussion.
- */
- async discard(): Promise {
- if (!this.eventId) {
- return;
- }
-
- try {
- await CoreDomUtils.showConfirm(Translate.instant('core.areyousure'));
-
- try {
- await AddonCalendarOffline.deleteEvent(this.eventId);
-
- CoreForms.triggerFormCancelledEvent(this.formElement, this.currentSite.getId());
-
- this.returnToList();
- } catch {
- // Shouldn't happen.
- CoreDomUtils.showErrorModal('Error discarding event.');
- }
- } catch {
- // Ignore errors
- }
- }
-
/**
* Check if we can leave the page or not.
*
From 8ce5414980586a68425f766a5524b3c849fe2674 Mon Sep 17 00:00:00 2001
From: Dani Palou
Date: Thu, 4 May 2023 09:49:01 +0200
Subject: [PATCH 5/5] MOBILE-4270 calendar: Make course filter list consistent
with LMS
---
src/addons/calendar/components/filter/filter.html | 4 ++--
src/addons/calendar/components/filter/filter.ts | 7 +++++--
2 files changed, 7 insertions(+), 4 deletions(-)
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() ?? ''));
}
/**