From 35d4bf356193f6703ac69166f39296d2f8fbaaa0 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 28 Apr 2023 10:25:05 +0200 Subject: [PATCH 1/5] MOBILE-4270 core: Set right version for LMS 4.2 --- src/core/classes/site.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/classes/site.ts b/src/core/classes/site.ts index 0e4326ea7..d0dc364dc 100644 --- a/src/core/classes/site.ts +++ b/src/core/classes/site.ts @@ -109,7 +109,7 @@ export class CoreSite { '3.11': 2021051700, '4.0': 2022041900, '4.1': 2022112800, - '4.2': 2023011300, // @todo [4.2] replace with right value when released. Using a tmp value to be able to test new things. + '4.2': 2023042400, }; // Possible cache update frequencies. From 4820ff18a3d18c02cf6fa10f2a580b8c3d144381 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 3 May 2023 10:25:15 +0200 Subject: [PATCH 2/5] MOBILE-4270 calendar: Fix app overridden when clicking some dates --- .../upcoming-events/addon-calendar-upcoming-events.html | 4 +++- src/addons/calendar/pages/day/day.html | 4 +++- src/addons/calendar/pages/event/event.html | 3 +-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/addons/calendar/components/upcoming-events/addon-calendar-upcoming-events.html b/src/addons/calendar/components/upcoming-events/addon-calendar-upcoming-events.html index 701ee61b4..c16291fdc 100644 --- a/src/addons/calendar/components/upcoming-events/addon-calendar-upcoming-events.html +++ b/src/addons/calendar/components/upcoming-events/addon-calendar-upcoming-events.html @@ -21,7 +21,9 @@

-

+

+ +

diff --git a/src/addons/calendar/pages/day/day.html b/src/addons/calendar/pages/day/day.html index ed5537bf9..acdb94351 100644 --- a/src/addons/calendar/pages/day/day.html +++ b/src/addons/calendar/pages/day/day.html @@ -86,7 +86,9 @@

-

+

+ +

diff --git a/src/addons/calendar/pages/event/event.html b/src/addons/calendar/pages/event/event.html index 9657c471a..bd590325b 100644 --- a/src/addons/calendar/pages/event/event.html +++ b/src/addons/calendar/pages/event/event.html @@ -61,8 +61,7 @@

{{ 'addon.calendar.when' | translate }}

- +
{{ 'core.deletedoffline' | translate }} From cf595146a83a3a631c895b1661afb52c0dcef1ea Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 3 May 2023 12:50:32 +0200 Subject: [PATCH 3/5] MOBILE-4270 collapsible-header: Fix changes not detected Before this change, listenEvents was called after initializeFloatingTitle, so the mutationObserver didn't exist when initializeFloatingTitle was executed. --- src/core/directives/collapsible-header.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/directives/collapsible-header.ts b/src/core/directives/collapsible-header.ts index 28d1c7f09..bdc9dc474 100644 --- a/src/core/directives/collapsible-header.ts +++ b/src/core/directives/collapsible-header.ts @@ -125,6 +125,8 @@ export class CoreCollapsibleHeaderDirective implements OnInit, OnChanges, OnDest await this.enteredPromise, ]); + this.listenEvents(); + await this.initializeFloatingTitle(); this.initializeContent(); } @@ -291,8 +293,6 @@ export class CoreCollapsibleHeaderDirective implements OnInit, OnChanges, OnDest return; } - this.listenEvents(); - // Initialize from tabs. const tabs = CoreDirectivesRegistry.resolve(this.page.querySelector('core-tabs-outlet'), CoreTabsOutletComponent); From c030fed670c254b23de4c362ac329f8434e21aae Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 3 May 2023 14:44:55 +0200 Subject: [PATCH 4/5] MOBILE-4270 calendar: Remove discard option when editing offline event Offline events can now be deleted in the event page, this Discard option is redundant and causes some navigation problems --- .../calendar/pages/edit-event/edit-event.html | 4 -- .../calendar/pages/edit-event/edit-event.ts | 48 ++++--------------- 2 files changed, 9 insertions(+), 43 deletions(-) diff --git a/src/addons/calendar/pages/edit-event/edit-event.html b/src/addons/calendar/pages/edit-event/edit-event.html index 23cea6789..a926b9025 100644 --- a/src/addons/calendar/pages/edit-event/edit-event.html +++ b/src/addons/calendar/pages/edit-event/edit-event.html @@ -235,10 +235,6 @@
- - {{ '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() ?? '')); } /**