From 4fadda5a86bf0d6fc5881b6f40622ef7767ffffc Mon Sep 17 00:00:00 2001 From: Luigi Date: Wed, 19 Jun 2019 16:18:45 -0300 Subject: [PATCH] Revert "Alerta de valores en editar producto" This reverts commit dc8ce4a6c192ae08d89f155def4a045dcd34b2df. --- src/js/controller.js | 24 ++++++------------------ src/views/nota-pedido.html | 16 ++++++++++------ 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/js/controller.js b/src/js/controller.js index a39522f..c42626a 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -228,13 +228,6 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', console.info(error); }); }; - $scope.setTempCantidadArticulo = function (articulo) { - articulo.tmpCantidad = articulo.cantidad; - }; - - $scope.setTempPrecioArticulo = function (articulo) { - articulo.tmpPrecio = articulo.precio; - }; $scope.seleccionarNotaPedido = function () { var modalInstance = $uibModal.open( @@ -839,24 +832,19 @@ angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', } }; - $scope.editarArticulo = function (key, articulo, bandera) { + $scope.editarArticulo = function (key, articulo, tmpCantidad, tmpPrecio) { if (key === 13) { - var valorAEditar = bandera === 'precio' ? articulo.precio : articulo.cantidad; - var tempValor = bandera === 'precio' ? articulo.tmpPrecio - : articulo.tmpCantidad; - if (tempValor === '') { + if (!articulo.cantidad || !articulo.precio || !tmpCantidad || !tmpPrecio) { focaModalService.alert('Los valores deben ser al menos 1'); return; - } else if (tempValor === '0') { - focaModalService.alert('Esta ingresando un producto con valor 0'); - } else if (valorAEditar < 0) { + } else if (articulo.cantidad < 0 || articulo.precio < 0) { focaModalService.alert('Los valores no pueden ser negativos'); return; } - articulo[bandera] = parseFloat(tempValor); + articulo.cantidad = tmpCantidad; + articulo.precio = tmpPrecio; $scope.getTotal(); - var propiedad = 'edit' + bandera.charAt(0).toUpperCase() + bandera.slice(1); - articulo[propiedad] = false; + articulo.editCantidad = articulo.editPrecio = false; } }; diff --git a/src/views/nota-pedido.html b/src/views/nota-pedido.html index af9d0b7..2e24802 100644 --- a/src/views/nota-pedido.html +++ b/src/views/nota-pedido.html @@ -69,14 +69,16 @@