Commit b38bec800a7cd143fd6648c903d8c62d1a624cf6
1 parent
1b737409d1
Exists in
master
and in
1 other branch
refactor filtros
Showing
2 changed files
with
16 additions
and
4 deletions
Show diff stats
src/js/controllerModal.js
... | ... | @@ -28,6 +28,7 @@ angular.module('focaModal') |
28 | 28 | $scope.searchLoading = false; |
29 | 29 | $scope.primerBusqueda = true; |
30 | 30 | $scope.entidades = res.data; |
31 | + filtros($scope.entidades); | |
31 | 32 | $scope.search(true); |
32 | 33 | primera(); |
33 | 34 | } |
... | ... | @@ -35,7 +36,18 @@ angular.module('focaModal') |
35 | 36 | } |
36 | 37 | }; |
37 | 38 | $scope.busquedaPress(13); |
38 | - | |
39 | + function filtros(entidades) { | |
40 | + for (var i = 0; i < $scope.parametrosModal.columnas.length; i++) { | |
41 | + var filtro = $scope.parametrosModal.columnas[i].filtro; | |
42 | + if (filtro) { | |
43 | + for (var j = 0; j < entidades.length; j++) { | |
44 | + entidades[j][$scope.parametrosModal.columnas[i].propiedad] = | |
45 | + $filter(filtro.nombre)(entidades[j][$scope | |
46 | + .parametrosModal.columnas[i].propiedad], filtro.parametro); | |
47 | + } | |
48 | + } | |
49 | + } | |
50 | + } | |
39 | 51 | $scope.search = function(pressed) { |
40 | 52 | if($scope.entidades.length > 0) { |
41 | 53 | $scope.filteredEntidades = $filter('filter')( |
src/views/foca-modal.html
... | ... | @@ -42,7 +42,7 @@ |
42 | 42 | <table ng-show="primerBusqueda" class="table table-striped table-sm col-12"> |
43 | 43 | <thead> |
44 | 44 | <tr> |
45 | - <th ng-repeat="nombre in parametrosModal.columnas.nombre" ng-bind="nombre"></th> | |
45 | + <th ng-repeat="columna in parametrosModal.columnas" ng-bind="columna.nombre"></th> | |
46 | 46 | <th></th> |
47 | 47 | </tr> |
48 | 48 | </thead> |
... | ... | @@ -57,8 +57,8 @@ |
57 | 57 | ng-click="select(entidad)" |
58 | 58 | > |
59 | 59 | <td |
60 | - ng-repeat="propiedad in parametrosModal.columnas.propiedad" | |
61 | - ng-bind="entidad[propiedad]"></td> | |
60 | + ng-repeat="columna in parametrosModal.columnas" | |
61 | + ng-bind="entidad[columna.propiedad]"></td> | |
62 | 62 | <td class="d-md-none text-primary"> |
63 | 63 | <i class="fa fa-circle-thin" aria-hidden="true"></i> |
64 | 64 | </td> |