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 | 1 | angular.module('focaAbmPreciosCondiciones') |
2 | 2 | .controller('focaAbmPreciosCondicionesController', [ |
3 | - '$scope', 'focaAbmPreciosCondicionesService', '$location', '$uibModal', | |
4 | - function($scope, focaAbmPreciosCondicionesService, $location, $uibModal) { | |
3 | + '$scope', 'focaAbmPreciosCondicionesService', '$location', 'focaModalService', | |
4 | + function($scope, focaAbmPreciosCondicionesService, $location, focaModalService) { | |
5 | 5 | focaAbmPreciosCondicionesService.obtenerPreciosCondiciones().then(function(datos) { |
6 | 6 | $scope.preciosCondiciones = datos.data; |
7 | 7 | }); |
... | ... | @@ -9,28 +9,27 @@ angular.module('focaAbmPreciosCondiciones') |
9 | 9 | $location.path('/precio-condicion/' + id); |
10 | 10 | }; |
11 | 11 | $scope.solicitarConfirmacion = function(precioCondicion) { |
12 | - $uibModal.open({ | |
13 | - templateUrl: 'foca-abm-precios-condiciones-modal-confirmar.html', | |
14 | - controller: 'focaAbmPreciosCondicionesModalConfirmarController', | |
15 | - animation: false, | |
16 | - backdrop: false, | |
17 | - resolve: {precioCondicion: function(){return precioCondicion;}} | |
18 | - }) | |
19 | - .result.then(function(precioCondicion){ | |
20 | - focaAbmPreciosCondicionesService.borrarPrecioCondicion(precioCondicion.id); | |
21 | - $scope.preciosCondiciones.splice( | |
22 | - $scope.preciosCondiciones.indexOf(precioCondicion), 1 | |
12 | + focaModalService.confirm('¿Está seguro que desea borrar el precio condición' + | |
13 | + precioCondicion.codigo + ' ' + precioCondicion.nombre + ' ?').then( | |
14 | + function(data) { | |
15 | + if (data) { | |
16 | + focaAbmPreciosCondicionesService | |
17 | + .borrarPrecioCondicion(precioCondicion.id); | |
18 | + $scope.preciosCondiciones.splice( | |
19 | + $scope.preciosCondiciones.indexOf(precioCondicion), 1 | |
20 | + ); | |
21 | + } | |
22 | + } | |
23 | 23 | ); |
24 | - }); | |
25 | 24 | }; |
26 | 25 | } |
27 | 26 | ]) |
28 | 27 | .controller('focaAbmPrecioCondicionController', [ |
29 | 28 | '$scope', 'focaAbmPreciosCondicionesService', |
30 | - '$routeParams', '$location', '$uibModal', | |
29 | + '$routeParams', '$location', 'focaModalService', | |
31 | 30 | function( |
32 | 31 | $scope, focaAbmPreciosCondicionesService, |
33 | - $routeParams, $location, $uibModal | |
32 | + $routeParams, $location, focaModalService | |
34 | 33 | ) { |
35 | 34 | focaAbmPreciosCondicionesService.obtenerPrecioCondicion($routeParams.id) |
36 | 35 | .then(function(datos) { |
... | ... | @@ -42,10 +41,10 @@ angular.module('focaAbmPreciosCondiciones') |
42 | 41 | idListaPrecio: 0, |
43 | 42 | vigencia: new Date() |
44 | 43 | }; |
45 | - if(datos.data.id) { | |
44 | + if (datos.data.id) { | |
46 | 45 | $scope.precioCondicion = datos.data; |
47 | 46 | focaAbmPreciosCondicionesService.obtenerPlazoPago(datos.data.id) |
48 | - .then(function(datos){ | |
47 | + .then(function(datos) { | |
49 | 48 | $scope.precioCondicion.plazos = datos.data; |
50 | 49 | }); |
51 | 50 | } |
... | ... | @@ -66,43 +65,17 @@ angular.module('focaAbmPreciosCondiciones') |
66 | 65 | ); |
67 | 66 | }; |
68 | 67 | $scope.solicitarConfirmacionPlazoPago = function(plazoPago) { |
69 | - $uibModal.open({ | |
70 | - templateUrl: 'foca-abm-plazos-pago-modal-confirmar.html', | |
71 | - controller: 'focaAbmPlazosPagosModalConfirmarController', | |
72 | - animation: false, | |
73 | - backdrop: false, | |
74 | - resolve: {plazoPago: function(){return plazoPago;}} | |
75 | - }) | |
76 | - .result.then(function(plazoPago){ | |
77 | - focaAbmPreciosCondicionesService.borrarPlazoPago(plazoPago.id); | |
78 | - $scope.precioCondicion.plazos.splice( | |
79 | - $scope.precioCondicion.plazos.indexOf(plazoPago), 1 | |
68 | + focaModalService.confirm('¿Está seguro que desea borrar el plazo de pago '+ | |
69 | + plazoPago.item+' '+plazoPago.dias + ' ?').then( | |
70 | + function(confirm) { | |
71 | + if (confirm) { | |
72 | + focaAbmPreciosCondicionesService.borrarPlazoPago(plazoPago.id); | |
73 | + $scope.precioCondicion.plazos.splice( | |
74 | + $scope.precioCondicion.plazos.indexOf(plazoPago), 1 | |
75 | + ); | |
76 | + } | |
77 | + } | |
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 | ]); |