Commit 717a69624b63404c955f04eb599102c641fdd83a
1 parent
1460dc1e50
Exists in
master
buscador sin resultados hace focus
Showing
2 changed files
with
13 additions
and
4 deletions
Show diff stats
src/js/controller.js
| 1 | 1 | angular.module('focaModalRemito') |
| 2 | 2 | .controller('focaModalRemitoController', |
| 3 | 3 | [ |
| 4 | + '$timeout', | |
| 4 | 5 | '$filter', |
| 5 | 6 | '$scope', |
| 6 | 7 | '$uibModalInstance', |
| 7 | 8 | 'focaModalRemitoService', |
| 8 | 9 | 'usadoPor', |
| 9 | - function($filter, $scope, $uibModalInstance, | |
| 10 | + function($timeout, $filter, $scope, $uibModalInstance, | |
| 10 | 11 | focaModalRemitoService, usadoPor |
| 11 | 12 | ) { |
| 12 | 13 | var fecha = new Date(); |
| ... | ... | @@ -55,16 +56,23 @@ angular.module('focaModalRemito') |
| 55 | 56 | $scope.searchLoading = false; |
| 56 | 57 | $scope.primerBusqueda = true; |
| 57 | 58 | $scope.remitos = res.data; |
| 58 | - $scope.search(); | |
| 59 | + $scope.search(true); | |
| 59 | 60 | primera(); |
| 60 | 61 | } |
| 61 | - $scope.search = function() { | |
| 62 | + $scope.search = function(pressed) { | |
| 62 | 63 | if($scope.remitos.length > 0) { |
| 63 | 64 | $scope.filteredRemitos = $filter('filter')( |
| 64 | 65 | $scope.remitos, |
| 65 | 66 | {$: $scope.filters} |
| 66 | 67 | ); |
| 67 | 68 | |
| 69 | + if(pressed && $scope.filteredRemitos.length === 0){ | |
| 70 | + $timeout(function() { | |
| 71 | + angular.element('#search')[0].focus(); | |
| 72 | + $scope.filters = ''; | |
| 73 | + }); | |
| 74 | + } | |
| 75 | + | |
| 68 | 76 | $scope.lastPage = Math.ceil( |
| 69 | 77 | $scope.filteredRemitos.length / $scope.numPerPage |
| 70 | 78 | ); |
src/views/foca-modal-remito.html
| 1 | 1 | <div class="modal-header py-1"> |
| 2 | 2 | <div class="row w-100"> |
| 3 | 3 | <div class="col-lg-6"> |
| 4 | - <h5 class="modal-title my-1">Busqueda de Remito</h5> | |
| 4 | + <h5 class="modal-title my-1">Búsqueda de Remito</h5> | |
| 5 | 5 | </div> |
| 6 | 6 | <div class="input-group col-lg-6 pr-0 my-2"> |
| 7 | 7 | <input |
| ... | ... | @@ -15,6 +15,7 @@ |
| 15 | 15 | ng-keypress="busquedaPress($event.keyCode)" |
| 16 | 16 | foca-focus="selectedRemito == -1" |
| 17 | 17 | ng-focus="selectedRemito = -1" |
| 18 | + id="search" | |
| 18 | 19 | teclado-virtual |
| 19 | 20 | > |
| 20 | 21 | <div class="input-group-append"> |