Commit ae8735fb11040d73fda02855469c1f8c99021047
Exists in
master
Merge branch 'master' into 'master'
buscador en header, paginacion en footer, cambio icons, focus input cuando no hay resultados See merge request !2
Showing
2 changed files
Show diff stats
src/js/controller.js
| 1 | 1 | angular.module('focaModalBanco') |
| 2 | 2 | .controller('focaModalBancoController', [ |
| 3 | + '$timeout', | |
| 3 | 4 | '$filter', |
| 4 | 5 | '$scope', |
| 5 | 6 | '$uibModalInstance', |
| 6 | 7 | 'focaModalBancoService', |
| 7 | 8 | 'filters', |
| 8 | - function($filter, $scope, $uibModalInstance, focaModalBancoService, filters) { | |
| 9 | + function($timeout, $filter, $scope, $uibModalInstance, focaModalBancoService, filters) { | |
| 9 | 10 | |
| 10 | 11 | $scope.filters = filters; |
| 11 | 12 | $scope.bancos = []; |
| ... | ... | @@ -26,18 +27,26 @@ angular.module('focaModalBanco') |
| 26 | 27 | $scope.searchLoading = false; |
| 27 | 28 | $scope.primerBusqueda = true; |
| 28 | 29 | $scope.bancos = res.data; |
| 29 | - $scope.search(); | |
| 30 | + $scope.search(true); | |
| 30 | 31 | primera(); |
| 31 | 32 | } |
| 32 | 33 | ); |
| 33 | 34 | } |
| 34 | 35 | }; |
| 35 | 36 | |
| 36 | - $scope.search = function() { | |
| 37 | + $scope.search = function(pressed) { | |
| 37 | 38 | if($scope.bancos.length > 0) { |
| 38 | 39 | $scope.filteredBancos = $filter('filter')( |
| 39 | - $scope.bancos, { $: $scope.filters } | |
| 40 | + $scope.bancos, { $: $scope.filters } | |
| 40 | 41 | ); |
| 42 | + | |
| 43 | + if(pressed && $scope.filteredBancos.length === 0){ | |
| 44 | + $timeout(function() { | |
| 45 | + angular.element('#search')[0].focus(); | |
| 46 | + $scope.filters = ''; | |
| 47 | + }); | |
| 48 | + } | |
| 49 | + | |
| 41 | 50 | $scope.lastPage = Math.ceil( |
| 42 | 51 | $scope.filteredBancos.length / $scope.numPerPage |
| 43 | 52 | ); |
src/views/modal-bancos.html
| ... | ... | @@ -7,7 +7,8 @@ |
| 7 | 7 | ladda="searchLoading" |
| 8 | 8 | type="text" |
| 9 | 9 | class="form-control form-control-sm" |
| 10 | - placeholder="Busqueda" | |
| 10 | + id="search" | |
| 11 | + placeholder="Búsqueda" | |
| 11 | 12 | ng-model="filters" |
| 12 | 13 | ng-change="search()" |
| 13 | 14 | ng-keydown="busquedaDown($event.keyCode)" |
| ... | ... | @@ -48,7 +49,7 @@ |
| 48 | 49 | <td ng-bind="banco.ID"></td> |
| 49 | 50 | <td ng-bind="banco.desbco"></td> |
| 50 | 51 | <td class="d-md-none text-primary"> |
| 51 | - <i class="fa fa-arrow-right" aria-hidden="true"></i> | |
| 52 | + <i class="fa fa-circle-thin" aria-hidden="true"></i> | |
| 52 | 53 | </td> |
| 53 | 54 | <td class="d-none d-md-table-cell"> |
| 54 | 55 | <button |
| ... | ... | @@ -60,13 +61,15 @@ |
| 60 | 61 | }" |
| 61 | 62 | foca-focus="selectedBanco == {{key}}" |
| 62 | 63 | ng-keydown="itemBanco($event.keyCode)"> |
| 63 | - <i class="fa fa-arrow-right" aria-hidden="true"></i> | |
| 64 | + <i class="fa fa-circle-thin" aria-hidden="true"></i> | |
| 64 | 65 | </button> |
| 65 | 66 | </td> |
| 66 | 67 | </tr> |
| 67 | 68 | </tbody> |
| 68 | 69 | </table> |
| 69 | - <nav ng-show="currentPageBancos.length > 0 && primerBusqueda"> | |
| 70 | +</div> | |
| 71 | +<div class="modal-footer"> | |
| 72 | + <nav ng-show="currentPageBancos.length > 0 && primerBusqueda" class="mr-auto"> | |
| 70 | 73 | <ul class="pagination pagination-sm justify-content mb-0"> |
| 71 | 74 | <li class="page-item" ng-class="{'disabled': currentPage == 1}"> |
| 72 | 75 | <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage - 1)"> |
| ... | ... | @@ -94,7 +97,5 @@ |
| 94 | 97 | </li> |
| 95 | 98 | </ul> |
| 96 | 99 | </nav> |
| 97 | -</div> | |
| 98 | -<div class="modal-footer"> | |
| 99 | 100 | <button class="btn btn-sm btn-secondary my-1" type="button" ng-click="cancel()">Cancelar</button> |
| 100 | 101 | </div> |