Commit c649a3237e5de4dfeac664bc6495fd380e10dae9
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
Master See merge request !8
Showing
3 changed files
 
Show diff stats
src/js/controller.js
| ... | ... | @@ -67,17 +67,30 @@ angular.module('focaModalPuntoDescarga') | 
| 67 | 67 | }); | 
| 68 | 68 | }; | 
| 69 | 69 | |
| 70 | - $scope.eliminar = function(idx, id) { | |
| 71 | - focaModalPuntoDescargaService.eliminarPuntoDescarga(id).then(function() { | |
| 72 | - $scope.puntosDescarga.splice(idx, 1); | |
| 73 | - }); | |
| 70 | + $scope.eliminar = function(idx, puntoDescarga) { | |
| 71 | + focaModalService.confirm('¿Está seguro que desea borrar el punto de descarga '+ | |
| 72 | + puntoDescarga.descripcion + '?').then(function(data) { | |
| 73 | + if(data) { | |
| 74 | + focaModalPuntoDescargaService | |
| 75 | + .eliminarPuntoDescarga(puntoDescarga.id) | |
| 76 | + .then(function() { | |
| 77 | + $scope.puntosDescarga.splice(idx, 1); | |
| 78 | + }); | |
| 79 | + } | |
| 80 | + }); | |
| 74 | 81 | }; | 
| 75 | 82 | |
| 76 | - $scope.seleccionarPunto = function(idx) { | |
| 83 | + $scope.seleccionarPunto = function(idx, esCheckbox) { | |
| 77 | 84 | var indexPunto = $scope.puntosSeleccionados.indexOf(idx); | 
| 78 | 85 | if(indexPunto !== -1) { | 
| 86 | + if(!esCheckbox){ | |
| 87 | + $scope.puntosDescarga[idx].seleccionado = false; | |
| 88 | + } | |
| 79 | 89 | $scope.puntosSeleccionados.splice(indexPunto, 1); | 
| 80 | 90 | }else { | 
| 91 | + if(!esCheckbox){ | |
| 92 | + $scope.puntosDescarga[idx].seleccionado = true; | |
| 93 | + } | |
| 81 | 94 | $scope.puntosSeleccionados.push(idx); | 
| 82 | 95 | } | 
| 83 | 96 | }; | 
| ... | ... | @@ -90,9 +103,11 @@ angular.module('focaModalPuntoDescarga') | 
| 90 | 103 | cantidadRestante = articulo.restante - punto.cantidadACargar; | 
| 91 | 104 | |
| 92 | 105 | if(cantidadRestante < 0) { | 
| 93 | - focaModalService.alert('La cantidad a cargar debe ser menor o igual al restante'); | |
| 106 | + focaModalService | |
| 107 | + .alert('La cantidad a cargar debe ser menor o igual al restante'); | |
| 94 | 108 | }else if(punto.cantidadACargar <= 0) { | 
| 95 | - focaModalService.alert('La cantidad a cargar debe ser mayor que cero'); | |
| 109 | + focaModalService | |
| 110 | + .alert('La cantidad a cargar debe ser mayor que cero'); | |
| 96 | 111 | }else { | 
| 97 | 112 | punto.cargado += parseInt(punto.cantidadACargar); | 
| 98 | 113 | articulo.restante = cantidadRestante; | 
| ... | ... | @@ -103,7 +118,8 @@ angular.module('focaModalPuntoDescarga') | 
| 103 | 118 | //Si el articulo ya fue agregado | 
| 104 | 119 | if(existeArticulo.length) { | 
| 105 | 120 | //Solo sumo cantidad | 
| 106 | - var total = parseInt(existeArticulo[0].cantidad) + parseInt(punto.cantidadACargar); | |
| 121 | + var total = parseInt(existeArticulo[0].cantidad) + | |
| 122 | + parseInt(punto.cantidadACargar); | |
| 107 | 123 | existeArticulo[0].cantidad = total; | 
| 108 | 124 | }else { | 
| 109 | 125 | //Agrego el articulo con la cantidad | 
| ... | ... | @@ -121,7 +137,7 @@ angular.module('focaModalPuntoDescarga') | 
| 121 | 137 | |
| 122 | 138 | $scope.quitarArticulo = function(articulo, idx, punto) { | 
| 123 | 139 | var articuloAEliminar = $scope.articulos.filter(function(art) { | 
| 124 | - return art.id == articulo.id; | |
| 140 | + return art.id === articulo.id; | |
| 125 | 141 | }); | 
| 126 | 142 | var restante = parseInt(articuloAEliminar[0].restante); | 
| 127 | 143 | restante += parseInt(articulo.cantidad); | 
| ... | ... | @@ -167,7 +183,7 @@ angular.module('focaModalPuntoDescarga') | 
| 167 | 183 | //Recorro los articulos cargados en cada punto | 
| 168 | 184 | punto.articulosAgregados.forEach(function(articulo) { | 
| 169 | 185 | var articuloARestar = $scope.articulos.filter(function(art) { | 
| 170 | - return art.idArticulo == articulo.id; | |
| 186 | + return art.idArticulo === articulo.id; | |
| 171 | 187 | }); | 
| 172 | 188 | articuloARestar[0].restante -= articulo.cantidad; | 
| 173 | 189 | }); | 
src/js/osm-directive.js
| ... | ... | @@ -12,7 +12,7 @@ angular.module('focaModalPuntoDescarga').directive('osmPuntoDescarga', function( | 
| 12 | 12 | //resuelve bug mapa gris en modales | 
| 13 | 13 | $timeout(function() { | 
| 14 | 14 | $scope.map.invalidateSize(); | 
| 15 | - }, 1000); | |
| 15 | + }, 100); | |
| 16 | 16 | |
| 17 | 17 | $scope.markers = []; | 
| 18 | 18 | $scope.$watchGroup(['latitud', 'longitud'], function() { | 
src/views/modal-punto-descarga.html
| ... | ... | @@ -32,26 +32,33 @@ | 
| 32 | 32 | <tr class="selected" | 
| 33 | 33 | ng-repeat="(key, puntoDescarga) in puntosDescarga | filter: filters" | 
| 34 | 34 | > | 
| 35 | - <td ng-bind="puntoDescarga.id | rellenarDigitos: 3: 0"></td> | |
| 36 | - <td ng-bind="puntoDescarga.descripcion"></td> | |
| 37 | - <td ng-bind="puntoDescarga.latitud"></td> | |
| 38 | - <td ng-bind="puntoDescarga.longitud"></td> | |
| 39 | - <td class="d-md-none text-primary"> | |
| 40 | - <i class="fa fa-circle-thin" aria-hidden="true"></i> | |
| 41 | - </td> | |
| 42 | - <td class="d-none d-md-table-cell"> | |
| 35 | + <td | |
| 36 | + ng-bind="puntoDescarga.id | rellenarDigitos: 3: 0" | |
| 37 | + ng-click="seleccionarPunto(key)"></td> | |
| 38 | + <td | |
| 39 | + ng-bind="puntoDescarga.descripcion" | |
| 40 | + ng-click="seleccionarPunto(key)"></td> | |
| 41 | + <td | |
| 42 | + ng-bind="puntoDescarga.latitud" | |
| 43 | + ng-click="seleccionarPunto(key)"></td> | |
| 44 | + <td | |
| 45 | + ng-bind="puntoDescarga.longitud" | |
| 46 | + ng-click="seleccionarPunto(key)"></td> | |
| 47 | + <td> | |
| 43 | 48 | <input | 
| 44 | 49 | type="checkbox" | 
| 45 | 50 | class="custom-control-input float-right" | 
| 46 | - id="checkSelect{{key}}"> | |
| 51 | + id="checkSelect{{key}}" | |
| 52 | + ng-model="puntoDescarga.seleccionado" | |
| 53 | + ng-change="seleccionarPunto(key, true)" | |
| 54 | + > | |
| 47 | 55 | <label | 
| 48 | 56 | class="custom-control-label float-right" | 
| 49 | - for="checkSelect{{key}}" | |
| 50 | - ng-click="seleccionarPunto(key)"></label> | |
| 57 | + for="checkSelect{{key}}"></label> | |
| 51 | 58 | <button | 
| 52 | 59 | type="button" | 
| 53 | 60 | class="btn btn-xs p-1 float-right mr-5" | 
| 54 | - ng-click="eliminar(key, puntoDescarga.id)" | |
| 61 | + ng-click="eliminar(key, puntoDescarga)" | |
| 55 | 62 | title="Eliminar"> | 
| 56 | 63 | <i class="fa fa-trash" aria-hidden="true"></i> | 
| 57 | 64 | </button> | 
| ... | ... | @@ -202,6 +209,7 @@ | 
| 202 | 209 | latitud="puntoDescarga.latitud" | 
| 203 | 210 | longitud="puntoDescarga.longitud" | 
| 204 | 211 | zoom="14" | 
| 212 | + ng-if="ingreso" | |
| 205 | 213 | /> | 
| 206 | 214 | </form> | 
| 207 | 215 | </div> |