Commit ad4591d555700d964635ba9e022d43d4ac651d1d

Authored by Eric Fernandez
Exists in master

Merge branch 'develop' into 'master'

Develop

See merge request !17
spec/controllerSpec.js
1 describe('Controladores abm precios condiciones', function() { 1 describe('Controladores abm precios condiciones', function() {
2 2
3 var $controller; 3 var $controller;
4 var timeout; 4 var timeout;
5 5
6 beforeEach(function() { 6 beforeEach(function() {
7 module('focaAbmPreciosCondiciones'); 7 module('focaAbmPreciosCondiciones');
8 inject(function(_$controller_) { 8 inject(function(_$controller_) {
9 $controller = _$controller_; 9 $controller = _$controller_;
10 }); 10 });
11 }); 11 });
12 12
13 beforeEach(function() { 13 beforeEach(function() {
14 inject(function($timeout) { 14 inject(function($timeout) {
15 timeout = $timeout; 15 timeout = $timeout;
16 }); 16 });
17 }); 17 });
18 18
19 describe('Controlador focaAbmPreciosCondiciones', function() { 19 describe('Controlador focaAbmPreciosCondiciones', function() {
20 20
21 it('Existe el controlador', function() { 21 it('Existe el controlador', function() {
22 //act 22 //act
23 var controlador = $controller('focaAbmPreciosCondicionesController', { 23 var controlador = $controller('focaAbmPreciosCondicionesController', {
24 $scope: {}, 24 $scope: {},
25 focaAbmPreciosCondicionesService: {}, 25 focaAbmPreciosCondicionesService: {},
26 $location: {}, 26 $location: {},
27 focaModalService: {}, 27 focaModalService: {},
28 $localStorage: {},
28 focaBotoneraLateralService: {}, 29 focaBotoneraLateralService: {},
29 $timeout: timeout 30 $timeout: timeout
30 }); 31 });
31 32
32 //assert 33 //assert
33 expect(typeof controlador).toEqual('object'); 34 expect(typeof controlador).toEqual('object');
34 }); 35 });
35 36
36 it('$scope.editar lleva a la ruta correcta', function() { 37 it('$scope.editar lleva a la ruta correcta', function() {
37 inject(function($location) { 38 inject(function($location) {
38 //arrange 39 //arrange
39 var scope = {}; 40 var scope = {};
40 var paramFake = 1; 41 var paramFake = 1;
41 $controller('focaAbmPreciosCondicionesController', { 42 $controller('focaAbmPreciosCondicionesController', {
42 $scope: scope, 43 $scope: scope,
43 focaAbmPreciosCondicionesService: {}, 44 focaAbmPreciosCondicionesService: {},
44 $location: $location, 45 $location: $location,
46 $localStorage: {},
45 focaModalService: {}, 47 focaModalService: {},
46 focaBotoneraLateralService: {}, 48 focaBotoneraLateralService: {},
47 $timeout: timeout 49 $timeout: timeout
48 }); 50 });
49 51
50 52
51 //act 53 //act
52 scope.editar(paramFake); 54 scope.editar(paramFake);
53 55
54 //assert 56 //assert
55 expect($location.url()).toEqual('/precio-condicion/' + paramFake); 57 expect($location.url()).toEqual('/precio-condicion/' + paramFake);
56 }); 58 });
57 }); 59 });
58 60
59 it('$scope.solicitarConfirmacion levanta modal confirm', function() { 61 it('$scope.solicitarConfirmacion levanta modal confirm', function() {
60 //arrange 62 //arrange
61 var scope = {}; 63 var scope = {};
62 var paramFake = 1; 64 var paramFake = 1;
63 var focaModalService = { 65 var focaModalService = {
64 confirm: function() { } 66 confirm: function() { }
65 }; 67 };
66 $controller('focaAbmPreciosCondicionesController', { 68 $controller('focaAbmPreciosCondicionesController', {
67 $scope: scope, 69 $scope: scope,
68 focaAbmPreciosCondicionesService: {}, 70 focaAbmPreciosCondicionesService: {},
69 $location: {}, 71 $location: {},
72 $localStorage: {},
70 focaModalService: focaModalService, 73 focaModalService: focaModalService,
71 focaBotoneraLateralService: {}, 74 focaBotoneraLateralService: {},
72 $timeout: timeout 75 $timeout: timeout
73 }); 76 });
74 77
75 //act 78 //act
76 spyOn(focaModalService, 'confirm').and.returnValue({ then: function() { }}); 79 spyOn(focaModalService, 'confirm').and.returnValue({ then: function() { }});
77 scope.solicitarConfirmacion(paramFake); 80 scope.solicitarConfirmacion(paramFake);
78 81
79 //assert 82 //assert
80 expect(focaModalService.confirm).toHaveBeenCalled(); 83 expect(focaModalService.confirm).toHaveBeenCalled();
81 }); 84 });
82 85
83 it('$scope.solicitarConfirmacion elimina al confirmar ok', function(done) { 86 it('$scope.solicitarConfirmacion elimina al confirmar ok', function(done) {
84 //arrange 87 //arrange
85 var scope = {}; 88 var scope = {};
86 var paramFake = 1; 89 var paramFake = 1;
87 var focaModalService = { 90 var focaModalService = {
88 confirm: function() { } 91 confirm: function() { }
89 }; 92 };
90 var focaAbmPreciosCondicionesService = { 93 var focaAbmPreciosCondicionesService = {
91 borrarPrecioCondicion: function() { } 94 borrarPrecioCondicion: function() { }
92 }; 95 };
93 $controller('focaAbmPreciosCondicionesController', { 96 $controller('focaAbmPreciosCondicionesController', {
94 $scope: scope, 97 $scope: scope,
95 focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, 98 focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService,
96 $location: {}, 99 $location: {},
100 $localStorage: {},
97 focaModalService: focaModalService, 101 focaModalService: focaModalService,
98 focaBotoneraLateralService: {}, 102 focaBotoneraLateralService: {},
99 $timeout: timeout 103 $timeout: timeout
100 }); 104 });
101 var promesaConfirm = Promise.resolve(true); 105 var promesaConfirm = Promise.resolve(true);
102 scope.preciosCondiciones = []; 106 scope.preciosCondiciones = [];
103 107
104 //act 108 //act
105 spyOn(focaModalService, 'confirm').and.returnValue(promesaConfirm); 109 spyOn(focaModalService, 'confirm').and.returnValue(promesaConfirm);
106 spyOn(focaAbmPreciosCondicionesService, 'borrarPrecioCondicion'); 110 spyOn(focaAbmPreciosCondicionesService, 'borrarPrecioCondicion');
107 scope.solicitarConfirmacion(paramFake); 111 scope.solicitarConfirmacion(paramFake);
108 112
109 //assert 113 //assert
110 promesaConfirm.then(function() { 114 promesaConfirm.then(function() {
111 expect(focaAbmPreciosCondicionesService.borrarPrecioCondicion).toHaveBeenCalled(); 115 expect(focaAbmPreciosCondicionesService.borrarPrecioCondicion).toHaveBeenCalled();
112 done(); 116 done();
113 }); 117 });
114 }); 118 });
115 119
116 it('$scope.buscar llama a obtenerPreciosCondiciones', function() { 120 it('$scope.buscar llama a obtenerPreciosCondiciones', function() {
117 //arrange 121 //arrange
118 var scope = {}; 122 var scope = {};
119 var focaAbmPreciosCondicionesService = { 123 var focaAbmPreciosCondicionesService = {
120 obtenerPreciosCondiciones: function() { } 124 obtenerPreciosCondiciones: function() { }
121 }; 125 };
122 $controller('focaAbmPreciosCondicionesController', { 126 $controller('focaAbmPreciosCondicionesController', {
123 $scope: scope, 127 $scope: scope,
124 focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, 128 focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService,
125 $location: {}, 129 $location: {},
130 $localStorage: {},
126 focaModalService: {}, 131 focaModalService: {},
127 focaBotoneraLateralService: {}, 132 focaBotoneraLateralService: {},
128 $timeout: timeout 133 $timeout: timeout
129 }); 134 });
130 135
131 //act 136 //act
132 spyOn(focaAbmPreciosCondicionesService, 'obtenerPreciosCondiciones') 137 spyOn(focaAbmPreciosCondicionesService, 'obtenerPreciosCondiciones')
133 .and.returnValue({ then: function() { }}); 138 .and.returnValue({ then: function() { }});
134 scope.buscar(13); 139 scope.buscar(13);
135 140
136 //assert 141 //assert
137 expect(focaAbmPreciosCondicionesService.obtenerPreciosCondiciones).toHaveBeenCalled(); 142 expect(focaAbmPreciosCondicionesService.obtenerPreciosCondiciones).toHaveBeenCalled();
138 }); 143 });
139 }); 144 });
140 145
141 describe('Controlador focaAbmPrecioCondicionController', function() { 146 describe('Controlador focaAbmPrecioCondicionController', function() {
142 147
143 it('Existe el controlador focaAbmPrecioCondicionController', function() { 148 it('Existe el controlador focaAbmPrecioCondicionController', function() {
144 //act 149 //act
145 var controlador = $controller('focaAbmPrecioCondicionController', { 150 var controlador = $controller('focaAbmPrecioCondicionController', {
146 $scope: {}, 151 $scope: {
152 $watch: function(){}
153 },
147 focaAbmPreciosCondicionesService: { 154 focaAbmPreciosCondicionesService: {
148 obtenerPrecioCondicion: function() { 155 obtenerPrecioCondicion: function() {
149 return { 156 return {
150 then: function() { } 157 then: function() { }
151 }; 158 };
152 } 159 }
153 }, 160 },
154 focaBotoneraLateralService: {}, 161 focaBotoneraLateralService: {},
155 $routeParams: {}, 162 $routeParams: {},
156 $location: {}, 163 $location: {},
157 focaModalService: {}, 164 focaModalService: {},
158 $timeout: timeout, 165 $timeout: timeout,
159 $uibModal: {}, 166 $uibModal: {},
167 $localStorage: {},
160 $window: {} 168 $window: {}
161 }); 169 });
162 170
163 //assert 171 //assert
164 expect(typeof controlador).toEqual('object'); 172 expect(typeof controlador).toEqual('object');
165 }); 173 });
166 174
167 it('La funcion $scope.cancelar lleva a la ruta correcta', function() { 175 it('La funcion $scope.cancelar lleva a la ruta correcta', function() {
168 inject(function($location) { 176 inject(function($location) {
169 //arrange 177 //arrange
170 var scope = {}; 178 var scope = {
179 $watch: function() {},
180 salir: function() {},
181 formPrecioCondicion: ''
182 };
171 $controller('focaAbmPrecioCondicionController', { 183 $controller('focaAbmPrecioCondicionController', {
172 $scope: scope, 184 $scope: scope,
173 focaAbmPreciosCondicionesService: { 185 focaAbmPreciosCondicionesService: {
174 obtenerPrecioCondicion: function() { 186 obtenerPrecioCondicion: function() {
175 return { 187 return {
176 then: function() { } 188 then: function() { }
177 }; 189 };
178 } 190 }
179 }, 191 },
180 focaBotoneraLateralService: {}, 192 focaBotoneraLateralService: {},
181 $routeParams: {}, 193 $routeParams: {},
182 $location: $location, 194 $location: $location,
195 $localStorage: {},
183 focaModalService: {}, 196 focaModalService: {},
184 $timeout: timeout, 197 $timeout: timeout,
185 $uibModal: {}, 198 $uibModal: {},
186 $window: {} 199 $window: {}
187 }); 200 });
188 201
189 //act 202 //act
190 scope.cancelar(); 203 scope.salir();
191 204
192 //assert 205 //assert
193 expect($location.url()).toEqual('/precio-condicion'); 206 expect($location.url()).toEqual('/precio-condicion');
194 }); 207 });
195 }); 208 });
196 209
197 it('La funcion $scope.guardar llama a servicio.guardarPrecioCondicion', function() { 210 it('La funcion $scope.guardar llama a servicio.guardarPrecioCondicion', function() {
198 inject(function($location) { 211 inject(function($location) {
199 //arrange 212 //arrange
200 var scope = {}; 213 var scope = {
214 $watch: function() { }
215 };
201 var focaAbmPreciosCondicionesService = { 216 var focaAbmPreciosCondicionesService = {
202 obtenerPrecioCondicion: function() { 217 obtenerPrecioCondicion: function() {
203 return { 218 return {
204 then: function() { } 219 then: function() { }
205 }; 220 };
206 }, 221 },
207 guardarPrecioCondicion: function() { } 222 guardarPrecioCondicion: function() { }
208 }; 223 };
209 var window = { 224 var window = {
210 location: { 225 location: {
211 assign: function() { } 226 assign: function() { }
212 } 227 }
213 }; 228 };
214 $controller('focaAbmPrecioCondicionController', { 229 $controller('focaAbmPrecioCondicionController', {
215 $scope: scope, 230 $scope: scope,
216 focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, 231 focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService,
217 focaBotoneraLateralService: {}, 232 focaBotoneraLateralService: {},
218 $routeParams: {}, 233 $routeParams: {},
219 $location: $location, 234 $location: $location,
220 focaModalService: {}, 235 focaModalService: {
236 alert: function() {}
237 },
221 $timeout: timeout, 238 $timeout: timeout,
222 $uibModal: {}, 239 $uibModal: {},
240 $localStorage: {},
223 $window: window 241 $window: window
224 }); 242 });
225 var promesaGuardarPrecioCondicion = Promise.resolve(true); 243 var promesaGuardarPrecioCondicion = Promise.resolve(true);
226 scope.precioCondicion = { listaPrecio: {} }; 244 scope.precioCondicion = {
245 listaPrecio: {},
246 nombre: true,
247 descripcion: true,
248 idListaPrecio: true
249 };
227 250
228 //act 251 //act
229 //spyOn(window, 'location').and.returnValue({ assign: function() {} }); 252 //spyOn(window, 'location').and.returnValue({ assign: function() {} });
230 spyOn(focaAbmPreciosCondicionesService, 'guardarPrecioCondicion') 253 spyOn(focaAbmPreciosCondicionesService, 'guardarPrecioCondicion')
231 .and.returnValue(promesaGuardarPrecioCondicion); 254 .and.returnValue(promesaGuardarPrecioCondicion);
232 scope.guardar(); 255 scope.guardar();
233 256
234 //assert 257 //assert
235 expect(focaAbmPreciosCondicionesService.guardarPrecioCondicion).toHaveBeenCalled(); 258 expect(focaAbmPreciosCondicionesService.guardarPrecioCondicion).toHaveBeenCalled();
236 }); 259 });
237 }); 260 });
238 261
239 it('La funcion $scope.solicitarConfirmacionPlazoPago levanta modal confirm', function() { 262 it('La funcion $scope.solicitarConfirmacionPlazoPago levanta modal confirm', function() {
240 //act 263 //act
241 var scope = {}; 264 var scope = {
265 $watch: function() {}
266 };
242 var focaModalService = { 267 var focaModalService = {
243 confirm: function() { } 268 confirm: function() { }
244 }; 269 };
245 $controller('focaAbmPrecioCondicionController', { 270 $controller('focaAbmPrecioCondicionController', {
246 $scope: scope, 271 $scope: scope,
247 focaAbmPreciosCondicionesService: { 272 focaAbmPreciosCondicionesService: {
248 obtenerPrecioCondicion: function() { 273 obtenerPrecioCondicion: function() {
249 return { 274 return {
250 then:function() { } 275 then:function() { }
251 }; 276 };
252 } 277 }
253 }, 278 },
254 focaBotoneraLateralService: {}, 279 focaBotoneraLateralService: {},
255 $routeParams: {}, 280 $routeParams: {},
256 $location: {}, 281 $location: {},
257 focaModalService: focaModalService, 282 focaModalService: focaModalService,
258 $timeout: timeout, 283 $timeout: timeout,
259 $uibModal: {}, 284 $uibModal: {},
285 $localStorage: {},
260 $window: {} 286 $window: {}
261 }); 287 });
262 288
263 //act 289 //act
264 spyOn(focaModalService, 'confirm') 290 spyOn(focaModalService, 'confirm')
265 .and.returnValue({ then: function() {} }); 291 .and.returnValue({ then: function() {} });
266 scope.solicitarConfirmacionPlazoPago({ data: 'test' }); 292 scope.solicitarConfirmacionPlazoPago({ data: 'test' });
267 293
268 //assert 294 //assert
269 expect(focaModalService.confirm).toHaveBeenCalled(); 295 expect(focaModalService.confirm).toHaveBeenCalled();
270 }); 296 });
271 297
272 it('La funcion $scope.solicitarConfirmacionPlazoPago borra al dar ok', function(done) { 298 it('La funcion $scope.solicitarConfirmacionPlazoPago borra al dar ok', function(done) {
273 //act 299 //act
274 var scope = {}; 300 var scope = {
301 $watch: function() { }
302 };
275 var focaModalService = { 303 var focaModalService = {
276 confirm: function() { } 304 confirm: function() { }
277 }; 305 };
278 var focaAbmPreciosCondicionesService = { 306 var focaAbmPreciosCondicionesService = {
279 obtenerPrecioCondicion: function() { 307 obtenerPrecioCondicion: function() {
280 return { 308 return {
281 then:function() { } 309 then:function() { }
282 }; 310 };
283 }, 311 },
284 borrarPlazoPago: function() { } 312 borrarPlazoPago: function() { }
285 }; 313 };
286 $controller('focaAbmPrecioCondicionController', { 314 $controller('focaAbmPrecioCondicionController', {
287 $scope: scope, 315 $scope: scope,
288 focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, 316 focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService,
289 focaBotoneraLateralService: {}, 317 focaBotoneraLateralService: {},
290 $routeParams: {}, 318 $routeParams: {},
291 $location: {}, 319 $location: {},
292 focaModalService: focaModalService, 320 focaModalService: focaModalService,
293 $timeout: timeout, 321 $timeout: timeout,
322 $localStorage: {},
294 $uibModal: {}, 323 $uibModal: {},
295 $window: {} 324 $window: {}
296 }); 325 });
297 var promesaConfirm = Promise.resolve(true); 326 var promesaConfirm = Promise.resolve(true);
298 scope.precioCondicion = { 327 scope.precioCondicion = {
299 plazos: [] 328 plazos: []
300 }; 329 };
301 330
302 //act 331 //act
303 spyOn(focaModalService, 'confirm').and.returnValue(promesaConfirm); 332 spyOn(focaModalService, 'confirm').and.returnValue(promesaConfirm);
304 spyOn(focaAbmPreciosCondicionesService, 'borrarPlazoPago'); 333 spyOn(focaAbmPreciosCondicionesService, 'borrarPlazoPago');
305 scope.solicitarConfirmacionPlazoPago({ data: 'test' }); 334 scope.solicitarConfirmacionPlazoPago({ data: 'test' });
306 335
307 //assert 336 //assert
308 promesaConfirm.then(function() { 337 promesaConfirm.then(function() {
309 expect(focaAbmPreciosCondicionesService.borrarPlazoPago).toHaveBeenCalled(); 338 expect(focaAbmPreciosCondicionesService.borrarPlazoPago).toHaveBeenCalled();
310 done(); 339 done();
311 }); 340 });
312 }); 341 });
313 342
314 it('La funcion $scope.seleccionarListaPrecio levanta modal', function() { 343 it('La funcion $scope.seleccionarListaPrecio levanta modal', function() {
315 //arrange 344 //arrange
316 var scope = {}; 345 var scope = {
346 $watch: function() {}
347 };
317 var uibModal = { 348 var uibModal = {
318 open: function() { } 349 open: function() { }
319 }; 350 };
320 var focaAbmPreciosCondicionesService = { 351 var focaAbmPreciosCondicionesService = {
321 obtenerPrecioCondicion: function() { 352 obtenerPrecioCondicion: function() {
322 return { 353 return {
323 then:function() { } 354 then:function() { }
324 }; 355 };
325 } 356 }
326 }; 357 };
327 $controller('focaAbmPrecioCondicionController', { 358 $controller('focaAbmPrecioCondicionController', {
328 $scope: scope, 359 $scope: scope,
329 focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, 360 focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService,
330 focaBotoneraLateralService: {}, 361 focaBotoneraLateralService: {},
331 $routeParams: {}, 362 $routeParams: {},
332 $location: {}, 363 $location: {},
333 focaModalService: {}, 364 focaModalService: {},
334 $timeout: timeout, 365 $timeout: timeout,
335 $uibModal: uibModal, 366 $uibModal: uibModal,
367 $localStorage: {},
336 $window: {} 368 $window: {}
337 }); 369 });
338 370
339 //act 371 //act
340 spyOn(uibModal, 'open').and.returnValue({ result: { then: function() { } } }); 372 spyOn(uibModal, 'open').and.returnValue({ result: { then: function() { } } });
341 scope.seleccionarListaPrecio(13); 373 scope.seleccionarListaPrecio(13);
342 374
343 //assert 375 //assert
344 expect(uibModal.open).toHaveBeenCalled(); 376 expect(uibModal.open).toHaveBeenCalled();
345 }); 377 });
346 378
347 it('La funcion $scope.verProductosListaPrecio levanta modal', function() { 379 it('La funcion $scope.verProductosListaPrecio levanta modal', function() {
348 //arrange 380 //arrange
349 var scope = {}; 381 var scope = {
382 $watch: function() {}
383 };
350 var uibModal = { 384 var uibModal = {
351 open: function() { } 385 open: function() { }
352 }; 386 };
353 var focaAbmPreciosCondicionesService = { 387 var focaAbmPreciosCondicionesService = {
354 obtenerPrecioCondicion: function() { 388 obtenerPrecioCondicion: function() {
355 return { 389 return {
356 then:function() { } 390 then:function() { }
357 }; 391 };
358 } 392 }
359 }; 393 };
360 $controller('focaAbmPrecioCondicionController', { 394 $controller('focaAbmPrecioCondicionController', {
361 $scope: scope, 395 $scope: scope,
362 focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, 396 focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService,
363 focaBotoneraLateralService: {}, 397 focaBotoneraLateralService: {},
364 $routeParams: {}, 398 $routeParams: {},
365 $location: {}, 399 $location: {},
366 focaModalService: {}, 400 focaModalService: {},
367 $timeout: timeout, 401 $timeout: timeout,
368 $uibModal: uibModal, 402 $uibModal: uibModal,
403 $localStorage: {},
369 $window: {} 404 $window: {}
370 }); 405 });
371 scope.precioCondicion = { 406 scope.precioCondicion = {
372 listaPrecio: {} 407 listaPrecio: {}
373 }; 408 };
374 //act 409 //act
375 spyOn(uibModal, 'open'); 410 spyOn(uibModal, 'open');
376 scope.verProductosListaPrecio(); 411 scope.verProductosListaPrecio();
377 412
378 //assert 413 //assert
379 expect(uibModal.open).toHaveBeenCalled(); 414 expect(uibModal.open).toHaveBeenCalled();
380 }); 415 });
381 416
382 it('la función next suma uno a $scope.focused', function() { 417 it('la función next suma uno a $scope.focused', function() {
383 //arrange 418 //arrange
384 var scope = {}; 419 var scope = {
420 $watch: function() {}
421 };
385 var focaAbmPreciosCondicionesService = { 422 var focaAbmPreciosCondicionesService = {
386 obtenerPrecioCondicion: function() { 423 obtenerPrecioCondicion: function() {
387 return { 424 return {
388 then:function() { } 425 then:function() { }
389 }; 426 };
390 } 427 }
391 }; 428 };
392 $controller('focaAbmPrecioCondicionController', { 429 $controller('focaAbmPrecioCondicionController', {
393 $scope: scope, 430 $scope: scope,
394 focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService, 431 focaAbmPreciosCondicionesService: focaAbmPreciosCondicionesService,
395 focaBotoneraLateralService: {}, 432 focaBotoneraLateralService: {},
396 $routeParams: {}, 433 $routeParams: {},
397 $location: {}, 434 $location: {},
398 focaModalService: {}, 435 focaModalService: {},
399 $timeout: timeout, 436 $timeout: timeout,
400 $uibModal: {}, 437 $uibModal: {},
438 $localStorage: {},
401 $window: {} 439 $window: {}
402 }); 440 });
403 441
404 //act 442 //act
405 var esperado = scope.focused + 1; 443 var esperado = scope.focused + 1;
406 scope.next(13); 444 scope.next(13);
407 445
408 //assert 446 //assert
409 expect(scope.focused).toEqual(esperado); 447 expect(scope.focused).toEqual(esperado);
410 }); 448 });
411 }); 449 });
412 }); 450 });
413 451
src/js/controller.js
1 angular.module('focaAbmPreciosCondiciones') 1 angular.module('focaAbmPreciosCondiciones')
2 .controller('focaAbmPreciosCondicionesController', [ 2 .controller('focaAbmPreciosCondicionesController', [
3 '$scope', 'focaAbmPreciosCondicionesService', '$location', 3 '$scope', 'focaAbmPreciosCondicionesService', '$location',
4 'focaModalService', 'focaBotoneraLateralService', '$timeout', 4 'focaModalService', 'focaBotoneraLateralService', '$timeout', '$localStorage',
5 function($scope, focaAbmPreciosCondicionesService, $location, 5 function($scope, focaAbmPreciosCondicionesService, $location,
6 focaModalService, focaBotoneraLateralService, $timeout) { 6 focaModalService, focaBotoneraLateralService, $timeout, $localStorage) {
7 7
8 $scope.focusSearch = false;
9 $scope.filters = '';
10 $scope.now = new Date();
8 $timeout(function() { 11 $timeout(function() {
9 focaBotoneraLateralService.showSalir(true); 12 focaBotoneraLateralService.showSalir(true);
10 focaBotoneraLateralService.showPausar(false); 13 focaBotoneraLateralService.showPausar(false);
11 focaBotoneraLateralService.showCancelar(false); 14 focaBotoneraLateralService.showCancelar(false);
12 focaBotoneraLateralService.showGuardar(false); 15 focaBotoneraLateralService.showGuardar(false);
16
17 $scope.focusSearch = true;
13 }); 18 });
19
14 $scope.filters = ''; 20 $scope.filters = '';
15 $scope.now = new Date(); 21 $scope.now = new Date();
16 $scope.editar = function(id) { 22 $scope.editar = function(id) {
17 $location.path('/precio-condicion/' + id); 23 $location.path('/precio-condicion/' + id);
18 }; 24 };
19 $scope.solicitarConfirmacion = function(precioCondicion) { 25 $scope.solicitarConfirmacion = function(precioCondicion) {
20 focaModalService.confirm('¿Está seguro que desea borrar el precio condición' + 26 focaModalService.confirm('¿Está seguro que desea borrar el precio condición' +
21 precioCondicion.codigo + ' ' + precioCondicion.nombre + ' ?').then( 27 precioCondicion.codigo + ' ' + precioCondicion.nombre + ' ?').then(
22 function(data) { 28 function(data) {
23 if (data) { 29 if (data) {
24 focaAbmPreciosCondicionesService 30 focaAbmPreciosCondicionesService
25 .borrarPrecioCondicion(precioCondicion.id); 31 .borrarPrecioCondicion(precioCondicion.id);
26 $scope.preciosCondiciones.splice( 32 $scope.preciosCondiciones.splice(
27 $scope.preciosCondiciones.indexOf(precioCondicion), 1 33 $scope.preciosCondiciones.indexOf(precioCondicion), 1
28 ); 34 );
29 } 35 }
30 } 36 }
31 ); 37 );
32 }; 38 };
33 39
34 $scope.buscar = function(key) { 40 $scope.buscar = function(key) {
35 if(key === 13){ 41 if(key === 13){
36 focaAbmPreciosCondicionesService 42 focaAbmPreciosCondicionesService
37 .obtenerPreciosCondiciones($scope.filters) 43 .obtenerPreciosCondiciones($scope.filters)
38 .then(function(datos) { 44 .then(function(datos) {
39 $scope.preciosCondiciones = datos.data; 45 $scope.preciosCondiciones = datos.data;
40 $scope.preciosCondiciones.forEach(function(precioCondicion) { 46 $scope.preciosCondiciones.forEach(function(precioCondicion) {
41 precioCondicion.plazoPago.sort(function(a, b) { 47 precioCondicion.plazoPago.sort(function(a, b) {
42 return a.dias- b.dias; 48 return a.dias- b.dias;
43 }); 49 });
44 }); 50 });
45 }); 51 });
46 } 52 }
47 }; 53 };
54
55 if ($localStorage.precioCondicion) {
56 var precioCondicion = JSON.parse($localStorage.precioCondicion);
57 if (!precioCondicion.id) { precioCondicion.id = 0; }
58 $location.path('/precio-condicion/' + precioCondicion.id);
59 }
48 } 60 }
49 ]) 61 ])
50 .controller('focaAbmPrecioCondicionController', [ 62 .controller('focaAbmPrecioCondicionController', [
51 '$scope', 'focaAbmPreciosCondicionesService', 'focaBotoneraLateralService', 63 '$scope', 'focaAbmPreciosCondicionesService', 'focaBotoneraLateralService',
52 '$routeParams', '$location', 'focaModalService', '$timeout', '$uibModal', '$window', 64 '$routeParams', '$location', 'focaModalService', '$timeout', '$uibModal', '$window', '$localStorage', '$filter',
53 function( 65 function(
54 $scope, focaAbmPreciosCondicionesService, focaBotoneraLateralService, 66 $scope, focaAbmPreciosCondicionesService, focaBotoneraLateralService,
55 $routeParams, $location, focaModalService, $timeout, $uibModal, $window 67 $routeParams, $location, focaModalService, $timeout, $uibModal, $window, $localStorage, $filter) {
56 ) {
57 $scope.focused = 1; 68 $scope.focused = 1;
58 $scope.plazosAEliminar = []; 69 $scope.plazosAEliminar = [];
59 $scope.mostrarPlazos = $routeParams.id > 0; 70 $scope.mostrarPlazos = $routeParams.id > 0;
60 $scope.now = new Date(); 71 $scope.now = new Date();
61 $scope.listaPrecioLabel = ''; 72 $scope.listaPrecioLabel = '';
73 $scope.precioCondicion = {
74 id: 0,
75 codigo: '',
76 nombre: '',
77 descripcion: '',
78 idListaPrecio: 0,
79 vigencia: new Date()
80 };
62 focaAbmPreciosCondicionesService.obtenerPrecioCondicion($routeParams.id) 81 focaAbmPreciosCondicionesService.obtenerPrecioCondicion($routeParams.id)
63 .then(function(datos) { 82 .then(function(datos) {
64 $scope.precioCondicion = { 83 if (datos.data.id) {
65 id: 0,
66 codigo: '',
67 nombre: '',
68 descripcion: '',
69 idListaPrecio: 0,
70 vigencia: new Date()
71 };
72 if(datos.data.id) {
73 $scope.precioCondicion = datos.data; 84 $scope.precioCondicion = datos.data;
74 $scope.listaPrecioLabel = datos.data.listaPrecio.ID.trim() + 85 $scope.listaPrecioLabel = datos.data.listaPrecio.ID.trim() +
75 ' - ' + datos.data.listaPrecio.DES; 86 ' - ' + datos.data.listaPrecio.DES;
76 $scope.$broadcast('addCabecera', { 87 $scope.$broadcast('addCabecera', {
77 label: 'Precio y condición:', 88 label: 'Precio y condición:',
78 valor: datos.data.nombre 89 valor: datos.data.nombre
79 }); 90 });
80 focaAbmPreciosCondicionesService.obtenerPlazoPago(datos.data.id) 91 focaAbmPreciosCondicionesService.obtenerPlazoPago(datos.data.id)
81 .then(function(datos) { 92 .then(function(datos) {
82 $scope.precioCondicion.plazos = datos.data; 93 $scope.precioCondicion.plazos = datos.data;
83 $scope.precioCondicion.plazos.sort(function(a, b) { 94 $scope.precioCondicion.plazos.sort(function(a, b) {
84 return a.dias- b.dias; 95 return a.dias- b.dias;
85 }); 96 });
86 $scope.plazoACargar = 97 $scope.plazoACargar =
87 { 98 {
88 item: datos.data.length + 1 99 item: datos.data.length + 1
89 }; 100 };
90 }); 101 });
91 } 102 }
92 }); 103 });
93 104
105 $timeout(function() {getLSPrecioC();});
106
94 $timeout(function() { 107 $timeout(function() {
95 focaBotoneraLateralService.showSalir(false); 108 focaBotoneraLateralService.showSalir(false);
96 focaBotoneraLateralService.showPausar(true); 109 focaBotoneraLateralService.showPausar(true);
97 focaBotoneraLateralService.showCancelar(true); 110 focaBotoneraLateralService.showCancelar(false);
98 focaBotoneraLateralService.showGuardar(true, $scope.guardar); 111 focaBotoneraLateralService.showGuardar(true, $scope.guardar);
112 focaBotoneraLateralService.addCustomButton('Salir', $scope.salir);
99 }); 113 });
100 114
101 $scope.cancelar = function() { 115 $scope.salir = function() {
102 $location.path('/precio-condicion'); 116
117 if ($scope.formPrecioCondicion.$pristine == false) {
118 focaModalService.confirm(
119 '¿Está seguro de que desea salir? Se perderán todos los datos cargados.'
120 ).then(function(data) {
121 if (data) {
122 $location.path('/precio-condicion');
123 }
124 });
125 } else {
126 $location.path('/precio-condicion');
127 }
103 }; 128 };
104 $scope.guardar = function() { 129 $scope.guardar = function() {
105 130
106 console.log($scope.precioCondicion);
107
108 if (!$scope.precioCondicion.nombre) { 131 if (!$scope.precioCondicion.nombre) {
109 focaModalService.alert('Ingrese nombre'); 132 focaModalService.alert('Ingrese nombre');
110 return; 133 return;
111 } else if (!$scope.precioCondicion.descripcion) { 134 } else if (!$scope.precioCondicion.descripcion) {
112 focaModalService.alert('Ingrese descripcion'); 135 focaModalService.alert('Ingrese descripcion');
113 return; 136 return;
114 } else if (!$scope.precioCondicion.idListaPrecio) { 137 } else if (!$scope.precioCondicion.idListaPrecio) {
115 focaModalService.alert('Seleccione precio'); 138 focaModalService.alert('Seleccione precio');
116 return; 139 return;
117 } 140 }
118 141
119 var promises = []; 142 var promises = [];
120 var precioCondicion = $scope.precioCondicion; 143 var precioCondicion = $scope.precioCondicion;
121 precioCondicion.idListaPrecio = precioCondicion.listaPrecio.ID; 144 precioCondicion.idListaPrecio = precioCondicion.listaPrecio.ID;
122 delete precioCondicion.listaPrecio; 145 delete precioCondicion.listaPrecio;
123 if($scope.mostrarPlazos) { 146 if ($scope.mostrarPlazos) {
124 promises.push( 147 promises.push(
125 focaAbmPreciosCondicionesService 148 focaAbmPreciosCondicionesService
126 .guardarPlazosPago($scope.precioCondicion.plazos) 149 .guardarPlazosPago($scope.precioCondicion.plazos)
127 ); 150 );
128 $scope.plazosAEliminar.forEach(function(id) { 151 $scope.plazosAEliminar.forEach(function(id) {
129 promises.push( 152 promises.push(
130 focaAbmPreciosCondicionesService 153 focaAbmPreciosCondicionesService
131 .borrarPlazoPago(id) 154 .borrarPlazoPago(id)
132 ); 155 );
133 }); 156 });
134 } 157 }
135 promises.push( 158 promises.push(
136 focaAbmPreciosCondicionesService 159 focaAbmPreciosCondicionesService
137 .guardarPrecioCondicion(precioCondicion) 160 .guardarPrecioCondicion(precioCondicion)
138 ); 161 );
139 162
140 Promise.all(promises).then(function() { 163 Promise.all(promises).then(function() {
141 $timeout(function() { 164 $timeout(function() {
142 $location.path('/precio-condicion'); 165 $location.path('/precio-condicion');
143 }, 0); 166 }, 0);
144 }, function(err){ 167 }, function(err){
145 console.error(err); 168 console.error(err);
146 }); 169 });
147 }; 170 };
148 171
149 $scope.agregarPlazo = function(key) { 172 $scope.agregarPlazo = function(key) {
150 if(key === 13) { 173 if (key === 13) {
151 if(!$scope.plazoACargar.dias && $scope.plazoACargar.dias !== 0) { 174 if (!$scope.plazoACargar.dias && $scope.plazoACargar.dias !== 0) {
152 focaModalService.alert('Ingrese cantidad de días'); 175 focaModalService.alert('Ingrese cantidad de días');
153 return; 176 return;
154 } 177 }
155 var tieneEseDia = $scope.precioCondicion.plazos.filter(function(a) { 178 var tieneEseDia = $scope.precioCondicion.plazos.filter(function(a) {
156 return a.dias === $scope.plazoACargar.dias; 179 return a.dias === $scope.plazoACargar.dias;
157 }); 180 });
158 if(tieneEseDia.length > 0) { 181 if (tieneEseDia.length > 0) {
159 focaModalService.alert('Ya ha ingresado un plazo con esos días'); 182 focaModalService.alert('Ya ha ingresado un plazo con esos días');
160 return; 183 return;
161 } 184 }
162 $scope.plazoACargar.idPreciosCondiciones = $scope.precioCondicion.id; 185 $scope.plazoACargar.idPreciosCondiciones = $scope.precioCondicion.id;
163 $scope.plazoACargar.activo = true; 186 $scope.plazoACargar.activo = true;
164 $scope.precioCondicion.plazos.push($scope.plazoACargar); 187 $scope.precioCondicion.plazos.push($scope.plazoACargar);
165 $scope.plazoACargar = 188 $scope.plazoACargar =
166 { 189 {
167 item: $scope.precioCondicion.plazos.length + 1 190 item: $scope.precioCondicion.plazos.length + 1
168 }; 191 };
169 } 192 }
170 }; 193 };
171 $scope.quitarPlazo = function(key) { 194 $scope.quitarPlazo = function(key) {
172 if($scope.precioCondicion.plazos[key].id) 195 if ($scope.precioCondicion.plazos[key].id)
173 $scope.plazosAEliminar.push($scope.precioCondicion.plazos[key].id); 196 $scope.plazosAEliminar.push($scope.precioCondicion.plazos[key].id);
174 197
175 $scope.precioCondicion.plazos.splice(key, 1); 198 $scope.precioCondicion.plazos.splice(key, 1);
176 $scope.plazoACargar = 199 $scope.plazoACargar =
177 { 200 {
178 item: $scope.precioCondicion.plazos.length + 1 201 item: $scope.precioCondicion.plazos.length + 1
179 }; 202 };
180 }; 203 };
181 $scope.solicitarConfirmacionPlazoPago = function(plazoPago) { 204 $scope.solicitarConfirmacionPlazoPago = function(plazoPago) {
182 focaModalService.confirm('¿Está seguro que desea borrar el plazo de pago ' + 205 focaModalService.confirm('¿Está seguro que desea borrar el plazo de pago ' +
183 plazoPago.item + ' ' + plazoPago.dias + ' ?').then( 206 plazoPago.item + ' ' + plazoPago.dias + ' ?').then(
184 function(confirm) { 207 function(confirm) {
185 if (confirm) { 208 if (confirm) {
186 focaAbmPreciosCondicionesService.borrarPlazoPago(plazoPago.id); 209 focaAbmPreciosCondicionesService.borrarPlazoPago(plazoPago.id);
187 $scope.precioCondicion.plazos.splice( 210 $scope.precioCondicion.plazos.splice(
188 $scope.precioCondicion.plazos.indexOf(plazoPago), 1 211 $scope.precioCondicion.plazos.indexOf(plazoPago), 1
189 ); 212 );
190 } 213 }
191 } 214 }
192 ); 215 );
193 }; 216 };
194 217
195 $scope.seleccionarListaPrecio = function(key) { 218 $scope.seleccionarListaPrecio = function(key) {
196 if(key === 13){ 219 if (key === 13){
197 var modalInstance = $uibModal.open( 220 var modalInstance = $uibModal.open(
198 { 221 {
199 ariaLabelledBy: 'Busqueda de Listas de precio', 222 ariaLabelledBy: 'Busqueda de Listas de precio',
200 templateUrl: 'modal-lista-precio.html', 223 templateUrl: 'modal-lista-precio.html',
201 controller: 'focaModalListaPrecioCtrl', 224 controller: 'focaModalListaPrecioCtrl',
202 size: 'lg' 225 size: 'lg'
203 } 226 }
204 ); 227 );
205 modalInstance.result.then(function(listaPrecio) { 228 modalInstance.result.then(function(listaPrecio) {
206 $scope.precioCondicion.idListaPrecio = listaPrecio.ID; 229 $scope.precioCondicion.idListaPrecio = listaPrecio.ID;
207 $scope.precioCondicion.listaPrecio = listaPrecio; 230 $scope.precioCondicion.listaPrecio = listaPrecio;
208 $scope.listaPrecioLabel = listaPrecio.ID + ' - ' + listaPrecio.DES; 231 $scope.listaPrecioLabel = listaPrecio.ID + ' - ' + listaPrecio.DES;
209 $scope.focused = 4; 232 $scope.focused = 4;
210 }); 233 });
211 } 234 }
212 }; 235 };
213 236
214 $scope.verProductosListaPrecio = function() { 237 $scope.verProductosListaPrecio = function() {
215 $uibModal.open( 238 $uibModal.open(
216 { 239 {
217 ariaLabelledBy: 'Busqueda de Productos', 240 ariaLabelledBy: 'Busqueda de Productos',
218 templateUrl: 'modal-busqueda-productos.html', 241 templateUrl: 'modal-busqueda-productos.html',
219 controller: 'modalBusquedaProductosCtrl', 242 controller: 'modalBusquedaProductosCtrl',
220 resolve: { 243 resolve: {
221 parametroProducto: { 244 parametroProducto: {
222 idLista: $scope.precioCondicion.listaPrecio.ID, 245 idLista: $scope.precioCondicion.listaPrecio.ID,
223 cotizacion: 1, 246 cotizacion: 1,
224 simbolo: '$', 247 simbolo: '$',
225 soloMostrar: true 248 soloMostrar: true
226 } 249 }
227 }, 250 },
228 size: 'md' 251 size: 'md'
229 } 252 }
230 ); 253 );
231 }; 254 };
232 255
233 $scope.next = function(key) { 256 $scope.next = function(key) {
234 if(key === 13) $scope.focused++; 257 if (key === 13) $scope.focused++;
235 }; 258 };
259
260 //watch
261 $scope.$watch('precioCondicion', function(newValue) {
262 focaBotoneraLateralService.setPausarData({
263 label: 'precioCondicion',
264 val: newValue
265 });
266 }, true);
267
268 function setearPrecioCondicion(precioCondicion) {
269 $scope.precioCondicion = precioCondicion;
270 $scope.$broadcast('addCabecera', {
271 label: 'Precio y Condicion:',
272 valor: $filter('rellenarDigitos')(precioCondicion.id)
273 });
274 }
275
src/views/foca-abm-precios-condiciones-item.html
1 <div class="row"> 1 <div class="row">
2 <foca-cabecera-facturador 2 <foca-cabecera-facturador
3 titulo="'Precios y condiciones'" 3 titulo="'Precios y condiciones'"
4 fecha="now" 4 fecha="now"
5 class="mb-0 col-lg-12" 5 class="mb-0 col-lg-12"
6 ></foca-cabecera-facturador> 6 ></foca-cabecera-facturador>
7 </div> 7 </div>
8 <div class="row"> 8 <div class="row">
9 <form class="col-md-10"> 9 <form class= "col-md-10" name="formPrecioCondicion">
10 <input type="hidden" name="id" ng-model="precioCondicion.id" /> 10 <input type="hidden" name="id" ng-model="precioCondicion.id" />
11 <div class="row mb-3"> 11 <div class="row mb-3">
12 <label class="col-sm-2 col-form-label">Código</label> 12 <label class="col-sm-2 col-form-label">Código</label>
13 <input 13 <input
14 class="form-control col-sm-4" 14 class="form-control col-sm-4"
15 type="text" 15 type="text"
16 name="codigo" 16 name="codigo"
17 ng-value="precioCondicion.id | rellenarDigitos: 4: 0" 17 ng-value="precioCondicion.id | rellenarDigitos: 4: 0"
18 autocomplete="off" 18 autocomplete="off"
19 readonly 19 readonly
20 /> 20 />
21 <label class="col-sm-2 col-form-label">Nombre</label> 21 <label class="col-sm-2 col-form-label">Nombre</label>
22 <input 22 <input
23 class="form-control col-sm-4" 23 class="form-control col-sm-4"
24 type="text" 24 type="text"
25 name="nombre" 25 name="nombre"
26 ng-model="precioCondicion.nombre" 26 ng-model="precioCondicion.nombre"
27 autocomplete="off" 27 autocomplete="off"
28 foca-focus="focused == 1" 28 foca-focus="focused == 1"
29 ng-focus="focused = 1" 29 ng-focus="focused = 1"
30 ng-keypress="next($event.keyCode)" 30 ng-keypress="next($event.keyCode)"
31 teclado-virtual 31 teclado-virtual
32 /> 32 />
33 </div> 33 </div>
34 <div class="form-group row"> 34 <div class="form-group row">
35 <label class="col-sm-2 col-form-label">Descripción</label> 35 <label class="col-sm-2 col-form-label">Descripción</label>
36 <input 36 <input
37 class="form-control col-sm-10" 37 class="form-control col-sm-10"
38 type="text" 38 type="text"
39 name="nombre" 39 name="nombre"
40 ng-model="precioCondicion.descripcion" 40 ng-model="precioCondicion.descripcion"
41 autocomplete="off" 41 autocomplete="off"
42 foca-focus="focused == 2" 42 foca-focus="focused == 2"
43 ng-focus="focused = 2" 43 ng-focus="focused = 2"
44 ng-keypress="next($event.keyCode)" 44 ng-keypress="next($event.keyCode)"
45 teclado-virtual 45 teclado-virtual
46 /> 46 />
47 </div> 47 </div>
48 <div class="row"> 48 <div class="row">
49 <label class="col-sm-2 col-form-label">Lista de precios</label> 49 <label class="col-sm-2 col-form-label">Lista de precios</label>
50 <div class="col-sm-4 input-group p-0"> 50 <div class="col-sm-4 input-group p-0">
51 <input 51 <input
52 ng-model="listaPrecioLabel" 52 ng-model="listaPrecioLabel"
53 class="form-control" 53 class="form-control"
54 foca-focus="focused == 3" 54 foca-focus="focused == 3"
55 ng-focus="focused = 3" 55 ng-focus="focused = 3"
56 ng-keypress="seleccionarListaPrecio($event.keyCode)" 56 ng-keypress="seleccionarListaPrecio($event.keyCode)"
57 readonly 57 readonly
58 /> 58 />
59 <div class="input-group-append"> 59 <div class="input-group-append">
60 <button 60 <button
61 class="btn btn-outline-secondary form-control" 61 class="btn btn-outline-secondary form-control"
62 title="Ver productos" 62 title="Ver productos"
63 type="button" 63 type="button"
64 ng-click="verProductosListaPrecio()" 64 ng-click="verProductosListaPrecio()"
65 ng-show="precioCondicion.listaPrecio" 65 ng-show="precioCondicion.listaPrecio"
66 > 66 >
67 <i class="fa fa-eye" aria-hidden="true"></i> 67 <i class="fa fa-eye" aria-hidden="true"></i>
68 </button> 68 </button>
69 <button 69 <button
70 ladda="searchLoading" 70 ladda="searchLoading"
71 class="btn btn-outline-secondary form-control" 71 class="btn btn-outline-secondary form-control"
72 title="Buscar" 72 title="Buscar"
73 type="button" 73 type="button"
74 ng-click="seleccionarListaPrecio(13)" 74 ng-click="seleccionarListaPrecio(13)"
75 > 75 >
76 <i class="fa fa-search" aria-hidden="true"></i> 76 <i class="fa fa-search" aria-hidden="true"></i>
77 </button> 77 </button>
78 </div> 78 </div>
79 </div> 79 </div>
80 <label class="col-sm-2 col-form-label" ng-show="mostrarPlazos">Plazos</label> 80 <label class="col-sm-2 col-form-label" ng-show="mostrarPlazos">Plazos</label>
81 <div class="col-sm-4 p-0" ng-show="mostrarPlazos"> 81 <div class="col-sm-4 p-0" ng-show="mostrarPlazos">
82 <div class="input-group p-0"> 82 <div class="input-group p-0">
83 <input 83 <input
84 type="number" 84 type="number"
85 class="form-control text-right" 85 class="form-control text-right"
86 min="0" 86 min="0"
87 ng-model="plazoACargar.dias" 87 ng-model="plazoACargar.dias"
88 ng-keypress="agregarPlazo($event.keyCode)" 88 ng-keypress="agregarPlazo($event.keyCode)"
89 foca-focus="focused == 4" 89 foca-focus="focused == 4"
90 ng-focus="focused = 4" 90 ng-focus="focused = 4"
91 placeholder="Días" 91 placeholder="Días"
92 teclado-virtual
92 /> 93 />
93 <div class="input-group-append"> 94 <div class="input-group-append">
94 <button 95 <button
95 class="btn btn-outline-secondary form-control" 96 class="btn btn-outline-secondary form-control"
96 title="Agregar" 97 title="Agregar"
97 type="button" 98 type="button"
98 ng-click="agregarPlazo(13)" 99 ng-click="agregarPlazo(13)"
99 > 100 >
100 <i class="fa fa-save" aria-hidden="true"></i> 101 <i class="fa fa-save" aria-hidden="true"></i>
101 </button> 102 </button>
102 </div> 103 </div>
103 </div> 104 </div>
104 <table class="table table-striped table-sm"> 105 <table class="table table-striped table-sm">
105 <tbody> 106 <tbody>
106 <tr ng-repeat="(key, plazo) in precioCondicion.plazos"> 107 <tr ng-repeat="(key, plazo) in precioCondicion.plazos">
107 <td class="text-right" > 108 <td class="text-right" >
108 <span ng-bind="plazo.dias + ' días'"></span> 109 <span ng-bind="plazo.dias + ' días'"></span>
109 <button 110 <button
110 type="button" 111 type="button"
111 title="Eliminar" 112 title="Eliminar"
112 class="btn btn-outline-secondary ml-1" 113 class="btn btn-outline-secondary ml-1"
113 ng-click="quitarPlazo(key)" 114 ng-click="quitarPlazo(key)"
114 > 115 >
115 <i class="fa fa-trash"></i> 116 <i class="fa fa-trash"></i>
116 </button> 117 </button>
117 </td> 118 </td>
118 </tr> 119 </tr>
119 </tbody> 120 </tbody>
120 </table> 121 </table>
121 </div> 122 </div>
122 </div> 123 </div>
123 </form> 124 </form>
124 </div> 125 </div>
125 126
src/views/foca-abm-precios-condiciones-listado.html
1 <div class="row"> 1 <div class="row">
2 <foca-cabecera-facturador 2 <foca-cabecera-facturador
3 titulo="'Precios y condiciones'" 3 titulo="'Precios y condiciones'"
4 fecha="now" 4 fecha="now"
5 class="mb-0 col-lg-12" 5 class="mb-0 col-lg-12"
6 ></foca-cabecera-facturador> 6 ></foca-cabecera-facturador>
7 </div> 7 </div>
8 <div class="row"> 8 <div class="row">
9 <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded"> 9 <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded">
10 <div class="form-group input-group mt-3 px-5"> 10 <div class="form-group input-group mt-3 px-5">
11 <input 11 <input
12 type="text" 12 type="text"
13 class="form-control form-control-sm" 13 class="form-control form-control-sm"
14 id="search" 14 id="search"
15 placeholder="Búsqueda" 15 placeholder="Búsqueda"
16 teclado-virtual 16 teclado-virtual
17 ng-keypress="buscar($event.keyCode)" 17 ng-keypress="buscar($event.keyCode)"
18 ng-model="filters" 18 ng-model="filters"
19 foca-focus="focusSearch"
19 /> 20 />
20 <div class="input-group-append"> 21 <div class="input-group-append">
21 <button 22 <button
22 ladda="searchLoading" 23 ladda="searchLoading"
23 class="btn btn-outline-secondary" 24 class="btn btn-outline-secondary"
24 type="button" 25 type="button"
25 ng-click="buscar(13)" 26 ng-click="buscar(13)"
26 > 27 >
27 <i class="fa fa-search" aria-hidden="true"></i> 28 <i class="fa fa-search" aria-hidden="true"></i>
28 </button> 29 </button>
29 </div> 30 </div>
30 </div> 31 </div>
31 <table class="table table-default table-hover table-sm table-abm table-striped mb-0"> 32 <table class="table table-default table-hover table-sm table-abm table-striped mb-0">
32 <thead> 33 <thead>
33 <tr> 34 <tr>
34 <th>Código</th> 35 <th>Código</th>
35 <th>Nombre</th> 36 <th>Nombre</th>
36 <th>Lista de precio</th> 37 <th>Lista de precio</th>
37 <th>Plazos</th> 38 <th>Plazos</th>
38 <th colspan="2" class="text-center"> 39 <th colspan="2" class="text-center">
39 <button 40 <button
40 title="Agregar" 41 title="Agregar"
41 class="btn btn-outline-debo boton-accion" 42 class="btn btn-outline-debo boton-accion"
42 ng-click="editar(0)"> 43 ng-click="editar(0)">
43 <i class="fa fa-plus"></i> 44 <i class="fa fa-plus"></i>
44 </button> 45 </button>
45 </th> 46 </th>
46 </tr> 47 </tr>
47 </thead> 48 </thead>
48 <tbody> 49 <tbody>
49 <tr ng-repeat="precioCondicion in preciosCondiciones"> 50 <tr ng-repeat="precioCondicion in preciosCondiciones">
50 <td ng-bind="precioCondicion.id | rellenarDigitos: 4: 0"></td> 51 <td ng-bind="precioCondicion.id | rellenarDigitos: 4: 0"></td>
51 <td ng-bind="precioCondicion.nombre"></td> 52 <td ng-bind="precioCondicion.nombre"></td>
52 <td ng-bind="precioCondicion.listaPrecio.ID + ' - ' + precioCondicion.listaPrecio.DES + ' - ' + precioCondicion.listaPrecio.moneda.DETALLE"></td> 53 <td ng-bind="precioCondicion.listaPrecio.ID + ' - ' + precioCondicion.listaPrecio.DES + ' - ' + precioCondicion.listaPrecio.moneda.DETALLE"></td>
53 <td><span 54 <td><span
54 ng-repeat="plazo in precioCondicion.plazoPago" 55 ng-repeat="plazo in precioCondicion.plazoPago"
55 ng-if="plazo.activo" 56 ng-if="plazo.activo"
56 ng-bind="$last ? plazo.dias : plazo.dias + ', '"></span></td> 57 ng-bind="$last ? plazo.dias : plazo.dias + ', '"></span></td>
57 <td class="text-center"> 58 <td class="text-center">
58 <button 59 <button
59 title="Editar" 60 title="Editar"
60 class="btn btn-outline-dark boton-accion" 61 class="btn btn-outline-dark boton-accion"
61 ng-click="editar(precioCondicion.id)"> 62 ng-click="editar(precioCondicion.id)">
62 <i class="fa fa-pencil"></i> 63 <i class="fa fa-pencil"></i>
63 </button> 64 </button>
64 <button 65 <button
65 title="Eliminar" 66 title="Eliminar"
66 class="btn btn-outline-dark boton-accion" 67 class="btn btn-outline-dark boton-accion"
67 ng-click="solicitarConfirmacion(precioCondicion)"> 68 ng-click="solicitarConfirmacion(precioCondicion)">
68 <i class="fa fa-trash"></i> 69 <i class="fa fa-trash"></i>
69 </button> 70 </button>
70 </td> 71 </td>
71 </tr> 72 </tr>
72 </tbody> 73 </tbody>
73 </table> 74 </table>
74 </div> 75 </div>
75 </div> 76 </div>
76 77