Commit 88e26c3a1b3b24b99d7887f45132f1abea56c871
Exists in
master
Merge remote-tracking branch 'upstream/master'
Showing
2 changed files
Show diff stats
src/js/controller.js
| 1 | 1 | angular.module('focaBusquedaCliente') |
| 2 | 2 | .controller('focaBusquedaClienteModalController', [ |
| 3 | - '$uibModalInstance', 'focaBusquedaClienteService', '$scope', '$filter', | |
| 4 | - function($uibModalInstance, focaBusquedaClienteService, $scope, $filter) { | |
| 3 | + '$uibModalInstance', 'focaBusquedaClienteService', '$scope', '$filter', '$timeout', | |
| 4 | + function($uibModalInstance, focaBusquedaClienteService, $scope, $filter, $timeout) { | |
| 5 | 5 | |
| 6 | 6 | $scope.filters = ''; |
| 7 | 7 | $scope.primerBusqueda = false; |
| ... | ... | @@ -19,19 +19,26 @@ angular.module('focaBusquedaCliente') |
| 19 | 19 | function(res) { |
| 20 | 20 | $scope.primerBusqueda = true; |
| 21 | 21 | $scope.clientes = res.data; |
| 22 | - $scope.search(); | |
| 22 | + $scope.search(true); | |
| 23 | 23 | primera(); |
| 24 | 24 | $scope.searchLoading = false; |
| 25 | 25 | }); |
| 26 | 26 | } |
| 27 | 27 | }; |
| 28 | 28 | |
| 29 | - $scope.search = function () { | |
| 29 | + $scope.search = function (pressed) { | |
| 30 | 30 | if($scope.primerBusqueda) { |
| 31 | 31 | $scope.filteredClientes = $filter('filter')( |
| 32 | 32 | $scope.clientes, {$: $scope.filters} |
| 33 | 33 | ); |
| 34 | 34 | |
| 35 | + if(pressed && $scope.filteredClientes.length === 0){ | |
| 36 | + $timeout(function() { | |
| 37 | + angular.element('#search')[0].focus(); | |
| 38 | + $scope.filters = ''; | |
| 39 | + }); | |
| 40 | + } | |
| 41 | + | |
| 35 | 42 | $scope.lastPage = Math.ceil( |
| 36 | 43 | $scope.filteredClientes.length / $scope.numPerPage |
| 37 | 44 | ); |
src/views/foca-busqueda-cliente-modal.html
| ... | ... | @@ -8,6 +8,7 @@ |
| 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()" |
| ... | ... | @@ -20,6 +21,7 @@ |
| 20 | 21 | <div class="input-group-append"> |
| 21 | 22 | <button |
| 22 | 23 | ladda="searchLoading" |
| 24 | + data-spinner-color="#FF0000" | |
| 23 | 25 | class="btn btn-outline-secondary" |
| 24 | 26 | type="button" |
| 25 | 27 | ng-click="busquedaPress(13)"> |