Commit 92253b8d9b4b8b83ec1efb817a7cf3aa4423a032
Exists in
master
Merge branch 'master' into 'master'
buscador sin resultados hace focus See merge request !2
Showing
2 changed files
Show diff stats
src/js/controller.js
1 | 1 | angular.module('focaModalCobradores') |
2 | 2 | .controller('focaModalCobradoresController', [ |
3 | + '$timeout', | |
3 | 4 | '$filter', |
4 | 5 | '$scope', |
5 | 6 | '$uibModalInstance', |
6 | 7 | 'focaModalCobradoresService', |
7 | - function($filter, $scope, $uibModalInstance, focaModalCobradoresService) { | |
8 | + function($timeout, $filter, $scope, $uibModalInstance, focaModalCobradoresService) { | |
8 | 9 | |
9 | 10 | $scope.filters = ''; |
10 | 11 | $scope.cobradores = []; |
... | ... | @@ -25,14 +26,15 @@ angular.module('focaModalCobradores') |
25 | 26 | $scope.searchLoading = false; |
26 | 27 | $scope.primerBusqueda = true; |
27 | 28 | $scope.cobradores = res.data; |
28 | - $scope.search(); | |
29 | + $scope.search(true); | |
29 | 30 | primera(); |
30 | 31 | } |
31 | 32 | ); |
32 | 33 | } |
33 | 34 | }; |
34 | 35 | |
35 | - $scope.search = function() { | |
36 | + $scope.search = function(pressed) { | |
37 | + | |
36 | 38 | if($scope.cobradores.length > 0) { |
37 | 39 | $scope.filteredCobradores = $filter('filter')( |
38 | 40 | $scope.cobradores, { $: $scope.filters } |
... | ... | @@ -41,6 +43,12 @@ angular.module('focaModalCobradores') |
41 | 43 | $scope.filteredCobradores.length / $scope.numPerPage |
42 | 44 | ); |
43 | 45 | $scope.resetPage(); |
46 | + if(pressed && $scope.filteredCobradores.length === 0){ | |
47 | + $timeout(function() { | |
48 | + angular.element('#search')[0].focus(); | |
49 | + $scope.filters = ''; | |
50 | + }); | |
51 | + } | |
44 | 52 | } |
45 | 53 | }; |
46 | 54 |
src/views/modal-cobradores.html
... | ... | @@ -16,6 +16,7 @@ |
16 | 16 | foca-focus="selectedCobrador == -1" |
17 | 17 | ng-focus="selectedCobrador = -1" |
18 | 18 | teclado-virtual |
19 | + id="search" | |
19 | 20 | > |
20 | 21 | <div class="input-group-append"> |
21 | 22 | <button |
... | ... | @@ -76,7 +77,7 @@ |
76 | 77 | </tbody> |
77 | 78 | </table> |
78 | 79 | </div> |
79 | -<div class="modal-footer"> | |
80 | +<div class="modal-footer py-1"> | |
80 | 81 | <nav ng-show="currentPageCobradores.length > 0 && primerBusqueda" class="mr-auto"> |
81 | 82 | <ul class="pagination pagination-sm justify-content mb-0"> |
82 | 83 | <li class="page-item" ng-class="{'disabled': currentPage == 1}"> |