Commit 4786b133fb93eb04f2aed834459735eb2fa574e4
1 parent
4a3ff5358a
Exists in
master
focus input si no hay resultados
Showing
2 changed files
with
17 additions
and
3 deletions
Show diff stats
src/js/controller.js
1 | 1 | angular.module('focaModalPrecioCondicion') |
2 | 2 | .controller('focaModalPrecioCondicionController', |
3 | 3 | [ |
4 | + '$timeout', | |
4 | 5 | '$filter', |
5 | 6 | '$scope', |
6 | 7 | '$uibModalInstance', |
7 | 8 | 'focaModalService', |
8 | 9 | 'focaModalPrecioCondicionService', |
9 | 10 | function( |
10 | - $filter, $scope, $uibModalInstance, | |
11 | + $timeout, $filter, $scope, $uibModalInstance, | |
11 | 12 | focaModalService, focaModalPrecioCondicionService |
12 | 13 | ) { |
13 | 14 | |
... | ... | @@ -24,6 +25,7 @@ angular.module('focaModalPrecioCondicion') |
24 | 25 | $scope.search(); |
25 | 26 | } |
26 | 27 | ); |
28 | + $scope.filters = ''; | |
27 | 29 | $scope.ingreso = false; |
28 | 30 | $scope.plazosNuevos = []; |
29 | 31 | $scope.plazoACargar = |
... | ... | @@ -77,12 +79,23 @@ angular.module('focaModalPrecioCondicion') |
77 | 79 | }; |
78 | 80 | }; |
79 | 81 | |
80 | - $scope.search = function() { | |
82 | + $scope.search = function(pressed) { | |
81 | 83 | $scope.filteredPrecioCondicion = $filter('filter')( |
82 | 84 | $scope.precioCondicion, |
83 | 85 | {$: $scope.filters} |
84 | 86 | ); |
85 | 87 | |
88 | + if(pressed){ | |
89 | + if($scope.filteredPrecioCondicion.length === 0){ | |
90 | + $timeout(function() { | |
91 | + angular.element('#search')[0].focus(); | |
92 | + $scope.filters = ''; | |
93 | + }); | |
94 | + }else{ | |
95 | + primera(); | |
96 | + } | |
97 | + } | |
98 | + | |
86 | 99 | $scope.lastPage = Math.ceil( |
87 | 100 | $scope.filteredPrecioCondicion.length / $scope.numPerPage |
88 | 101 | ); |
... | ... | @@ -121,7 +134,7 @@ angular.module('focaModalPrecioCondicion') |
121 | 134 | |
122 | 135 | $scope.busquedaPress = function(key) { |
123 | 136 | if (key === 13) { |
124 | - primera(key); | |
137 | + $scope.search(true); | |
125 | 138 | } |
126 | 139 | }; |
127 | 140 |