Commit e4c0f65364ee6a71bef71910568c9d977f70e6c8

Authored by Luigi
Exists in master

Merge remote-tracking branch 'upstream/develop'

spec/controllerSpec.js
... ... @@ -154,6 +154,11 @@ describe('Controladores módulo crear hoja de ruta', function() {
154 154 return {
155 155 then: function() { }
156 156 };
  157 + },
  158 + getParametros: function () {
  159 + return {
  160 + then: function() { }
  161 + };
157 162 }
158 163 },
159 164 focaModalService: {},
... ... @@ -189,6 +194,11 @@ describe('Controladores módulo crear hoja de ruta', function() {
189 194 return {
190 195 then: function() { }
191 196 };
  197 + },
  198 + getParametros: function () {
  199 + return {
  200 + then: function() { }
  201 + };
192 202 }
193 203 },
194 204 focaModalService: focaModalService,
... ... @@ -230,6 +240,11 @@ describe('Controladores módulo crear hoja de ruta', function() {
230 240 return {
231 241 then: function() { }
232 242 };
  243 + },
  244 + getParametros: function () {
  245 + return {
  246 + then: function() { }
  247 + };
233 248 }
234 249 },
235 250 focaModalService: focaModalService,
... ... @@ -275,6 +290,11 @@ describe('Controladores módulo crear hoja de ruta', function() {
275 290 return {
276 291 then: function() { }
277 292 };
  293 + },
  294 + getParametros: function () {
  295 + return {
  296 + then: function() { }
  297 + };
278 298 }
279 299 },
280 300 focaModalService: focaModalService,
... ... @@ -320,6 +340,11 @@ describe('Controladores módulo crear hoja de ruta', function() {
320 340 return {
321 341 then: function() { }
322 342 };
  343 + },
  344 + getParametros: function () {
  345 + return {
  346 + then: function() { }
  347 + };
323 348 }
324 349 },
325 350 focaModalService: focaModalService,
... ... @@ -366,6 +391,11 @@ describe('Controladores módulo crear hoja de ruta', function() {
366 391 return {
367 392 then: function() { }
368 393 };
  394 + },
  395 + getParametros: function () {
  396 + return {
  397 + then: function() { }
  398 + };
369 399 }
370 400 },
371 401 focaModalService: focaModalService,
... ... @@ -377,7 +407,6 @@ describe('Controladores módulo crear hoja de ruta', function() {
377 407 chofer: { id: true },
378 408 vehiculo: { id: true },
379 409 transportista: { COD: true },
380   - tarifario: { },
381 410 remitosTabla: [1]
382 411 };
383 412  
... ... @@ -413,6 +442,11 @@ describe('Controladores módulo crear hoja de ruta', function() {
413 442 return {
414 443 then: function() { }
415 444 };
  445 + },
  446 + getParametros: function () {
  447 + return {
  448 + then: function() { }
  449 + };
416 450 }
417 451 },
418 452 focaModalService: focaModalService,
... ... @@ -451,7 +485,12 @@ describe('Controladores módulo crear hoja de ruta', function() {
451 485 then: function() { }
452 486 };
453 487 },
454   - crearHojaRuta: function() { }
  488 + crearHojaRuta: function() { },
  489 + getParametros: function () {
  490 + return {
  491 + then: function() { }
  492 + };
  493 + }
455 494 };
456 495  
457 496 $controller('hojaRutaCtrl', {
... ... @@ -510,6 +549,11 @@ describe('Controladores módulo crear hoja de ruta', function() {
510 549 return {
511 550 then: function() { }
512 551 };
  552 + },
  553 + getParametros: function () {
  554 + return {
  555 + then: function() { }
  556 + };
513 557 }
514 558 },
515 559 focaModalService: focaModalService,
... ... @@ -560,6 +604,11 @@ describe('Controladores módulo crear hoja de ruta', function() {
560 604 return {
561 605 then: function() { }
562 606 };
  607 + },
  608 + getParametros: function () {
  609 + return {
  610 + then: function() { }
  611 + };
563 612 }
564 613 },
565 614 focaModalService: focaModalService,
... ... @@ -610,6 +659,11 @@ describe('Controladores módulo crear hoja de ruta', function() {
610 659 return {
611 660 then: function() { }
612 661 };
  662 + },
  663 + getParametros: function () {
  664 + return {
  665 + then: function() { }
  666 + };
613 667 }
614 668 },
615 669 focaModalService: focaModalService,
... ... @@ -631,7 +685,7 @@ describe('Controladores módulo crear hoja de ruta', function() {
631 685 promesa.then(function() {
632 686 expect(focaModalService.prompt).toHaveBeenCalled();
633 687 expect(scope.$broadcast).toHaveBeenCalled();
634   - expect(scope.hojaRuta.tarifario.costo).toEqual(respuesta);
  688 + expect(scope.hojaRuta.tarifario).toEqual(respuesta);
635 689 done();
636 690 });
637 691  
... ... @@ -660,6 +714,11 @@ describe('Controladores módulo crear hoja de ruta', function() {
660 714 return {
661 715 then: function() { }
662 716 };
  717 + },
  718 + getParametros: function () {
  719 + return {
  720 + then: function() { }
  721 + };
663 722 }
664 723 },
665 724 focaModalService: {
... ... @@ -715,6 +774,11 @@ describe('Controladores módulo crear hoja de ruta', function() {
715 774 return {
716 775 then: function() { }
717 776 };
  777 + },
  778 + getParametros: function () {
  779 + return {
  780 + then: function() { }
  781 + };
718 782 }
719 783 };
720 784  
... ... @@ -780,6 +844,11 @@ describe('Controladores módulo crear hoja de ruta', function() {
780 844 return {
781 845 then: function() { }
782 846 };
  847 + },
  848 + getParametros: function () {
  849 + return {
  850 + then: function() { }
  851 + };
783 852 }
784 853 },
785 854 focaModalService: {
... ... @@ -822,7 +891,10 @@ describe('Controladores módulo crear hoja de ruta', function() {
822 891 $watch: function() {}
823 892 };
824 893 var focaModalService = {
825   - modalFecha: function() { }
  894 + modalFecha: function() { },
  895 + confirm: function() {
  896 + return Promise.resolve({});
  897 + }
826 898 };
827 899  
828 900 $controller('hojaRutaCtrl', {
... ... @@ -837,6 +909,11 @@ describe('Controladores módulo crear hoja de ruta', function() {
837 909 return {
838 910 then: function() { }
839 911 };
  912 + },
  913 + getParametros: function () {
  914 + return {
  915 + then: function() { }
  916 + };
840 917 }
841 918 },
842 919 focaModalService: focaModalService,
... ... @@ -856,9 +933,12 @@ describe('Controladores módulo crear hoja de ruta', function() {
856 933  
857 934 //assert
858 935 promesa.then(function() {
859   - expect(focaModalService.modalFecha).toHaveBeenCalled();
860   - expect(scope.$broadcast).toHaveBeenCalled();
861   - done();
  936 + setTimeout(function() {
  937 +
  938 + expect(focaModalService.modalFecha).toHaveBeenCalled();
  939 + expect(scope.$broadcast).toHaveBeenCalled();
  940 + done();
  941 + });
862 942 });
863 943  
864 944 });
src/js/controller.js
... ... @@ -33,8 +33,23 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
33 33 focaBotoneraLateralService.addCustomButton('Salir', salir);
34 34 });
35 35  
  36 + focaCrearHojaRutaService.getParametros().then(function(res) {
  37 +
  38 + var parametros = JSON.parse(res.data[0].jsonText);
  39 +
  40 + if ($localStorage.hojaRuta) {
  41 + $timeout(function() {getLSHojaRuta();});
  42 + } else {
  43 +
  44 + for(var property in parametros) {
  45 + $scope.hojaRuta[property] = parametros[property];
  46 + $scope.inicial[property] = parametros[property];
  47 + }
  48 +
  49 + setearHojaRuta($scope.hojaRuta);
  50 + }
  51 + });
36 52 init();
37   - $timeout(function() {getLSHojaRuta();});
38 53 }
39 54  
40 55 function init() {
... ... @@ -48,9 +63,6 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
48 63 capacidad: 0
49 64 },
50 65 transportista: {},
51   - tarifario: {
52   - costo: null
53   - },
54 66 remitosTabla: []
55 67 };
56 68 $scope.idLista = undefined;
... ... @@ -70,6 +82,19 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
70 82 }
71 83  
72 84 $scope.$watch('hojaRuta', function(newValue) {
  85 +
  86 + // Seteo checked en remitos
  87 + if ($scope.hojaRuta.remitosTabla.length) {
  88 +
  89 + $filter('filter')($scope.botonera, {
  90 + label: 'Remitos',
  91 + })[0].checked = true;
  92 + } else {
  93 + $filter('filter')($scope.botonera, {
  94 + label: 'Remitos',
  95 + })[0].checked = false;
  96 + }
  97 +
73 98 focaBotoneraLateralService.setPausarData({
74 99 label: 'hojaRuta',
75 100 val: newValue
... ... @@ -93,7 +118,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
93 118 focaModalService.alert('Ingrese Transportista');
94 119 return;
95 120 }
96   - if (!$scope.hojaRuta.tarifario.costo) {
  121 + if (!$scope.hojaRuta.tarifario) {
97 122 focaModalService.alert('Ingrese Tarifario');
98 123 return;
99 124 }
... ... @@ -110,7 +135,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
110 135 idTransportista: $scope.hojaRuta.transportista.COD,
111 136 idChofer: $scope.hojaRuta.chofer.id,
112 137 idVehiculo: $scope.hojaRuta.vehiculo.id,
113   - tarifaFlete: $scope.hojaRuta.tarifario.costo,
  138 + tarifaFlete: $scope.hojaRuta.tarifario,
114 139 fechaReparto:
115 140 new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10),
116 141 estado: 0
... ... @@ -126,7 +151,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
126 151 $filter('rellenarDigitos')(data.data.numeroHojaRuta, 8)
127 152 );
128 153  
129   - init();
  154 + config();
130 155 },
131 156 function(error) {
132 157 focaModalService.alert('Hubo un error al crear la hoja de ruta');
... ... @@ -163,6 +188,10 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
163 188 valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' +
164 189 proveedor.NOM
165 190 });
  191 +
  192 + $filter('filter')($scope.botonera, {
  193 + label: 'Transportista',
  194 + })[0].checked = true;
166 195 }, function() {
167 196  
168 197 }
... ... @@ -203,6 +232,10 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
203 232 label: 'Chofer:',
204 233 valor: $filter('rellenarDigitos')(chofer.id, 3) + ' - ' +chofer.nombre
205 234 });
  235 +
  236 + $filter('filter')($scope.botonera, {
  237 + label: 'Chofer',
  238 + })[0].checked = true;
206 239 }, function() {
207 240 // funcion ejecutada cuando se cancela el modal
208 241 }
... ... @@ -218,7 +251,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
218 251 focaModalService
219 252 .prompt({
220 253 titulo: 'Tarifa flete',
221   - value: $scope.hojaRuta.tarifario.costo
  254 + value: $scope.hojaRuta.tarifario
222 255 })
223 256 .then(function(costo) {
224 257 if (isNaN(costo)) {
... ... @@ -231,11 +264,15 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
231 264 return;
232 265 }
233 266  
234   - $scope.hojaRuta.tarifario.costo = costo;
  267 + $scope.hojaRuta.tarifario = costo;
235 268 $scope.$broadcast('addCabecera', {
236 269 label: 'Tarifario:',
237 270 valor: costo
238 271 });
  272 +
  273 + $filter('filter')($scope.botonera, {
  274 + label: 'Tarifario',
  275 + })[0].checked = true;
239 276 });
240 277 };
241 278  
... ... @@ -334,7 +371,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
334 371 $scope.seleccionarFechaEntrega = function() {
335 372 var confirmacion = false;
336 373 var hasVehiculoId = $scope.hojaRuta.vehiculo.id !== undefined;
337   - var hasTarifario = $scope.hojaRuta.tarifario.costo !== null;
  374 + var hasTarifario = $scope.hojaRuta.tarifario !== null;
338 375 var hasTransportista = Object.keys($scope.hojaRuta.transportista).length > 0;
339 376 var hasChofer = Object.keys($scope.hojaRuta.chofer).length > 0;
340 377 var hasDatosExtra = $scope.hojaRuta.datosExtra !== undefined;
... ... @@ -348,7 +385,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
348 385 .then(function(data) {
349 386 if(data) {
350 387 $scope.hojaRuta.vehiculo.id = undefined;
351   - $scope.hojaRuta.tarifario.costo = null;
  388 + $scope.hojaRuta.tarifario = null;
352 389 $scope.hojaRuta.transportista = {};
353 390 $scope.hojaRuta.chofer = {};
354 391 $scope.hojaRuta.datosExtra = undefined;
... ... @@ -361,7 +398,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
361 398 } else {
362 399 elegirFecha();
363 400 }
364   - }
  401 + };
365 402  
366 403 function setearFecha(fecha) {
367 404 $timeout(function() {
... ... @@ -370,6 +407,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
370 407 valor: fecha.toLocaleDateString()
371 408 });
372 409 $scope.hojaRuta.fechaReparto = fecha;
  410 + $scope.inicial.fechaReparto = fecha;
373 411 });
374 412 }
375 413  
... ... @@ -390,6 +428,11 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
390 428 }
391 429 );
392 430 return modalInstance.result.then(function(datosExtra) {
  431 +
  432 + $filter('filter')($scope.botonera, {
  433 + label: 'Datos extra',
  434 + })[0].checked = true;
  435 +
393 436 $scope.hojaRuta.datosExtra = datosExtra;
394 437 }, function() {
395 438 //se ejecuta cuando se cancela el modal
... ... @@ -438,11 +481,17 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
438 481 minDate: new Date()
439 482 };
440 483 focaModalService.modalFecha(fechaEntrega).then(function(fecha) {
  484 +
  485 + $scope.hojaRuta.fechaReparto = fecha;
  486 +
441 487 $scope.$broadcast('addCabecera', {
442 488 label: 'Fecha de entrega: ',
443 489 valor: fecha.toLocaleDateString()
444 490 });
445   - $scope.hojaRuta.fechaReparto = fecha;
  491 +
  492 + $filter('filter')($scope.botonera, {
  493 + label: 'Fecha Entrega',
  494 + })[0].checked = true;
446 495 });
447 496 }
448 497  
... ... @@ -509,12 +558,22 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
509 558 focaCrearHojaRutaService
510 559 .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto)
511 560 .then(function(res) {
  561 +
  562 + $filter('filter')($scope.botonera, {
  563 + label: 'Vehiculos precargados',
  564 + })[0].checked = true;
  565 +
512 566 $scope.hojaRuta.remitosTabla = res.data;
513 567 });
514 568 } else {
515 569 focaCrearHojaRutaService
516 570 .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto, true)
517 571 .then(function(res) {
  572 +
  573 + $filter('filter')($scope.botonera, {
  574 + label: 'Vehiculo',
  575 + })[0].checked = true;
  576 +
518 577 $scope.hojaRuta.remitosTabla = res.data;
519 578 });
520 579 }
... ... @@ -530,6 +589,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
530 589 label: 'Capacidad:',
531 590 valor: vehiculo.capacidad
532 591 });
  592 +
533 593 });
534 594 }
535 595  
... ... @@ -581,6 +641,10 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
581 641 label: 'Fecha de entrega:',
582 642 valor: $filter('date')(hojaRuta.fechaReparto, 'dd/MM/yyyy')
583 643 });
  644 +
  645 + $filter('filter')( $scope.botonera, {
  646 + label: 'Fecha Entrega'
  647 + })[0].checked = true;
584 648 }
585 649 if (hojaRuta.transportista.COD) {
586 650 cabeceras.push({
... ... @@ -588,6 +652,10 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
588 652 valor: $filter('rellenarDigitos')(hojaRuta.transportista.COD, 5) + ' - ' +
589 653 hojaRuta.transportista.NOM
590 654 });
  655 +
  656 + $filter('filter')( $scope.botonera, {
  657 + label: 'Transportista'
  658 + })[0].checked = true;
591 659 }
592 660 if (hojaRuta.chofer.id) {
593 661 cabeceras.push({
... ... @@ -595,6 +663,10 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
595 663 valor: $filter('rellenarDigitos')(hojaRuta.chofer.id, 3) +
596 664 ' - ' + hojaRuta.chofer.nombre
597 665 });
  666 +
  667 + $filter('filter')( $scope.botonera, {
  668 + label: 'Chofer'
  669 + })[0].checked = true;
598 670 }
599 671 if (hojaRuta.vehiculo.id) {
600 672 cabeceras.push({
... ... @@ -609,12 +681,20 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
609 681 label: 'Capacidad:',
610 682 valor: hojaRuta.vehiculo.capacidad
611 683 });
  684 +
  685 + $filter('filter')( $scope.botonera, {
  686 + label: 'Vehiculo'
  687 + })[0].checked = true;
612 688 }
613   - if (hojaRuta.tarifario.costo) {
  689 + if (hojaRuta.tarifario) {
614 690 cabeceras.push({
615 691 label: 'Tarifario:',
616   - valor: hojaRuta.tarifario.costo
  692 + valor: hojaRuta.tarifario
617 693 });
  694 +
  695 + $filter('filter')( $scope.botonera, {
  696 + label: 'Tarifario'
  697 + })[0].checked = true;
618 698 }
619 699  
620 700 addArrayCabecera(cabeceras);
... ... @@ -69,6 +69,9 @@ angular.module('focaCrearHojaRuta')
69 69 vehiculoSinRemitos: sinRemitos
70 70 });
71 71 },
  72 + getParametros: function() {
  73 + return $http.get(API_ENDPOINT.URL + '/parametros/hojaRuta');
  74 + },
72 75 getBotonera: function() {
73 76 return [
74 77 {