Procházet zdrojové kódy

add order features except save, extends models to base model to expose database defaults fields and add list view modes to reuse these views

robert2206 před 8 roky
rodič
revize
0eea90888f

+ 12 - 3
src/app/app.component.ts

@@ -43,7 +43,10 @@ export class MyApp {
                         visible: true,
                         title: "Clientes",
                         icon: "people",
-                        component: CustomersPage
+                        component: CustomersPage,
+                        params: {
+                            mode: "list"
+                        }
                     },
                     {
                         visible: true,
@@ -69,13 +72,19 @@ export class MyApp {
                         visible: true,
                         title: 'Productos',
                         icon: "cube",
-                        component: ProductsPage
+                        component: ProductsPage,
+                        params: {
+                            mode: "list"
+                        }
                     },
                     {
                         visible: true,
                         title: 'Variantes',
                         icon: "list-box",
-                        component: VariantsPage
+                        component: VariantsPage,
+                        params: {
+                            mode: "list"
+                        }
                     },
                 ]
             },

+ 0 - 6
src/app/app.module.ts

@@ -24,8 +24,6 @@ import { AboutPage } from "../pages/about/about";
 import { CustomerPage } from "../pages/customer/customer";
 import { ProductPage } from "../pages/product/product";
 import { OrderPage } from "../pages/order/order";
-import { CustomerSelectionPage } from "../pages/order/customer-selection/customer-selection";
-import { ProductSelectionPage } from "../pages/order/product-selection/product-selection";
 import { LeadPage } from "../pages/lead/lead";
 import { PhonecallPage } from "../pages/phonecall/phonecall";
 
@@ -61,8 +59,6 @@ import { DoubleTap } from "../directives/double-tap";
         CustomerPage,
         ProductPage,
         OrderPage,
-        CustomerSelectionPage,
-        ProductSelectionPage,
         LeadPage,
         PhonecallPage,
         // Components
@@ -95,8 +91,6 @@ import { DoubleTap } from "../directives/double-tap";
         CustomerPage,
         ProductPage,
         OrderPage,
-        CustomerSelectionPage,
-        ProductSelectionPage,
         LeadPage,
         PhonecallPage,
         // Other Pages

+ 38 - 5
src/base/base-list-view.ts

@@ -24,18 +24,20 @@ export abstract class BaseListView<T> extends BaseView<T>{
     filters: Array<[string, string, any]>;
     search: boolean;
     range: { start: number, end: number };
+    mode: string;
 
-    constructor(c: { new (): T; }, ...filters: Array<[string, string, any]>) {
+    constructor(c: { new (): T; }, mode?: string, ...filters: Array<[string, string, any]>) {
         super(c, PouchService);
 
         this.items = [];
         this.itemsShown = [];
         this.itemsMatched = [];
         this.selectedItem = null;
+        this.mode = mode ? mode: "list";
         this.filters = filters;
         this.search = false;
-        this.range = { start: 0, end: 10 }
-        
+        this.range = { start: 0, end: 10 };
+       
         this.initialize();
     }
 
@@ -89,6 +91,13 @@ export abstract class BaseListView<T> extends BaseView<T>{
     getRange(): { start: number, end: number } {
         return this.range;
     }
+
+    /**
+     * 
+     */
+    getMode(): string {
+        return this.mode;
+    }
     
     // -----------------------------------------------------------
     //  ███████╗███████╗████████╗████████╗███████╗██████╗ ███████╗
@@ -117,8 +126,6 @@ export abstract class BaseListView<T> extends BaseView<T>{
         this.itemsShown = itemsShown;
     } 
 
-    
-
     /**
      * 
      * @param itemsMatched 
@@ -168,6 +175,14 @@ export abstract class BaseListView<T> extends BaseView<T>{
         this.range = range;
     }
 
+    /**
+     * 
+     * @param mode 
+     */
+    setMode(mode: string): void {
+        this.mode = mode;
+    }
+
     // -------------------------------------------------------------------------------------------------------------------
     //  ███████╗██████╗ ███████╗ ██████╗██╗ █████╗ ██╗          ██████╗ ███████╗████████╗████████╗███████╗██████╗ ███████╗
     //  ██╔════╝██╔══██╗██╔════╝██╔════╝██║██╔══██╗██║         ██╔════╝ ██╔════╝╚══██╔══╝╚══██╔══╝██╔════╝██╔══██╗██╔════╝
@@ -403,10 +418,28 @@ export abstract class BaseListView<T> extends BaseView<T>{
         this.items.splice(this.getSelectedIndexInAll(), 1);
     }
 
+    /**
+     * 
+     * @param item 
+     */
+    selectItem(item: T): void {
+        this.setSelectedItem(item);
+
+        EventsManager.publish("app:select", {
+            type: super.getType(),
+            item: item
+        });
+    }
+
     /**
      * Deselecciona el elemento que haya sido previamente seleccionado.
      */
     unselectItem(): void {
+        EventsManager.publish("app:unselect",  {
+            type: super.getType(),
+            item: this.getSelectedItem()
+        });
+
         this.setSelectedItem(null);
     }
 

+ 7 - 0
src/odoo/models/base.ts

@@ -0,0 +1,7 @@
+export abstract class Base {
+    _id: string;
+    _rev: string;
+    odoo_id: number;
+    odoo_model: string;
+    odoo_status: string;
+}

+ 3 - 1
src/odoo/models/product.product.ts

@@ -2,8 +2,10 @@ import { OdooModel } from "../decorators/model";
 import { OdooField } from "../decorators/field";
 import { FieldTypes } from "../types/field";
 
+import { Base } from "./base";
+
 @OdooModel("product.product", [["sale_ok", "=", true], ["qty_available", ">", 0], ["active", "=", true]])
-export class ProductProduct {
+export class ProductProduct extends Base {
 
     @OdooField(FieldTypes.ONE2MANY)
     attribute_line_ids: any;

+ 3 - 1
src/odoo/models/res.partner.ts

@@ -2,8 +2,10 @@ import { OdooModel } from "../decorators/model";
 import { OdooField } from "../decorators/field";
 import { FieldTypes } from "../types/field";
 
+import { Base } from "./base";
+
 @OdooModel("res.partner", [["active", "=", true]])
-export class Partner {
+export class Partner extends Base {
 
     @OdooField(FieldTypes.ONE2MANY)
     child_ids: any;

+ 1 - 1
src/pages/customers/customers.html

@@ -47,7 +47,7 @@
 	<div class="no-items" *ngIf="!hasItemsShown()">
         <h2>Sin elementos</h2>
     </div>
-	<ion-fab right bottom>
+	<ion-fab right bottom *ngIf="getMode() === 'list'">
         <button ion-fab (click)="goToDetails()">
             <ion-icon name="add"></ion-icon>
         </button>

+ 45 - 41
src/pages/customers/customers.ts

@@ -17,7 +17,7 @@ export class CustomersPage extends BaseListView<Partner> {
         public actionSheetCtrl: ActionSheetController,
         public alertCtrl: AlertController
     ) {
-        super(Partner, ["customer", "=", true]);
+        super(Partner, navParams.data.params.mode, ["customer", "=", true]);        
     }
 
     /**
@@ -39,49 +39,53 @@ export class CustomersPage extends BaseListView<Partner> {
      * @param item
      */
     openOptions(item: Partner): void {
-        super.setSelectedItem(item);
+        super.selectItem(item);
         
-        this.actionSheetCtrl.create({
-            title: "Opciones",
-            buttons: [
-                {
-                    text: "Abrir",
-                    icon: "open",
-                    handler: () => {
-                        this.goToDetails();
-                    }
-                },
-                {
-                    text: "Ir a ubicación",
-                    icon: "navigate",
-                    handler: () => {
+        if (super.getMode() === "list") {
+            this.actionSheetCtrl.create({
+                title: "Opciones",
+                buttons: [
+                    {
+                        text: "Abrir",
+                        icon: "open",
+                        handler: () => {
+                            this.goToDetails();
+                        }
+                    },
+                    {
+                        text: "Ir a ubicación",
+                        icon: "navigate",
+                        handler: () => {
 
-                    }
-                },
-                {
-                    text: "Llamar",
-                    icon: "call",
-                    handler: () => {
+                        }
+                    },
+                    {
+                        text: "Llamar",
+                        icon: "call",
+                        handler: () => {
 
-                    }
-                },
-                {
-                    text: "Eliminar",
-                    icon: "close",
-                    role: "destructive",
-                    handler: () => {
-                        this.askIfDelete();
-                    }
-                },
-                {
-                    text: "Cancelar",
-                    role: "cancel",
-                    handler: () => {
-                        super.unselectItem();
-                    }
-                },
-            ]
-        }).present();
+                        }
+                    },
+                    {
+                        text: "Eliminar",
+                        icon: "close",
+                        role: "destructive",
+                        handler: () => {
+                            this.askIfDelete();
+                        }
+                    },
+                    {
+                        text: "Cancelar",
+                        role: "cancel",
+                        handler: () => {
+                            super.unselectItem();
+                        }
+                    },
+                ]
+            }).present();
+        } else {
+            this.navCtrl.pop();
+        }
     }
 
     /**

+ 0 - 8
src/pages/order/customer-selection/customer-selection.html

@@ -1,8 +0,0 @@
-<ion-header>
-    <ion-navbar>
-        <ion-title>Seleccione un Cliente</ion-title>
-    </ion-navbar>
-</ion-header>
-<ion-content>
-    <ion-searchbar placeholder="Buscar"></ion-searchbar>
-</ion-content>

+ 0 - 13
src/pages/order/customer-selection/customer-selection.ts

@@ -1,13 +0,0 @@
-import { Component } from "@angular/core";
-import { NavController } from "ionic-angular";
-
-@Component({
-    selector: 'customer-selection',
-    templateUrl: 'customer-selection.html'
-})
-export class CustomerSelectionPage {
-
-    constructor(
-        public navCtrl: NavController
-    ) { }
-}

+ 127 - 0
src/pages/order/models/cart-item.ts

@@ -0,0 +1,127 @@
+import { ProductProduct } from "../../../odoo/models/product.product";
+
+export class CartItem {
+
+    product: ProductProduct;
+    price: number;
+    quantity: number;
+    subtotal: number;
+
+    constructor(
+        product?: ProductProduct,
+        price?: number,
+        quantity?: number,
+        subtotal?: number
+    ) {
+        this.product = product;
+        this.price = price ? price : 0;
+        this.quantity = quantity ? quantity : 0;
+        this.subtotal = subtotal ? subtotal : 0;
+    }
+
+    /**
+     * 
+     */
+    getProduct(): ProductProduct {
+        return this.product;
+    }
+
+    /**
+     * 
+     */
+    getProductName(): string {
+        return this.getProduct() ? this.getProduct().name : "n/a";
+    }
+
+    /**
+     * 
+     */
+    getImage(): string {
+        return this.getProduct().image_medium;
+    }
+
+    /**
+     * 
+     */
+    getPrice(): number {
+        return this.price;
+    }
+
+    /**
+     * 
+     */
+    getQuantity(): number {
+        return this.quantity;
+    }
+
+    /**
+     * 
+     */
+    getSubtotal(): number {
+        return this.subtotal;
+    }
+
+    /**
+     * 
+     * @param product 
+     */
+    setProduct(product: ProductProduct): void {
+        this.product = product;
+    }
+
+    /**
+     * 
+     * @param price 
+     */
+    setPrice(price: number): void {
+        this.price = price;
+    }
+
+    /**
+     * 
+     * @param quantity 
+     */
+    setQuantity(quantity: number): void {
+        this.quantity = quantity;
+    }
+
+    /**
+     * 
+     * @param subtotal 
+     */
+    setSubtotal(subtotal: number): void {
+        this.subtotal = subtotal;
+    }
+
+    /**
+     * 
+     */
+    hasImage(): boolean {
+        return !!this.getProduct().image_medium;
+    }
+
+    /**
+     * 
+     * @param quantity 
+     */
+    updateQuantity(quantity: number): void {
+        this.setQuantity(this.getQuantity() + quantity);
+        this.computeSubtotal();
+    }
+
+    /**
+     * 
+     * @param price 
+     */
+    updatePrice(price: number): void {
+        this.setPrice(price);
+        this.computeSubtotal();
+    }
+
+    /**
+     * 
+     */
+    computeSubtotal(): void {
+        this.setSubtotal(this.getPrice() * this.getQuantity());
+    }
+}

+ 161 - 0
src/pages/order/models/cart.ts

@@ -0,0 +1,161 @@
+import { Partner } from "../../../odoo/models/res.partner";
+import { ProductProduct } from "../../../odoo/models/product.product";
+import { CartItem } from "./cart-item"
+
+export class Cart {
+
+    customer: Partner;
+    items: Array<CartItem>;
+    total: number;
+
+    constructor(
+        customer?: Partner,
+        items?: Array<CartItem>,
+        total?: number
+    ) { 
+        this.customer = customer;
+        this.items = items ? items : [];
+        this.total = total;
+    }
+
+    /**
+     * 
+     */
+    getCustomer(): Partner {
+        return this.customer;
+    }
+
+    /**
+     * 
+     */
+    getItems(): Array<CartItem> {
+        return this.items;
+    }
+
+    /**
+     * 
+     */
+    getTotal(): number {
+        return this.total;
+    }
+
+    /**
+     * 
+     * @param customer 
+     */
+    setCustomer(customer: Partner): void {
+        this.customer = customer;
+    }
+
+    /**
+     * 
+     * @param items 
+     */
+    setItems(items: Array<CartItem>): void {
+        this.items = items;
+    }
+
+    /**
+     * 
+     * @param total 
+     */
+    setTotal(total: number): void {
+        this.total = total;
+    }
+
+    /**
+     * 
+     * @param index 
+     */
+    getItem(index: number): CartItem {
+        return this.getItems()[index];
+    }
+
+    /**
+     * 
+     */
+    size(): number {
+        return this.getItems().length;
+    }
+
+    /**
+     * 
+     * @param item 
+     */
+    add(product: ProductProduct, price: number, quantity: number): void {
+        let index = this.exists(product);
+        let item: CartItem = null;
+
+        if (index === -1) {
+            item = new CartItem();
+            
+            item.setProduct(product);
+            item.setPrice(price);
+
+            item.updateQuantity(quantity)
+
+            this.getItems().push(item);
+        } else {
+            let item = this.getItem(index);
+
+            item.setPrice(price);
+            item.setQuantity(item.getQuantity() + quantity);
+
+            item.computeSubtotal();
+        }
+
+        this.updateTotal();
+    }
+
+    /**
+     * 
+     * @param item 
+     */
+    remove(item: CartItem): void {
+        let index = this.exists(item.getProduct());
+
+        this.getItems().splice(index, 1);
+        this.updateTotal();
+    }
+
+    /**
+     * 
+     * @param items 
+     */
+    exists(product: ProductProduct): number {
+        for (let i = 0; i < this.size(); i++) {
+            if (product._id === this.getItem(i).getProduct()._id) {
+                return i;
+            }
+        }
+
+        return -1;
+    } 
+
+    /**
+     * 
+     */
+    updateTotal(): void {
+        let sum = 0;
+
+        for (let i = 0; i < this.size(); i++) {
+            sum = sum + this.getItem(i).getSubtotal();
+        }
+
+        this.setTotal(sum);
+    }
+
+    /**
+     * 
+     */
+    empty(): boolean {
+        return this.size() === 0;
+    }
+
+    /**
+     * 
+     */
+    isValid(): boolean {
+        return this.getCustomer() && !!this.size();
+    }
+}

+ 14 - 14
src/pages/order/order.html

@@ -2,7 +2,7 @@
     <ion-navbar>
         <ion-title>{{ title }}</ion-title>
         <ion-buttons end>
-            <button ion-button icon-only type="submit" form="details-form">
+            <button ion-button icon-only [disabled]="!getCart().isValid()" (click)="submit()">
                 <i class="fa fa-save fa-lg"></i>
             </button>
         </ion-buttons>
@@ -13,30 +13,31 @@
          <ion-item-divider>
             Cliente
         </ion-item-divider>
-        <ion-item>
-            <ion-input type="text" readonly></ion-input>
+        <ion-item (tap)="selectCustomer()">
+            <ion-input type="text" placeholder="Toque aquí para seleccionar" readonly value="{{ getCustomerName() }}"></ion-input>
         </ion-item>
         <ion-item-divider>
             Productos
         </ion-item-divider>
         <ion-list>
-            <ion-item *ngFor="let item of getCart()" >
-                <ion-avatar item-left>
-                    <img src="./assets/images/product.png" />
-			    </ion-avatar>
+            <ion-item *ngFor="let item of getItems()" >
+                <ion-thumbnail item-left>
+                    <img src="./assets/images/product.png" *ngIf="!item.hasImage()" />
+				    <img [src]="item.getImage() | sanitizeUrl" *ngIf="item.hasImage()" />
+			    </ion-thumbnail>
                 <div (doubleTap)="openOptions(item)">
-                    <h2>{{ item.name }}</h2>
+                    <h2>{{ item.getProductName() }}</h2>
                     <p>
                         <strong>Precio:</strong>
-                        {{ item.price }}
+                        {{ item.getPrice() }}
                     </p>
                     <p>
                         <strong>Cantidad:</strong>
-                        {{ item.qty }}
+                        {{ item.getQuantity() }}
                     </p>
                     <p>
                         <strong>Subtotal:</strong>
-                        {{ item.subtotal }}
+                        {{ item.getSubtotal() }}
                     </p>
                 </div>
                 <div item-right>
@@ -48,8 +49,7 @@
 				    </button>
 			    </div>
             </ion-item>
-            <ion-item class="empty-cart" *ngIf="emptyCart()">
-                <h2>Sin productos</h2>
+            <ion-item class="empty-cart" *ngIf="getCart().empty()">
                 <button ion-button icon-left (click)="selectProduct()">
                     <ion-icon name="add"></ion-icon>
                     Agregar un producto
@@ -60,7 +60,7 @@
             Total
         </ion-item-divider>
         <ion-item>
-            <ion-input type="number" value="{{ updateTotal() }}" readonly></ion-input>
+            <ion-input type="number" value="{{ getTotal() }}" readonly></ion-input>
         </ion-item>
     </form>
 

+ 1 - 6
src/pages/order/order.scss

@@ -64,6 +64,7 @@ page-order {
 
     ion-input > input {
         margin: 8px !important;
+        font-size: 10pt;
     }
 
     form > ion-item:nth-last-child(1) {
@@ -80,12 +81,6 @@ page-order {
         align-items: center;
     }
 
-    .empty-cart > div > div > ion-label > h2 {
-        font-size: 10pt;
-        color: $disabled-text;
-        padding-bottom: 25px;
-    }
-
     .empty-cart > div > div > ion-label > button {
         background: $eiru-color;
     }

+ 100 - 107
src/pages/order/order.ts

@@ -2,12 +2,17 @@ import {  Component } from '@angular/core';
 import { NavController, NavParams, ActionSheetController, AlertController } from 'ionic-angular';
 
 import { SaleOrder } from "../../odoo/models/sale.order";
+import { Partner } from "../../odoo/models/res.partner";
 import { ProductProduct } from "../../odoo/models/product.product";
-// import { SaleOrderLine } from "../../odoo/models/sale.order.line";
 import { BaseDetailsView } from "../../base/base-details-view";
 
-import { CustomerSelectionPage } from "./customer-selection/customer-selection";
-import { ProductSelectionPage } from "./product-selection/product-selection";
+import { CustomersPage } from "../customers/customers";
+import { VariantsPage } from "../variants/variants";
+
+import { Cart } from "./models/cart";
+import { CartItem } from "./models/cart-item"
+
+import { EventsManager } from "../../base/events/event-manager";
 
 @Component({
     selector: 'page-order',
@@ -15,153 +20,147 @@ import { ProductSelectionPage } from "./product-selection/product-selection";
 })
 export class OrderPage extends BaseDetailsView<SaleOrder> {
 
-    cart = [
-        // {
-        //     id: 1,
-        //     name: "Producto 001",
-        //     price: 2000,
-        //     qty: 1,
-        //     subtotal: 2000
-        // },
-        // {
-        //     id: 2,
-        //     name: "Producto 002",
-        //     price: 2000,
-        //     qty: 1,
-        //     subtotal: 2000
-        // },
-        // {
-        //     id: 3,
-        //     name: "Producto 003",
-        //     price: 2000,
-        //     qty: 1,
-        //     subtotal: 2000
-        // },
-        // {
-        //     id: 4,
-        //     name: "Producto 004",
-        //     price: 2000,
-        //     qty: 1,
-        //     subtotal: 2000
-        // },
-        // {
-        //     id: 5,
-        //     name: "Producto 005",
-        //     price: 2000,
-        //     qty: 1,
-        //     subtotal: 2000
-        // },
-        // {
-        //     id: 6,
-        //     name: "Producto 006",
-        //     price: 2000,
-        //     qty: 1,
-        //     subtotal: 2000
-        // },
-        // {
-        //     id: 7,
-        //     name: "Producto 006",
-        //     price: 2000,
-        //     qty: 1,
-        //     subtotal: 2000
-        // },
-        // {
-        //     id: 8,
-        //     name: "Producto 006",
-        //     price: 2000,
-        //     qty: 1,
-        //     subtotal: 2000
-        // }
-    ];
+    cart: Cart;
 
     constructor(
         public navCtrl: NavController,
         public navParams: NavParams,
         public actionSheetCtrl: ActionSheetController,
-        public alertCtrl: AlertController
+        public alertCtrl: AlertController,
     ) { 
         super(SaleOrder, navParams.data.item, navParams.data.kind);
 
         let titleKind = super.getKind() === "budget" ? "Presupuesto" : "Venta";
         super.setTitle(super.itemExists() ? "Editar " + titleKind : "Crear " + titleKind);
 
-        this.updateTotal();
+        this.cart = new Cart();
     }
 
     /**
      * 
      */
     ionViewDidLoad() {
-        console.log('ionViewDidLoad OrderPage');
+        EventsManager.subscribe("app:select", data => { 
+            if (data.type instanceof Partner) {
+                this.setCustomer(data.item);
+            }
+
+            if (data.type instanceof ProductProduct) {
+                this.addProduct(data.item);
+            }
+        });
     }
 
     /**
      * 
      */
-    selectCustomer(): void {
-        this.navCtrl.push(CustomerSelectionPage);
+    getCart(): Cart {
+        return this.cart;
     }
 
     /**
      * 
      */
-    getCart(): Array<any> {
-        return this.cart;
+    getCustomer(): Partner {
+        return this.getCart().getCustomer();
     }
 
     /**
      * 
-     * @param item 
-     * @param quantity 
      */
-    updateQuantity(item: any, quantity: number) {
-        if ((item.qty + quantity) <= 0) {
-            this.askIfRemove(item);
-            return;
-        }
+    getCustomerName(): string {
+        return this.getCustomer() ? this.getCustomer().name : "";
+    }
 
-        item.qty = item.qty + quantity;
-        item.subtotal = item.price * item.qty;
+    /**
+     * 
+     */
+    getItems(): Array<CartItem> {
+        return this.getCart().getItems();
+    }
 
-        this.updateTotal();
+    /**
+     * 
+     */
+    getTotal(): number {
+        return this.getCart().getTotal();
     }
 
     /**
      * 
-     * @param item 
-     * @param price 
+     * @param cart 
      */
-    updatePrice(item: any, price: number) {
-        item.price = price;
-        item.subtotal = item.price * item.qty;
+    setCart(cart: Cart): void {
+        this.cart = cart;
+    }
 
-        this.updateTotal();
+    /**
+     * 
+     * @param customer 
+     */
+    setCustomer(customer: Partner): void {
+        this.getCart().setCustomer(customer);
     }
 
     /**
      * 
      */
-    updateTotal(): number {
-        let total: number = 0;
+    selectCustomer(): void {
+        this.navCtrl.push(CustomersPage, { 
+            params: {
+                mode: "selection"
+            }
+        });
+    }
 
-        for (let i = 0; i < this.getCart().length; i++) {
-            total = total + this.getCart()[i].subtotal;
-        }
-        
-        return total;
+    /**
+     * 
+     */
+    selectProduct(): void {
+        this.navCtrl.push(VariantsPage, { 
+            params: {
+                mode: "selection"
+            }
+        });
     }
-    
+
     /**
      * 
+     * @param product 
      */
-    openBarcodeReader(): void {
+    addProduct(product: ProductProduct): void {
+        this.getCart().add(product, product.list_price, 1);
     }
 
     /**
      * 
+     * @param item 
+     * @param quantity 
      */
-    selectProduct(): void {
-        this.navCtrl.push(ProductSelectionPage);
+    updateQuantity(item: CartItem, quantity: number): void {
+        if ((item.getQuantity() + quantity) <= 0) {
+            this.askIfRemove(item);
+            return;
+        }
+
+        item.updateQuantity(quantity);
+        this.cart.updateTotal();
+    }
+
+    /**
+     * 
+     * @param item 
+     * @param price 
+     */
+    updatePrice(item: CartItem, price: number): void {
+        item.updatePrice(price);
+        this.cart.updateTotal();
+    }
+    
+    /**
+     * 
+     */
+    openBarcodeReader(): void {
     }
 
     /**
@@ -269,7 +268,7 @@ export class OrderPage extends BaseDetailsView<SaleOrder> {
                 {
                     text: "Aceptar",
                     handler: () => {
-                        this.remove(item);
+                        this.removeFromCart(item);
                     }
                 }
             ]
@@ -280,22 +279,16 @@ export class OrderPage extends BaseDetailsView<SaleOrder> {
      * 
      * @param item 
      */
-    remove(item: any): void {
-        console.log(item);
-    }
-
-    /**
-     * 
-     */
-    emptyCart(): boolean {
-        return this.getCart().length === 0;
+    removeFromCart(item: CartItem): void {
+        this.cart.remove(item);
     }
 
     /**
      * 
      * @param data 
      */
-    submit(data: any) { 
-        console.log(data);
+    submit() { 
+        console.log(this.getCart());
+        
     }
 }

+ 0 - 8
src/pages/order/product-selection/product-selection.html

@@ -1,8 +0,0 @@
-<ion-header>
-    <ion-navbar>
-        <ion-title>Seleccione un Producto</ion-title>
-    </ion-navbar>
-</ion-header>
-<ion-content>
-    <ion-searchbar placeholder="Buscar"></ion-searchbar>
-</ion-content>

+ 0 - 13
src/pages/order/product-selection/product-selection.ts

@@ -1,13 +0,0 @@
-import { Component } from "@angular/core";
-import { NavController } from "ionic-angular";
-
-@Component({
-    selector: 'product-selection',
-    templateUrl: 'product-selection.html'
-})
-export class ProductSelectionPage {
-
-    constructor(
-        public navCtrl: NavController
-    ) {}
-}

+ 17 - 2
src/pages/variants/variants.ts

@@ -14,11 +14,26 @@ export class VariantsPage extends BaseListView<ProductProduct> {
         public navCtrl: NavController,
         public navParams: NavParams
     ) { 
-        super(ProductProduct);
+        super(ProductProduct, navParams.data.params.mode);
     }
 
+    /**
+     * 
+     */
     ionViewDidLoad() {
-        console.log('ionViewDidLoad VariantsPage');
     }
 
+     /**
+     * 
+     * @param item
+     */
+    openOptions(item: ProductProduct): void {
+        super.selectItem(item);
+
+        if (super.getMode() === "list") {
+            // TODO
+        } else {
+            this.navCtrl.pop();
+        }    
+    }
 }