Skip to content

Commit

Permalink
feat(dashboard): Deleting an ongoing measure is now possible
Browse files Browse the repository at this point in the history
Fixes #80
  • Loading branch information
MathieuNls committed Nov 12, 2016
1 parent 46ed622 commit d34bcdd
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/assets/i18n
Submodule i18n updated 1 files
+2 −0 en.json
17 changes: 10 additions & 7 deletions src/pages/dashboard/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,22 @@ <h3>{{ watch.name }}</h3>

</div>



</ion-item>
<ion-item-options side="left">
<button (click)="deleteWatch(watch, slidingItem)" color="danger" ion-button icon-only>
<ion-icon name="ios-trash-outline"></ion-icon>
<button [disabled]="submitAttempt" (click)="deleteWatch(watch, slidingItem)" color="danger" ion-button icon-only>
<ion-icon [hidden]="submitAttempt" name="md-watch"></ion-icon>
<ion-spinner [hidden]="!submitAttempt"></ion-spinner>
</button>

</ion-item-options>
<ion-item-options side="right">
<button (click)="updateWatch(watch, slidingItem)" color="secondary" ion-button icon-only>
<ion-icon name="ios-build-outline"></ion-icon>
</button>

</ion-item-options>
<ion-item-options *ngIf="watch.next !== WatchAction.Measure" side="right">
<button [disabled]="submitAttempt" (click)="deleteMeasure(watch, slidingItem)" color="danger" ion-button icon-only>
<ion-icon [hidden]="submitAttempt" name="ios-stopwatch-outline"></ion-icon>
<ion-spinner [hidden]="!submitAttempt"></ion-spinner>
</button>
</ion-item-options>
</ion-item-sliding>
</ion-list>
Expand Down
38 changes: 35 additions & 3 deletions src/pages/dashboard/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class DashboardPage {
WatchStatus = WatchStatus;
MeasureStatus = MeasureStatus;
WatchAction = WatchAction;
submitAttempt:boolean = false;
public static userChanged = new EventEmitter();
static cachedBackgrounds = [];
backgrounds = [];
Expand Down Expand Up @@ -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'),
Expand All @@ -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;
}
);
Expand Down
2 changes: 1 addition & 1 deletion src/share
Submodule share updated from e45f67 to 606cfb

0 comments on commit d34bcdd

Please sign in to comment.