Commit 667901cd86229e64d1fdb3f64d8ce7c1ba6b5e8d
1 parent
c57af58f8e
Exists in
master
Nueva versión de modal
Showing
4 changed files
with
60 additions
and
37 deletions
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,30 +5,51 @@ 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 | - | |
| 15 | 8 | // pagination |
| 9 | + $scope.filters = ''; | |
| 16 | 10 | $scope.numPerPage = 10; |
| 17 | 11 | $scope.currentPage = 1; |
| 18 | 12 | $scope.filteredVendedores = []; |
| 19 | 13 | $scope.currentPageVendedores = []; |
| 20 | 14 | $scope.selectedVendedor = -1; |
| 21 | 15 | |
| 16 | + $scope.busquedaPress = function(key) { | |
| 17 | + if (key === 13) { | |
| 18 | + focaVendedoresService.getVendedores($scope.filters).then( | |
| 19 | + function(res) { | |
| 20 | + $scope.vendedores = res.data; | |
| 21 | + if(res.data.length === 0) { | |
| 22 | + $scope.conResultados = false; | |
| 23 | + $scope.sinResultados = true; | |
| 24 | + } else { | |
| 25 | + $scope.conResultados = true; | |
| 26 | + $scope.sinResultados = false; | |
| 27 | + $scope.search(); | |
| 28 | + primera(); | |
| 29 | + } | |
| 30 | + } | |
| 31 | + ); | |
| 32 | + } | |
| 33 | + }; | |
| 34 | + | |
| 22 | 35 | $scope.search = function() { |
| 23 | - $scope.filteredVendedores = $filter('filter')( | |
| 24 | - $scope.vendedores, { $: $scope.filters } | |
| 25 | - ); | |
| 26 | - | |
| 27 | - $scope.lastPage = Math.ceil( | |
| 28 | - $scope.filteredVendedores.length / $scope.numPerPage | |
| 29 | - ); | |
| 30 | - | |
| 31 | - $scope.resetPage(); | |
| 36 | + if($scope.vendedores) { | |
| 37 | + $scope.filteredVendedores = $filter('filter')( | |
| 38 | + $scope.vendedores, { $: $scope.filters } | |
| 39 | + ); | |
| 40 | + if($scope.filteredVendedores.length === 0) { | |
| 41 | + $scope.sinResultados = true; | |
| 42 | + $scope.conResultados = false; | |
| 43 | + } else { | |
| 44 | + $scope.sinResultados = false; | |
| 45 | + $scope.conResultados = true; | |
| 46 | + } | |
| 47 | + $scope.lastPage = Math.ceil( | |
| 48 | + $scope.filteredVendedores.length / $scope.numPerPage | |
| 49 | + ); | |
| 50 | + | |
| 51 | + $scope.resetPage(); | |
| 52 | + } | |
| 32 | 53 | }; |
| 33 | 54 | |
| 34 | 55 | $scope.resetPage = function() { |
| ... | ... | @@ -59,12 +80,6 @@ angular.module('focaModalVendedores') |
| 59 | 80 | } |
| 60 | 81 | }; |
| 61 | 82 | |
| 62 | - $scope.busquedaPress = function(key) { | |
| 63 | - if (key === 13) { | |
| 64 | - primera(key); | |
| 65 | - } | |
| 66 | - }; | |
| 67 | - | |
| 68 | 83 | $scope.itemVendedor = function(key) { |
| 69 | 84 | if (key === 38) { |
| 70 | 85 | 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
| ... | ... | @@ -4,17 +4,22 @@ |
| 4 | 4 | <div class="modal-body" id="modal-body"> |
| 5 | 5 | <div class="input-group mb-3"> |
| 6 | 6 | <input |
| 7 | - type="text" | |
| 8 | - class="form-control" | |
| 9 | - placeholder="Busqueda" | |
| 10 | - ng-model="filters" | |
| 7 | + type="text" | |
| 8 | + class="form-control" | |
| 9 | + placeholder="Busqueda" | |
| 10 | + ng-model="filters" | |
| 11 | 11 | ng-change="search()" |
| 12 | 12 | ng-keydown="busquedaDown($event.keyCode)" |
| 13 | 13 | ng-keypress="busquedaPress($event.keyCode)" |
| 14 | 14 | foca-focus="selectedVendedor == -1" |
| 15 | 15 | ng-focus="selectedVendedor = -1" |
| 16 | 16 | > |
| 17 | - <table class="table table-striped table-sm"> | |
| 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> | |
| 22 | + <table ng-show="conResultados" class="table table-striped table-sm"> | |
| 18 | 23 | <thead> |
| 19 | 24 | <tr> |
| 20 | 25 | <th>Código</th> |
| ... | ... | @@ -29,7 +34,7 @@ |
| 29 | 34 | <td ng-bind="vendedor.CodVen"></td> |
| 30 | 35 | <td ng-bind="vendedor.NomVen"></td> |
| 31 | 36 | <td> |
| 32 | - <button | |
| 37 | + <button | |
| 33 | 38 | type="button" |
| 34 | 39 | class="btn p-2 float-right" |
| 35 | 40 | ng-class="{ |
| ... | ... | @@ -44,7 +49,7 @@ |
| 44 | 49 | </tr> |
| 45 | 50 | </tbody> |
| 46 | 51 | </table> |
| 47 | - <nav> | |
| 52 | + <nav ng-show="conResultados"> | |
| 48 | 53 | <ul class="pagination justify-content-end"> |
| 49 | 54 | <li class="page-item" ng-class="{'disabled': currentPage == 1}"> |
| 50 | 55 | <a class="page-link" href="#" ng-click="selectPage(currentPage - 1)"> |
| ... | ... | @@ -52,14 +57,14 @@ |
| 52 | 57 | <span class="sr-only">Anterior</span> |
| 53 | 58 | </a> |
| 54 | 59 | </li> |
| 55 | - <li | |
| 60 | + <li | |
| 56 | 61 | class="page-item" |
| 57 | 62 | ng-repeat="pagina in paginas" |
| 58 | 63 | ng-class="{'active': pagina == currentPage}" |
| 59 | 64 | > |
| 60 | 65 | <a |
| 61 | - class="page-link" | |
| 62 | - href="#" | |
| 66 | + class="page-link" | |
| 67 | + href="#" | |
| 63 | 68 | ng-click="selectPage(pagina)" |
| 64 | 69 | ng-bind="pagina" |
| 65 | 70 | ></a> |
| ... | ... | @@ -73,7 +78,10 @@ |
| 73 | 78 | </ul> |
| 74 | 79 | </nav> |
| 75 | 80 | </div> |
| 81 | + <div ng-show="sinResultados"> | |
| 82 | + <i class="fa fa-minus"></i> No se encontraron resultados. | |
| 83 | + </div> | |
| 76 | 84 | </div> |
| 77 | 85 | <div class="modal-footer"> |
| 78 | 86 | <button class="btn btn-secondary" type="button" ng-click="cancel()">Cancelar</button> |
| 79 | -</div> | |
| 80 | 87 | \ No newline at end of file |
| 88 | +</div> |