Skip to content

Commit

Permalink
Close sliding items when edit/delete are done. Fix #46
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuNls committed Jul 21, 2016
1 parent d719404 commit 6da4676
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions app/pages/dashboard/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</ion-refresher>

<ion-list *ngIf="user" >
<ion-item-sliding *ngFor="let watch of user.watches">
<ion-item-sliding #slidingItem *ngFor="let watch of user.watches">

<ion-item>
<h2>{{ watch.brand }}</h2>
Expand Down Expand Up @@ -46,12 +46,12 @@ <h3>{{ watch.name }}</h3>

</ion-item>
<ion-item-options side="left">
<button (click)="deleteWatch(watch)" danger>
<button (click)="deleteWatch(watch, slidingItem)" danger>
<ion-icon name="ios-trash-outline"></ion-icon>
</button>
</ion-item-options>
<ion-item-options side="right">
<button (click)="updateWatch(watch)" secondary>
<button (click)="updateWatch(watch, slidingItem)" secondary>
<ion-icon name="ios-build-outline"></ion-icon>
</button>
</ion-item-options>
Expand Down
9 changes: 5 additions & 4 deletions app/pages/dashboard/dashboard.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component, ElementRef, EventEmitter, ViewChild} from '@angular/core';
import {Alert, Nav, Loading, NavController, NavParams, ActionSheet} from 'ionic-angular';
import {Alert, Nav, Loading, NavController, NavParams, ActionSheet, ItemSliding} from 'ionic-angular';
import {LoginComponent} from 'tw-common/dist/app/directives/login/login.component';
import {TwAPIService} from 'tw-common/dist/app/services/twapi.service';
import {Watch, WatchStatus, WatchAction} from 'tw-common/dist/app/models/watch.model';
Expand Down Expand Up @@ -48,11 +48,12 @@ export class DashboardPage {
this.user = this.navParams.get('user');
}

updateWatch(watch:Watch){
updateWatch(watch:Watch, slidingItem: ItemSliding){
this.nav.push(WatchPage, {
watch: watch,
user: this.user
});
slidingItem.close();
}

measureWatch(watch: Watch){
Expand All @@ -61,7 +62,6 @@ export class DashboardPage {
watch: watch,
user: this.user
});

}

share(){
Expand Down Expand Up @@ -95,7 +95,7 @@ export class DashboardPage {

}

deleteWatch(watch:Watch){
deleteWatch(watch:Watch, slidingItem: ItemSliding){


let alert = Alert.create({
Expand All @@ -106,6 +106,7 @@ export class DashboardPage {
text: this.translate.instant('cancel'),
role: 'cancel',
handler: () => {
slidingItem.close();
console.log('Cancel clicked');
}
},
Expand Down

0 comments on commit 6da4676

Please sign in to comment.