From d34bcdd4ad4ae95546a273263b65fbaafb75b838 Mon Sep 17 00:00:00 2001 From: Mathieu Nayrolles Date: Sat, 12 Nov 2016 12:42:06 -0500 Subject: [PATCH] feat(dashboard): Deleting an ongoing measure is now possible Fixes #80 --- src/assets/i18n | 2 +- src/pages/dashboard/dashboard.html | 17 +++++++------ src/pages/dashboard/dashboard.ts | 38 +++++++++++++++++++++++++++--- src/share | 2 +- 4 files changed, 47 insertions(+), 12 deletions(-) diff --git a/src/assets/i18n b/src/assets/i18n index 825e7f6..63d2727 160000 --- a/src/assets/i18n +++ b/src/assets/i18n @@ -1 +1 @@ -Subproject commit 825e7f6b8faca145841475d953f4ccff3a79987b +Subproject commit 63d272727ba9ccf292202c1bd698ee36f21915ba diff --git a/src/pages/dashboard/dashboard.html b/src/pages/dashboard/dashboard.html index 3a61a14..230df18 100644 --- a/src/pages/dashboard/dashboard.html +++ b/src/pages/dashboard/dashboard.html @@ -95,19 +95,22 @@

{{ watch.name }}

- - - - - - + + + + diff --git a/src/pages/dashboard/dashboard.ts b/src/pages/dashboard/dashboard.ts index 8d9c430..4bd33e9 100644 --- a/src/pages/dashboard/dashboard.ts +++ b/src/pages/dashboard/dashboard.ts @@ -39,6 +39,7 @@ export class DashboardPage { WatchStatus = WatchStatus; MeasureStatus = MeasureStatus; WatchAction = WatchAction; + submitAttempt:boolean = false; public static userChanged = new EventEmitter(); static cachedBackgrounds = []; backgrounds = []; @@ -140,8 +141,39 @@ export class DashboardPage { }); } - deleteWatch(watch:Watch, slidingItem: ItemSliding){ + deleteMeasure(watch:Watch, slidingItem: ItemSliding){ + let alert = this.alertController.create({ + title: this.translate.instant('delete-pending-measure'), + message: this.translate.instant('delete-pending-measure-confirm'), + buttons: [ + { + text: this.translate.instant('cancel'), + role: 'cancel', + handler: () => { + slidingItem.close(); + } + }, + { + text: this.translate.instant('confirm'), + handler: () => { + this.submitAttempt = true; + + this.twapi.deleteMeasure(watch, watch.currentMeasure()).then( + res => { + this.submitAttempt = false; + this.user.upsertWatch(res); + slidingItem.close(); + } + ); + } + } + ] + }); + alert.present(); + } + + deleteWatch(watch:Watch, slidingItem: ItemSliding){ let alert = this.alertController.create({ title: this.translate.instant('delete-watch-alert'), @@ -152,15 +184,15 @@ export class DashboardPage { role: 'cancel', handler: () => { slidingItem.close(); - console.log('Cancel clicked'); } }, { text: this.translate.instant('confirm'), handler: () => { - + this.submitAttempt = true; this.twapi.deleteWatch(this.user, watch).then( res => { + this.submitAttempt = false; this.user = res; } ); diff --git a/src/share b/src/share index e45f67a..606cfb6 160000 --- a/src/share +++ b/src/share @@ -1 +1 @@ -Subproject commit e45f67a6a898efcdd83024ea44efb3e842083738 +Subproject commit 606cfb696a0c3cee715aa24f269f34fa1a7dca6b