Commit ed1aca3ec6743fa274f5aa0e9277aa7bc1049ba7
Exists in
master
Merge branch 'master' into 'master'
cambio icons, focus input si no hay resultados See merge request !1
Showing
2 changed files
Show diff stats
src/js/controller.js
| 1 | 1 | angular.module('focaModalLocalidad') |
| 2 | 2 | .controller('focaModalLocalidadController', [ |
| 3 | + '$timeout', | |
| 3 | 4 | '$filter', |
| 4 | 5 | '$scope', |
| 5 | 6 | '$uibModalInstance', |
| 6 | 7 | 'focaModalLocalidadService', |
| 7 | 8 | 'filters', |
| 8 | - function($filter, $scope, $uibModalInstance, focaModalLocalidadService, filters) { | |
| 9 | + function($timeout, $filter, $scope, $uibModalInstance, focaModalLocalidadService, filters) { | |
| 9 | 10 | |
| 10 | 11 | $scope.filters = filters.busqueda; |
| 11 | 12 | $scope.provincias = []; |
| ... | ... | @@ -27,18 +28,26 @@ angular.module('focaModalLocalidad') |
| 27 | 28 | $scope.searchLoading = false; |
| 28 | 29 | $scope.primerBusqueda = true; |
| 29 | 30 | $scope.provincias = res.data; |
| 30 | - $scope.search(); | |
| 31 | + $scope.search(true); | |
| 31 | 32 | primera(); |
| 32 | 33 | } |
| 33 | 34 | ); |
| 34 | 35 | } |
| 35 | 36 | }; |
| 36 | 37 | |
| 37 | - $scope.search = function() { | |
| 38 | + $scope.search = function(pressed) { | |
| 38 | 39 | if($scope.provincias.length > 0) { |
| 39 | 40 | $scope.filteredLocalidades = $filter('filter')( |
| 40 | - $scope.provincias, { $: $scope.filters } | |
| 41 | + $scope.provincias, { $: $scope.filters } | |
| 41 | 42 | ); |
| 43 | + | |
| 44 | + if(pressed && $scope.filteredLocalidades.length === 0) { | |
| 45 | + $timeout(function() { | |
| 46 | + angular.element('#search')[0].focus(); | |
| 47 | + $scope.filters = ''; | |
| 48 | + }); | |
| 49 | + } | |
| 50 | + | |
| 42 | 51 | $scope.lastPage = Math.ceil( |
| 43 | 52 | $scope.filteredLocalidades.length / $scope.numPerPage |
| 44 | 53 | ); |
src/views/modal-localidades.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="localidad.ID"></td> |
| 49 | 50 | <td ng-bind="localidad.NOMBRE"></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,7 +61,7 @@ |
| 60 | 61 | }" |
| 61 | 62 | foca-focus="selectedLocalidades == {{key}}" |
| 62 | 63 | ng-keydown="itemLocalidad($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> |