Commit ee49b766600bfda5f19d326d70c9a8bf7db6f31d

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

Merge branch 'master' into 'develop'

Master

See merge request !62
src/js/controller.js
... ... @@ -46,8 +46,15 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
46 46  
47 47 var parametros = JSON.parse(res.data[0].jsonText);
48 48  
49   - if ($localStorage.hojaRuta) {
50   - $timeout(function () { getLSHojaRuta(); });
  49 + $timeout(function () {
  50 + getLSBotoneraPrincipal();
  51 + });
  52 +
  53 + if ($localStorage.data) {
  54 + $timeout(function () {
  55 + getLSHojaRuta();
  56 + });
  57 +
51 58 } else {
52 59 for (var property in parametros) {
53 60 $scope.hojaRuta[property] = parametros[property];
... ... @@ -88,24 +95,14 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
88 95 $scope.inicial = angular.copy($scope.hojaRuta);
89 96 }
90 97  
91   - // $scope.$watch('hojaRuta', function(newValue) {
92   -
93   - // // Seteo checked en remitos
94   - // if ($scope.hojaRuta.remitosTabla.length) {
95   - // $filter('filter')($scope.botonera, {
96   - // label: 'Remitos',
97   - // })[0].checked = true;
98   - // } else {
99   - // $filter('filter')($scope.botonera, {
100   - // label: 'Remitos',
101   - // })[0].checked = false;
102   - // }
103   -
104   - // focaBotoneraLateralService.setPausarData({
105   - // label: 'hojaRuta',
106   - // val: newValue
107   - // });
108   - // }, true);
  98 + $scope.$watchGroup(['hojaRuta','precargado','cargaRemito','remitoAbierto'], function(newValues) {
  99 + focaBotoneraLateralService.setPausarData(
  100 + {
  101 + label: 'data',
  102 + val: newValues
  103 + }
  104 + );
  105 + });
109 106  
110 107 $scope.seleccionarRemitoAbierto = function () {
111 108 $scope.remitoAbierto = true;
... ... @@ -128,7 +125,6 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
128 125 label: 'Remito Abierto',
129 126 })[0].checked = true;
130 127 $scope.botonera = focaCrearHojaRutaService.getBotonFecha();
131   -
132 128 });
133 129 } else {
134 130 $scope.$broadcast('cleanCabecera');
... ... @@ -137,9 +133,9 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
137 133 label: 'Remito Abierto',
138 134 })[0].checked = true;
139 135 $scope.botonera = focaCrearHojaRutaService.getBotonFecha();
140   -
  136 +
141 137 }
142   -
  138 +
143 139 $scope.botonera = focaCrearHojaRutaService.getRemitoAbierto();
144 140 };
145 141  
... ... @@ -988,7 +984,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
988 984 $filter('filter')($scope.botonera, {
989 985 label: 'Detalle de Carga',
990 986 })[0].checked = true;
991   - }, function () {
  987 + }, function () {
992 988 //se ejecuta cuando se cancela el modal
993 989 });
994 990 };
... ... @@ -1244,12 +1240,46 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl',
1244 1240 }
1245 1241  
1246 1242 function getLSHojaRuta() {
1247   - var hojaRuta = JSON.parse($localStorage.hojaRuta || null);
  1243 + if ($localStorage.data === undefined) return;
  1244 +
  1245 + var hojaRuta = (JSON.parse($localStorage.data))[0] || null;
1248 1246 if (hojaRuta) {
1249 1247 setearHojaRuta(hojaRuta);
1250   - delete $localStorage.hojaRuta;
  1248 + delete $localStorage.data;
1251 1249 }
1252 1250 }
  1251 +
  1252 + function getLSBotoneraPrincipal() {
  1253 + if ($localStorage.data === undefined) return;
  1254 +
  1255 + var precargado = (JSON.parse($localStorage.data))[1] || null;
  1256 + var cargaRemito = (JSON.parse($localStorage.data))[2] || null;
  1257 + var remitoAbierto = (JSON.parse($localStorage.data))[3] || null;
  1258 + if (remitoAbierto) {
  1259 + $scope.remitoAbierto = remitoAbierto;
  1260 + $filter('filter')($scope.botoneraPrincipal, {
  1261 + label: 'Remito Abierto'
  1262 + })[0].checked = $scope.remitoAbierto;
  1263 + $scope.botonera = focaCrearHojaRutaService.getRemitoAbierto();
  1264 + }
  1265 + if (precargado) {
  1266 + $scope.precargado = precargado;
  1267 + $filter('filter')($scope.botoneraPrincipal, {
  1268 + label: 'Precargados'
  1269 + })[0].checked = $scope.precargado;
  1270 + $scope.botonera = focaCrearHojaRutaService.getBotonFecha();
  1271 + Array.prototype.push.apply($scope.botonera,focaCrearHojaRutaService.getBotoneraPrecargado());
  1272 + }
  1273 + if (cargaRemito) {
  1274 + $scope.cargaRemito = cargaRemito;
  1275 + $filter('filter')($scope.botoneraPrincipal, {
  1276 + label: 'Cargar Remitos'
  1277 + })[0].checked = $scope.cargaRemito;
  1278 + $scope.botonera = focaCrearHojaRutaService.getBotonFecha();
  1279 + Array.prototype.push.apply($scope.botonera,focaCrearHojaRutaService.getBotoneraCargarRemito());
  1280 + }
  1281 + }
  1282 +
1253 1283 function addArrayCabecera(array) {
1254 1284 for (var i = 0; i < array.length; i++) {
1255 1285 $scope.$broadcast('addCabecera', {
... ... @@ -185,7 +185,6 @@ angular.module(&#39;focaCrearHojaRuta&#39;)
185 185 },
186 186 getBotoneraPrecargado: function () {
187 187 return [
188   -
189 188 {
190 189 label: 'Transportista',
191 190 image: 'transportista.png'