Commit 8272c62be876244bb6f3950840801b6702165bc8

Authored by Marcelo Puebla
1 parent e99531c001
Exists in master

Codigo indentado.

Showing 1 changed file with 46 additions and 46 deletions   Show diff stats
src/js/controller.js
1 1 angular.module('focaModalPrecioCondicion')
2   - .controller('focaModalPrecioCondicionController',
  2 + .controller('focaModalPrecioCondicionController',
3 3 [
4 4 '$timeout',
5 5 '$filter',
... ... @@ -9,18 +9,18 @@ angular.module('focaModalPrecioCondicion')
9 9 'focaModalService',
10 10 'focaModalPrecioCondicionService',
11 11 'idListaPrecio',
12   - function(
  12 + function (
13 13 $timeout, $filter, $scope, $uibModal, $uibModalInstance,
14 14 focaModalService, focaModalPrecioCondicionService, idListaPrecio
15 15 ) {
16   -
  16 +
17 17 $scope.filters = '';
18 18 $scope.ingreso = false;
19 19 $scope.plazosNuevos = [];
20 20 $scope.plazoACargar =
21   - {
22   - item: 1
23   - };
  21 + {
  22 + item: 1
  23 + };
24 24 // pagination
25 25 $scope.numPerPage = 10;
26 26 $scope.currentPage = 1;
... ... @@ -30,13 +30,13 @@ angular.module('focaModalPrecioCondicion')
30 30  
31 31 var funcionGet = idListaPrecio ? 'getPreciosCondicionesByIdListaPrecio' :
32 32 'getPreciosCondiciones';
33   -
  33 +
34 34 focaModalPrecioCondicionService
35   - [funcionGet](idListaPrecio)
36   - .then(function(res) {
  35 + [funcionGet](idListaPrecio)
  36 + .then(function (res) {
37 37 for (var i = 0; i < res.data.length; i++) {
38 38 var plazosTemp = '';
39   - res.data[i].plazoPago.sort(function(a, b) {
  39 + res.data[i].plazoPago.sort(function (a, b) {
40 40 return a.dias - b.dias;
41 41 });
42 42 for (var j = 0; j < res.data[i].plazoPago.length; j++) {
... ... @@ -53,57 +53,57 @@ angular.module(&#39;focaModalPrecioCondicion&#39;)
53 53 });
54 54  
55 55 //METODOS
56   - $scope.agregarPlazo = function(key) {
57   - if(key === 13) {
58   - if(!$scope.plazoACargar.dias) {
  56 + $scope.agregarPlazo = function (key) {
  57 + if (key === 13) {
  58 + if (!$scope.plazoACargar.dias) {
59 59 focaModalService.alert('Ingrese cantidad de días');
60 60 return;
61 61 }
62   - var tieneEseDia = $scope.plazosNuevos.filter(function(a) {
  62 + var tieneEseDia = $scope.plazosNuevos.filter(function (a) {
63 63 return a.dias === $scope.plazoACargar.dias;
64 64 });
65   - if(tieneEseDia.length > 0) {
  65 + if (tieneEseDia.length > 0) {
66 66 focaModalService.alert('Ya ha ingresado un plazo con esos días');
67 67 return;
68 68 }
69 69 $scope.plazosNuevos.push($scope.plazoACargar);
70 70 $scope.plazoACargar =
71   - {
72   - item: $scope.plazosNuevos.length + 1
73   - };
  71 + {
  72 + item: $scope.plazosNuevos.length + 1
  73 + };
74 74 }
75 75 };
76 76  
77   - $scope.volver = function() {
  77 + $scope.volver = function () {
78 78 $scope.ingreso = false;
79 79 $scope.plazosNuevos = [];
80 80 $scope.plazoACargar =
81   - {
82   - item: $scope.plazosNuevos.length + 1
83   - };
  81 + {
  82 + item: $scope.plazosNuevos.length + 1
  83 + };
84 84 };
85   -
86   - $scope.quitarPlazo = function(key) {
  85 +
  86 + $scope.quitarPlazo = function (key) {
87 87 $scope.plazosNuevos.splice(key, 1);
88 88 $scope.plazoACargar =
89   - {
90   - item: $scope.plazosNuevos.length + 1
91   - };
  89 + {
  90 + item: $scope.plazosNuevos.length + 1
  91 + };
92 92 };
93 93  
94   - $scope.search = function(pressed) {
  94 + $scope.search = function (pressed) {
95 95 $scope.filteredPrecioCondicion = $filter('filter')(
96   - $scope.precioCondicion,
97   - {$: $scope.filters}
  96 + $scope.precioCondicion,
  97 + { $: $scope.filters }
98 98 );
99 99  
100   - if(pressed) {
101   - if($scope.filteredPrecioCondicion.length === 0) {
102   - $timeout(function() {
  100 + if (pressed) {
  101 + if ($scope.filteredPrecioCondicion.length === 0) {
  102 + $timeout(function () {
103 103 angular.element('#search')[0].focus();
104 104 $scope.filters = '';
105 105 });
106   - }else {
  106 + } else {
107 107 primera();
108 108 }
109 109 }
... ... @@ -115,12 +115,12 @@ angular.module(&#39;focaModalPrecioCondicion&#39;)
115 115 $scope.resetPage();
116 116 };
117 117  
118   - $scope.resetPage = function() {
  118 + $scope.resetPage = function () {
119 119 $scope.currentPage = 1;
120 120 $scope.selectPage(1);
121 121 };
122 122  
123   - $scope.selectPage = function(page) {
  123 + $scope.selectPage = function (page) {
124 124 var start = (page - 1) * $scope.numPerPage;
125 125 var end = start + $scope.numPerPage;
126 126 $scope.paginas = [];
... ... @@ -130,27 +130,27 @@ angular.module(&#39;focaModalPrecioCondicion&#39;)
130 130 $scope.currentPage = page;
131 131 };
132 132  
133   - $scope.select = function(precioCondicion) {
  133 + $scope.select = function (precioCondicion) {
134 134 $uibModalInstance.close(precioCondicion);
135 135 };
136 136  
137   - $scope.cancel = function() {
  137 + $scope.cancel = function () {
138 138 $uibModalInstance.dismiss('cancel');
139 139 };
140 140  
141   - $scope.busquedaDown = function(key) {
  141 + $scope.busquedaDown = function (key) {
142 142 if (key === 40) {
143 143 primera(key);
144 144 }
145 145 };
146 146  
147   - $scope.busquedaPress = function(key) {
  147 + $scope.busquedaPress = function (key) {
148 148 if (key === 13) {
149 149 $scope.search(true);
150 150 }
151 151 };
152 152  
153   - $scope.itemProducto = function(key) {
  153 + $scope.itemProducto = function (key) {
154 154 if (key === 38) {
155 155 anterior(key);
156 156 }
... ... @@ -167,8 +167,8 @@ angular.module(&#39;focaModalPrecioCondicion&#39;)
167 167 avanzarPagina();
168 168 }
169 169 };
170   -
171   - $scope.verListaPrecio = function(id) {
  170 +
  171 + $scope.verListaPrecio = function (id) {
172 172 $uibModal.open(
173 173 {
174 174 ariaLabelledBy: 'Busqueda de Productos',
... ... @@ -192,7 +192,7 @@ angular.module(&#39;focaModalPrecioCondicion&#39;)
192 192 paginas.push(paginaActual);
193 193  
194 194 if (paginaActual - 1 > 1) {
195   -
  195 +
196 196 paginas.unshift(paginaActual - 1);
197 197 if (paginaActual - 2 > 1) {
198 198 paginas.unshift(paginaActual - 2);
... ... @@ -231,10 +231,10 @@ angular.module(&#39;focaModalPrecioCondicion&#39;)
231 231  
232 232 function siguiente() {
233 233 if ($scope.selectedPrecioCondicion <
234   - $scope.currentPagePrecioCondicion.length ) {
  234 + $scope.currentPagePrecioCondicion.length) {
235 235 $scope.selectedPrecioCondicion++;
236 236 } else {
237   - avanzarPagina();
  237 + avanzarPagina();
238 238 }
239 239 }
240 240