Commit 03ecc36c1b87de4848583ab735648c9b41014957

Authored by Marcelo
1 parent 8fc201c41d
Exists in master

Agregada funcionalidad para que si se editan los detalles y se apreta esc, los v…

…alores vuelven a ser los iniciales.
Showing 2 changed files with 33 additions and 17 deletions   Show diff stats
src/js/controller.js
... ... @@ -23,6 +23,8 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
23 23  
24 24 function config() {
25 25 // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA
  26 + $scope.tmpCantidad = Number;
  27 + $scope.tmpPrecio = Number;
26 28 $scope.notaPedido = {};
27 29 $scope.isNumber = angular.isNumber;
28 30 $scope.datepickerAbierto = false;
... ... @@ -739,17 +741,27 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
739 741 $scope.notaPedido.articulosNotaPedido.splice(key, 1);
740 742 };
741 743  
742   - $scope.editarArticulo = function(key, articulo) {
  744 + $scope.editarArticulo = function(key, articulo, tmpCantidad, tmpPrecio) {
743 745 if (key === 13) {
744   - if (articulo.cantidad === null || articulo.cantidad === 0 ||
745   - articulo.cantidad === undefined) {
746   - focaModalService.alert('El valor debe ser al menos 1');
  746 + if (!articulo.cantidad || !articulo.precio) {
  747 + focaModalService.alert('Los valores deben ser al menos 1');
  748 + return;
  749 + } else if (articulo.cantidad < 0 || articulo.precio < 0) {
  750 + focaModalService.alert('Los valores no pueden ser negativos');
747 751 return;
748 752 }
749   - articulo.editCantidad = false;
750   - articulo.editPrecio = false;
  753 + articulo.cantidad = tmpCantidad;
  754 + articulo.precio = tmpPrecio;
  755 + $scope.getTotal();
  756 + articulo.editCantidad = articulo.editPrecio = false;
751 757 }
752 758 };
  759 +
  760 + $scope.cancelarEditar = function(articulo) {
  761 + $scope.tmpCantidad = articulo.cantidad;
  762 + $scope.tmpPrecio = articulo.precio;
  763 + articulo.editCantidad = articulo.editPrecio = false;
  764 + };
753 765  
754 766 $scope.cambioEdit = function(articulo, propiedad) {
755 767 if (propiedad === 'cantidad') {
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"
72   - ng-model="articulo.cantidad"
  72 + ng-model="tmpCantidad"
73 73 class="form-control"
74 74 foca-tipo-input
75 75 min="1"
76   - step="0.001"
77 76 foca-focus="articulo.editCantidad"
78   - ng-keypress="editarArticulo($event.keyCode, articulo)"
79   - ng-focus="selectFocus($event)"
  77 + ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);"
  78 + esc-key="cancelarEditar(articulo)"
  79 + ng-focus="selectFocus($event);
  80 + tmpCantidad = articulo.cantidad;
  81 + tmpPrecio = articulo.precio"
80 82 teclado-virtual
81 83 >
82 84 <i
... ... @@ -89,22 +91,24 @@
89 91 <td class="col text-right">
90 92 <input
91 93 ng-show="articulo.editPrecio"
92   - ng-model="articulo.precio"
  94 + ng-model="tmpPrecio"
93 95 class="form-control"
94 96 foca-tipo-input
95   - min="0"
  97 + min="1"
96 98 step="0.0001"
97 99 foca-focus="articulo.editPrecio"
98   - ng-keypress="editarArticulo($event.keyCode, articulo)"
99   - ng-focus="selectFocus($event)"
  100 + ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);"
  101 + esc-key="cancelarEditar(articulo)"
  102 + ng-focus="selectFocus($event);
  103 + tmpCantidad = articulo.cantidad;
  104 + tmpPrecio = articulo.precio"
100 105 teclado-virtual
101 106 >
102 107 <i
103 108 class="selectable"
104   - ng-click="idLista == -1 && cambioEdit(articulo, 'precio')"
  109 + ng-click="cambioEdit(articulo, 'precio')"
105 110 ng-hide="articulo.editPrecio"
106   - ng-bind="articulo.precio |
107   - number: 4">
  111 + ng-bind="articulo.precio | number: 4">
108 112 </i>
109 113 </td>
110 114 <td