Commit d6a59d25b722f30de0051955ce36710180aee311

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

Merge branch 'master' into 'develop'

Master

See merge request !50
src/js/controller.js
... ... @@ -21,12 +21,8 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
21 21  
22 22 $scope.botoneraPrincipal = focaCrearHojaRutaService.getBotones();
23 23 $scope.botonera = [];
24   -
25 24 $scope.datepickerAbierto = false;
26 25 $scope.show = false;
27   - $scope.precargado = false;
28   - $scope.cargaRemito = false;
29   - $scope.remitoAbierto = false;
30 26 $scope.cisternaCargas = [];
31 27 $scope.cargando = true;
32 28 $scope.articulos = [];
... ... @@ -114,13 +110,16 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
114 110 $scope.seleccionarRemitoAbierto = function () {
115 111 $scope.remitoAbierto = true;
116 112 $scope.cargaRemito = false;
  113 + $scope.precargado = false;
117 114  
118 115 var isBotoneraDirty = $scope.botonera.find(function (boton) {
119 116 return boton.checked;
120 117 });
121   -
  118 +
  119 + config();
  120 +
122 121 if (isBotoneraDirty) {
123   - init();
  122 + $scope.$broadcast('cleanCabecera');
124 123 focaModalService.confirm('Se perderan los cambios')
125 124 .then(function () {
126 125 limpiarBotonera($scope.botonera);
... ... @@ -132,7 +131,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
132 131  
133 132 });
134 133 } else {
135   - init();
  134 + $scope.$broadcast('cleanCabecera');
136 135 limpiarBotonera($scope.botoneraPrincipal);
137 136 $filter('filter')($scope.botoneraPrincipal, {
138 137 label: 'Remito Abierto',
... ... @@ -146,13 +145,17 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
146 145  
147 146 $scope.seleccionarCargarRemitos = function () {
148 147 $scope.cargaRemito = true;
  148 + $scope.remitoAbierto = false;
  149 + $scope.precargado = false;
149 150  
150 151 var isBotoneraDirty = $scope.botonera.find(function (boton) {
151 152 return boton.checked;
152 153 });
153   -
  154 +
  155 + config();
  156 +
154 157 if (isBotoneraDirty) {
155   - init();
  158 + $scope.$broadcast('cleanCabecera');
156 159 focaModalService.confirm('Se perderan los cambios')
157 160 .then(function () {
158 161 limpiarBotonera($scope.botonera);
... ... @@ -164,7 +167,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
164 167 $scope.botonera = focaCrearHojaRutaService.getBotonFecha();
165 168 });
166 169 } else {
167   - init();
  170 + $scope.$broadcast('cleanCabecera');
168 171 limpiarBotonera($scope.botoneraPrincipal);
169 172 $filter('filter')($scope.botoneraPrincipal, {
170 173 label: 'Cargar Remitos',
... ... @@ -176,14 +179,18 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
176 179  
177 180 $scope.seleccionarPrecargados = function () {
178 181 $scope.precargado = true;
  182 + $scope.cargaRemito = false;
  183 + $scope.remitoAbierto = false;
179 184 var isBotoneraDirty = $scope.botonera.find(function (boton) {
180 185 return boton.checked;
181 186 });
182   -
  187 +
  188 + config();
  189 +
183 190 if (isBotoneraDirty) {
184   - init();
185 191 focaModalService.confirm('Se perderan los cambios')
186 192 .then(function () {
  193 + $scope.$broadcast('cleanCabecera');
187 194 limpiarBotonera($scope.botonera);
188 195 limpiarBotonera($scope.botoneraPrincipal);
189 196 $filter('filter')($scope.botoneraPrincipal, {
... ... @@ -192,7 +199,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
192 199 $scope.botonera = focaCrearHojaRutaService.getBotonFecha();
193 200 });
194 201 } else {
195   - init();
  202 + $scope.$broadcast('cleanCabecera');
196 203 limpiarBotonera($scope.botoneraPrincipal);
197 204 $filter('filter')($scope.botoneraPrincipal, {
198 205 label: 'Precargado',
... ... @@ -363,7 +370,6 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
363 370  
364 371 function guardarHojaRuta(idRemito) {
365 372  
366   -
367 373 var save2 = {
368 374 hojaRuta: {
369 375 id: 0,
... ... @@ -835,34 +841,28 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
835 841 };
836 842  
837 843 $scope.seleccionarFechaEntrega = function () {
  844 +
838 845 var confirmacion = false;
839   - var hasVehiculoId = $scope.hojaRuta.vehiculo.id !== undefined;
840   - var hasTarifario = $scope.hojaRuta.tarifario !== null;
841   - var hasTransportista = Object.keys($scope.hojaRuta.transportista).length > 0;
842   - var hasChofer = Object.keys($scope.hojaRuta.chofer).length > 0;
843   - var hasDatosExtra = $scope.hojaRuta.datosExtra !== undefined;
844   -
845   - if (hasVehiculoId || hasTransportista ||
846   - hasChofer || hasDatosExtra) {
  846 +
  847 + if (!angular.equals($scope.hojaRuta, $scope.inicial)) {
847 848 confirmacion = true;
848   - if (confirmacion) {
849   - focaModalService
850   - .confirm('Si cambia la fecha se perderán los datos actuales')
851   - .then(function (data) {
852   - if (data) {
853   - $scope.hojaRuta.vehiculo.id = undefined;
854   - $scope.hojaRuta.tarifario = null;
855   - $scope.hojaRuta.transportista = {};
856   - $scope.hojaRuta.chofer = {};
857   - $scope.hojaRuta.datosExtra = undefined;
858   - elegirFecha();
859   - }
860   - }, function () {
861   - return;
862   - });
863   - } else {
864   - elegirFecha();
865   - }
  849 + }
  850 +
  851 + if (confirmacion) {
  852 + focaModalService
  853 + .confirm('Si cambia la fecha se perderán los datos actuales')
  854 + .then(function (data) {
  855 + if (data) {
  856 + $scope.hojaRuta.vehiculo.id = undefined;
  857 + $scope.hojaRuta.tarifario = null;
  858 + $scope.hojaRuta.transportista = {};
  859 + $scope.hojaRuta.chofer = {};
  860 + $scope.hojaRuta.datosExtra = undefined;
  861 + elegirFecha();
  862 + }
  863 + }, function () {
  864 + return;
  865 + });
866 866 } else {
867 867 elegirFecha();
868 868 }
... ... @@ -953,6 +953,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
953 953 hojasRutas: function () { return hojasRutas; }
954 954 },
955 955 size: 'lg',
  956 + backdrop: false
956 957 }
957 958 );
958 959 return modalInstance.result.then(function (res) {
src/js/controllerDetalles.js
... ... @@ -49,8 +49,6 @@ angular.module('focaCrearHojaRuta')
49 49 },
50 50 ],
51 51 }).then(function (res) {
52   - console.log('Res: ', res);
53   -
54 52 var newArt =
55 53 {
56 54 id: 0,
... ... @@ -90,7 +88,7 @@ angular.module('focaCrearHojaRuta')
90 88 $scope.guardar = function () {
91 89  
92 90 var cisternasFilter = $scope.hojasRutas.vehiculo.cisternas.filter(function (cisterna) {
93   - return parseInt(cisterna.disponible) > 0;
  91 + return parseInt(cisterna.disponible) > 0 || cisterna.articuloSeleccionado;
94 92 });
95 93  
96 94