1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | "use strict";
|
8 | Object.defineProperty(exports, "__esModule", { value: true });
|
9 | var ChangedPath = (function () {
|
10 | function ChangedPath(keepingColumns) {
|
11 | this.active = true;
|
12 | this.nodeIdsToBoolean = {};
|
13 | this.nodeIdsToColumns = {};
|
14 | this.keepingColumns = keepingColumns;
|
15 | }
|
16 | ChangedPath.prototype.setInactive = function () {
|
17 | this.active = false;
|
18 | };
|
19 | ChangedPath.prototype.isActive = function () {
|
20 | return this.active;
|
21 | };
|
22 | ChangedPath.prototype.addParentNode = function (rowNode, columns) {
|
23 | var _this = this;
|
24 | this.validateActive();
|
25 | var pointer = rowNode;
|
26 | while (pointer) {
|
27 |
|
28 | this.nodeIdsToBoolean[pointer.id] = true;
|
29 |
|
30 |
|
31 | if (this.keepingColumns && columns) {
|
32 | if (!this.nodeIdsToColumns[pointer.id]) {
|
33 | this.nodeIdsToColumns[pointer.id] = {};
|
34 | }
|
35 | columns.forEach(function (col) { return _this.nodeIdsToColumns[pointer.id][col.getId()] = true; });
|
36 | }
|
37 | pointer = pointer.parent;
|
38 | }
|
39 | };
|
40 | ChangedPath.prototype.isInPath = function (rowNode) {
|
41 | this.validateActive();
|
42 | return this.nodeIdsToBoolean[rowNode.id];
|
43 | };
|
44 | ChangedPath.prototype.getValueColumnsForNode = function (rowNode, valueColumns) {
|
45 | this.validateActive();
|
46 | if (!this.keepingColumns) {
|
47 | return valueColumns;
|
48 | }
|
49 | var colsForThisNode = this.nodeIdsToColumns[rowNode.id];
|
50 | var result = valueColumns.filter(function (col) { return colsForThisNode[col.getId()]; });
|
51 | return result;
|
52 | };
|
53 | ChangedPath.prototype.getNotValueColumnsForNode = function (rowNode, valueColumns) {
|
54 | this.validateActive();
|
55 | if (!this.keepingColumns) {
|
56 | return null;
|
57 | }
|
58 | var colsForThisNode = this.nodeIdsToColumns[rowNode.id];
|
59 | var result = valueColumns.filter(function (col) { return !colsForThisNode[col.getId()]; });
|
60 | return result;
|
61 | };
|
62 |
|
63 |
|
64 | ChangedPath.prototype.validateActive = function () {
|
65 | if (!this.active) {
|
66 | throw "ag-Grid: tried to work on an invalid changed path";
|
67 | }
|
68 | };
|
69 | return ChangedPath;
|
70 | }());
|
71 | exports.ChangedPath = ChangedPath;
|