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
main
Dani Palou 2023-05-03 14:44:55 +02:00
parent cf595146a8
commit c030fed670
2 changed files with 9 additions and 43 deletions

View File

@ -235,10 +235,6 @@
</form>
<div collapsible-footer appearOnBottom *ngIf="loaded && !error" slot="fixed">
<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">
{{ 'core.save' | translate }}
</ion-button>

View File

@ -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,7 +575,6 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave {
this.currentSite.getId(),
);
} else {
if (event) {
CoreEvents.trigger(
AddonCalendarProvider.NEW_EVENT_EVENT,
{
@ -584,41 +583,12 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave {
},
this.currentSite.getId(),
);
} else {
CoreEvents.trigger(AddonCalendarProvider.NEW_EVENT_DISCARDED_EVENT, {}, this.currentSite.getId());
}
}
this.originalData = undefined; // Avoid asking for confirmation.
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.
*