Merge pull request #3650 from dpalou/MOBILE-4270

MOBILE-4270 core: Set right version for LMS 4.2
main
Pau Ferrer Ocaña 2023-05-04 10:11:10 +02:00 committed by GitHub
commit 3ddf2326a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 26 additions and 54 deletions

View File

@ -17,9 +17,9 @@
<core-spacer *ngIf="filter.course || filter.category || filter.group"></core-spacer> <core-spacer *ngIf="filter.course || filter.category || filter.group"></core-spacer>
<ng-container *ngIf="filter.course || filter.category || filter.group"> <ng-container *ngIf="filter.course || filter.category || filter.group">
<ion-radio-group [(ngModel)]="courseId" (ionChange)="onChange()"> <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> <ion-label>
<core-format-text [text]="course.fullname"></core-format-text> <core-format-text [text]="course.shortname"></core-format-text>
</ion-label> </ion-label>
<ion-radio slot="end" [value]="course.id"></ion-radio> <ion-radio slot="end" [value]="course.id"></ion-radio>
</ion-item> </ion-item>

View File

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

View File

@ -21,7 +21,9 @@
<core-format-text [text]="event.name" [contextLevel]="event.contextLevel" <core-format-text [text]="event.name" [contextLevel]="event.contextLevel"
[contextInstanceId]="event.contextInstanceId"></core-format-text> [contextInstanceId]="event.contextInstanceId"></core-format-text>
</p> </p>
<p [innerHTML]="event.formattedtime"></p> <p>
<core-format-text [text]="event.formattedtime" [filter]="false"></core-format-text>
</p>
</ion-label> </ion-label>
<ion-note *ngIf="event.offline && !event.deleted" slot="end"> <ion-note *ngIf="event.offline && !event.deleted" slot="end">
<ion-icon name="fas-clock" aria-hidden="true"></ion-icon> <ion-icon name="fas-clock" aria-hidden="true"></ion-icon>

View File

@ -86,7 +86,9 @@
<core-format-text [text]="event.name" [contextLevel]="event.contextLevel" <core-format-text [text]="event.name" [contextLevel]="event.contextLevel"
[contextInstanceId]="event.contextInstanceId"></core-format-text> [contextInstanceId]="event.contextInstanceId"></core-format-text>
</p> </p>
<p [innerHTML]="event.formattedtime"></p> <p>
<core-format-text [text]="event.formattedtime" [filter]="false"></core-format-text>
</p>
</ion-label> </ion-label>
<ion-note *ngIf="event.offline && !event.deleted" slot="end"> <ion-note *ngIf="event.offline && !event.deleted" slot="end">
<ion-icon name="fas-clock" aria-hidden="true"></ion-icon> <ion-icon name="fas-clock" aria-hidden="true"></ion-icon>

View File

@ -235,10 +235,6 @@
</form> </form>
<div collapsible-footer appearOnBottom *ngIf="loaded && !error" slot="fixed"> <div collapsible-footer appearOnBottom *ngIf="loaded && !error" slot="fixed">
<div class="list-item-limited-width adaptable-buttons-row"> <div class="list-item-limited-width adaptable-buttons-row">
<ion-button *ngIf="hasOffline && eventId && eventId < 0" expand="block" fill="outline" (click)="discard()"
class="ion-margin ion-text-wrap">
{{ 'core.discard' | translate }}
</ion-button>
<ion-button expand="block" (click)="submit()" [disabled]="!form.valid" type="submit" class="ion-margin ion-text-wrap"> <ion-button expand="block" (click)="submit()" [disabled]="!form.valid" type="submit" class="ion-margin ion-text-wrap">
{{ 'core.save' | translate }} {{ 'core.save' | translate }}
</ion-button> </ion-button>

View File

@ -563,7 +563,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave {
* *
* @param event Event. * @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. // Unblock the sync because the view will be destroyed and the sync process could be triggered before ngOnDestroy.
this.unblockSync(); this.unblockSync();
@ -575,7 +575,6 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave {
this.currentSite.getId(), this.currentSite.getId(),
); );
} else { } else {
if (event) {
CoreEvents.trigger( CoreEvents.trigger(
AddonCalendarProvider.NEW_EVENT_EVENT, AddonCalendarProvider.NEW_EVENT_EVENT,
{ {
@ -584,41 +583,12 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave {
}, },
this.currentSite.getId(), this.currentSite.getId(),
); );
} else {
CoreEvents.trigger(AddonCalendarProvider.NEW_EVENT_DISCARDED_EVENT, {}, this.currentSite.getId());
}
} }
this.originalData = undefined; // Avoid asking for confirmation. this.originalData = undefined; // Avoid asking for confirmation.
CoreNavigator.back(); CoreNavigator.back();
} }
/**
* Discard an offline saved discussion.
*/
async discard(): Promise<void> {
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. * Check if we can leave the page or not.
* *

View File

@ -61,8 +61,7 @@
<ion-item class="ion-text-wrap"> <ion-item class="ion-text-wrap">
<ion-label> <ion-label>
<p class="item-heading">{{ 'addon.calendar.when' | translate }}</p> <p class="item-heading">{{ 'addon.calendar.when' | translate }}</p>
<core-format-text [text]="event.formattedtime" [contextLevel]="event.contextLevel" <core-format-text [text]="event.formattedtime" [filter]="false"></core-format-text>
[contextInstanceId]="event.contextInstanceId"></core-format-text>
</ion-label> </ion-label>
<ion-note slot="end" *ngIf="event.deleted"> <ion-note slot="end" *ngIf="event.deleted">
<ion-icon name="fas-trash" aria-hidden="true"></ion-icon> {{ 'core.deletedoffline' | translate }} <ion-icon name="fas-trash" aria-hidden="true"></ion-icon> {{ 'core.deletedoffline' | translate }}

View File

@ -109,7 +109,7 @@ export class CoreSite {
'3.11': 2021051700, '3.11': 2021051700,
'4.0': 2022041900, '4.0': 2022041900,
'4.1': 2022112800, '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. // Possible cache update frequencies.

View File

@ -125,6 +125,8 @@ export class CoreCollapsibleHeaderDirective implements OnInit, OnChanges, OnDest
await this.enteredPromise, await this.enteredPromise,
]); ]);
this.listenEvents();
await this.initializeFloatingTitle(); await this.initializeFloatingTitle();
this.initializeContent(); this.initializeContent();
} }
@ -291,8 +293,6 @@ export class CoreCollapsibleHeaderDirective implements OnInit, OnChanges, OnDest
return; return;
} }
this.listenEvents();
// Initialize from tabs. // Initialize from tabs.
const tabs = CoreDirectivesRegistry.resolve(this.page.querySelector('core-tabs-outlet'), CoreTabsOutletComponent); const tabs = CoreDirectivesRegistry.resolve(this.page.querySelector('core-tabs-outlet'), CoreTabsOutletComponent);