Commit 49538eae3a0dafdd966de1a3e9a677d11cb0f6db
1 parent
9e2be9728b
Exists in
master
and in
2 other branches
Editar anterior
Showing
2 changed files
with
21 additions
and
20 deletions
Show diff stats
src/js/controller.js
| ... | ... | @@ -11,6 +11,8 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 11 | 11 | var cotizacionPArgentino = {}; |
| 12 | 12 | |
| 13 | 13 | function config() { |
| 14 | + $scope.tmpCantidad = Number; | |
| 15 | + $scope.tmpPrecio = Number; | |
| 14 | 16 | $scope.botonera = crearRemitoService.getBotonera(); |
| 15 | 17 | $scope.isNumber = angular.isNumber; |
| 16 | 18 | $scope.datepickerAbierto = false; |
| ... | ... | @@ -971,8 +973,9 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 971 | 973 | return result; |
| 972 | 974 | }; |
| 973 | 975 | |
| 974 | - $scope.editarArticulo = function (key, articulo, bandera) { | |
| 976 | + $scope.editarArticulo = function (key, articulo, tmpCantidad, tmpPrecio) { | |
| 975 | 977 | if (key === 13) { |
| 978 | +<<<<<<< HEAD | |
| 976 | 979 | var valorAEditar = bandera === 'precio' ? articulo.precio : articulo.cantidad; |
| 977 | 980 | var tempValor = bandera === 'precio' ? articulo.tmpPrecio |
| 978 | 981 | : articulo.tmpCantidad; |
| ... | ... | @@ -980,29 +983,24 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 980 | 983 | return; |
| 981 | 984 | } |
| 982 | 985 | if (tempValor === '') { |
| 986 | +======= | |
| 987 | + if (!articulo.cantidad || !articulo.precio || !tmpCantidad || !tmpPrecio) { | |
| 988 | +>>>>>>> parent of 60be8ea... Arreglo alerta al editar campos del producto | |
| 983 | 989 | focaModalService.alert('Los valores deben ser al menos 1'); |
| 984 | 990 | return; |
| 985 | - } else if (tempValor === '0') { | |
| 991 | + } else if (tmpCantidad === "0" || tmpPrecio === "0") { | |
| 986 | 992 | focaModalService.alert('Esta ingresando un producto con valor 0'); |
| 987 | - } else if (valorAEditar < 0) { | |
| 993 | + } else if (articulo.cantidad < 0 || articulo.precio < 0) { | |
| 988 | 994 | focaModalService.alert('Los valores no pueden ser negativos'); |
| 989 | 995 | return; |
| 990 | 996 | } |
| 991 | - articulo[bandera] = parseFloat(tempValor); | |
| 997 | + articulo.cantidad = tmpCantidad; | |
| 998 | + articulo.precio = tmpPrecio; | |
| 992 | 999 | $scope.getTotal(); |
| 993 | - var propiedad = 'edit' + bandera.charAt(0).toUpperCase() + bandera.slice(1); | |
| 994 | - articulo[propiedad] = false; | |
| 1000 | + articulo.editCantidad = articulo.editPrecio = false; | |
| 995 | 1001 | } |
| 996 | 1002 | }; |
| 997 | 1003 | |
| 998 | - $scope.setTempCantidadArticulo = function (articulo) { | |
| 999 | - articulo.tmpCantidad = articulo.cantidad; | |
| 1000 | - }; | |
| 1001 | - | |
| 1002 | - $scope.setTempPrecioArticulo = function (articulo) { | |
| 1003 | - articulo.tmpPrecio = articulo.precio; | |
| 1004 | - }; | |
| 1005 | - | |
| 1006 | 1004 | $scope.cancelarEditar = function (articulo) { |
| 1007 | 1005 | $scope.tmpCantidad = articulo.cantidad; |
| 1008 | 1006 | $scope.tmpPrecio = articulo.precio; |
src/views/remito.html
| ... | ... | @@ -69,13 +69,14 @@ |
| 69 | 69 | <td class="col text-right"> |
| 70 | 70 | <input |
| 71 | 71 | ng-show="articulo.editCantidad" |
| 72 | - ng-model="articulo.tmpCantidad" | |
| 72 | + ng-model="tmpCantidad" | |
| 73 | 73 | class="form-control" |
| 74 | 74 | foca-tipo-input |
| 75 | + min="1" | |
| 75 | 76 | foca-focus="articulo.editCantidad" |
| 76 | - ng-keypress="editarArticulo($event.keyCode, articulo, 'cantidad');" | |
| 77 | + ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" | |
| 77 | 78 | esc-key="cancelarEditar(articulo)" |
| 78 | - ng-focus="selectFocus($event); setTempCantidadArticulo(articulo);" | |
| 79 | + ng-focus="selectFocus($event); tmpCantidad = articulo.cantidad; tmpPrecio = articulo.precio" | |
| 79 | 80 | teclado-virtual |
| 80 | 81 | > |
| 81 | 82 | <i |
| ... | ... | @@ -88,15 +89,17 @@ |
| 88 | 89 | <td class="col text-right"> |
| 89 | 90 | <input |
| 90 | 91 | ng-show="articulo.editPrecio" |
| 91 | - ng-model="articulo.tmpPrecio" | |
| 92 | + ng-model="tmpPrecio" | |
| 92 | 93 | class="form-control" |
| 93 | 94 | foca-tipo-input |
| 94 | 95 | min="1" |
| 95 | 96 | step="0.0001" |
| 96 | 97 | foca-focus="articulo.editPrecio" |
| 97 | - ng-keypress="editarArticulo($event.keyCode, articulo, 'precio');" | |
| 98 | + ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" | |
| 98 | 99 | esc-key="cancelarEditar(articulo)" |
| 99 | - ng-focus="selectFocus($event); setTempPrecioArticulo(articulo);" | |
| 100 | + ng-focus="selectFocus($event); | |
| 101 | + tmpCantidad = articulo.cantidad; | |
| 102 | + tmpPrecio = articulo.precio" | |
| 100 | 103 | teclado-virtual |
| 101 | 104 | > |
| 102 | 105 | <i |