Browse Source

some style added

robert2206 8 years ago
parent
commit
09e10fd82a

+ 24 - 2
src/app/app.component.ts

@@ -1,5 +1,5 @@
 import { Component, ViewChild } from '@angular/core';
-import { Nav, Platform, Loading, LoadingController } from 'ionic-angular';
+import { Nav, Platform, Loading, LoadingController, AlertController } from 'ionic-angular';
 import { StatusBar, Splashscreen } from 'ionic-native';
 
 import { LoginPage } from "../pages/login/login";
@@ -28,7 +28,8 @@ export class MyApp {
 
     constructor(
         public platform: Platform,
-        public loadingCtrl: LoadingController
+        public loadingCtrl: LoadingController,
+        public alertCtrl: AlertController
     ) {
         this.initializeApp();
 
@@ -145,6 +146,27 @@ export class MyApp {
                     this.loader.dismiss();
                 }
             });
+
+            EventsManager.subscribe("app:error", data => {
+                this.alertCtrl.create({
+                    title: "Error",
+                    message: "Ha ocurrido un error",
+                    buttons: [
+                        {
+                            text: "Ver detalles",
+                            handler: () => {
+                                this.alertCtrl.create({
+                                    title: "Detalles del error",
+                                    message: data
+                                }).present();
+                            }
+                        },
+                        {
+                            text: "Cerrar"
+                        }
+                    ]
+                }).present();
+            });
         });
     }
 

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

@@ -23,6 +23,7 @@ import { AboutPage } from "../pages/about/about";
 // Detail Pages
 import { CustomerPage } from "../pages/customer/customer";
 import { ProductPage } from "../pages/product/product";
+import { OrderPage } from "../pages/order/order";
 
 // Services
 import { OdooRPCService } from "angular2-odoo-jsonrpc";
@@ -55,6 +56,7 @@ import { DoubleTap } from "../directives/double-tap";
         // Detail Pages
         CustomerPage,
         ProductPage,
+        OrderPage,
         // Components
         OMasterHeader,
         OMasterFooter,
@@ -84,6 +86,7 @@ import { DoubleTap } from "../directives/double-tap";
         // Detail Pages
         CustomerPage,
         ProductPage,
+        OrderPage,
         // Other Pages
         ToolsPage,
         AboutPage,

+ 20 - 18
src/app/app.scss

@@ -1,21 +1,22 @@
-// http://ionicframework.com/docs/v2/theming/
-
-
-// App Global Sass
-// --------------------------------------------------
-// Put style rules here that you want to apply globally. These
-// styles are for the entire app and not just one component.
-// Additionally, this file can be also used as an entry point
-// to import other Sass files to be included in the output CSS.
-//
-// Shared Sass variables, which can be used to adjust Ionic's
-// default Sass variables, belong in "theme/variables.scss".
-//
-// 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.
+$eiru-color: #3f50b4;
+$button-color: #fbc02d;
+$header-font-color: #fff;
+$selected-color: rgba(211, 211, 211, 0.5);
+
+ion-toolbar > div, ion-navbar > div {
+    background: $eiru-color !important;
+}
+
+ion-label > ion-icon {
+    color: $eiru-color !important;
+}
+
+ion-title > div, ion-navbar > button, ion-buttons > button {
+    color: $header-font-color !important;
+}
+
 ion-fab > button {
-    background-color: #FBC02D !important;
+    background: $button-color !important;
 }
 
 p {
@@ -24,7 +25,8 @@ p {
 }
 
 .selected-item {
-    border-right: 5px solid rgba(0, 0, 0, 0.4)
+    background: $selected-color;
+    border-radius: 30px 0px;
 }
 
 // body.menu-open .side-menu-open {

+ 5 - 1
src/base/base-details-view.ts

@@ -50,7 +50,11 @@ export abstract class BaseDetailsView<T> extends BaseView<T> {
      * 
      */
     itemExists(): boolean {
-        return !!Object.keys(this.getItem()).length;
+        try {
+            return !!Object.keys(this.getItem()).length;   
+        } catch (error) {
+            return false;
+        }
     }
 
     /**

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

@@ -1,6 +1,6 @@
 <ion-header>
     <ion-navbar>
-        <ion-title>Cliente</ion-title>
+        <ion-title>{{ title }}</ion-title>
         <ion-buttons end>
             <button ion-button type="submit" form="details-form" [disabled]="customerForm.invalid">
                 GUARDAR

+ 1 - 0
src/pages/customer/customer.ts

@@ -19,6 +19,7 @@ export class CustomerPage extends BaseDetailsView<Partner>{
         public formBuilder: FormBuilder
     ) {
         super(Partner, navParams.data); 
+        super.setTitle(super.itemExists() ? "Editar Cliente" : "Nuevo Cliente");
 
         this.customerForm = this.formBuilder.group({
             name: ["", Validators.required],

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

@@ -8,7 +8,7 @@
 </ion-header>
 <ion-content>
 	<ion-list [virtualScroll]="getItems()" approxItemHeight="105px">
-		<ion-item *virtualItem="let item" (doubleTap)="openOptions(item)">
+		<ion-item *virtualItem="let item" (doubleTap)="openOptions(item)" [ngClass]="{ 'selected-item': item === getSelectedItem() }">
 			<ion-thumbnail item-left>
 				<img src="./assets/images/customer.png" *ngIf="!item.image_medium"/>
 				<img [src]="item.image_medium | sanitizeUrl" *ngIf="item.image_medium"/>

+ 3 - 3
src/pages/customers/customers.ts

@@ -15,7 +15,7 @@ export class CustomersPage extends BaseListView<Partner> {
         public navCtrl: NavController,
         public navParams: NavParams,
         public actionSheetCtrl: ActionSheetController,
-        public alertController: AlertController
+        public alertCtrl: AlertController
     ) {
         super(Partner, ["customer", "=", true]);
     }
@@ -74,7 +74,7 @@ export class CustomersPage extends BaseListView<Partner> {
                     }
                 },
                 {
-                    text: "Cancel",
+                    text: "Cancelar",
                     role: "cancel",
                     handler: () => {
                         super.setSelectedIndex(-1);
@@ -95,7 +95,7 @@ export class CustomersPage extends BaseListView<Partner> {
      * 
      */
     askIfDelete(): void {
-        this.alertController.create({
+        this.alertCtrl.create({
             title: "Confirmar",
             message: "Quieres eliminar este cliente?",
             buttons: [

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

@@ -0,0 +1,14 @@
+<ion-header>
+    <ion-navbar>
+        <ion-title>{{ title }}</ion-title>
+         <ion-buttons end>
+            <!--<button ion-button type="submit" form="details-form" [visible]="productForm.invalid">-->
+            <button ion-button type="submit" form="details-form">
+                GUARDAR
+            </button>
+        </ion-buttons>
+    </ion-navbar>
+</ion-header>
+<ion-content>
+
+</ion-content>

+ 3 - 0
src/pages/order/order.scss

@@ -0,0 +1,3 @@
+page-order {
+
+}

+ 30 - 0
src/pages/order/order.ts

@@ -0,0 +1,30 @@
+import { Component } from '@angular/core';
+import { NavController, NavParams } from 'ionic-angular';
+
+import { SaleOrder } from "../../odoo/models/sale.order";
+import { SaleOrderLine } from "../../odoo/models/sale.order.line";
+import { BaseDetailsView } from "../../base/base-details-view";
+
+@Component({
+    selector: 'page-order',
+    templateUrl: 'order.html'
+})
+export class OrderPage extends BaseDetailsView<SaleOrder> {
+
+    constructor(
+        public navCtrl: NavController,
+        public navParams: NavParams
+    ) { 
+        super(SaleOrder, navParams.data.item);
+        console.log(navParams.data);
+        
+        super.setTitle(super.itemExists() ? "Editar Presupuesto" : "Nuevo Presupuesto");
+    }
+
+    /**
+     * 
+     */
+    ionViewDidLoad() {
+        console.log('ionViewDidLoad OrderPage');
+    }
+}

+ 2 - 2
src/pages/orders/orders.html

@@ -8,7 +8,7 @@
 </ion-header>
 <ion-content>
     <ion-list [virtualScroll]="getItems()" approxItemHeight="141px">
-		<ion-item *virtualItem="let item">
+		<ion-item *virtualItem="let item" (doubleTap)="openOptions(item)">
 			<h2>{{ item.name }}</h2>
             <p>
                 <strong>Cantidad:</strong>
@@ -33,7 +33,7 @@
 		</ion-item>
 	</ion-list>
     <ion-fab right bottom>
-        <button ion-fab>
+        <button ion-fab (click)="goToDetails()">
             <ion-icon name="add"></ion-icon>
         </button>
     </ion-fab>

+ 85 - 4
src/pages/orders/orders.ts

@@ -1,8 +1,9 @@
 import { Component } from '@angular/core';
-import { NavController, NavParams } from 'ionic-angular';
+import { NavController, NavParams, ActionSheetController, AlertController } from 'ionic-angular';
 
 import { BaseListView } from "../../base/base-list-view";
 import { SaleOrder } from "../../odoo/models/sale.order";
+import { OrderPage } from "../order/order";
 
 @Component({
     selector: 'page-orders',
@@ -12,12 +13,14 @@ export class OrdersPage extends BaseListView<SaleOrder> {
 
     constructor(
         public navCtrl: NavController,
-        public navParams: NavParams
+        public navParams: NavParams,
+        public actionSheetCtrl: ActionSheetController,
+        public alertCtrl: AlertController
     ) { 
         super(SaleOrder);
 
-        this.setTitle(navParams.data.title);
-        this.setFilters(navParams.data.params.filters);
+        super.setTitle(navParams.data.title);
+        super.setFilters(navParams.data.params.filters);
     }
 
     /**
@@ -26,4 +29,82 @@ export class OrdersPage extends BaseListView<SaleOrder> {
     ionViewDidLoad() {
         console.log('ionViewDidLoad OrdersPage');
     }
+
+    /**
+     * 
+     */
+    ionViewDidEnter() {
+        super.setSelectedIndex(-1);
+    }
+
+    /**
+     * 
+     * @param item
+     */
+    openOptions(item: SaleOrder): void {
+        super.setSelectedItem(item);
+        
+        this.actionSheetCtrl.create({
+            title: "Opciones",
+            buttons: [
+                {
+                    text: "Abrir",
+                    icon: "open",
+                    handler: () => {
+                        this.goToDetails();
+                    }
+                },
+                {
+                    text: "Convertir a Venta",
+                    icon: "share-alt",
+                    handler: () => {
+                        console.log("convert");
+                    }
+                },
+                {
+                    text: "Eliminar",
+                    icon: "close",
+                    role: "destructive",
+                    handler: () => {
+                        this.askIfDelete();
+                    }
+                },
+                {
+                    text: "Cancel",
+                    role: "cancel",
+                    handler: () => {
+                        super.setSelectedIndex(-1);
+                    }
+                },
+            ]
+        }).present();
+    }
+
+    /**
+     * 
+     */
+    goToDetails(): void {
+        this.navCtrl.push(OrderPage, super.getSelectedItem());
+    }
+
+    /**
+     * 
+     */
+    askIfDelete(): void {
+        this.alertCtrl.create({
+            title: "Confirmar",
+            message: "Quieres eliminar este presupuesto?",
+            buttons: [
+                {
+                    text: "Cancelar"
+                },
+                {
+                    text: "Aceptar",
+                    handler: () => {
+                        super.performDelete();
+                    }
+                }
+            ]
+        }).present();
+    }
 }

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

@@ -1,6 +1,6 @@
 <ion-header>
     <ion-navbar>
-        <ion-title>Producto</ion-title>
+        <ion-title>{{ title }}</ion-title>
         <ion-buttons end>
             <button ion-button type="submit" form="details-form" [disabled]="productForm.invalid">
                 GUARDAR

+ 2 - 1
src/pages/product/product.ts

@@ -19,6 +19,7 @@ export class ProductPage extends BaseDetailsView<ProductTemplate>{
         public formBuilder: FormBuilder
     ) { 
         super(ProductTemplate, navParams.data);
+        super.setTitle(super.itemExists() ? "Editar Producto" : "Nuevo Producto");
 
         this.productForm = this.formBuilder.group({
             name: ["", Validators.required],
@@ -44,7 +45,7 @@ export class ProductPage extends BaseDetailsView<ProductTemplate>{
             return;
         }
 
-        super.setItem(Object.assign(this.getItem(), data));
+        // super.setItem(Object.assign(this.getItem(), data));
         super.performSave();
         this.navCtrl.pop();
     }

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

@@ -8,7 +8,7 @@
 </ion-header>
 <ion-content>
     <ion-list [virtualScroll]="getItems()" approxItemHeight="97px">
-		<ion-item *virtualItem="let item" (doubleTap)="openOptions(item)">
+		<ion-item *virtualItem="let item" (doubleTap)="openOptions(item)" [ngClass]="{ 'selected-item': item === getSelectedItem() }">
 			<ion-thumbnail item-left>
                 <img src="./assets/images/product.png" *ngIf="!item.image_medium"/>
 				<img [src]="item.image_medium | sanitizeUrl" *ngIf="item.image_medium"/>

+ 2 - 5
src/pages/products/products.ts

@@ -15,7 +15,7 @@ export class ProductsPage extends BaseListView<ProductTemplate> {
         public navCtrl: NavController,
         public navParams: NavParams,
         public actionSheetCtrl: ActionSheetController,
-        public alertController: AlertController
+        public alertCtrl: AlertController
     ) { 
         super(ProductTemplate);
     }
@@ -74,8 +74,6 @@ export class ProductsPage extends BaseListView<ProductTemplate> {
      * 
      */
     goToDetails(): void {
-        console.log("CLICK");
-        
         this.navCtrl.push(ProductPage, super.getSelectedItem());
     }
 
@@ -83,7 +81,7 @@ export class ProductsPage extends BaseListView<ProductTemplate> {
      * 
      */
     askIfDelete(): void {
-        this.alertController.create({
+        this.alertCtrl.create({
             title: "Confirmar",
             message: "Quieres eliminar este producto?",
             buttons: [
@@ -99,5 +97,4 @@ export class ProductsPage extends BaseListView<ProductTemplate> {
             ]
         }).present();
     }
-
 }

+ 0 - 62
src/theme/variables.scss

@@ -1,28 +1,7 @@
-// Ionic Variables and Theming. For more info, please see:
-// http://ionicframework.com/docs/v2/theming/
 $font-path: "../assets/fonts";
 
 @import "ionic.globals";
 
-
-// Shared Variables
-// --------------------------------------------------
-// To customize the look and feel of this app, you can override
-// the Sass variables found in Ionic's source scss files.
-// To view all the possible Ionic variables, see:
-// http://ionicframework.com/docs/v2/theming/overriding-ionic-variables/
-
-
-
-
-// Named Color Variables
-// --------------------------------------------------
-// Named colors makes it easy to reuse colors on various components.
-// It's highly recommended to change the default colors
-// to match your app's branding. Ionic uses a Sass map of
-// colors so you can add, rename and remove colors as needed.
-// The "primary" color is the only required color in the map.
-
 $colors: (
   primary:    #387ef5,
   secondary:  #32db64,
@@ -31,48 +10,7 @@ $colors: (
   dark:       #222,
 );
 
-
-// App iOS Variables
-// --------------------------------------------------
-// iOS only Sass variables can go here
-
-
-
-
-// App Material Design Variables
-// --------------------------------------------------
-// Material Design only Sass variables can go here
-
-
-
-
-// App Windows Variables
-// --------------------------------------------------
-// Windows only Sass variables can go here
-
-
-
-
-// App Theme
-// --------------------------------------------------
-// Ionic apps can have different themes applied, which can
-// then be future customized. This import comes last
-// so that the above variables are used and Ionic's
-// default are overridden.
-
 @import "ionic.theme.default";
-
-
-// Ionicons
-// --------------------------------------------------
-// The premium icon font for Ionic. For more info, please see:
-// http://ionicframework.com/docs/v2/ionicons/
-
 @import "ionic.ionicons";
-
-
-// Fonts
-// --------------------------------------------------
-
 @import "roboto";
 @import "noto-sans";