Commit ab05224f132a5dfc0abf415af6e63a76bca08c34
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('focaModalVendedores') |
2 | 2 | .controller('modalVendedoresCtrl', [ |
3 | + '$timeout', | |
3 | 4 | '$filter', |
4 | 5 | '$scope', |
5 | 6 | '$uibModalInstance', |
6 | 7 | 'focaVendedoresService', |
7 | - function($filter, $scope, $uibModalInstance, focaVendedoresService) { | |
8 | + function($timeout, $filter, $scope, $uibModalInstance, focaVendedoresService) { | |
8 | 9 | |
9 | 10 | $scope.filters = ''; |
10 | 11 | $scope.vendedores = []; |
... | ... | @@ -25,22 +26,28 @@ angular.module('focaModalVendedores') |
25 | 26 | $scope.searchLoading = false; |
26 | 27 | $scope.primerBusqueda = true; |
27 | 28 | $scope.vendedores = 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) { | |
36 | 37 | if($scope.vendedores.length > 0) { |
37 | 38 | $scope.filteredVendedores = $filter('filter')( |
38 | - $scope.vendedores, { $: $scope.filters } | |
39 | + $scope.vendedores, { $: $scope.filters } | |
39 | 40 | ); |
41 | + | |
40 | 42 | $scope.lastPage = Math.ceil( |
41 | 43 | $scope.filteredVendedores.length / $scope.numPerPage |
42 | 44 | ); |
43 | 45 | $scope.resetPage(); |
46 | + }else if(pressed){ | |
47 | + $timeout(function() { | |
48 | + angular.element('#search')[0].focus(); | |
49 | + $scope.filters = ''; | |
50 | + }); | |
44 | 51 | } |
45 | 52 | }; |
46 | 53 |
src/views/modal-vendedores.html
1 | 1 | <div class="modal-header py-1"> |
2 | 2 | <div class="row w-100"> |
3 | - <div class="col-lg-6 col-xs-12"> | |
3 | + <div class="col-lg-6"> | |
4 | 4 | <h5 class="modal-title my-1">Búsqueda de vendedores</h5> |
5 | 5 | </div> |
6 | - <div class="input-group col-lg-6 col-xs-12 pr-0 my-2"> | |
6 | + <div class="input-group col-lg-6 pr-0 my-2"> | |
7 | 7 | <input |
8 | 8 | ladda="searchLoading" |
9 | 9 | type="text" |
10 | 10 | class="form-control form-control-sm" |
11 | + id="search" | |
11 | 12 | placeholder="Busqueda" |
12 | 13 | ng-model="filters" |
13 | 14 | ng-change="search()" |