Commit 0fd397057c75448a9820d778864405aa5f7fe67c
1 parent
51c9800474
Exists in
master
Arreglo en alerta
Showing
1 changed file
with
3 additions
and
9 deletions
Show diff stats
src/js/controller.js
... | ... | @@ -107,6 +107,7 @@ angular.module('focaAbmVehiculo') |
107 | 107 | $scope.crear = false; |
108 | 108 | $scope.transportistaStamp = ''; |
109 | 109 | $scope.cisternas = []; |
110 | + $scope.cisternasInicial = []; | |
110 | 111 | |
111 | 112 | $timeout(function () { |
112 | 113 | focaBotoneraLateralService.showSalir(false); |
... | ... | @@ -161,6 +162,7 @@ angular.module('focaAbmVehiculo') |
161 | 162 | .getCisternas($routeParams.idVehiculo) |
162 | 163 | .then(function (res) { |
163 | 164 | $scope.cisternas = res; |
165 | + $scope.cisternasInicial = angular.copy($scope.cisternas); | |
164 | 166 | $scope.$apply(); |
165 | 167 | }); |
166 | 168 | } |
... | ... | @@ -171,13 +173,7 @@ angular.module('focaAbmVehiculo') |
171 | 173 | }; |
172 | 174 | |
173 | 175 | $scope.salir = function () { |
174 | - var cisternaEdit = []; | |
175 | - $scope.cisternas.forEach( function (cisterna) { | |
176 | - if (cisterna.editando === true) { | |
177 | - cisternaEdit.push(cisterna); | |
178 | - } | |
179 | - }); | |
180 | - if (!$scope.formVehiculo.$pristine || cisternaEdit.length > 0) { | |
176 | + if (!$scope.formVehiculo.$pristine || !angular.equals($scope.cisternasInicial, $scope.cisternas)) { | |
181 | 177 | focaModalService.confirm('¿Está seguro de que desea salir? Se perderán todos los datos cargados.').then(function (data) { |
182 | 178 | if (data) { |
183 | 179 | $location.path('/vehiculo'); |
... | ... | @@ -249,7 +245,6 @@ angular.module('focaAbmVehiculo') |
249 | 245 | $scope.salir(); |
250 | 246 | return; |
251 | 247 | } |
252 | - | |
253 | 248 | for (var i = 0; i < $scope.cisternas.length; i++) { |
254 | 249 | if (!validarCisterna($scope.cisternas[i])){ |
255 | 250 | return; |
... | ... | @@ -356,7 +351,6 @@ angular.module('focaAbmVehiculo') |
356 | 351 | }); |
357 | 352 | }); |
358 | 353 | } |
359 | - | |
360 | 354 | function validaTotalCargas() { |
361 | 355 | var total = 0; |
362 | 356 | $scope.cisternas.forEach(function (cisterna) { |