Commit 02ce8ad9fb57f0a555aa103d76eb62ff1e0a0465

Authored by Eric Fernandez
1 parent fab780a800
Exists in master and in 1 other branch develop

selección múltiple de items

validación que elija al menos un item
src/js/controller.js
... ... @@ -48,6 +48,17 @@ angular.module('focaModalFactura')
48 48 .then(llenarDatos);
49 49 }
50 50 };
  51 +
  52 + $scope.aceptar = function() {
  53 + var result = $scope.facturas.filter(function(a) {return a.checked === true;});
  54 + $uibModalInstance.close(result);
  55 + };
  56 +
  57 + $scope.tieneAlMenosUno = function() {
  58 + var result = $scope.facturas.filter(function(a) {return a.checked === true;});
  59 + return result.length === 0 ? true : false;
  60 + };
  61 +
51 62 function llenarDatos(res) {
52 63 $scope.facturas = [];
53 64 $scope.filteredFacturas = [];
... ... @@ -88,10 +99,6 @@ angular.module('focaModalFactura')
88 99 $scope.currentPage = page;
89 100 };
90 101  
91   - $scope.select = function(notaPedido) {
92   - $uibModalInstance.close(notaPedido);
93   - };
94   -
95 102 $scope.cancel = function() {
96 103 $uibModalInstance.dismiss('cancel');
97 104 };
... ... @@ -102,7 +109,7 @@ angular.module('focaModalFactura')
102 109 }
103 110 };
104 111  
105   - $scope.itemNotaPedido = function(key) {
  112 + $scope.itemFactura = function(key) {
106 113 if (key === 38) {
107 114 anterior(key);
108 115 }
src/views/foca-modal-factura.html
... ... @@ -80,27 +80,21 @@
80 80 </td>
81 81 </tr>
82 82 <tr class="selectable"
83   - ng-repeat="(key,factura) in currentPageFacturas"
84   - ng-click="select(factura)">
  83 + ng-repeat="(key,factura) in currentPageFacturas">
85 84 <td ng-bind="factura.cliente.NOM"></td>
86 85 <td ng-bind="factura.FEP | date : 'dd/MM/yyyy'"></td>
87 86 <td ng-bind=
88 87 "(factura.TCO + '-' + factura.TIP + '-' + factura.SUC + '-' + factura.NCO)">
89 88 </td>
90   - <td ng-bind="factura.IPA"></td>
91   - <td>
92   - <button
93   - type="button"
94   - class="btn btn-xs p-1 float-right"
  89 + <td class="text-right" ng-bind="factura.IPA | currency:'$'"></td>
  90 + <td><input
95 91 ng-class="{
96   - 'btn-secondary': selectedFactura != key,
97   - 'btn-primary': selectedFactura == key
98   - }"
  92 + 'btn-secondary': selectedFactura != key,
  93 + 'btn-primary': selectedFactura == key}"
  94 + ng-keydown="itemFactura($event.keyCode)"
99 95 foca-focus="selectedFactura == {{key}}"
100   - ng-keydown="itemNotaPedido($event.keyCode)"
101   - >
102   - <i class="fa fa-arrow-right" aria-hidden="true"></i>
103   - </button>
  96 + type="checkbox"
  97 + ng-model="factura.checked"/>
104 98 </td>
105 99 </tr>
106 100 </tbody>
... ... @@ -136,4 +130,10 @@
136 130 </div>
137 131 <div class="modal-footer py-1">
138 132 <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button>
  133 + <button
  134 + class="btn btn-sm btn-primary"
  135 + type="button"
  136 + ng-click="aceptar()"
  137 + ng-disabled="tieneAlMenosUno()"
  138 + >Aceptar</button>
139 139 </div>