Commit 4fadda5a86bf0d6fc5881b6f40622ef7767ffffc

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

Revert "Alerta de valores en editar producto"

This reverts commit dc8ce4a6c192ae08d89f155def4a045dcd34b2df.
Showing 2 changed files with 16 additions and 24 deletions   Show diff stats
src/js/controller.js
... ... @@ -228,13 +228,6 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl',
228 228 console.info(error);
229 229 });
230 230 };
231   - $scope.setTempCantidadArticulo = function (articulo) {
232   - articulo.tmpCantidad = articulo.cantidad;
233   - };
234   -
235   - $scope.setTempPrecioArticulo = function (articulo) {
236   - articulo.tmpPrecio = articulo.precio;
237   - };
238 231  
239 232 $scope.seleccionarNotaPedido = function () {
240 233 var modalInstance = $uibModal.open(
... ... @@ -839,24 +832,19 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl',
839 832 }
840 833 };
841 834  
842   - $scope.editarArticulo = function (key, articulo, bandera) {
  835 + $scope.editarArticulo = function (key, articulo, tmpCantidad, tmpPrecio) {
843 836 if (key === 13) {
844   - var valorAEditar = bandera === 'precio' ? articulo.precio : articulo.cantidad;
845   - var tempValor = bandera === 'precio' ? articulo.tmpPrecio
846   - : articulo.tmpCantidad;
847   - if (tempValor === '') {
  837 + if (!articulo.cantidad || !articulo.precio || !tmpCantidad || !tmpPrecio) {
848 838 focaModalService.alert('Los valores deben ser al menos 1');
849 839 return;
850   - } else if (tempValor === '0') {
851   - focaModalService.alert('Esta ingresando un producto con valor 0');
852   - } else if (valorAEditar < 0) {
  840 + } else if (articulo.cantidad < 0 || articulo.precio < 0) {
853 841 focaModalService.alert('Los valores no pueden ser negativos');
854 842 return;
855 843 }
856   - articulo[bandera] = parseFloat(tempValor);
  844 + articulo.cantidad = tmpCantidad;
  845 + articulo.precio = tmpPrecio;
857 846 $scope.getTotal();
858   - var propiedad = 'edit' + bandera.charAt(0).toUpperCase() + bandera.slice(1);
859   - articulo[propiedad] = false;
  847 + articulo.editCantidad = articulo.editPrecio = false;
860 848 }
861 849 };
862 850  
src/views/nota-pedido.html
... ... @@ -69,14 +69,16 @@
69 69 <td class="col text-right">
70 70 <input
71 71 ng-show="articulo.editCantidad && notaPedido.idRemito !== -1"
72   - ng-model="articulo.tmpCantidad"
  72 + ng-model="tmpCantidad"
73 73 class="form-control"
74 74 foca-tipo-input
75 75 min="1"
76 76 foca-focus="articulo.editCantidad"
77   - ng-keypress="editarArticulo($event.keyCode, articulo, 'cantidad');"
  77 + ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);"
78 78 esc-key="cancelarEditar(articulo)"
79   - ng-focus="selectFocus($event);setTempCantidadArticulo(articulo);"
  79 + ng-focus="selectFocus($event);
  80 + tmpCantidad = articulo.cantidad;
  81 + tmpPrecio = articulo.precio"
80 82 teclado-virtual
81 83 >
82 84 <i
... ... @@ -89,15 +91,17 @@
89 91 <td class="col text-right">
90 92 <input
91 93 ng-show="articulo.editPrecio && notaPedido.idRemito !== -1"
92   - ng-model="articulo.tmpPrecio"
  94 + ng-model="tmpPrecio"
93 95 class="form-control"
94 96 foca-tipo-input
95 97 min="0"
96 98 step="0.0001"
97 99 foca-focus="articulo.editPrecio"
98   - ng-keypress="editarArticulo($event.keyCode, articulo, 'precio');"
  100 + ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);"
99 101 esc-key="cancelarEditar(articulo)"
100   - ng-focus="selectFocus($event); setTempPrecioArticulo(articulo);"
  102 + ng-focus="selectFocus($event);
  103 + tmpCantidad = articulo.cantidad;
  104 + tmpPrecio = articulo.precio"
101 105 teclado-virtual
102 106 >
103 107 <i