Commit 9d3b0486fb657b7b47662c509b9e6b097b00162e
1 parent
0a622cf988
Exists in
master
cambio icons, input focus si no hay resultados
Showing
2 changed files
with
17 additions
and
7 deletions
Show diff stats
src/js/controller.js
1 | 1 | angular.module('focaModalProvincia') |
2 | 2 | .controller('focaModalProvinciaController', [ |
3 | + '$timeout', | |
3 | 4 | '$filter', |
4 | 5 | '$scope', |
5 | 6 | '$uibModalInstance', |
6 | 7 | 'focaModalProvinciaService', |
7 | 8 | 'filters', |
8 | - function($filter, $scope, $uibModalInstance, focaModalProvinciaService, filters) { | |
9 | + function($timeout, $filter, $scope, $uibModalInstance, focaModalProvinciaService, filters) { | |
9 | 10 | |
10 | 11 | $scope.filters = filters; |
11 | 12 | $scope.provincias = []; |
... | ... | @@ -26,18 +27,26 @@ angular.module('focaModalProvincia') |
26 | 27 | $scope.searchLoading = false; |
27 | 28 | $scope.primerBusqueda = true; |
28 | 29 | $scope.provincias = 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.provincias.length > 0) { |
38 | 39 | $scope.filteredProvincias = $filter('filter')( |
39 | - $scope.provincias, { $: $scope.filters } | |
40 | + $scope.provincias, { $: $scope.filters } | |
40 | 41 | ); |
42 | + | |
43 | + if(pressed && $scope.filteredProvincias.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.filteredProvincias.length / $scope.numPerPage |
43 | 52 | ); |
src/views/modal-provincias.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="provincia.ID"></td> |
49 | 50 | <td ng-bind="provincia.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="selectedProvincia == {{key}}" |
62 | 63 | ng-keydown="itemProvincia($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> |