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 problemsmain
parent
cf595146a8
commit
c030fed670
|
@ -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>
|
||||
|
|
|
@ -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<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.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue