Commit 60be8ea2bc0a38f644a06f68a5b2405049daa7fc

Authored by Luigi
1 parent ad95f17eba
Exists in master and in 1 other branch develop

Arreglo alerta al editar campos del producto

Showing 2 changed files with 24 additions and 18 deletions   Show diff stats
src/js/controller.js
... ... @@ -11,8 +11,6 @@ angular.module('focaCrearRemito').controller('remitoController',
11 11 var cotizacionPArgentino = {};
12 12  
13 13 function config() {
14   - $scope.tmpCantidad = Number;
15   - $scope.tmpPrecio = Number;
16 14 $scope.botonera = crearRemitoService.getBotonera();
17 15 $scope.isNumber = angular.isNumber;
18 16 $scope.datepickerAbierto = false;
... ... @@ -963,24 +961,35 @@ angular.module('focaCrearRemito').controller('remitoController',
963 961 return result;
964 962 };
965 963  
966   - $scope.editarArticulo = function (key, articulo, tmpCantidad, tmpPrecio) {
  964 + $scope.editarArticulo = function (key, articulo, bandera) {
967 965 if (key === 13) {
968   - if (!articulo.cantidad || !articulo.precio || !tmpCantidad || !tmpPrecio) {
  966 + var valorAEditar = bandera === 'precio' ? articulo.precio : articulo.cantidad;
  967 + var tempValor = bandera === 'precio' ? articulo.tmpPrecio
  968 + : articulo.tmpCantidad;
  969 + if (tempValor === '') {
969 970 focaModalService.alert('Los valores deben ser al menos 1');
970 971 return;
971   - } else if (tmpCantidad === "0" || tmpPrecio === "0") {
  972 + } else if (tempValor === '0') {
972 973 focaModalService.alert('Esta ingresando un producto con valor 0');
973   - } else if (articulo.cantidad < 0 || articulo.precio < 0) {
  974 + } else if (valorAEditar < 0) {
974 975 focaModalService.alert('Los valores no pueden ser negativos');
975 976 return;
976 977 }
977   - articulo.cantidad = tmpCantidad;
978   - articulo.precio = tmpPrecio;
  978 + articulo[bandera] = parseFloat(tempValor);
979 979 $scope.getTotal();
980   - articulo.editCantidad = articulo.editPrecio = false;
  980 + var propiedad = 'edit' + bandera.charAt(0).toUpperCase() + bandera.slice(1);
  981 + articulo[propiedad] = false;
981 982 }
982 983 };
983 984  
  985 + $scope.setTempCantidadArticulo = function (articulo) {
  986 + articulo.tmpCantidad = articulo.cantidad;
  987 + };
  988 +
  989 + $scope.setTempPrecioArticulo = function (articulo) {
  990 + articulo.tmpPrecio = articulo.precio;
  991 + };
  992 +
984 993 $scope.cancelarEditar = function (articulo) {
985 994 $scope.tmpCantidad = articulo.cantidad;
986 995 $scope.tmpPrecio = articulo.precio;
src/views/remito.html
... ... @@ -69,14 +69,13 @@
69 69 <td class="col text-right">
70 70 <input
71 71 ng-show="articulo.editCantidad"
72   - ng-model="tmpCantidad"
  72 + ng-model="articulo.tmpCantidad"
73 73 class="form-control"
74 74 foca-tipo-input
75   - min="1"
76 75 foca-focus="articulo.editCantidad"
77   - ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);"
  76 + ng-keypress="editarArticulo($event.keyCode, articulo, 'cantidad');"
78 77 esc-key="cancelarEditar(articulo)"
79   - ng-focus="selectFocus($event); tmpCantidad = articulo.cantidad; tmpPrecio = articulo.precio"
  78 + ng-focus="selectFocus($event); setTempCantidadArticulo(articulo);"
80 79 teclado-virtual
81 80 >
82 81 <i
... ... @@ -89,17 +88,15 @@
89 88 <td class="col text-right">
90 89 <input
91 90 ng-show="articulo.editPrecio"
92   - ng-model="tmpPrecio"
  91 + ng-model="articulo.tmpPrecio"
93 92 class="form-control"
94 93 foca-tipo-input
95 94 min="1"
96 95 step="0.0001"
97 96 foca-focus="articulo.editPrecio"
98   - ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);"
  97 + ng-keypress="editarArticulo($event.keyCode, articulo, 'precio');"
99 98 esc-key="cancelarEditar(articulo)"
100   - ng-focus="selectFocus($event);
101   - tmpCantidad = articulo.cantidad;
102   - tmpPrecio = articulo.precio"
  99 + ng-focus="selectFocus($event); setTempPrecioArticulo(articulo);"
103 100 teclado-virtual
104 101 >
105 102 <i