Commit e6e01e595da30860105de9ecdd09102338a0f069
1 parent
8c34b01447
Exists in
master
buscador en header, paginacion en footer, cambio icons
Showing
2 changed files
with
12 additions
and
4 deletions
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 | ); |