From 60be8ea2bc0a38f644a06f68a5b2405049daa7fc Mon Sep 17 00:00:00 2001 From: Luigi Date: Wed, 19 Jun 2019 16:03:46 -0300 Subject: [PATCH] Arreglo alerta al editar campos del producto --- src/js/controller.js | 27 ++++++++++++++++++--------- src/views/remito.html | 15 ++++++--------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/js/controller.js b/src/js/controller.js index 47ed6c3..f4bcd04 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -11,8 +11,6 @@ angular.module('focaCrearRemito').controller('remitoController', var cotizacionPArgentino = {}; function config() { - $scope.tmpCantidad = Number; - $scope.tmpPrecio = Number; $scope.botonera = crearRemitoService.getBotonera(); $scope.isNumber = angular.isNumber; $scope.datepickerAbierto = false; @@ -963,24 +961,35 @@ angular.module('focaCrearRemito').controller('remitoController', return result; }; - $scope.editarArticulo = function (key, articulo, tmpCantidad, tmpPrecio) { + $scope.editarArticulo = function (key, articulo, bandera) { if (key === 13) { - if (!articulo.cantidad || !articulo.precio || !tmpCantidad || !tmpPrecio) { + var valorAEditar = bandera === 'precio' ? articulo.precio : articulo.cantidad; + var tempValor = bandera === 'precio' ? articulo.tmpPrecio + : articulo.tmpCantidad; + if (tempValor === '') { focaModalService.alert('Los valores deben ser al menos 1'); return; - } else if (tmpCantidad === "0" || tmpPrecio === "0") { + } else if (tempValor === '0') { focaModalService.alert('Esta ingresando un producto con valor 0'); - } else if (articulo.cantidad < 0 || articulo.precio < 0) { + } else if (valorAEditar < 0) { focaModalService.alert('Los valores no pueden ser negativos'); return; } - articulo.cantidad = tmpCantidad; - articulo.precio = tmpPrecio; + articulo[bandera] = parseFloat(tempValor); $scope.getTotal(); - articulo.editCantidad = articulo.editPrecio = false; + var propiedad = 'edit' + bandera.charAt(0).toUpperCase() + bandera.slice(1); + articulo[propiedad] = false; } }; + $scope.setTempCantidadArticulo = function (articulo) { + articulo.tmpCantidad = articulo.cantidad; + }; + + $scope.setTempPrecioArticulo = function (articulo) { + articulo.tmpPrecio = articulo.precio; + }; + $scope.cancelarEditar = function (articulo) { $scope.tmpCantidad = articulo.cantidad; $scope.tmpPrecio = articulo.precio; diff --git a/src/views/remito.html b/src/views/remito.html index 50204a3..a81b466 100644 --- a/src/views/remito.html +++ b/src/views/remito.html @@ -69,14 +69,13 @@