Commit b462bdd6e1386dde4df8fab45a91770dde7a3449
1 parent
74977059
Exists in
master
[Redmine Atendimento #4890]Filter customizado
Showing
2 changed files
with
56 additions
and
4 deletions
Show diff stats
cit-portal-web/src/main/webapp/assets/js/angular/custom/directive/ListViewDirective.js
@@ -15,7 +15,11 @@ citApp.directive("listView", ["$translate", "$injector", "$timeout", "$filter", | @@ -15,7 +15,11 @@ citApp.directive("listView", ["$translate", "$injector", "$timeout", "$filter", | ||
15 | exibirColunaSelecao : '=?ngExibirColunaSelecao', | 15 | exibirColunaSelecao : '=?ngExibirColunaSelecao', |
16 | templateTransclude : '@transclude', | 16 | templateTransclude : '@transclude', |
17 | modelParent : '=?ngModelParent', | 17 | modelParent : '=?ngModelParent', |
18 | - customTransclude : '&ngCustomTransclude' | 18 | + customTransclude : '&ngCustomTransclude', |
19 | + setTotalPages : '=?setTotalPages', | ||
20 | + setTotalItens : '=?setTotalItens', | ||
21 | + useCustomFilterTemp : '=?useCustomFilterTemp', | ||
22 | + customFilter : '&ngCustomFilter' | ||
19 | }, | 23 | }, |
20 | replace : true, | 24 | replace : true, |
21 | restrict : 'E', | 25 | restrict : 'E', |
@@ -23,8 +27,18 @@ citApp.directive("listView", ["$translate", "$injector", "$timeout", "$filter", | @@ -23,8 +27,18 @@ citApp.directive("listView", ["$translate", "$injector", "$timeout", "$filter", | ||
23 | templateUrl : 'assets/js/angular/custom/directive/html/listView.html', | 27 | templateUrl : 'assets/js/angular/custom/directive/html/listView.html', |
24 | controller: ['$scope', '$element', '$attrs', function($scope, $element, $attrs) { | 28 | controller: ['$scope', '$element', '$attrs', function($scope, $element, $attrs) { |
25 | 29 | ||
26 | - $scope.totalPages = 10; | ||
27 | - $scope.totalItens = 0; | 30 | + if($scope.setTotalPages){ |
31 | + $scope.totalPages = $scope.setTotalPages; | ||
32 | + }else{ | ||
33 | + $scope.totalPages = 10; | ||
34 | + } | ||
35 | + | ||
36 | + if($scope.setTotalItens){ | ||
37 | + $scope.totalItens = $scope.setTotalPages; | ||
38 | + }else{ | ||
39 | + $scope.totalItens = 0; | ||
40 | + } | ||
41 | + | ||
28 | $scope.limit = 10; | 42 | $scope.limit = 10; |
29 | $scope.repositorio = $injector.get($scope.repository); | 43 | $scope.repositorio = $injector.get($scope.repository); |
30 | $scope.appController = angular.element("#citapp-controller").scope(); | 44 | $scope.appController = angular.element("#citapp-controller").scope(); |
@@ -75,6 +89,11 @@ citApp.directive("listView", ["$translate", "$injector", "$timeout", "$filter", | @@ -75,6 +89,11 @@ citApp.directive("listView", ["$translate", "$injector", "$timeout", "$filter", | ||
75 | } | 89 | } |
76 | }); | 90 | }); |
77 | 91 | ||
92 | + if($scope.useCustomFilterTemp){ | ||
93 | + $scope.customFilter(); | ||
94 | + return; | ||
95 | + } | ||
96 | + | ||
78 | $scope.fetchResult().then(function() { | 97 | $scope.fetchResult().then(function() { |
79 | // The request fires correctly but sometimes the ui doesn't update, | 98 | // The request fires correctly but sometimes the ui doesn't update, |
80 | // that's a fix | 99 | // that's a fix |
@@ -94,6 +113,12 @@ citApp.directive("listView", ["$translate", "$injector", "$timeout", "$filter", | @@ -94,6 +113,12 @@ citApp.directive("listView", ["$translate", "$injector", "$timeout", "$filter", | ||
94 | $scope.filterCriteria.dir = sortDir; | 113 | $scope.filterCriteria.dir = sortDir; |
95 | $scope.filterCriteria.sort = sortedBy; | 114 | $scope.filterCriteria.sort = sortedBy; |
96 | $scope.filterCriteria.start = 1; | 115 | $scope.filterCriteria.start = 1; |
116 | + | ||
117 | + if($scope.useCustomFilterTemp){ | ||
118 | + $scope.customFilter(); | ||
119 | + return; | ||
120 | + } | ||
121 | + | ||
97 | $scope.fetchResult().then(function() { | 122 | $scope.fetchResult().then(function() { |
98 | // The request fires correctly but sometimes the ui doesn't update, | 123 | // The request fires correctly but sometimes the ui doesn't update, |
99 | // that's a fix | 124 | // that's a fix |
@@ -103,6 +128,13 @@ citApp.directive("listView", ["$translate", "$injector", "$timeout", "$filter", | @@ -103,6 +128,13 @@ citApp.directive("listView", ["$translate", "$injector", "$timeout", "$filter", | ||
103 | 128 | ||
104 | // RECUPERA LISTA E SETA RESULTADO NA GRID | 129 | // RECUPERA LISTA E SETA RESULTADO NA GRID |
105 | $scope.fetchResult = function(page) { | 130 | $scope.fetchResult = function(page) { |
131 | + | ||
132 | + if($scope.useCustomFilterTemp){ | ||
133 | + $scope.customFilter(); | ||
134 | + return; | ||
135 | + } | ||
136 | + | ||
137 | + | ||
106 | $scope.appController.setLoadingPesquisa(true); | 138 | $scope.appController.setLoadingPesquisa(true); |
107 | $scope.itemSelecionado = undefined; | 139 | $scope.itemSelecionado = undefined; |
108 | return $scope.repositorio.getListPage($scope.filterCriteria).then(function(result) { | 140 | return $scope.repositorio.getListPage($scope.filterCriteria).then(function(result) { |
@@ -176,6 +208,7 @@ citApp.directive("listView", ["$translate", "$injector", "$timeout", "$filter", | @@ -176,6 +208,7 @@ citApp.directive("listView", ["$translate", "$injector", "$timeout", "$filter", | ||
176 | 208 | ||
177 | // Limpa os filtros avançados | 209 | // Limpa os filtros avançados |
178 | $scope.limparFilters = function() { | 210 | $scope.limparFilters = function() { |
211 | + $scope.useCustomFilterTemp = false; | ||
179 | $scope.filterCriteria.keywordValue = null; | 212 | $scope.filterCriteria.keywordValue = null; |
180 | if($scope.filtersCopy){ | 213 | if($scope.filtersCopy){ |
181 | $scope.filterCriteria.filters= angular.copy($scope.filtersCopy); | 214 | $scope.filterCriteria.filters= angular.copy($scope.filtersCopy); |
@@ -225,6 +258,22 @@ citApp.directive("listView", ["$translate", "$injector", "$timeout", "$filter", | @@ -225,6 +258,22 @@ citApp.directive("listView", ["$translate", "$injector", "$timeout", "$filter", | ||
225 | $scope.aplicarMask = function(value, mask){ | 258 | $scope.aplicarMask = function(value, mask){ |
226 | return value.replace(mask[0], mask[1]); | 259 | return value.replace(mask[0], mask[1]); |
227 | }; | 260 | }; |
261 | + | ||
262 | + $scope.$watch('setTotalPages', function() { | ||
263 | + if($scope.setTotalPages){ | ||
264 | + $scope.totalPages = $scope.setTotalPages; | ||
265 | + }else{ | ||
266 | + $scope.totalPages = 10; | ||
267 | + } | ||
268 | + }); | ||
269 | + | ||
270 | + $scope.$watch('setTotalItens', function() { | ||
271 | + if($scope.setTotalItens){ | ||
272 | + $scope.totalItens = $scope.setTotalItens; | ||
273 | + }else{ | ||
274 | + $scope.totalItens = 10; | ||
275 | + } | ||
276 | + }); | ||
228 | 277 | ||
229 | $scope.$on('filtroDirective-listViewDirective', function(event, active) { | 278 | $scope.$on('filtroDirective-listViewDirective', function(event, active) { |
230 | $scope.$showAdvancedFilters = active; | 279 | $scope.$showAdvancedFilters = active; |
cit-portal-web/src/main/webapp/assets/js/angular/custom/directive/html/listView.html
@@ -28,9 +28,12 @@ | @@ -28,9 +28,12 @@ | ||
28 | <th ng-if="isCheckBox != undefined && isCheckBox" class="text-center"><input type="checkbox" ng-model="$parent.selectedAll" ng-checked="selectedAll" ng-click="checkAll();" /></th> | 28 | <th ng-if="isCheckBox != undefined && isCheckBox" class="text-center"><input type="checkbox" ng-model="$parent.selectedAll" ng-checked="selectedAll" ng-click="checkAll();" /></th> |
29 | <th ng-if="(isCheckBox == undefined || !isCheckBox) && exibirColunaSelecao" class="text-center" style="width: 5%"></th> | 29 | <th ng-if="(isCheckBox == undefined || !isCheckBox) && exibirColunaSelecao" class="text-center" style="width: 5%"></th> |
30 | <th ng-if="exibirExpandir" class="text-center" style="width: 5%"></th> | 30 | <th ng-if="exibirExpandir" class="text-center" style="width: 5%"></th> |
31 | - <th class="text-center" ng-repeat="header in headers" style="width: {{header.tamanho ? header.tamanho : divisaoColunas}}%"> | 31 | + <th class="text-center" ng-repeat="header in headers" style="width: {{header.tamanho ? header.tamanho : divisaoColunas}}%" ng-if="!header.notSort"> |
32 | <sort-by onsort="onSort" sortdir="filterCriteria.dir" sortedby="filterCriteria.sort" sortvalue="{{ header.value }}">{{ header.title }}</sort-by> | 32 | <sort-by onsort="onSort" sortdir="filterCriteria.dir" sortedby="filterCriteria.sort" sortvalue="{{ header.value }}">{{ header.title }}</sort-by> |
33 | </th> | 33 | </th> |
34 | + <th class="text-center" ng-repeat="header in headers" style="width: {{header.tamanho ? header.tamanho : divisaoColunas}}%" ng-if="header.notSort"> | ||
35 | + {{ header.title }} | ||
36 | + </th> | ||
34 | </tr> | 37 | </tr> |
35 | </thead> | 38 | </thead> |
36 | <tfoot> | 39 | <tfoot> |