Commit 012e6078288dba29db8084654bedff63ce471ed0

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

Merge branch 'develop' into 'master'

Develop

See merge request !18
src/js/controller.js
1 1 angular.module('focaModalPuntoDescarga')
2 2 .controller('focaModalPuntoDescargaController', [
3   - '$timeout',
4   - '$filter',
5 3 '$scope',
6 4 '$uibModalInstance',
7 5 'focaModalPuntoDescargaService',
8 6 'filters',
9 7 'focaModalService',
10   - function($timeout, $filter, $scope, $uibModalInstance,
  8 + function($scope, $uibModalInstance,
11 9 focaModalPuntoDescargaService, filters, focaModalService) {
12 10  
  11 + console.log('filters', filters);
  12 +
13 13 $scope.cantidadArticulo = 0;
14 14 $scope.articuloSeleccionado = 0;
15 15 $scope.ivas = [];
... ... @@ -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;
src/js/osm-directive.js
... ... @@ -5,7 +5,7 @@ angular.module(&#39;focaModalPuntoDescarga&#39;).directive(&#39;osmPuntoDescarga&#39;, function(
5 5 var contenedor = document.createElement('div');
6 6 contenedor.className = 'w-100 h-50 mt-3';
7 7 el.append(contenedor);
8   - scope.map = L.map(contenedor).setView([-32.89214159952345, -68.84572999101856], attrs.zoom);
  8 + scope.map = L.map(contenedor);
9 9 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map);
10 10 },
11 11 controller: ['$scope', '$timeout', function($scope, $timeout) {
... ... @@ -19,8 +19,9 @@ angular.module(&#39;focaModalPuntoDescarga&#39;).directive(&#39;osmPuntoDescarga&#39;, function(
19 19 for(var i in $scope.markers) {
20 20 $scope.map.removeLayer($scope.markers[i]);
21 21 }
  22 + $scope.map.setView([$scope.latitud, $scope.longitud], 14);
22 23 $scope.markers.push(
23   - L.marker([$scope.latitud, $scope.longitud], {draggable: $scope.draggable})
  24 + L.marker([$scope.latitud, $scope.longitud], {draggable: true})
24 25 .addTo($scope.map)
25 26 .on('dragend', function() {
26 27 $scope.latitud = this.getLatLng().lat;
... ... @@ -33,8 +34,7 @@ angular.module(&#39;focaModalPuntoDescarga&#39;).directive(&#39;osmPuntoDescarga&#39;, function(
33 34 scope: {
34 35 latitud: '=',
35 36 longitud: '=',
36   - zoom: '=',
37   - draggable: '<'
  37 + zoom: '='
38 38 }
39 39 };
40 40 });
src/views/modal-punto-descarga.html
... ... @@ -3,7 +3,7 @@
3 3 <h5 class="modal-title my-1" ng-show="ingreso">Crear punto de descarga</h5>
4 4 <h5 class="modal-title my-1" ng-show="cargaArticulos">Cargar artículos en puntos de descarga</h5>
5 5 <button
6   - class="btn btn-primary"
  6 + class="btn btn-outline-debo"
7 7 title="Nuevo"
8 8 ng-click="ingreso = true"
9 9 ng-hide="ingreso || cargaArticulos">
... ... @@ -43,6 +43,7 @@
43 43 id="checkSelect{{key}}"
44 44 ng-model="puntoDescarga.seleccionado"
45 45 ng-change="seleccionarPunto(key, true)"
  46 + teclado-virtual
46 47 >
47 48 <label
48 49 class="custom-control-label float-right"
... ... @@ -176,7 +177,9 @@
176 177 ng-model="puntoDescarga.descripcion"
177 178 foca-focus="ingreso"
178 179 ng-keypress="guardar($event.keyCode)"
179   - uppercase-only>
  180 + uppercase-only
  181 + teclado-virtual
  182 + />
180 183 </div>
181 184 </div>
182 185 <div class="row">
... ... @@ -188,6 +191,7 @@
188 191 ng-model="puntoDescarga.latitud"
189 192 ng-required="true"
190 193 ng-readonly="editando"
  194 + teclado-virtual
191 195 />
192 196 </div>
193 197 <div class="col-6">
... ... @@ -198,6 +202,7 @@
198 202 ng-model="puntoDescarga.longitud"
199 203 ng-required="true"
200 204 ng-readonly="editando"
  205 + teclado-virtual
201 206 />
202 207 </div>
203 208 </div>