Commit b462bdd6e1386dde4df8fab45a91770dde7a3449

Authored by erick.sato
1 parent 74977059
Exists in master

[Redmine Atendimento #4890]Filter customizado

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 15 exibirColunaSelecao : '=?ngExibirColunaSelecao',
16 16 templateTransclude : '@transclude',
17 17 modelParent : '=?ngModelParent',
18   - customTransclude : '&ngCustomTransclude'
  18 + customTransclude : '&ngCustomTransclude',
  19 + setTotalPages : '=?setTotalPages',
  20 + setTotalItens : '=?setTotalItens',
  21 + useCustomFilterTemp : '=?useCustomFilterTemp',
  22 + customFilter : '&ngCustomFilter'
19 23 },
20 24 replace : true,
21 25 restrict : 'E',
... ... @@ -23,8 +27,18 @@ citApp.directive("listView", ["$translate", "$injector", "$timeout", "$filter",
23 27 templateUrl : 'assets/js/angular/custom/directive/html/listView.html',
24 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 42 $scope.limit = 10;
29 43 $scope.repositorio = $injector.get($scope.repository);
30 44 $scope.appController = angular.element("#citapp-controller").scope();
... ... @@ -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 97 $scope.fetchResult().then(function() {
79 98 // The request fires correctly but sometimes the ui doesn't update,
80 99 // that's a fix
... ... @@ -94,6 +113,12 @@ citApp.directive("listView", ["$translate", "$injector", "$timeout", "$filter",
94 113 $scope.filterCriteria.dir = sortDir;
95 114 $scope.filterCriteria.sort = sortedBy;
96 115 $scope.filterCriteria.start = 1;
  116 +
  117 + if($scope.useCustomFilterTemp){
  118 + $scope.customFilter();
  119 + return;
  120 + }
  121 +
97 122 $scope.fetchResult().then(function() {
98 123 // The request fires correctly but sometimes the ui doesn't update,
99 124 // that's a fix
... ... @@ -103,6 +128,13 @@ citApp.directive("listView", ["$translate", "$injector", "$timeout", "$filter",
103 128  
104 129 // RECUPERA LISTA E SETA RESULTADO NA GRID
105 130 $scope.fetchResult = function(page) {
  131 +
  132 + if($scope.useCustomFilterTemp){
  133 + $scope.customFilter();
  134 + return;
  135 + }
  136 +
  137 +
106 138 $scope.appController.setLoadingPesquisa(true);
107 139 $scope.itemSelecionado = undefined;
108 140 return $scope.repositorio.getListPage($scope.filterCriteria).then(function(result) {
... ... @@ -176,6 +208,7 @@ citApp.directive("listView", ["$translate", "$injector", "$timeout", "$filter",
176 208  
177 209 // Limpa os filtros avançados
178 210 $scope.limparFilters = function() {
  211 + $scope.useCustomFilterTemp = false;
179 212 $scope.filterCriteria.keywordValue = null;
180 213 if($scope.filtersCopy){
181 214 $scope.filterCriteria.filters= angular.copy($scope.filtersCopy);
... ... @@ -225,6 +258,22 @@ citApp.directive("listView", ["$translate", "$injector", "$timeout", "$filter",
225 258 $scope.aplicarMask = function(value, mask){
226 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 278 $scope.$on('filtroDirective-listViewDirective', function(event, active) {
230 279 $scope.$showAdvancedFilters = active;
... ...
cit-portal-web/src/main/webapp/assets/js/angular/custom/directive/html/listView.html
... ... @@ -28,9 +28,12 @@
28 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 29 <th ng-if="(isCheckBox == undefined || !isCheckBox) && exibirColunaSelecao" class="text-center" style="width: 5%"></th>
30 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 32 <sort-by onsort="onSort" sortdir="filterCriteria.dir" sortedby="filterCriteria.sort" sortvalue="{{ header.value }}">{{ header.title }}</sort-by>
33 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 37 </tr>
35 38 </thead>
36 39 <tfoot>
... ...