Commit de5576d401795e8fa8e160cae29a83437283ea54
1 parent
21eb1f4f00
Exists in
master
inyecto servicio foca-modal para confirmar
actualizo llamada a modal confirmar
Showing
1 changed file
with
27 additions
and
54 deletions
Show diff stats
src/js/controller.js
1 | angular.module('focaAbmPreciosCondiciones') | 1 | angular.module('focaAbmPreciosCondiciones') |
2 | .controller('focaAbmPreciosCondicionesController', [ | 2 | .controller('focaAbmPreciosCondicionesController', [ |
3 | '$scope', 'focaAbmPreciosCondicionesService', '$location', '$uibModal', | 3 | '$scope', 'focaAbmPreciosCondicionesService', '$location', 'focaModalService', |
4 | function($scope, focaAbmPreciosCondicionesService, $location, $uibModal) { | 4 | function($scope, focaAbmPreciosCondicionesService, $location, focaModalService) { |
5 | focaAbmPreciosCondicionesService.obtenerPreciosCondiciones().then(function(datos) { | 5 | focaAbmPreciosCondicionesService.obtenerPreciosCondiciones().then(function(datos) { |
6 | $scope.preciosCondiciones = datos.data; | 6 | $scope.preciosCondiciones = datos.data; |
7 | }); | 7 | }); |
8 | $scope.editar = function(id) { | 8 | $scope.editar = function(id) { |
9 | $location.path('/precio-condicion/' + id); | 9 | $location.path('/precio-condicion/' + id); |
10 | }; | 10 | }; |
11 | $scope.solicitarConfirmacion = function(precioCondicion) { | 11 | $scope.solicitarConfirmacion = function(precioCondicion) { |
12 | $uibModal.open({ | 12 | focaModalService.confirm('¿Está seguro que desea borrar el precio condición' + |
13 | templateUrl: 'foca-abm-precios-condiciones-modal-confirmar.html', | 13 | precioCondicion.codigo + ' ' + precioCondicion.nombre + ' ?').then( |
14 | controller: 'focaAbmPreciosCondicionesModalConfirmarController', | 14 | function(data) { |
15 | animation: false, | 15 | if (data) { |
16 | backdrop: false, | 16 | focaAbmPreciosCondicionesService |
17 | resolve: {precioCondicion: function(){return precioCondicion;}} | 17 | .borrarPrecioCondicion(precioCondicion.id); |
18 | }) | 18 | $scope.preciosCondiciones.splice( |
19 | .result.then(function(precioCondicion){ | 19 | $scope.preciosCondiciones.indexOf(precioCondicion), 1 |
20 | focaAbmPreciosCondicionesService.borrarPrecioCondicion(precioCondicion.id); | 20 | ); |
21 | $scope.preciosCondiciones.splice( | 21 | } |
22 | $scope.preciosCondiciones.indexOf(precioCondicion), 1 | 22 | } |
23 | ); | 23 | ); |
24 | }); | ||
25 | }; | 24 | }; |
26 | } | 25 | } |
27 | ]) | 26 | ]) |
28 | .controller('focaAbmPrecioCondicionController', [ | 27 | .controller('focaAbmPrecioCondicionController', [ |
29 | '$scope', 'focaAbmPreciosCondicionesService', | 28 | '$scope', 'focaAbmPreciosCondicionesService', |
30 | '$routeParams', '$location', '$uibModal', | 29 | '$routeParams', '$location', 'focaModalService', |
31 | function( | 30 | function( |
32 | $scope, focaAbmPreciosCondicionesService, | 31 | $scope, focaAbmPreciosCondicionesService, |
33 | $routeParams, $location, $uibModal | 32 | $routeParams, $location, focaModalService |
34 | ) { | 33 | ) { |
35 | focaAbmPreciosCondicionesService.obtenerPrecioCondicion($routeParams.id) | 34 | focaAbmPreciosCondicionesService.obtenerPrecioCondicion($routeParams.id) |
36 | .then(function(datos) { | 35 | .then(function(datos) { |
37 | $scope.precioCondicion = { | 36 | $scope.precioCondicion = { |
38 | id: 0, | 37 | id: 0, |
39 | codigo: '', | 38 | codigo: '', |
40 | nombre: '', | 39 | nombre: '', |
41 | descripcion: '', | 40 | descripcion: '', |
42 | idListaPrecio: 0, | 41 | idListaPrecio: 0, |
43 | vigencia: new Date() | 42 | vigencia: new Date() |
44 | }; | 43 | }; |
45 | if(datos.data.id) { | 44 | if (datos.data.id) { |
46 | $scope.precioCondicion = datos.data; | 45 | $scope.precioCondicion = datos.data; |
47 | focaAbmPreciosCondicionesService.obtenerPlazoPago(datos.data.id) | 46 | focaAbmPreciosCondicionesService.obtenerPlazoPago(datos.data.id) |
48 | .then(function(datos){ | 47 | .then(function(datos) { |
49 | $scope.precioCondicion.plazos = datos.data; | 48 | $scope.precioCondicion.plazos = datos.data; |
50 | }); | 49 | }); |
51 | } | 50 | } |
52 | }); | 51 | }); |
53 | $scope.cancelar = function() { | 52 | $scope.cancelar = function() { |
54 | $location.path('/precio-condicion'); | 53 | $location.path('/precio-condicion'); |
55 | }; | 54 | }; |
56 | $scope.guardar = function(precioCondicion) { | 55 | $scope.guardar = function(precioCondicion) { |
57 | focaAbmPreciosCondicionesService.guardarPrecioCondicion(precioCondicion) | 56 | focaAbmPreciosCondicionesService.guardarPrecioCondicion(precioCondicion) |
58 | .then(function() { | 57 | .then(function() { |
59 | $location.path('/precio-condicion'); | 58 | $location.path('/precio-condicion'); |
60 | }); | 59 | }); |
61 | }; | 60 | }; |
62 | $scope.editarPlazoPago = function(id) { | 61 | $scope.editarPlazoPago = function(id) { |
63 | $location.path( | 62 | $location.path( |
64 | '/precio-condicion/' + $scope.precioCondicion.id + | 63 | '/precio-condicion/' + $scope.precioCondicion.id + |
65 | '/plazo-pago/' + id | 64 | '/plazo-pago/' + id |
66 | ); | 65 | ); |
67 | }; | 66 | }; |
68 | $scope.solicitarConfirmacionPlazoPago = function(plazoPago) { | 67 | $scope.solicitarConfirmacionPlazoPago = function(plazoPago) { |
69 | $uibModal.open({ | 68 | focaModalService.confirm('¿Está seguro que desea borrar el plazo de pago '+ |
70 | templateUrl: 'foca-abm-plazos-pago-modal-confirmar.html', | 69 | plazoPago.item+' '+plazoPago.dias + ' ?').then( |
71 | controller: 'focaAbmPlazosPagosModalConfirmarController', | 70 | function(confirm) { |
72 | animation: false, | 71 | if (confirm) { |
73 | backdrop: false, | 72 | focaAbmPreciosCondicionesService.borrarPlazoPago(plazoPago.id); |
74 | resolve: {plazoPago: function(){return plazoPago;}} | 73 | $scope.precioCondicion.plazos.splice( |
75 | }) | 74 | $scope.precioCondicion.plazos.indexOf(plazoPago), 1 |
76 | .result.then(function(plazoPago){ | 75 | ); |
77 | focaAbmPreciosCondicionesService.borrarPlazoPago(plazoPago.id); | 76 | } |
78 | $scope.precioCondicion.plazos.splice( | 77 | } |
79 | $scope.precioCondicion.plazos.indexOf(plazoPago), 1 | ||
80 | ); | 78 | ); |
81 | }); | ||
82 | }; | ||
83 | } | ||
84 | ]) | ||
85 | .controller('focaAbmPreciosCondicionesModalConfirmarController', [ | ||
86 | '$uibModalInstance', '$scope', 'precioCondicion', | ||
87 | function($uibModalInstance, $scope, precioCondicion) { | ||
88 | $scope.precioCondicion = precioCondicion; | ||
89 | $scope.cancelar = function() { | ||
90 | $uibModalInstance.dismiss(); | ||
91 | }; | ||
92 | $scope.borrar = function() { | ||
93 | $uibModalInstance.close(precioCondicion); | ||
94 | }; | ||
95 | } | ||
96 | ]) | ||
97 | .controller('focaAbmPlazosPagosModalConfirmarController', [ | ||
98 | '$uibModalInstance', '$scope', 'plazoPago', | ||
99 | function($uibModalInstance, $scope, plazoPago) { | ||
100 | $scope.plazoPago = plazoPago; | ||
101 | $scope.cancelar = function() { | ||
102 | $uibModalInstance.dismiss(); | ||
103 | }; | ||
104 | $scope.borrar = function() { | ||
105 | $uibModalInstance.close(plazoPago); | ||
106 | }; | 79 | }; |
107 | } | 80 | } |
108 | ]); | 81 | ]); |
109 | 82 |