Parcourir la source

organize modules in folder by funcionality

robert2206 il y a 8 ans
Parent
commit
115b2ffe23

+ 2 - 1
www/index.html

@@ -26,7 +26,8 @@
     <script src="js/factories/utils.factory.js"></script>
     <script src="js/factories/storage.factory.js"></script>
     <script src="js/factories/odoo.factory.js"></script>
-    <script src="js/factories/sync.factory.js"></script>
+    <script src="js/factories/sale/sync.customer.factory.js"></script>
+    <script src="js/factories/sale/sync.lead.factory.js"></script>
     <!-- 3rd Party -->
     <script src="lib/angular-xmlrpc/xmlrpc.js"></script>
   </head>

+ 12 - 2
www/js/app.js

@@ -85,7 +85,7 @@ angular.module('odoo',['ionic', 'ngCordova', 'xml-rpc'])
             url: 'app/sales',
             views: {
                 'content': {
-                    templateUrl: 'templates/sales.html',
+                    templateUrl: 'templates/sale/sales.html',
                     controller: 'SaleController'
                 }
             }
@@ -95,12 +95,22 @@ angular.module('odoo',['ionic', 'ngCordova', 'xml-rpc'])
             url: 'app/customers',
             views: {
                 'content': {
-                    templateUrl: 'templates/customers.html',
+                    templateUrl: 'templates/sale/customers.html',
                     controller: 'CustomersController'
                 }
             }
         })
 
+        .state('app.leads', {
+            url: 'app/leads',
+            views: {
+                'content': {
+                    templateUrl: 'templates/sale/leads.html',
+                    controller: 'LeadsController'
+                }
+            }
+        })
+
         .state('configuration', {
             url: '/configuration',
             templateUrl: 'templates/configuration.html',

+ 3 - 3
www/js/controllers/customer.controller.js

@@ -7,7 +7,7 @@ angular.module('odoo')
     $ionicModal,
     $ionicActionSheet,
     $ionicPopup,
-    sync,
+    customers,
     odoo,
     storage,
     camera,
@@ -18,7 +18,7 @@ angular.module('odoo')
     $scope.customer = {};
     $scope.customers = [];
 
-    $ionicModal.fromTemplateUrl('templates/customer.html', {
+    $ionicModal.fromTemplateUrl('templates/sale/customer.html', {
         scope: $scope,
         animation: 'slide-in-up'
     }).then(function(modal) {
@@ -41,7 +41,7 @@ angular.module('odoo')
     $scope.fill = function () {
         $ionicLoading.show();
 
-        sync.syncCustomers(function (customers) {
+        customers.sync(function (customers) {
             console.log('Customers sync correctly and receive ' + customers.length + ' items');
 
             $scope.getCustomers(function () {

+ 11 - 2
www/js/controllers/lead.controller.js

@@ -1,5 +1,14 @@
-angular.module('odoo.lead.controller', [])
+angular.module('odoo')
 
-.controller('LeadController', function () {
+.controller('LeadsController', function ($scope, leads) {
+    
+    leads.read(function (leads) {
+        console.log(leads);
+    }, function (error) {
+        console.log(error);
+    });
 
+    $scope.show = function () {
+
+    }
 });

+ 2 - 2
www/js/factories/sync.factory.js → www/js/factories/sale/sync.customer.factory.js

@@ -1,8 +1,8 @@
 angular.module('odoo')
 
-.factory('sync', function (storage, odoo, async) {
+.factory('customers', function (storage, odoo, async) {
     return {
-        syncCustomers: function (success, error) {
+        sync: function (success, error) {
             // Get current user saved on mobile
             storage.get('user', function (users) {
                 if (users.length == 1) {

+ 21 - 0
www/js/factories/sale/sync.lead.factory.js

@@ -0,0 +1,21 @@
+angular.module('odoo')
+
+.factory('leads', function (config, odoo) {
+    // Read leads from server
+    var readLeads = function (success, error) {
+        config(function (users) {
+            if (users.length)
+            odoo.read('crm.lead', [['active', '=', true]], function (leads) {
+                success(leads);
+            }, function (err) {
+                error(err);
+            });
+        }, function (err) {
+            error(err);
+        });
+    }
+
+    return {
+        read: readLeads
+    }
+});

+ 10 - 0
www/js/factories/utils.factory.js

@@ -1,5 +1,15 @@
 angular.module('odoo')
 
+.factory('config', function (storage) {
+    return function (success, error) {
+        storage.get('user', function (users) {
+            success(users);
+        }, function (err) {
+            error(err);
+        });
+    };
+})
+
 .factory('async', function () {
     return {
         loop: function (iterations, func, callback) {

+ 0 - 0
www/templates/customer.html → www/templates/sale/customer.html


+ 4 - 1
www/templates/customers.html → www/templates/sale/customers.html

@@ -1,8 +1,11 @@
 <ion-view title="Clientes">
+
     <ion-nav-buttons side="right">
         <button class="button button-clear ion-plus-round" style="font-size:22px !important;" ng-click="show()"></i></button>
     </ion-nav-buttons>
+
     <ion-content>
+
         <ion-refresher pulling-text="Actualizar" on-refresh="fill()"></ion-refresher>
         <ion-list>
           <ion-item class="item-avatar" on-hold="openOptions($index)" ng-repeat="c in customers">
@@ -14,6 +17,6 @@
               <span class="badge badge-positive">{{ c.opportunity_count || 0 }} </span>
           </ion-item>
         </ion-list>
-
     </ion-content>
+    
 </ion-view>

+ 10 - 0
www/templates/sale/leads.html

@@ -0,0 +1,10 @@
+<ion-view title="Iniciativas">
+
+    <ion-nav-buttons side="right">
+        <button class="button button-clear ion-plus-round" style="font-size:22px !important;" ng-click="show()"></i></button>
+    </ion-nav-buttons>
+
+    <ion-content>
+        
+    </ion-content>
+</ion-view>

+ 1 - 1
www/templates/sales.html → www/templates/sale/sales.html

@@ -2,7 +2,7 @@
     <ion-content>
         <ion-list>
             <ion-item class="item-icon-left" ui-sref="app.customers"><i class="ion-person-stalker" style="font-size:22px"></i> Clientes</ion-item>
-            <ion-item class="item-icon-left"><i class="ion-happy" style="font-size:22px"></i> Iniciativas</ion-item>
+            <ion-item class="item-icon-left" ui-sref="app.leads"><i class="ion-happy" style="font-size:22px"></i> Iniciativas</ion-item>
             <ion-item class="item-icon-left"><i class="ion-star" style="font-size:22px"></i> Oportunidades</ion-item>
         </ion-list>
     </ion-content>