1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | "use strict";
|
8 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
9 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
10 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
11 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
12 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
13 | };
|
14 | var __metadata = (this && this.__metadata) || function (k, v) {
|
15 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
16 | };
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | var context_1 = require("../context/context");
|
19 | var filterManager_1 = require("../filter/filterManager");
|
20 | var gridOptionsWrapper_1 = require("../gridOptionsWrapper");
|
21 | var FilterService = (function () {
|
22 | function FilterService() {
|
23 | }
|
24 | FilterService.prototype.postConstruct = function () {
|
25 | this.doingTreeData = this.gridOptionsWrapper.isTreeData();
|
26 | };
|
27 | FilterService.prototype.filterAccordingToColumnState = function (rowNode) {
|
28 | var filterActive = this.filterManager.isAnyFilterPresent();
|
29 | this.filter(rowNode, filterActive);
|
30 | };
|
31 | FilterService.prototype.filter = function (rowNode, filterActive) {
|
32 | var _this = this;
|
33 |
|
34 | if (rowNode.hasChildren()) {
|
35 | rowNode.childrenAfterGroup.forEach(function (node) { return _this.filter(node, filterActive); });
|
36 |
|
37 | if (filterActive) {
|
38 | rowNode.childrenAfterFilter = rowNode.childrenAfterGroup.filter(function (childNode) {
|
39 |
|
40 |
|
41 | var passBecauseChildren = childNode.childrenAfterFilter && childNode.childrenAfterFilter.length > 0;
|
42 |
|
43 |
|
44 | var passBecauseDataPasses = childNode.data && _this.filterManager.doesRowPassFilter(childNode);
|
45 |
|
46 | return passBecauseChildren || passBecauseDataPasses;
|
47 | });
|
48 | }
|
49 | else {
|
50 |
|
51 | rowNode.childrenAfterFilter = rowNode.childrenAfterGroup;
|
52 | }
|
53 | this.setAllChildrenCount(rowNode);
|
54 | }
|
55 | else {
|
56 | rowNode.childrenAfterFilter = rowNode.childrenAfterGroup;
|
57 | rowNode.setAllChildrenCount(null);
|
58 | }
|
59 | };
|
60 | FilterService.prototype.setAllChildrenCountTreeData = function (rowNode) {
|
61 |
|
62 | var allChildrenCount = 0;
|
63 | rowNode.childrenAfterFilter.forEach(function (child) {
|
64 |
|
65 | allChildrenCount++;
|
66 |
|
67 | allChildrenCount += child.allChildrenCount;
|
68 | });
|
69 | rowNode.setAllChildrenCount(allChildrenCount);
|
70 | };
|
71 | FilterService.prototype.setAllChildrenCountGridGrouping = function (rowNode) {
|
72 |
|
73 | var allChildrenCount = 0;
|
74 | rowNode.childrenAfterFilter.forEach(function (child) {
|
75 | if (child.group) {
|
76 | allChildrenCount += child.allChildrenCount;
|
77 | }
|
78 | else {
|
79 | allChildrenCount++;
|
80 | }
|
81 | });
|
82 | rowNode.setAllChildrenCount(allChildrenCount);
|
83 | };
|
84 | FilterService.prototype.setAllChildrenCount = function (rowNode) {
|
85 | if (this.doingTreeData) {
|
86 | this.setAllChildrenCountTreeData(rowNode);
|
87 | }
|
88 | else {
|
89 | this.setAllChildrenCountGridGrouping(rowNode);
|
90 | }
|
91 | };
|
92 | __decorate([
|
93 | context_1.Autowired('filterManager'),
|
94 | __metadata("design:type", filterManager_1.FilterManager)
|
95 | ], FilterService.prototype, "filterManager", void 0);
|
96 | __decorate([
|
97 | context_1.Autowired('gridOptionsWrapper'),
|
98 | __metadata("design:type", gridOptionsWrapper_1.GridOptionsWrapper)
|
99 | ], FilterService.prototype, "gridOptionsWrapper", void 0);
|
100 | __decorate([
|
101 | context_1.PostConstruct,
|
102 | __metadata("design:type", Function),
|
103 | __metadata("design:paramtypes", []),
|
104 | __metadata("design:returntype", void 0)
|
105 | ], FilterService.prototype, "postConstruct", null);
|
106 | FilterService = __decorate([
|
107 | context_1.Bean("filterService")
|
108 | ], FilterService);
|
109 | return FilterService;
|
110 | }());
|
111 | exports.FilterService = FilterService;
|