Commit ff7de186e77d20c45d24ab902bfea22e8693bcdb

Authored by Eric Fernandez
Exists in master and in 2 other branches develop, lab

Merge branch 'develop' into 'master'

Develop

See merge request !42
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() {