Commit 6d6faf043ee6b8d34c6b63ec18c0ec994e81d2d4
1 parent
76955028f0
Exists in
master
and in
1 other branch
pregunta antes de eliminar
Showing
2 changed files
with
20 additions
and
10 deletions
Show diff stats
src/js/controller.js
... | ... | @@ -67,10 +67,17 @@ angular.module('focaModalPuntoDescarga') |
67 | 67 | }); |
68 | 68 | }; |
69 | 69 | |
70 | - $scope.eliminar = function(idx, id) { | |
71 | - focaModalPuntoDescargaService.eliminarPuntoDescarga(id).then(function() { | |
72 | - $scope.puntosDescarga.splice(idx, 1); | |
73 | - }); | |
70 | + $scope.eliminar = function(idx, puntoDescarga) { | |
71 | + focaModalService.confirm('¿Está seguro que desea borrar el punto de descarga '+ | |
72 | + puntoDescarga.descripcion + '?').then(function(data) { | |
73 | + if(data) { | |
74 | + focaModalPuntoDescargaService | |
75 | + .eliminarPuntoDescarga(puntoDescarga.id) | |
76 | + .then(function() { | |
77 | + $scope.puntosDescarga.splice(idx, 1); | |
78 | + }); | |
79 | + } | |
80 | + }); | |
74 | 81 | }; |
75 | 82 | |
76 | 83 | $scope.seleccionarPunto = function(idx, esCheckbox) { |
... | ... | @@ -96,9 +103,11 @@ angular.module('focaModalPuntoDescarga') |
96 | 103 | cantidadRestante = articulo.restante - punto.cantidadACargar; |
97 | 104 | |
98 | 105 | if(cantidadRestante < 0) { |
99 | - focaModalService.alert('La cantidad a cargar debe ser menor o igual al restante'); | |
106 | + focaModalService | |
107 | + .alert('La cantidad a cargar debe ser menor o igual al restante'); | |
100 | 108 | }else if(punto.cantidadACargar <= 0) { |
101 | - focaModalService.alert('La cantidad a cargar debe ser mayor que cero'); | |
109 | + focaModalService | |
110 | + .alert('La cantidad a cargar debe ser mayor que cero'); | |
102 | 111 | }else { |
103 | 112 | punto.cargado += parseInt(punto.cantidadACargar); |
104 | 113 | articulo.restante = cantidadRestante; |
... | ... | @@ -109,7 +118,8 @@ angular.module('focaModalPuntoDescarga') |
109 | 118 | //Si el articulo ya fue agregado |
110 | 119 | if(existeArticulo.length) { |
111 | 120 | //Solo sumo cantidad |
112 | - var total = parseInt(existeArticulo[0].cantidad) + parseInt(punto.cantidadACargar); | |
121 | + var total = parseInt(existeArticulo[0].cantidad) + | |
122 | + parseInt(punto.cantidadACargar); | |
113 | 123 | existeArticulo[0].cantidad = total; |
114 | 124 | }else { |
115 | 125 | //Agrego el articulo con la cantidad |
... | ... | @@ -127,7 +137,7 @@ angular.module('focaModalPuntoDescarga') |
127 | 137 | |
128 | 138 | $scope.quitarArticulo = function(articulo, idx, punto) { |
129 | 139 | var articuloAEliminar = $scope.articulos.filter(function(art) { |
130 | - return art.id == articulo.id; | |
140 | + return art.id === articulo.id; | |
131 | 141 | }); |
132 | 142 | var restante = parseInt(articuloAEliminar[0].restante); |
133 | 143 | restante += parseInt(articulo.cantidad); |
... | ... | @@ -173,7 +183,7 @@ angular.module('focaModalPuntoDescarga') |
173 | 183 | //Recorro los articulos cargados en cada punto |
174 | 184 | punto.articulosAgregados.forEach(function(articulo) { |
175 | 185 | var articuloARestar = $scope.articulos.filter(function(art) { |
176 | - return art.idArticulo == articulo.id; | |
186 | + return art.idArticulo === articulo.id; | |
177 | 187 | }); |
178 | 188 | articuloARestar[0].restante -= articulo.cantidad; |
179 | 189 | }); |
src/views/modal-punto-descarga.html