Commit a77444589c8fdb71427636af1458aa1e32ca4d47
1 parent
d0de59b66f
Exists in
master
primer búsqueda al presionar enter
Showing
4 changed files
with
108 additions
and
92 deletions
Show diff stats
index.html
package.json
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | "gulp-pre-commit": "gulp pre-commit", |
8 | 8 | "compile": "gulp uglify", |
9 | 9 | "postinstall": "npm run compile && gulp clean-post-install", |
10 | - "install-dev": "npm install angular bootstrap jquery font-awesome gulp gulp-concat gulp-jshint gulp-rename gulp-replace gulp-uglify-es gulp-clean jshint pump gulp-connect gulp-uglify jasmine-core pre-commit gulp-angular-templatecache ui-bootstrap4 git+https://debo.suite.repo/modulos-npm/foca-directivas" | |
10 | + "install-dev": "npm install angular bootstrap jquery font-awesome gulp gulp-concat gulp-jshint gulp-rename gulp-replace gulp-uglify-es gulp-clean jshint pump gulp-connect gulp-uglify jasmine-core pre-commit gulp-angular-templatecache ui-bootstrap4 gulp-htmlmin git+https://debo.suite.repo/modulos-npm/foca-directivas" | |
11 | 11 | }, |
12 | 12 | "pre-commit": [ |
13 | 13 | "gulp-pre-commit" |
... | ... | @@ -42,7 +42,7 @@ |
42 | 42 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas", |
43 | 43 | "font-awesome": "^4.7.0", |
44 | 44 | "gulp": "^3.9.1", |
45 | - "gulp-angular-templatecache": "^2.2.1", | |
45 | + "gulp-angular-templatecache": "^2.2.3", | |
46 | 46 | "gulp-clean": "^0.4.0", |
47 | 47 | "gulp-concat": "^2.6.1", |
48 | 48 | "gulp-connect": "^5.6.1", |
... | ... | @@ -51,11 +51,14 @@ |
51 | 51 | "gulp-rename": "^1.4.0", |
52 | 52 | "gulp-replace": "^1.0.0", |
53 | 53 | "gulp-uglify": "^3.0.1", |
54 | - "jasmine-core": "^3.2.1", | |
54 | + "jasmine-core": "^3.3.0", | |
55 | 55 | "jquery": "^3.3.1", |
56 | 56 | "jshint": "^2.9.6", |
57 | 57 | "pre-commit": "^1.2.2", |
58 | 58 | "pump": "^3.0.0", |
59 | 59 | "ui-bootstrap4": "^3.0.5" |
60 | + }, | |
61 | + "dependencies": { | |
62 | + "gulp-uglify-es": "^1.0.4" | |
60 | 63 | } |
61 | 64 | } |
src/js/controller.js
... | ... | @@ -5,20 +5,9 @@ angular.module('focaModalProveedor') |
5 | 5 | '$uibModalInstance', |
6 | 6 | 'focaModalProveedorService', |
7 | 7 | function ($filter, $scope, $uibModalInstance, focaModalProveedorService) { |
8 | - var json = {razonCuitCod: ''}; | |
9 | - | |
10 | - focaModalProveedorService.getProveedores(json).then( | |
11 | - function (res) { | |
12 | - for (var i = res.data.length - 1; i >= 0; i--) { | |
13 | - if (res.data[i].COD === 0) { | |
14 | - delete res.data[i]; | |
15 | - } | |
16 | - } | |
17 | - | |
18 | - $scope.proveedores = res.data; | |
19 | - $scope.search(); | |
20 | - }); | |
21 | 8 | |
9 | + $scope.filters = ''; | |
10 | + $scope.primerBusqueda = false; | |
22 | 11 | // pagination |
23 | 12 | $scope.numPerPage = 10; |
24 | 13 | $scope.currentPage = 1; |
... | ... | @@ -26,6 +15,26 @@ angular.module('focaModalProveedor') |
26 | 15 | $scope.currentPageProveedores = []; |
27 | 16 | $scope.selectedProveedores = -1; |
28 | 17 | |
18 | + $scope.busquedaPress = function(key) { | |
19 | + if (key === 13) { | |
20 | + var json = { | |
21 | + razonCuitCod: $scope.filters | |
22 | + }; | |
23 | + focaModalProveedorService.getProveedores(json).then( | |
24 | + function (res) { | |
25 | + for (var i = res.data.length - 1; i >= 0; i--) { | |
26 | + if (res.data[i].COD === 0) { | |
27 | + delete res.data[i]; | |
28 | + } | |
29 | + } | |
30 | + $scope.primerBusqueda = true; | |
31 | + $scope.proveedores = res.data; | |
32 | + $scope.search(); | |
33 | + primera(); | |
34 | + }); | |
35 | + } | |
36 | + }; | |
37 | + | |
29 | 38 | $scope.search = function () { |
30 | 39 | $scope.filteredProveedores = $filter('filter')( |
31 | 40 | $scope.proveedores, {$: $scope.filters} |
... | ... | @@ -67,12 +76,6 @@ angular.module('focaModalProveedor') |
67 | 76 | } |
68 | 77 | }; |
69 | 78 | |
70 | - $scope.busquedaPress = function(key) { | |
71 | - if (key === 13) { | |
72 | - primera(key); | |
73 | - } | |
74 | - }; | |
75 | - | |
76 | 79 | $scope.itemProveedor = function(key) { |
77 | 80 | if (key === 38) { |
78 | 81 | anterior(key); |
src/views/modal-proveedor.html
... | ... | @@ -3,82 +3,92 @@ |
3 | 3 | </div> |
4 | 4 | <div class="modal-body" id="modal-body"> |
5 | 5 | <div class="input-group"> |
6 | - <input | |
7 | - type="text" | |
8 | - class="form-control" | |
9 | - placeholder="Busqueda" | |
10 | - ng-model="filters" | |
11 | - ng-change="search()" | |
6 | + <input | |
7 | + type="text" | |
8 | + class="form-control" | |
9 | + placeholder="Busqueda" | |
10 | + ng-model="filters" | |
11 | + ng-change="search()" | |
12 | 12 | ng-keydown="busquedaDown($event.keyCode)" |
13 | 13 | ng-keypress="busquedaPress($event.keyCode)" |
14 | 14 | foca-focus="selectedProveedores == -1" |
15 | 15 | ng-focus="selectedProveedores = -1" |
16 | 16 | > |
17 | - <table class="table table-striped table-sm"> | |
18 | - <thead> | |
19 | - <tr> | |
20 | - <th>Código</th> | |
21 | - <th>Nombre</th> | |
22 | - <th>CUIT</th> | |
23 | - <th></th> | |
24 | - </tr> | |
25 | - </thead> | |
26 | - <tbody> | |
27 | - <tr | |
28 | - class="selectable" | |
29 | - ng-repeat="(key, proveedor) in currentPageProveedores" | |
30 | - ng-click="select(proveedor)"> | |
31 | - <td ng-bind="proveedor.COD"></td> | |
32 | - <td ng-bind="proveedor.NOM"></td> | |
33 | - <td ng-bind="proveedor.CUIT"></td> | |
34 | - <td> | |
35 | - <button | |
36 | - type="button" | |
37 | - class="btn btn-xs p-1 float-right" | |
38 | - ng-class="{ | |
39 | - 'btn-secondary': selectedProveedores != key, | |
40 | - 'btn-primary': selectedProveedores == key | |
41 | - }" | |
42 | - ng-click="select(proveedor)" | |
43 | - foca-focus="selectedProveedores == {{key}}" | |
44 | - ng-keydown="itemProveedor($event.keyCode)" | |
45 | - > | |
46 | - <i class="fa fa-arrow-right" aria-hidden="true"></i> | |
47 | - </button> | |
48 | - </td> | |
49 | - </tr> | |
50 | - </tbody> | |
51 | - </table> | |
52 | - <nav> | |
53 | - <ul class="pagination pagination-sm justify-content-end mb-0"> | |
54 | - <li class="page-item" ng-class="{'disabled': currentPage == 1}"> | |
55 | - <a class="page-link" href="#" ng-click="selectPage(currentPage - 1)"> | |
56 | - <span aria-hidden="true">«</span> | |
57 | - <span class="sr-only">Anterior</span> | |
58 | - </a> | |
59 | - </li> | |
60 | - <li | |
61 | - class="page-item" | |
62 | - ng-repeat="pagina in paginas" | |
63 | - ng-class="{'active': pagina == currentPage}" | |
64 | - > | |
65 | - <a | |
66 | - class="page-link" | |
67 | - href="#" | |
68 | - ng-click="selectPage(pagina)" | |
69 | - ng-bind="pagina" | |
70 | - ></a> | |
71 | - </li> | |
72 | - <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> | |
73 | - <a class="page-link" href="#" ng-click="selectPage(currentPage + 1)"> | |
74 | - <span aria-hidden="true">»</span> | |
75 | - <span class="sr-only">Siguiente</span> | |
76 | - </a> | |
77 | - </li> | |
78 | - </ul> | |
79 | - </nav> | |
17 | + <div class="input-group-append"> | |
18 | + <button class="btn btn-outline-secondary" type="button" ng-click="busquedaPress(13)"> | |
19 | + <i class="fa fa-search" aria-hidden="true"></i> | |
20 | + </button> | |
80 | 21 | </div> |
81 | 22 | </div> |
23 | + <table ng-show="primerBusqueda" class="table table-striped table-sm"> | |
24 | + <thead> | |
25 | + <tr> | |
26 | + <th>Código</th> | |
27 | + <th>Nombre</th> | |
28 | + <th>CUIT</th> | |
29 | + <th></th> | |
30 | + </tr> | |
31 | + </thead> | |
32 | + <tbody> | |
33 | + <tr ng-show="currentPageProveedores.length == 0 && primerBusqueda"> | |
34 | + <td colspan="4"> | |
35 | + No se encontraron resultados. | |
36 | + </td> | |
37 | + </tr> | |
38 | + <tr | |
39 | + class="selectable" | |
40 | + ng-repeat="(key, proveedor) in currentPageProveedores" | |
41 | + ng-click="select(proveedor)"> | |
42 | + <td ng-bind="proveedor.COD"></td> | |
43 | + <td ng-bind="proveedor.NOM"></td> | |
44 | + <td ng-bind="proveedor.CUIT"></td> | |
45 | + <td> | |
46 | + <button | |
47 | + type="button" | |
48 | + class="btn btn-xs p-1 float-right" | |
49 | + ng-class="{ | |
50 | + 'btn-secondary': selectedProveedores != key, | |
51 | + 'btn-primary': selectedProveedores == key | |
52 | + }" | |
53 | + ng-click="select(proveedor)" | |
54 | + foca-focus="selectedProveedores == {{key}}" | |
55 | + ng-keydown="itemProveedor($event.keyCode)" | |
56 | + > | |
57 | + <i class="fa fa-arrow-right" aria-hidden="true"></i> | |
58 | + </button> | |
59 | + </td> | |
60 | + </tr> | |
61 | + </tbody> | |
62 | + </table> | |
63 | + <nav ng-show="currentPageProveedores.length > 0 && primerBusqueda"> | |
64 | + <ul class="pagination pagination-sm mb-0"> | |
65 | + <li class="page-item" ng-class="{'disabled': currentPage == 1}"> | |
66 | + <a class="page-link" href="#" ng-click="selectPage(currentPage - 1)"> | |
67 | + <span aria-hidden="true">«</span> | |
68 | + <span class="sr-only">Anterior</span> | |
69 | + </a> | |
70 | + </li> | |
71 | + <li | |
72 | + class="page-item" | |
73 | + ng-repeat="pagina in paginas" | |
74 | + ng-class="{'active': pagina == currentPage}" | |
75 | + > | |
76 | + <a | |
77 | + class="page-link" | |
78 | + href="#" | |
79 | + ng-click="selectPage(pagina)" | |
80 | + ng-bind="pagina" | |
81 | + ></a> | |
82 | + </li> | |
83 | + <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> | |
84 | + <a class="page-link" href="#" ng-click="selectPage(currentPage + 1)"> | |
85 | + <span aria-hidden="true">»</span> | |
86 | + <span class="sr-only">Siguiente</span> | |
87 | + </a> | |
88 | + </li> | |
89 | + </ul> | |
90 | + </nav> | |
91 | +</div> | |
82 | 92 | <div class="modal-footer py-1"> |
83 | 93 | <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> |
84 | 94 | </div> |