Commit 59965646b6883095c5640d7d8b9559ac5f8f96fa
Exists in
master
Merge branch 'master' into 'master'
Nueva versión de modal See merge request modulos-npm/foca-modal-vendedores!8
Showing
4 changed files
Show diff stats
package.json
... | ... | @@ -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,7 +51,7 @@ |
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", |
src/js/controller.js
... | ... | @@ -5,13 +5,10 @@ angular.module('focaModalVendedores') |
5 | 5 | '$uibModalInstance', |
6 | 6 | 'focaVendedoresService', |
7 | 7 | function($filter, $scope, $uibModalInstance, focaVendedoresService) { |
8 | - focaVendedoresService.getVendedores().then( | |
9 | - function(res) { | |
10 | - $scope.vendedores = res.data; | |
11 | - $scope.search(); | |
12 | - } | |
13 | - ); | |
14 | 8 | |
9 | + $scope.filters = ''; | |
10 | + $scope.vendedores = []; | |
11 | + $scope.primerBusqueda = false; | |
15 | 12 | // pagination |
16 | 13 | $scope.numPerPage = 10; |
17 | 14 | $scope.currentPage = 1; |
... | ... | @@ -19,16 +16,29 @@ angular.module('focaModalVendedores') |
19 | 16 | $scope.currentPageVendedores = []; |
20 | 17 | $scope.selectedVendedor = -1; |
21 | 18 | |
19 | + $scope.busquedaPress = function(key) { | |
20 | + if (key === 13) { | |
21 | + $scope.primerBusqueda = true; | |
22 | + focaVendedoresService.getVendedores($scope.filters).then( | |
23 | + function(res) { | |
24 | + $scope.vendedores = res.data; | |
25 | + $scope.search(); | |
26 | + primera(); | |
27 | + } | |
28 | + ); | |
29 | + } | |
30 | + }; | |
31 | + | |
22 | 32 | $scope.search = function() { |
23 | - $scope.filteredVendedores = $filter('filter')( | |
33 | + if($scope.vendedores.length > 0) { | |
34 | + $scope.filteredVendedores = $filter('filter')( | |
24 | 35 | $scope.vendedores, { $: $scope.filters } |
25 | - ); | |
26 | - | |
27 | - $scope.lastPage = Math.ceil( | |
28 | - $scope.filteredVendedores.length / $scope.numPerPage | |
29 | - ); | |
30 | - | |
31 | - $scope.resetPage(); | |
36 | + ); | |
37 | + $scope.lastPage = Math.ceil( | |
38 | + $scope.filteredVendedores.length / $scope.numPerPage | |
39 | + ); | |
40 | + $scope.resetPage(); | |
41 | + } | |
32 | 42 | }; |
33 | 43 | |
34 | 44 | $scope.resetPage = function() { |
... | ... | @@ -59,12 +69,6 @@ angular.module('focaModalVendedores') |
59 | 69 | } |
60 | 70 | }; |
61 | 71 | |
62 | - $scope.busquedaPress = function(key) { | |
63 | - if (key === 13) { | |
64 | - primera(key); | |
65 | - } | |
66 | - }; | |
67 | - | |
68 | 72 | $scope.itemVendedor = function(key) { |
69 | 73 | if (key === 38) { |
70 | 74 | anterior(key); |
src/js/service.js
1 | 1 | angular.module('focaModalVendedores') |
2 | 2 | .service('focaVendedoresService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { |
3 | 3 | return { |
4 | - getVendedores: function() { | |
4 | + getVendedores: function(filters) { | |
5 | 5 | // TODO ACOMODAR PARA TURNOS AHORA 1 HARDCODEO |
6 | - return $http.get(API_ENDPOINT.URL + '/vendedores/1'); | |
6 | + return $http.post(API_ENDPOINT.URL + '/vendedores', {nombre: filters}); | |
7 | 7 | } |
8 | 8 | }; |
9 | 9 | }]); |
src/views/modal-vendedores.html
... | ... | @@ -14,65 +14,78 @@ |
14 | 14 | foca-focus="selectedVendedor == -1" |
15 | 15 | ng-focus="selectedVendedor = -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></th> | |
23 | - </tr> | |
24 | - </thead> | |
25 | - <tbody> | |
26 | - <tr class="selected" | |
27 | - ng-repeat="(key, vendedor) in currentPageVendedores" | |
28 | - ng-click="select(vendedor)"> | |
29 | - <td ng-bind="vendedor.CodVen"></td> | |
30 | - <td ng-bind="vendedor.NomVen"></td> | |
31 | - <td> | |
32 | - <button | |
33 | - type="button" | |
34 | - class="btn btn-xs p-1 float-right" | |
35 | - ng-class="{ | |
36 | - 'btn-secondary': selectedVendedor != key, | |
37 | - 'btn-primary': selectedVendedor == key | |
38 | - }" | |
39 | - foca-focus="selectedVendedor == {{key}}" | |
40 | - ng-keydown="itemVendedor($event.keyCode)"> | |
41 | - <i class="fa fa-arrow-right" aria-hidden="true"></i> | |
42 | - </button> | |
43 | - </td> | |
44 | - </tr> | |
45 | - </tbody> | |
46 | - </table> | |
47 | - <nav> | |
48 | - <ul class="pagination pagination-sm justify-content-end mb-0"> | |
49 | - <li class="page-item" ng-class="{'disabled': currentPage == 1}"> | |
50 | - <a class="page-link" href="#" ng-click="selectPage(currentPage - 1)"> | |
51 | - <span aria-hidden="true">«</span> | |
52 | - <span class="sr-only">Anterior</span> | |
53 | - </a> | |
54 | - </li> | |
55 | - <li | |
56 | - class="page-item" | |
57 | - ng-repeat="pagina in paginas" | |
58 | - ng-class="{'active': pagina == currentPage}" | |
59 | - > | |
60 | - <a | |
61 | - class="page-link" | |
62 | - href="#" | |
63 | - ng-click="selectPage(pagina)" | |
64 | - ng-bind="pagina" | |
65 | - ></a> | |
66 | - </li> | |
67 | - <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> | |
68 | - <a class="page-link" href="#" ng-click="selectPage(currentPage + 1)"> | |
69 | - <span aria-hidden="true">»</span> | |
70 | - <span class="sr-only">Siguiente</span> | |
71 | - </a> | |
72 | - </li> | |
73 | - </ul> | |
74 | - </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> | |
21 | + </div> | |
75 | 22 | </div> |
23 | + <table ng-show="primerBusqueda" class="table table-striped table-sm col-12"> | |
24 | + <thead> | |
25 | + <tr> | |
26 | + <th>Código</th> | |
27 | + <th>Nombre</th> | |
28 | + <th></th> | |
29 | + </tr> | |
30 | + </thead> | |
31 | + <tbody> | |
32 | + <tr ng-show="currentPageVendedores.length == 0"> | |
33 | + <td colspan="3"> | |
34 | + No se encontraron resultados. | |
35 | + </td> | |
36 | + </tr> | |
37 | + <tr class="selected" | |
38 | + ng-repeat="(key, vendedor) in currentPageVendedores" | |
39 | + ng-click="select(vendedor)" | |
40 | + > | |
41 | + <td ng-bind="vendedor.CodVen"></td> | |
42 | + <td ng-bind="vendedor.NomVen"></td> | |
43 | + <td> | |
44 | + <button | |
45 | + type="button" | |
46 | + class="btn btn-xs p-1 float-right" | |
47 | + ng-class="{ | |
48 | + 'btn-secondary': selectedVendedor != key, | |
49 | + 'btn-primary': selectedVendedor == key | |
50 | + }" | |
51 | + foca-focus="selectedVendedor == {{key}}" | |
52 | + ng-keydown="itemVendedor($event.keyCode)"> | |
53 | + <i class="fa fa-arrow-right" aria-hidden="true"></i> | |
54 | + </button> | |
55 | + </td> | |
56 | + </tr> | |
57 | + </tbody> | |
58 | + </table> | |
59 | + <nav ng-show="currentPageVendedores.length > 0 && primerBusqueda"> | |
60 | + <ul class="pagination pagination-sm justify-content mb-0"> | |
61 | + <li class="page-item" ng-class="{'disabled': currentPage == 1}"> | |
62 | + <a class="page-link" href="#" ng-click="selectPage(currentPage - 1)"> | |
63 | + <span aria-hidden="true">«</span> | |
64 | + <span class="sr-only">Anterior</span> | |
65 | + </a> | |
66 | + </li> | |
67 | + <li | |
68 | + class="page-item" | |
69 | + ng-repeat="pagina in paginas" | |
70 | + ng-class="{'active': pagina == currentPage}" | |
71 | + > | |
72 | + <a | |
73 | + class="page-link" | |
74 | + href="#" | |
75 | + ng-click="selectPage(pagina)" | |
76 | + ng-bind="pagina" | |
77 | + ></a> | |
78 | + </li> | |
79 | + <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> | |
80 | + <a class="page-link" href="#" ng-click="selectPage(currentPage + 1)"> | |
81 | + <span aria-hidden="true">»</span> | |
82 | + <span class="sr-only">Siguiente</span> | |
83 | + </a> | |
84 | + </li> | |
85 | + </ul> | |
86 | + </nav> | |
87 | + | |
88 | + | |
76 | 89 | </div> |
77 | 90 | <div class="modal-footer py-1"> |
78 | 91 | <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> |