Commit 176b1cb45353c2370d6634c0a40b77dacf5b1ca2

Authored by Eric Fernandez
Exists in master and in 1 other branch develop

Merge branch 'master' into 'develop'

Master

See merge request !13
src/js/controller.js
... ... @@ -19,9 +19,10 @@ angular.module('focaModalPuntoDescarga')
19 19 id: 0,
20 20 id_cliente: filters.idCliente,
21 21 id_da_config_0: filters.idDomicilio,
22   - latitud: -32.89214159952345,
23   - longitud: -68.84572999101856
  22 + latitud: filters.domicilio.Latitud,
  23 + longitud: filters.domicilio.Longitud
24 24 };
  25 +
25 26 $scope.articulos = angular.copy(filters.articulos);
26 27 $scope.articulos.map(function(articulo) {
27 28 articulo.restante = articulo.cantidad;
... ... @@ -30,27 +31,27 @@ angular.module('focaModalPuntoDescarga')
30 31 cargarPuntos(filters.puntosDescarga);
31 32  
32 33 $scope.cancel = function() {
33   - if($scope.ingreso) {
  34 + if ($scope.ingreso) {
34 35 $scope.ingreso = false;
35 36 $scope.puntoDescarga = {
36 37 id: 0,
37 38 id_cliente: filters.idCliente,
38 39 id_da_config_0: filters.idDomicilio,
39   - latitud: -32.89214159952345,
40   - longitud: -68.84572999101856
  40 + latitud: filters.domicilio.Latitud,
  41 + longitud: filters.domicilio.Longitud
41 42 };
42 43 $scope.editando = false;
43   - }else {
  44 + } else {
44 45 $uibModalInstance.dismiss('cancel');
45 46 }
46 47 };
47 48  
48 49 $scope.aceptar = function() {
49   - if($scope.cargaArticulos) {
  50 + if ($scope.cargaArticulos) {
50 51 cargarArticulos();
51   - }else if(!$scope.puntosSeleccionados.length) {
  52 + } else if(!$scope.puntosSeleccionados.length) {
52 53 $uibModalInstance.dismiss('cancel');
53   - }else {
  54 + } else {
54 55 enviarPuntos();
55 56 }
56 57 };
... ... @@ -66,8 +67,8 @@ angular.module('focaModalPuntoDescarga')
66 67 id: 0,
67 68 id_cliente: filters.idCliente,
68 69 id_da_config_0: filters.idDomicilio,
69   - latitud: -32.89214159952345,
70   - longitud: -68.84572999101856
  70 + latitud: filters.domicilio.Latitud,
  71 + longitud: filters.domicilio.Longitud
71 72 };
72 73 $scope.editando = false;
73 74 });
... ... @@ -85,7 +86,7 @@ angular.module('focaModalPuntoDescarga')
85 86 $scope.eliminar = function(idx, puntoDescarga) {
86 87 focaModalService.confirm('¿Está seguro que desea borrar el punto de descarga '+
87 88 puntoDescarga.descripcion + '?').then(function(data) {
88   - if(data) {
  89 + if (data) {
89 90 focaModalPuntoDescargaService
90 91 .eliminarPuntoDescarga(puntoDescarga.id)
91 92 .then(function() {
... ... @@ -97,13 +98,13 @@ angular.module('focaModalPuntoDescarga')
97 98  
98 99 $scope.seleccionarPunto = function(idx, esCheckbox) {
99 100 var indexPunto = $scope.puntosSeleccionados.indexOf(idx);
100   - if(indexPunto !== -1) {
101   - if(!esCheckbox){
  101 + if (indexPunto !== -1) {
  102 + if (!esCheckbox) {
102 103 $scope.puntosDescarga[idx].seleccionado = false;
103 104 }
104 105 $scope.puntosSeleccionados.splice(indexPunto, 1);
105   - }else {
106   - if(!esCheckbox){
  106 + } else {
  107 + if (!esCheckbox) {
107 108 $scope.puntosDescarga[idx].seleccionado = true;
108 109 }
109 110 $scope.puntosSeleccionados.push(idx);
... ... @@ -113,17 +114,17 @@ angular.module('focaModalPuntoDescarga')
113 114 $scope.agregarArticulo = function(punto, key) {
114 115 key = (typeof key === 'undefined') ? 13 : key;
115 116  
116   - if(key === 13){
  117 + if (key === 13) {
117 118 var articulo = $scope.articulos[$scope.articuloSeleccionado],
118 119 cantidadRestante = articulo.restante - punto.cantidadACargar;
119 120  
120   - if(cantidadRestante < 0) {
  121 + if (cantidadRestante < 0) {
121 122 focaModalService
122 123 .alert('La cantidad a cargar debe ser menor o igual al restante');
123   - }else if(punto.cantidadACargar <= 0) {
  124 + } else if (punto.cantidadACargar <= 0) {
124 125 focaModalService
125 126 .alert('La cantidad a cargar debe ser mayor que cero');
126   - }else {
  127 + } else {
127 128 punto.cargado += parseInt(punto.cantidadACargar);
128 129 articulo.restante = cantidadRestante;
129 130 var existeArticulo = punto.articulosAgregados.filter(
... ... @@ -131,12 +132,12 @@ angular.module(&#39;focaModalPuntoDescarga&#39;)
131 132 return articuloAAgregar.id === articulo.idArticulo;
132 133 });
133 134 //Si el articulo ya fue agregado
134   - if(existeArticulo.length) {
  135 + if (existeArticulo.length) {
135 136 //Solo sumo cantidad
136 137 var total = parseInt(existeArticulo[0].cantidad) +
137 138 parseInt(punto.cantidadACargar);
138 139 existeArticulo[0].cantidad = total;
139   - }else {
  140 + } else {
140 141 //Agrego el articulo con la cantidad
141 142 punto.articulosAgregados.push({
142 143 id: articulo.idArticulo,
... ... @@ -187,8 +188,8 @@ angular.module(&#39;focaModalPuntoDescarga&#39;)
187 188 }
188 189 function cargarPuntos(puntosDescarga) {
189 190 //Si existen puntos ya cargados
190   - if(puntosDescarga) {
191   - if(!puntosDescarga[0].cargado) {
  191 + if (puntosDescarga) {
  192 + if (!puntosDescarga[0].cargado) {
192 193 agregarTotalCargado(puntosDescarga);
193 194 }
194 195 $scope.puntosACargar = puntosDescarga;