|
@@ -1,5 +1,5 @@
|
|
import { Component } from '@angular/core';
|
|
import { Component } from '@angular/core';
|
|
-import { NavController, ActionSheetController, ActionSheet } from 'ionic-angular';
|
|
|
|
|
|
+import { NavController, AlertController } from 'ionic-angular';
|
|
import { DefaultListable } from '../../defaults/default-listable';
|
|
import { DefaultListable } from '../../defaults/default-listable';
|
|
import { INavigable } from '../../interfaces/navigable-interface';
|
|
import { INavigable } from '../../interfaces/navigable-interface';
|
|
import { Product } from '../../models/product';
|
|
import { Product } from '../../models/product';
|
|
@@ -15,8 +15,8 @@ export class ProductListPage extends DefaultListable<Product> implements INaviga
|
|
|
|
|
|
constructor(
|
|
constructor(
|
|
public navCtrl: NavController,
|
|
public navCtrl: NavController,
|
|
- public actionSheetCtrl: ActionSheetController,
|
|
|
|
- public data: DataProvider
|
|
|
|
|
|
+ public data: DataProvider,
|
|
|
|
+ public alertCtrl: AlertController
|
|
){
|
|
){
|
|
super();
|
|
super();
|
|
this.initialize();
|
|
this.initialize();
|
|
@@ -26,7 +26,7 @@ export class ProductListPage extends DefaultListable<Product> implements INaviga
|
|
* Initialize data list
|
|
* Initialize data list
|
|
*/
|
|
*/
|
|
initialize(): void {
|
|
initialize(): void {
|
|
- this.data.getAll('product').then(r => {
|
|
|
|
|
|
+ this.data.getAll("product").then(r => {
|
|
this.elements = r.products;
|
|
this.elements = r.products;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -41,34 +41,39 @@ export class ProductListPage extends DefaultListable<Product> implements INaviga
|
|
/**
|
|
/**
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
- createOptions(): ActionSheet {
|
|
|
|
- return this.actionSheetCtrl.create({
|
|
|
|
- title: "Opciones",
|
|
|
|
|
|
+ openItem(product: any) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ removeItem() {
|
|
|
|
+ let confirm = this.alertCtrl.create({
|
|
|
|
+ title: "Confirmar",
|
|
|
|
+ message: "Desea borrar este producto?",
|
|
buttons: [
|
|
buttons: [
|
|
{
|
|
{
|
|
- text: "Eliminar",
|
|
|
|
- icon: "trash",
|
|
|
|
- role: "destructive",
|
|
|
|
|
|
+ text: "Cancelar",
|
|
handler: () => {
|
|
handler: () => {
|
|
- console.log("Eliminar");
|
|
|
|
|
|
+ this.toggleDelete(-1);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- text: 'Cancel',
|
|
|
|
- role: 'cancel',
|
|
|
|
|
|
+ text: "Aceptar",
|
|
handler: () => {
|
|
handler: () => {
|
|
- console.log('Cancel clicked');
|
|
|
|
|
|
+ let item = this.elements[this.selectedIndex];
|
|
|
|
+
|
|
|
|
+ this.data.delete("product", item).then(() => {
|
|
|
|
+
|
|
|
|
+ }).catch(() => {
|
|
|
|
+
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
]
|
|
});
|
|
});
|
|
- }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
- *
|
|
|
|
- */
|
|
|
|
- openItem(product: any) {
|
|
|
|
- let options = this.createOptions();
|
|
|
|
- options.present();
|
|
|
|
|
|
+ confirm.present();
|
|
}
|
|
}
|
|
}
|
|
}
|