Commit 143d90331839e5fb09e8c109001bd4b13c995547

Authored by Luigi
1 parent 5570c2fa3e
Exists in master and in 1 other branch develop

Revert "Paginacion"

This reverts commit 5570c2fa3ec91516d4d74d8bac7e34b73b4e8799.
src/js/controller.js
... ... @@ -9,7 +9,10 @@ angular.module('focaBusquedaCliente')
9 9 $scope.filters = '';
10 10 $scope.primerBusqueda = false;
11 11 // pagination
  12 + $scope.numPerPage = 10;
12 13 $scope.currentPage = 1;
  14 + $scope.filteredClientes = [];
  15 + $scope.currentPageClientes = [];
13 16 $scope.selectedClientes = -1;
14 17 $scope.ingreso = false;
15 18 $scope.regexCuit = new RegExp(/\b(20|23|24|27|30|33|34)(\D)?[0-9]{8}(\D)?[0-9]/g);
... ... @@ -57,11 +60,8 @@ angular.module('focaBusquedaCliente')
57 60 [funcion]($scope.filters, $scope.vendedor.id)
58 61 .then(
59 62 function(res) {
60   - console.log(res);
61 63 $scope.primerBusqueda = true;
62   - $scope.clientes = res.data.clientes;
63   - $scope.lastPage = res.data.cantidadPaginas;
64   - calcularPages();
  64 + $scope.clientes = res.data;
65 65 $scope.search(true);
66 66 primera();
67 67 $scope.searchLoading = false;
... ... @@ -81,6 +81,11 @@ angular.module('focaBusquedaCliente')
81 81 $scope.filters = '';
82 82 });
83 83 }
  84 +
  85 + $scope.lastPage = Math.ceil(
  86 + $scope.filteredClientes.length / $scope.numPerPage
  87 + );
  88 +
84 89 $scope.resetPage();
85 90 }
86 91 };
... ... @@ -94,7 +99,7 @@ angular.module('focaBusquedaCliente')
94 99 var start = (page - 1) * $scope.numPerPage;
95 100 var end = start + $scope.numPerPage;
96 101 $scope.paginas = [];
97   - $scope.paginas = calcularPages();
  102 + $scope.paginas = calcularPages(page);
98 103 $scope.currentPageClientes = $scope.filteredClientes.slice(start, end);
99 104 $scope.currentPage = page;
100 105 };
... ... @@ -493,12 +498,9 @@ angular.module('focaBusquedaCliente')
493 498 });
494 499 };
495 500  
496   -
497   -
498   - function calcularPages() {
  501 + function calcularPages(paginaActual) {
499 502 var paginas = [];
500   - var paginaActual = $scope.currentPage;
501   - paginas.push(paginaActual);
  503 + paginas.push(paginaActual);
502 504  
503 505 if (paginaActual - 1 > 1) {
504 506  
... ... @@ -527,7 +529,7 @@ angular.module('focaBusquedaCliente')
527 529 }
528 530  
529 531 function primera() {
530   - $scope.selectedClientes = 0;
  532 + $scope.selectedClientes = 0;
531 533 }
532 534  
533 535 function anterior() {
... ... @@ -538,11 +540,11 @@ angular.module('focaBusquedaCliente')
538 540 }
539 541 }
540 542  
541   - function siguiente() {
  543 + function siguiente() {
542 544 if ($scope.selectedClientes < $scope.currentPageClientes.length - 1 ) {
543 545 $scope.selectedClientes++;
544 546 } else {
545   - avanzarPagina();
  547 + avanzarPagina();
546 548 }
547 549 }
548 550  
src/views/foca-busqueda-cliente-modal.html
... ... @@ -66,18 +66,18 @@
66 66 </tr>
67 67 </thead>
68 68 <tbody>
69   - <tr ng-show="clientes.length == 0 && primerBusqueda">
  69 + <tr ng-show="currentPageClientes.length == 0 && primerBusqueda">
70 70 <td colspan="4">
71 71 No se encontraron resultados.
72 72 </td>
73 73 </tr>
74 74 <tr
75 75 class="selectable"
76   - ng-repeat="(key, cliente) in clientes"
  76 + ng-repeat="(key, cliente) in currentPageClientes"
77 77 ng-click="select(cliente)">
78   - <td ng-bind="('00000'+cliente.COD).slice(-5)"></td>
79   - <td ng-bind="cliente.NOM"></td>
80   - <td ng-bind="cliente.CUIT"></td>
  78 + <td ng-bind="('00000'+cliente.cod).slice(-5)"></td>
  79 + <td ng-bind="cliente.nom"></td>
  80 + <td ng-bind="cliente.cuit"></td>
81 81 <td>
82 82 <button
83 83 type="button"
... ... @@ -444,7 +444,7 @@
444 444 </form>
445 445 </div>
446 446 <div class="modal-footer py-1">
447   - <nav ng-show="clientes.length > 0 && primerBusqueda && !ingreso" class="mr-auto">
  447 + <nav ng-show="currentPageClientes.length > 0 && primerBusqueda && !ingreso" class="mr-auto">
448 448 <ul class="pagination pagination-sm mb-0">
449 449 <li class="page-item" ng-class="{'disabled': currentPage == 1}">
450 450 <a class="page-link" href="javascript:void()" ng-click="selectPage(currentPage - 1)">