Commit 83e62217006066f77284a2ecd092b73ac84c9dfa
Exists in
master
Merge branch 'master' into 'master'
teclado virtual funciona, focus input si no hay resultados See merge request !2
Showing
2 changed files
Show diff stats
src/js/controller.js
| 1 | 1 | angular.module('focaModalVehiculo') |
| 2 | 2 | .controller('focaModalVehiculoController', |
| 3 | 3 | [ |
| 4 | + '$timeout', | |
| 4 | 5 | '$filter', |
| 5 | 6 | '$scope', |
| 6 | 7 | '$uibModalInstance', |
| 7 | 8 | 'focaModalVehiculoService', |
| 8 | - function($filter, $scope, $uibModalInstance, | |
| 9 | + function($timeout, $filter, $scope, $uibModalInstance, | |
| 9 | 10 | focaModalVehiculoService |
| 10 | 11 | ) { |
| 11 | 12 | |
| ... | ... | @@ -31,16 +32,23 @@ angular.module('focaModalVehiculo') |
| 31 | 32 | $scope.searchLoading = false; |
| 32 | 33 | $scope.primerBusqueda = true; |
| 33 | 34 | $scope.vehiculos = res.data; |
| 34 | - $scope.search(); | |
| 35 | + $scope.search(true); | |
| 35 | 36 | primera(); |
| 36 | 37 | } |
| 37 | - $scope.search = function() { | |
| 38 | + $scope.search = function(pressed) { | |
| 38 | 39 | if($scope.vehiculos.length > 0) { |
| 39 | 40 | $scope.filteredVehiculos = $filter('filter')( |
| 40 | 41 | $scope.vehiculos, |
| 41 | 42 | {$: $scope.filters} |
| 42 | 43 | ); |
| 43 | 44 | |
| 45 | + if(pressed && $scope.filteredVehiculos.length === 0) { | |
| 46 | + $timeout(function() { | |
| 47 | + angular.element('#search')[0].focus(); | |
| 48 | + $scope.filters = ''; | |
| 49 | + }); | |
| 50 | + } | |
| 51 | + | |
| 44 | 52 | $scope.lastPage = Math.ceil( |
| 45 | 53 | $scope.filteredVehiculos.length / $scope.numPerPage |
| 46 | 54 | ); |
src/views/modal-vehiculo.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 Vehiculo</h5> | |
| 4 | + <h5 class="modal-title my-1">Búsqueda de Vehiculo</h5> | |
| 5 | 5 | </div> |
| 6 | 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" |
| 11 | - placeholder="Busqueda" | |
| 11 | + id="search" | |
| 12 | + placeholder="Búsqueda" | |
| 12 | 13 | ng-model="filters" |
| 13 | 14 | ng-change="search()" |
| 14 | 15 | ng-keydown="busquedaDown($event.keyCode)" |
| 15 | 16 | ng-keypress="busquedaPress($event.keyCode)" |
| 16 | 17 | foca-focus="selectedVehiculo == -1" |
| 17 | 18 | ng-focus="selectedVehiculo = -1" |
| 19 | + teclado-virtual | |
| 18 | 20 | > |
| 19 | 21 | <div class="input-group-append"> |
| 20 | 22 | <button |