Browse Source

more view list implemented

robert2206 8 years ago
parent
commit
e5793be21c

+ 30 - 0
src/app/app.scss

@@ -14,3 +14,33 @@
 // To declare rules for a specific mode, create a child rule
 // for the .md, .ios, or .wp mode classes. The mode class is
 // automatically applied to the <body> element in the app.
+ion-fab > button {
+    background-color: #FBC02D !important;
+}
+
+p {
+    word-break: keep-all;
+    white-space: normal;
+}
+
+.selected-item {
+    border-right: 5px solid rgba(0, 0, 0, 0.4)
+}
+
+// body.menu-open .side-menu-open {
+//     transform: translate3d(275px, 0px, 0px) scale(.9) !important;
+//     opacity: 0.9;
+//     -webkit-filter: blur(2px);
+//     filter: blur(2px);
+//     transform-origin: center center;
+// }
+
+// body.menu-open ion-side-menus, body.menu-open ion-side-menu{
+//     background: #11c1f3
+// }
+
+// ion-side-menu.menu-left-axis ion-item.item a.item-content, ion-side-menu.menu-left-axis ion-item.item{
+//     background-color: transparent !important;
+//     border-color: transparent !important;
+//     color:#fff
+// }

+ 52 - 0
src/base/base-list-view.ts

@@ -5,12 +5,14 @@ import { PouchService } from "../services/pouch-service";
 export abstract class BaseListView<T> extends BaseView<T>{
 
     items: T[];
+    selectedIndex: number;
     filters: Array<[string, string, any]>;
 
     constructor(c: { new (): T; }, ...filters: Array<[string, string, any]>) {
         super(c, PouchService);
 
         this.items = [];
+        this.selectedIndex = -1;
         this.filters = filters;
 
         this.initialize();
@@ -97,6 +99,56 @@ export abstract class BaseListView<T> extends BaseView<T>{
         this.applyFilter(this.getItems());
     }
 
+    /**
+     * 
+     */
+    getSelectedIndex(): number {
+        return this.selectedIndex;
+    }
+
+    /**
+     * 
+     * @param index 
+     */
+    setSelectedIndex(selectedIndex: number): void {
+        this.selectedIndex = selectedIndex;
+    }
+
+    /**
+     * 
+     * @param item 
+     */
+    indexOf(item: T): number {
+        return this.getItems().indexOf(item);
+    }
+
+    /**
+     * 
+     */
+    getSelectedItem(): T {
+        if (this.getSelectedIndex() === -1) {
+            return null;
+        }
+
+        return this.getItems()[this.getSelectedIndex()];
+    }
+
+    /**
+     * 
+     * @param item 
+     */
+    setSelectedItem(item: T): void {
+        let index = this.indexOf(item);
+        this.setSelectedIndex(index);
+    }
+
+    /**
+     * 
+     */
+    deselectItem(): void {
+        this.setSelectedIndex(-1);
+    }
+
     /**
      * 
      */

+ 7 - 10
src/pages/customers/customers.html

@@ -1,20 +1,14 @@
 <ion-header>
-
 	<ion-navbar>
 		<button ion-button menuToggle>
             <ion-icon name="menu"></ion-icon>
         </button>
-		
     	<ion-title>Clientes</ion-title>
   	</ion-navbar>
-
 </ion-header>
-
 <ion-content>
-	<ion-list [virtualScroll]="getItems()" approxItemHeight="35px">
-
-		<ion-item *virtualItem="let item" (doubleTap)="test()">
-
+	<ion-list [virtualScroll]="getItems()" approxItemHeight="105px">
+		<ion-item *virtualItem="let item" (doubleTap)="openOptions(item)">
 			<ion-thumbnail item-left>
 				<img src="./assets/images/customer.png" *ngIf="!item.image_medium"/>
 				<img [src]="item.image_medium | sanitizeUrl" *ngIf="item.image_medium"/>
@@ -33,8 +27,11 @@
 				<strong>Email:</strong>
 				{{ item.email || "n/a" }}
 			</p>
-			
 		</ion-item>
-
 	</ion-list>
+	<ion-fab right bottom>
+        <button ion-fab>
+            <ion-icon name="add"></ion-icon>
+        </button>
+    </ion-fab>
 </ion-content>

+ 56 - 4
src/pages/customers/customers.ts

@@ -1,5 +1,5 @@
 import { Component } from "@angular/core";
-import { NavController, NavParams } from "ionic-angular";
+import { NavController, NavParams, ActionSheetController } from "ionic-angular";
 
 import { BaseListView } from "../../base/base-list-view";
 import { Partner } from "../../odoo/models/res.partner";
@@ -12,7 +12,8 @@ export class CustomersPage extends BaseListView<Partner> {
 
     constructor(
         public navCtrl: NavController,
-        public navParams: NavParams
+        public navParams: NavParams,
+        public actionSheetCtrl: ActionSheetController 
     ) {
         super(Partner, ["customer", "=", true]);
      }
@@ -21,7 +22,58 @@ export class CustomersPage extends BaseListView<Partner> {
         console.log('ionViewDidLoad CustomersPage');
     }
 
-    test(): void {
-        console.log("hbasbjas");
+    /**
+     * 
+     * @param item
+     */
+    openOptions(item: Partner): void {
+        this.setSelectedItem(item);
+
+        console.log(this.getSelectedIndex());
+        console.log(this.getSelectedItem());
+        
+        
+        this.actionSheetCtrl.create({
+            title: "Opciones",
+            buttons: [
+                {
+                    text: "Abrir",
+                    icon: "open",
+                    handler: () => {
+
+                    }
+                },
+                {
+                    text: "Ir a ubicación",
+                    icon: "navigate",
+                    handler: () => {
+
+                    }
+                },
+                {
+                    text: "Llamar",
+                    icon: "call",
+                    handler: () => {
+
+                    }
+                },
+                {
+                    text: "Eliminar",
+                    icon: "close",
+                    role: "destructive",
+                    handler: () => {
+
+                    }
+                },
+                {
+                    text: "Cancel",
+                    role: "cancel",
+                    handler: () => {
+                        console.log("Canceled");
+                        
+                    }
+                },
+            ]
+        }).present();
     }
 }

+ 5 - 0
src/pages/leads/leads.html

@@ -29,4 +29,9 @@
             </p>
 		</ion-item>
 	</ion-list>
+    <ion-fab right bottom>
+        <button ion-fab>
+            <ion-icon name="add"></ion-icon>
+        </button>
+    </ion-fab>
 </ion-content>

+ 6 - 1
src/pages/orders/orders.html

@@ -7,7 +7,7 @@
     </ion-navbar>
 </ion-header>
 <ion-content>
-    <ion-list [virtualScroll]="getItems()" approxItemHeight="35px">
+    <ion-list [virtualScroll]="getItems()" approxItemHeight="141px">
 		<ion-item *virtualItem="let item">
 			<h2>{{ item.name }}</h2>
             <p>
@@ -32,4 +32,9 @@
             </p>
 		</ion-item>
 	</ion-list>
+    <ion-fab right bottom>
+        <button ion-fab>
+            <ion-icon name="add"></ion-icon>
+        </button>
+    </ion-fab>
 </ion-content>

+ 6 - 1
src/pages/phonecalls/phonecalls.html

@@ -7,7 +7,7 @@
     </ion-navbar>
 </ion-header>
 <ion-content>
-  <ion-list [virtualScroll]="getItems()" approxItemHeight="35px">
+  <ion-list [virtualScroll]="getItems()" approxItemHeight="215px">
 		<ion-item *virtualItem="let item">
 			<h2>{{ item.date }}</h2>
             <p>{{ item.name }}</p>
@@ -21,4 +21,9 @@
             </p>
 		</ion-item>
 	</ion-list>
+    <ion-fab right bottom>
+        <button ion-fab>
+            <ion-icon name="add"></ion-icon>
+        </button>
+    </ion-fab>
 </ion-content>

+ 6 - 8
src/pages/products/products.html

@@ -1,25 +1,19 @@
 <ion-header>
-
     <ion-navbar>
         <button ion-button menuToggle>
             <ion-icon name="menu"></ion-icon>
         </button>
-
         <ion-title>Productos</ion-title>
     </ion-navbar>
-
 </ion-header>
 
 <ion-content>
-    <ion-list [virtualScroll]="getItems()" approxItemHeight="35px">
-
+    <ion-list [virtualScroll]="getItems()" approxItemHeight="97px">
 		<ion-item *virtualItem="let item">
-
 			<ion-thumbnail item-left>
                 <img src="./assets/images/product.png" *ngIf="!item.image_medium"/>
 				<img [src]="item.image_medium | sanitizeUrl" *ngIf="item.image_medium"/>
 			</ion-thumbnail>
-
 			<h2>{{ item.name }}</h2>
 			<p>
 				<strong>Precio:</strong>
@@ -30,6 +24,10 @@
 				{{ item.qty_available }}
 			</p>
 		</ion-item>
-
 	</ion-list>
+	<ion-fab right bottom>
+        <button ion-fab>
+            <ion-icon name="add"></ion-icon>
+        </button>
+    </ion-fab>
 </ion-content>

+ 1 - 1
src/pages/tools/tools.ts

@@ -56,7 +56,7 @@ export class ToolsPage {
      *
      */
     syncData(): void {
-        let numberOfModels = getMetadataStorage().models.length;
+        let numberOfModels = getMetadataStorage().models.length - 1;
         let numberOfUpdated = 0;
 
         let loader = this.loadingCtrl.create({

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

@@ -13,7 +13,7 @@
 
 
 <ion-content>
-    <ion-list [virtualScroll]="getItems()" approxItemHeight="35px">
+    <ion-list [virtualScroll]="getItems()" approxItemHeight="140px">
 
 		<ion-item *virtualItem="let item">
 

+ 14 - 1
src/services/pouch-service.ts

@@ -1,5 +1,6 @@
 import { Injectable } from "@angular/core";
 import { Observable } from "rxjs/Observable";
+import { Observer } from "rxjs/Observer";
 import PouchDB from "pouchdb";
 
 import * as PouchFind from "pouchdb-find";
@@ -61,7 +62,16 @@ export class PouchService {
      *
      */
     removeAll(type: string): Observable<any> {
-        return this.getAll(type).concatMap(result => Observable.from(result.docs)).concatMap(doc => this.remove(Object.assign(doc, { _deleted: true })));
+        // return this.getAll(type).concatMap(result => Observable.from(result.docs)).concatMap(doc => this.remove(Object.assign(doc, { _deleted: true })));
+        return this.getAll(type).concatMap(result => this.test(result.docs.shift()));
+    }
+
+
+    private test(doc: any): Observable<any> {
+        return Observable.create((o: Observer<any>) => {
+            o.next(doc);
+            o.complete();
+        });
     }
 
     /**
@@ -79,6 +89,9 @@ export class PouchService {
      *
      */
     getAll(odoo_model: string): Observable<any> {
+        console.log(odoo_model);
+        
+
         return Observable.fromPromise(this.pouchDB.find({
             selector: {
                 odoo_model: {

+ 3 - 2
src/services/sync-service.ts

@@ -30,7 +30,8 @@ export class SyncService {
      *
      */
     do(): Observable<any> {
-        return this.login().concat(this.removeAll()).concat(this.download());
+        // return this.login().concat(this.removeAll()).concat(this.download());
+        return this.removeAll();
     }
 
     /**
@@ -61,7 +62,7 @@ export class SyncService {
      *
      */
     protected removeAll(): Observable<any> {
-        return this.getModels().concatMap(item => this.pouch.removeAll(item.model.document));
+        return this.getModels().concatMap(item => this.pouch.removeAll(item.model.name));
     }
 
     /**

+ 0 - 4
src/theme/odoo.scss

@@ -1,4 +0,0 @@
-p {
-    word-break: keep-all;
-    white-space: normal;
-}

+ 1 - 2
src/theme/variables.scss

@@ -28,7 +28,7 @@ $colors: (
   secondary:  #32db64,
   danger:     #f53d3d,
   light:      #f4f4f4,
-  dark:       #222
+  dark:       #222,
 );
 
 
@@ -76,4 +76,3 @@ $colors: (
 
 @import "roboto";
 @import "noto-sans";
-@import "odoo";