Commit bf0b86fcf930cd94e3901bdcf1bd45d7b1950a5f
1 parent
89b88d0e1c
Exists in
master
Arreglo la alerta solo se muestra cuando hay otros datos ingresados en la hoja de ruta.
Showing
1 changed file
with
28 additions
and
10 deletions
Show diff stats
src/js/controller.js
| ... | ... | @@ -332,18 +332,36 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
| 332 | 332 | }; |
| 333 | 333 | |
| 334 | 334 | $scope.seleccionarFechaEntrega = function() { |
| 335 | - if (!$scope.hojaRuta.fechaReparto) { | |
| 335 | + var confirmacion = false; | |
| 336 | + var hasVehiculoId = $scope.hojaRuta.vehiculo.id !== undefined; | |
| 337 | + var hasTarifario = $scope.hojaRuta.tarifario.costo !== null; | |
| 338 | + var hasTransportista = Object.keys($scope.hojaRuta.transportista).length > 0; | |
| 339 | + var hasChofer = Object.keys($scope.hojaRuta.chofer).length > 0; | |
| 340 | + var hasDatosExtra = $scope.hojaRuta.datosExtra !== undefined; | |
| 341 | + | |
| 342 | + if (hasVehiculoId || hasTarifario || hasTransportista || | |
| 343 | + hasChofer || hasDatosExtra) { | |
| 344 | + confirmacion = true; | |
| 345 | + if (confirmacion) { | |
| 346 | + focaModalService | |
| 347 | + .confirm('Si cambia la fecha se perderán los datos actuales') | |
| 348 | + .then(function(data) { | |
| 349 | + if(data){ | |
| 350 | + $scope.hojaRuta.vehiculo.id = undefined; | |
| 351 | + $scope.hojaRuta.tarifario.costo = null; | |
| 352 | + $scope.hojaRuta.transportista = {}; | |
| 353 | + $scope.hojaRuta.chofer = {}; | |
| 354 | + $scope.hojaRuta.datosExtra = undefined; | |
| 355 | + elegirFecha(); | |
| 356 | + } | |
| 357 | + }, function() { | |
| 358 | + return ; | |
| 359 | + }); | |
| 360 | + } | |
| 361 | + }else{ | |
| 336 | 362 | elegirFecha(); |
| 337 | - return; | |
| 338 | 363 | } |
| 339 | - focaModalService | |
| 340 | - .confirm('Si cambia la fecha se perderán los datos actuales') | |
| 341 | - .then(function() { | |
| 342 | - elegirFecha(); | |
| 343 | - }, function() { | |
| 344 | - return ; | |
| 345 | - }); | |
| 346 | - }; | |
| 364 | + } | |
| 347 | 365 | |
| 348 | 366 | function setearFecha(fecha) { |
| 349 | 367 | $timeout(function() { |