Commit 9d4fb6c4779378430ba70f57eb9d8e5b008d2e00
1 parent
a7ee896113
Exists in
master
and in
1 other branch
Agregada funcionalidad para que si se editan los detalles del remito y se apreta…
… esc, los valores vuelven a ser los iniciales.
Showing
2 changed files
with
24 additions
and
8 deletions
Show diff stats
src/js/controller.js
... | ... | @@ -10,6 +10,8 @@ angular.module('focaCrearRemito') .controller('remitoController', |
10 | 10 | config(); |
11 | 11 | |
12 | 12 | function config() { |
13 | + $scope.tmpCantidad = Number; | |
14 | + $scope.tmpPrecio = Number; | |
13 | 15 | $scope.botonera = crearRemitoService.getBotonera(); |
14 | 16 | $scope.isNumber = angular.isNumber; |
15 | 17 | $scope.datepickerAbierto = false; |
... | ... | @@ -844,7 +846,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
844 | 846 | $scope.remito.articulosRemito.splice(key, 1); |
845 | 847 | }; |
846 | 848 | |
847 | - $scope.editarArticulo = function(key, articulo) { | |
849 | + $scope.editarArticulo = function(key, articulo, tmpCantidad, tmpPrecio) { | |
848 | 850 | if (key === 13) { |
849 | 851 | if (!articulo.cantidad || !articulo.precio) { |
850 | 852 | focaModalService.alert('Los valores deben ser al menos 1'); |
... | ... | @@ -853,9 +855,18 @@ angular.module('focaCrearRemito') .controller('remitoController', |
853 | 855 | focaModalService.alert('Los valores no pueden ser negativos'); |
854 | 856 | return; |
855 | 857 | } |
858 | + articulo.cantidad = tmpCantidad; | |
859 | + articulo.precio = tmpPrecio; | |
860 | + $scope.getTotal(); | |
856 | 861 | articulo.editCantidad = articulo.editPrecio = false; |
857 | 862 | } |
858 | 863 | }; |
864 | + | |
865 | + $scope.cancelarEditar = function(articulo) { | |
866 | + $scope.tmpCantidad = articulo.cantidad; | |
867 | + $scope.tmpPrecio = articulo.precio; | |
868 | + articulo.editCantidad = articulo.editPrecio = false; | |
869 | + }; | |
859 | 870 | |
860 | 871 | $scope.cambioEdit = function(articulo, propiedad) { |
861 | 872 | if (propiedad === 'cantidad') { |
src/views/remito.html
... | ... | @@ -63,13 +63,16 @@ |
63 | 63 | <td class="col text-right"> |
64 | 64 | <input |
65 | 65 | ng-show="articulo.editCantidad" |
66 | - ng-model="articulo.cantidad" | |
66 | + ng-model="tmpCantidad" | |
67 | 67 | class="form-control" |
68 | 68 | foca-tipo-input |
69 | 69 | min="1" |
70 | 70 | foca-focus="articulo.editCantidad" |
71 | - ng-keypress="editarArticulo($event.keyCode, articulo)" | |
72 | - ng-focus="selectFocus($event)" | |
71 | + ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" | |
72 | + esc-key="cancelarEditar(articulo)" | |
73 | + ng-focus="selectFocus($event); | |
74 | + tmpCantidad = articulo.cantidad; | |
75 | + tmpPrecio = articulo.precio" | |
73 | 76 | teclado-virtual |
74 | 77 | > |
75 | 78 | <i |
... | ... | @@ -82,14 +85,16 @@ |
82 | 85 | <td class="col text-right"> |
83 | 86 | <input |
84 | 87 | ng-show="articulo.editPrecio" |
85 | - ng-model="articulo.precio" | |
88 | + ng-model="tmpPrecio" | |
86 | 89 | class="form-control" |
87 | 90 | foca-tipo-input |
88 | 91 | min="1" |
89 | 92 | step="0.0001" |
90 | - foca-focus="articulo.editPrecio" | |
91 | - ng-keypress="editarArticulo($event.keyCode, articulo)" | |
92 | - ng-focus="selectFocus($event)" | |
93 | + foca-focus="tmpPrecio" | |
94 | + ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" | |
95 | + ng-focus="selectFocus($event); | |
96 | + tmpCantidad = articulo.cantidad; | |
97 | + tmpPrecio = articulo.precio" | |
93 | 98 | teclado-virtual |
94 | 99 | > |
95 | 100 | <i |