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 utils_1 = require("../../utils");
|
19 | var constants_1 = require("../../constants");
|
20 | var gridOptionsWrapper_1 = require("../../gridOptionsWrapper");
|
21 | var columnApi_1 = require("../../columnController/columnApi");
|
22 | var columnController_1 = require("../../columnController/columnController");
|
23 | var filterManager_1 = require("../../filter/filterManager");
|
24 | var rowNode_1 = require("../../entities/rowNode");
|
25 | var eventService_1 = require("../../eventService");
|
26 | var events_1 = require("../../events");
|
27 | var context_1 = require("../../context/context");
|
28 | var selectionController_1 = require("../../selectionController");
|
29 | var clientSideNodeManager_1 = require("./clientSideNodeManager");
|
30 | var changedPath_1 = require("./changedPath");
|
31 | var valueService_1 = require("../../valueService/valueService");
|
32 | var valueCache_1 = require("../../valueService/valueCache");
|
33 | var gridApi_1 = require("../../gridApi");
|
34 | var RecursionType;
|
35 | (function (RecursionType) {
|
36 | RecursionType[RecursionType["Normal"] = 0] = "Normal";
|
37 | RecursionType[RecursionType["AfterFilter"] = 1] = "AfterFilter";
|
38 | RecursionType[RecursionType["AfterFilterAndSort"] = 2] = "AfterFilterAndSort";
|
39 | RecursionType[RecursionType["PivotNodes"] = 3] = "PivotNodes";
|
40 | })(RecursionType || (RecursionType = {}));
|
41 | ;
|
42 | var ClientSideRowModel = (function () {
|
43 | function ClientSideRowModel() {
|
44 | }
|
45 | ClientSideRowModel.prototype.init = function () {
|
46 | var refreshEverythingFunc = this.refreshModel.bind(this, { step: constants_1.Constants.STEP_EVERYTHING });
|
47 | this.eventService.addModalPriorityEventListener(events_1.Events.EVENT_COLUMN_EVERYTHING_CHANGED, refreshEverythingFunc);
|
48 | this.eventService.addModalPriorityEventListener(events_1.Events.EVENT_COLUMN_ROW_GROUP_CHANGED, refreshEverythingFunc);
|
49 | this.eventService.addModalPriorityEventListener(events_1.Events.EVENT_COLUMN_VALUE_CHANGED, this.onValueChanged.bind(this));
|
50 | this.eventService.addModalPriorityEventListener(events_1.Events.EVENT_COLUMN_PIVOT_CHANGED, this.refreshModel.bind(this, { step: constants_1.Constants.STEP_PIVOT }));
|
51 | this.eventService.addModalPriorityEventListener(events_1.Events.EVENT_ROW_GROUP_OPENED, this.onRowGroupOpened.bind(this));
|
52 | this.eventService.addModalPriorityEventListener(events_1.Events.EVENT_FILTER_CHANGED, this.onFilterChanged.bind(this));
|
53 | this.eventService.addModalPriorityEventListener(events_1.Events.EVENT_SORT_CHANGED, this.onSortChanged.bind(this));
|
54 | this.eventService.addModalPriorityEventListener(events_1.Events.EVENT_COLUMN_PIVOT_MODE_CHANGED, refreshEverythingFunc);
|
55 | var refreshMapFunc = this.refreshModel.bind(this, { step: constants_1.Constants.STEP_MAP, keepRenderedRows: true, animate: true });
|
56 | this.gridOptionsWrapper.addEventListener(gridOptionsWrapper_1.GridOptionsWrapper.PROP_GROUP_REMOVE_SINGLE_CHILDREN, refreshMapFunc);
|
57 | this.gridOptionsWrapper.addEventListener(gridOptionsWrapper_1.GridOptionsWrapper.PROP_GROUP_REMOVE_LOWEST_SINGLE_CHILDREN, refreshMapFunc);
|
58 | this.rootNode = new rowNode_1.RowNode();
|
59 | this.nodeManager = new clientSideNodeManager_1.ClientSideNodeManager(this.rootNode, this.gridOptionsWrapper, this.context, this.eventService, this.columnController, this.gridApi, this.columnApi, this.selectionController);
|
60 | this.context.wireBean(this.rootNode);
|
61 | };
|
62 |
|
63 | ClientSideRowModel.prototype.ensureRowAtPixel = function (rowNode, pixel) {
|
64 | var indexAtPixelNow = this.getRowIndexAtPixel(pixel);
|
65 | var rowNodeAtPixelNow = this.getRow(indexAtPixelNow);
|
66 | if (rowNodeAtPixelNow === rowNode) {
|
67 | return false;
|
68 | }
|
69 | utils_1.Utils.removeFromArray(this.rootNode.allLeafChildren, rowNode);
|
70 | utils_1.Utils.insertIntoArray(this.rootNode.allLeafChildren, rowNode, indexAtPixelNow);
|
71 | this.refreshModel({ step: constants_1.Constants.STEP_EVERYTHING, keepRenderedRows: true, animate: true, keepEditingRows: true });
|
72 | return true;
|
73 | };
|
74 | ClientSideRowModel.prototype.isLastRowFound = function () {
|
75 | return true;
|
76 | };
|
77 | ClientSideRowModel.prototype.getRowCount = function () {
|
78 | if (this.rowsToDisplay) {
|
79 | return this.rowsToDisplay.length;
|
80 | }
|
81 | else {
|
82 | return 0;
|
83 | }
|
84 | };
|
85 | ClientSideRowModel.prototype.getRowBounds = function (index) {
|
86 | if (utils_1.Utils.missing(this.rowsToDisplay)) {
|
87 | return null;
|
88 | }
|
89 | var rowNode = this.rowsToDisplay[index];
|
90 | if (rowNode) {
|
91 | return {
|
92 | rowTop: rowNode.rowTop,
|
93 | rowHeight: rowNode.rowHeight
|
94 | };
|
95 | }
|
96 | else {
|
97 | return null;
|
98 | }
|
99 | };
|
100 | ClientSideRowModel.prototype.onRowGroupOpened = function () {
|
101 | var animate = this.gridOptionsWrapper.isAnimateRows();
|
102 | this.refreshModel({ step: constants_1.Constants.STEP_MAP, keepRenderedRows: true, animate: animate });
|
103 | };
|
104 | ClientSideRowModel.prototype.onFilterChanged = function () {
|
105 | var animate = this.gridOptionsWrapper.isAnimateRows();
|
106 | this.refreshModel({ step: constants_1.Constants.STEP_FILTER, keepRenderedRows: true, animate: animate });
|
107 | };
|
108 | ClientSideRowModel.prototype.onSortChanged = function () {
|
109 |
|
110 |
|
111 | if (this.gridOptionsWrapper.isEnableServerSideSorting()) {
|
112 | return;
|
113 | }
|
114 | var animate = this.gridOptionsWrapper.isAnimateRows();
|
115 | this.refreshModel({ step: constants_1.Constants.STEP_SORT, keepRenderedRows: true, animate: animate, keepEditingRows: true });
|
116 | };
|
117 | ClientSideRowModel.prototype.getType = function () {
|
118 | return constants_1.Constants.ROW_MODEL_TYPE_CLIENT_SIDE;
|
119 | };
|
120 | ClientSideRowModel.prototype.onValueChanged = function () {
|
121 | if (this.columnController.isPivotActive()) {
|
122 | this.refreshModel({ step: constants_1.Constants.STEP_PIVOT });
|
123 | }
|
124 | else {
|
125 | this.refreshModel({ step: constants_1.Constants.STEP_AGGREGATE });
|
126 | }
|
127 | };
|
128 | ClientSideRowModel.prototype.createChangePath = function (rowNodeTransactions) {
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 | var valueColumns = this.columnController.getValueColumns();
|
137 | var noValueColumns = utils_1.Utils.missingOrEmpty(valueColumns);
|
138 | var noTransactions = utils_1.Utils.missingOrEmpty(rowNodeTransactions);
|
139 | var changedPath = new changedPath_1.ChangedPath(false);
|
140 | if (noValueColumns || noTransactions) {
|
141 | changedPath.setInactive();
|
142 | }
|
143 | return changedPath;
|
144 | };
|
145 | ClientSideRowModel.prototype.refreshModel = function (params) {
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 | var _this = this;
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 | var changedPath = this.createChangePath(params.rowNodeTransactions);
|
158 | switch (params.step) {
|
159 | case constants_1.Constants.STEP_EVERYTHING:
|
160 |
|
161 | this.doRowGrouping(params.groupState, params.rowNodeTransactions, params.rowNodeOrder, changedPath);
|
162 |
|
163 | case constants_1.Constants.STEP_FILTER:
|
164 |
|
165 | this.doFilter();
|
166 |
|
167 | case constants_1.Constants.STEP_PIVOT:
|
168 | this.doPivot(changedPath);
|
169 | case constants_1.Constants.STEP_AGGREGATE:
|
170 |
|
171 | this.doAggregate(changedPath);
|
172 |
|
173 | case constants_1.Constants.STEP_SORT:
|
174 |
|
175 | this.doSort();
|
176 |
|
177 | case constants_1.Constants.STEP_MAP:
|
178 |
|
179 | this.doRowsToDisplay();
|
180 | }
|
181 | var event = {
|
182 | type: events_1.Events.EVENT_MODEL_UPDATED,
|
183 | api: this.gridApi,
|
184 | columnApi: this.columnApi,
|
185 | animate: params.animate,
|
186 | keepRenderedRows: params.keepRenderedRows,
|
187 | newData: params.newData,
|
188 | newPage: false
|
189 | };
|
190 | this.eventService.dispatchEvent(event);
|
191 | if (this.$scope) {
|
192 | setTimeout(function () {
|
193 | _this.$scope.$apply();
|
194 | }, 0);
|
195 | }
|
196 | };
|
197 | ClientSideRowModel.prototype.isEmpty = function () {
|
198 | var rowsMissing;
|
199 | var doingLegacyTreeData = utils_1.Utils.exists(this.gridOptionsWrapper.getNodeChildDetailsFunc());
|
200 | if (doingLegacyTreeData) {
|
201 | rowsMissing = utils_1.Utils.missing(this.rootNode.childrenAfterGroup) || this.rootNode.childrenAfterGroup.length === 0;
|
202 | }
|
203 | else {
|
204 | rowsMissing = utils_1.Utils.missing(this.rootNode.allLeafChildren) || this.rootNode.allLeafChildren.length === 0;
|
205 | }
|
206 | var empty = utils_1.Utils.missing(this.rootNode) || rowsMissing || !this.columnController.isReady();
|
207 | return empty;
|
208 | };
|
209 | ClientSideRowModel.prototype.isRowsToRender = function () {
|
210 | return utils_1.Utils.exists(this.rowsToDisplay) && this.rowsToDisplay.length > 0;
|
211 | };
|
212 | ClientSideRowModel.prototype.getNodesInRangeForSelection = function (firstInRange, lastInRange) {
|
213 |
|
214 | var firstRowHit = !lastInRange;
|
215 | var lastRowHit = false;
|
216 | var lastRow;
|
217 | var result = [];
|
218 | var groupsSelectChildren = this.gridOptionsWrapper.isGroupSelectsChildren();
|
219 | this.forEachNodeAfterFilterAndSort(function (rowNode) {
|
220 | var lookingForLastRow = firstRowHit && !lastRowHit;
|
221 |
|
222 | if (!firstRowHit) {
|
223 | if (rowNode === lastInRange || rowNode === firstInRange) {
|
224 | firstRowHit = true;
|
225 | }
|
226 | }
|
227 | var skipThisGroupNode = rowNode.group && groupsSelectChildren;
|
228 | if (!skipThisGroupNode) {
|
229 | var inRange = firstRowHit && !lastRowHit;
|
230 | var childOfLastRow = rowNode.isParentOfNode(lastRow);
|
231 | if (inRange || childOfLastRow) {
|
232 | result.push(rowNode);
|
233 | }
|
234 | }
|
235 | if (lookingForLastRow) {
|
236 | if (rowNode === lastInRange || rowNode === firstInRange) {
|
237 | lastRowHit = true;
|
238 | if (rowNode === lastInRange) {
|
239 | lastRow = lastInRange;
|
240 | }
|
241 | else {
|
242 | lastRow = firstInRange;
|
243 | }
|
244 | }
|
245 | }
|
246 | });
|
247 | return result;
|
248 | };
|
249 | ClientSideRowModel.prototype.setDatasource = function (datasource) {
|
250 | console.error('ag-Grid: should never call setDatasource on clientSideRowController');
|
251 | };
|
252 | ClientSideRowModel.prototype.getTopLevelNodes = function () {
|
253 | return this.rootNode ? this.rootNode.childrenAfterGroup : null;
|
254 | };
|
255 | ClientSideRowModel.prototype.getRootNode = function () {
|
256 | return this.rootNode;
|
257 | };
|
258 | ClientSideRowModel.prototype.getRow = function (index) {
|
259 | return this.rowsToDisplay[index];
|
260 | };
|
261 | ClientSideRowModel.prototype.isRowPresent = function (rowNode) {
|
262 | return this.rowsToDisplay.indexOf(rowNode) >= 0;
|
263 | };
|
264 | ClientSideRowModel.prototype.getVirtualRowCount = function () {
|
265 | console.warn('ag-Grid: rowModel.getVirtualRowCount() is not longer a function, use rowModel.getRowCount() instead');
|
266 | return this.getPageLastRow();
|
267 | };
|
268 | ClientSideRowModel.prototype.getPageFirstRow = function () {
|
269 | return 0;
|
270 | };
|
271 | ClientSideRowModel.prototype.getPageLastRow = function () {
|
272 | if (this.rowsToDisplay) {
|
273 | return this.rowsToDisplay.length - 1;
|
274 | }
|
275 | else {
|
276 | return 0;
|
277 | }
|
278 | };
|
279 | ClientSideRowModel.prototype.getRowIndexAtPixel = function (pixelToMatch) {
|
280 | if (this.isEmpty()) {
|
281 | return -1;
|
282 | }
|
283 |
|
284 |
|
285 | var bottomPointer = 0;
|
286 | var topPointer = this.rowsToDisplay.length - 1;
|
287 |
|
288 | if (pixelToMatch <= 0) {
|
289 |
|
290 | return 0;
|
291 | }
|
292 | var lastNode = this.rowsToDisplay[this.rowsToDisplay.length - 1];
|
293 | if (lastNode.rowTop <= pixelToMatch) {
|
294 | return this.rowsToDisplay.length - 1;
|
295 | }
|
296 | while (true) {
|
297 | var midPointer = Math.floor((bottomPointer + topPointer) / 2);
|
298 | var currentRowNode = this.rowsToDisplay[midPointer];
|
299 | if (this.isRowInPixel(currentRowNode, pixelToMatch)) {
|
300 | return midPointer;
|
301 | }
|
302 | else if (currentRowNode.rowTop < pixelToMatch) {
|
303 | bottomPointer = midPointer + 1;
|
304 | }
|
305 | else if (currentRowNode.rowTop > pixelToMatch) {
|
306 | topPointer = midPointer - 1;
|
307 | }
|
308 | }
|
309 | };
|
310 | ClientSideRowModel.prototype.isRowInPixel = function (rowNode, pixelToMatch) {
|
311 | var topPixel = rowNode.rowTop;
|
312 | var bottomPixel = rowNode.rowTop + rowNode.rowHeight;
|
313 | var pixelInRow = topPixel <= pixelToMatch && bottomPixel > pixelToMatch;
|
314 | return pixelInRow;
|
315 | };
|
316 | ClientSideRowModel.prototype.getCurrentPageHeight = function () {
|
317 | if (this.rowsToDisplay && this.rowsToDisplay.length > 0) {
|
318 | var lastRow = this.rowsToDisplay[this.rowsToDisplay.length - 1];
|
319 | var lastPixel = lastRow.rowTop + lastRow.rowHeight;
|
320 | return lastPixel;
|
321 | }
|
322 | else {
|
323 | return 0;
|
324 | }
|
325 | };
|
326 | ClientSideRowModel.prototype.forEachLeafNode = function (callback) {
|
327 | if (this.rootNode.allLeafChildren) {
|
328 | this.rootNode.allLeafChildren.forEach(function (rowNode, index) { return callback(rowNode, index); });
|
329 | }
|
330 | };
|
331 | ClientSideRowModel.prototype.forEachNode = function (callback) {
|
332 | this.recursivelyWalkNodesAndCallback(this.rootNode.childrenAfterGroup, callback, RecursionType.Normal, 0);
|
333 | };
|
334 | ClientSideRowModel.prototype.forEachNodeAfterFilter = function (callback) {
|
335 | this.recursivelyWalkNodesAndCallback(this.rootNode.childrenAfterFilter, callback, RecursionType.AfterFilter, 0);
|
336 | };
|
337 | ClientSideRowModel.prototype.forEachNodeAfterFilterAndSort = function (callback) {
|
338 | this.recursivelyWalkNodesAndCallback(this.rootNode.childrenAfterSort, callback, RecursionType.AfterFilterAndSort, 0);
|
339 | };
|
340 | ClientSideRowModel.prototype.forEachPivotNode = function (callback) {
|
341 | this.recursivelyWalkNodesAndCallback([this.rootNode], callback, RecursionType.PivotNodes, 0);
|
342 | };
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 | ClientSideRowModel.prototype.recursivelyWalkNodesAndCallback = function (nodes, callback, recursionType, index) {
|
349 | if (nodes) {
|
350 | for (var i = 0; i < nodes.length; i++) {
|
351 | var node = nodes[i];
|
352 | callback(node, index++);
|
353 |
|
354 | if (node.hasChildren()) {
|
355 |
|
356 | var nodeChildren = void 0;
|
357 | switch (recursionType) {
|
358 | case RecursionType.Normal:
|
359 | nodeChildren = node.childrenAfterGroup;
|
360 | break;
|
361 | case RecursionType.AfterFilter:
|
362 | nodeChildren = node.childrenAfterFilter;
|
363 | break;
|
364 | case RecursionType.AfterFilterAndSort:
|
365 | nodeChildren = node.childrenAfterSort;
|
366 | break;
|
367 | case RecursionType.PivotNodes:
|
368 |
|
369 | nodeChildren = !node.leafGroup ? node.childrenAfterSort : null;
|
370 | break;
|
371 | }
|
372 | if (nodeChildren) {
|
373 | index = this.recursivelyWalkNodesAndCallback(nodeChildren, callback, recursionType, index);
|
374 | }
|
375 | }
|
376 | }
|
377 | }
|
378 | return index;
|
379 | };
|
380 |
|
381 |
|
382 | ClientSideRowModel.prototype.doAggregate = function (changedPath) {
|
383 | if (this.aggregationStage) {
|
384 | this.aggregationStage.execute({ rowNode: this.rootNode, changedPath: changedPath });
|
385 | }
|
386 | };
|
387 |
|
388 |
|
389 | ClientSideRowModel.prototype.expandOrCollapseAll = function (expand) {
|
390 | var usingTreeData = this.gridOptionsWrapper.isTreeData();
|
391 | if (this.rootNode) {
|
392 | recursiveExpandOrCollapse(this.rootNode.childrenAfterGroup);
|
393 | }
|
394 | function recursiveExpandOrCollapse(rowNodes) {
|
395 | if (!rowNodes) {
|
396 | return;
|
397 | }
|
398 | rowNodes.forEach(function (rowNode) {
|
399 | var shouldExpandOrCollapse = usingTreeData ? utils_1.Utils.exists(rowNode.childrenAfterGroup) : rowNode.group;
|
400 | if (shouldExpandOrCollapse) {
|
401 | rowNode.expanded = expand;
|
402 | recursiveExpandOrCollapse(rowNode.childrenAfterGroup);
|
403 | }
|
404 | });
|
405 | }
|
406 | this.refreshModel({ step: constants_1.Constants.STEP_MAP });
|
407 | };
|
408 | ClientSideRowModel.prototype.doSort = function () {
|
409 | this.sortStage.execute({ rowNode: this.rootNode });
|
410 | };
|
411 | ClientSideRowModel.prototype.doRowGrouping = function (groupState, rowNodeTransactions, rowNodeOrder, changedPath) {
|
412 | var _this = this;
|
413 |
|
414 | var doingLegacyTreeData = utils_1.Utils.exists(this.gridOptionsWrapper.getNodeChildDetailsFunc());
|
415 | if (doingLegacyTreeData) {
|
416 | return;
|
417 | }
|
418 | if (this.groupStage) {
|
419 | if (utils_1.Utils.exists(rowNodeTransactions)) {
|
420 | rowNodeTransactions.forEach(function (tran) {
|
421 | _this.groupStage.execute({ rowNode: _this.rootNode,
|
422 | rowNodeTransaction: tran,
|
423 | rowNodeOrder: rowNodeOrder,
|
424 | changedPath: changedPath });
|
425 | });
|
426 | }
|
427 | else {
|
428 |
|
429 | this.selectionController.removeGroupsFromSelection();
|
430 | this.groupStage.execute({ rowNode: this.rootNode, changedPath: changedPath });
|
431 |
|
432 | this.restoreGroupState(groupState);
|
433 | }
|
434 | if (this.gridOptionsWrapper.isGroupSelectsChildren()) {
|
435 | this.selectionController.updateGroupsFromChildrenSelections();
|
436 | }
|
437 | }
|
438 | else {
|
439 | this.rootNode.childrenAfterGroup = this.rootNode.allLeafChildren;
|
440 | }
|
441 | };
|
442 | ClientSideRowModel.prototype.restoreGroupState = function (groupState) {
|
443 | if (!groupState) {
|
444 | return;
|
445 | }
|
446 | utils_1.Utils.traverseNodesWithKey(this.rootNode.childrenAfterGroup, function (node, key) {
|
447 |
|
448 |
|
449 |
|
450 | if (typeof groupState[key] === 'boolean') {
|
451 | node.expanded = groupState[key];
|
452 | }
|
453 | });
|
454 | };
|
455 | ClientSideRowModel.prototype.doFilter = function () {
|
456 | this.filterStage.execute({ rowNode: this.rootNode });
|
457 | };
|
458 | ClientSideRowModel.prototype.doPivot = function (changedPath) {
|
459 | if (this.pivotStage) {
|
460 | this.pivotStage.execute({ rowNode: this.rootNode, changedPath: changedPath });
|
461 | }
|
462 | };
|
463 | ClientSideRowModel.prototype.getGroupState = function () {
|
464 | if (!this.rootNode.childrenAfterGroup || !this.gridOptionsWrapper.isRememberGroupStateWhenNewData()) {
|
465 | return null;
|
466 | }
|
467 | var result = {};
|
468 | utils_1.Utils.traverseNodesWithKey(this.rootNode.childrenAfterGroup, function (node, key) { return result[key] = node.expanded; });
|
469 | return result;
|
470 | };
|
471 | ClientSideRowModel.prototype.getCopyOfNodesMap = function () {
|
472 | return this.nodeManager.getCopyOfNodesMap();
|
473 | };
|
474 | ClientSideRowModel.prototype.getRowNode = function (id) {
|
475 | return this.nodeManager.getRowNode(id);
|
476 | };
|
477 |
|
478 | ClientSideRowModel.prototype.setRowData = function (rowData) {
|
479 |
|
480 |
|
481 |
|
482 | var groupState = this.getGroupState();
|
483 | this.nodeManager.setRowData(rowData);
|
484 |
|
485 |
|
486 |
|
487 |
|
488 | var rowDataChangedEvent = {
|
489 | type: events_1.Events.EVENT_ROW_DATA_CHANGED,
|
490 | api: this.gridApi,
|
491 | columnApi: this.columnApi
|
492 | };
|
493 | this.eventService.dispatchEvent(rowDataChangedEvent);
|
494 | this.refreshModel({
|
495 | step: constants_1.Constants.STEP_EVERYTHING,
|
496 | groupState: groupState,
|
497 | newData: true
|
498 | });
|
499 | };
|
500 | ClientSideRowModel.prototype.batchUpdateRowData = function (rowDataTransaction, callback) {
|
501 | var _this = this;
|
502 | if (!this.rowDataTransactionBatch) {
|
503 | this.rowDataTransactionBatch = [];
|
504 | var waitMillis = this.gridOptionsWrapper.getBatchUpdateWaitMillis();
|
505 | setTimeout(function () {
|
506 | _this.executeBatchUpdateRowData();
|
507 | _this.rowDataTransactionBatch = null;
|
508 | }, waitMillis);
|
509 | }
|
510 | this.rowDataTransactionBatch.push({ rowDataTransaction: rowDataTransaction, callback: callback });
|
511 | };
|
512 | ClientSideRowModel.prototype.executeBatchUpdateRowData = function () {
|
513 | var _this = this;
|
514 | this.valueCache.onDataChanged();
|
515 | var callbackFuncsBound = [];
|
516 | var rowNodeTrans = [];
|
517 | this.rowDataTransactionBatch.forEach(function (tranItem) {
|
518 | var rowNodeTran = _this.nodeManager.updateRowData(tranItem.rowDataTransaction, null);
|
519 | rowNodeTrans.push(rowNodeTran);
|
520 | if (tranItem.callback) {
|
521 | callbackFuncsBound.push(tranItem.callback.bind(rowNodeTran));
|
522 | }
|
523 | });
|
524 | this.commonUpdateRowData(rowNodeTrans);
|
525 |
|
526 | if (callbackFuncsBound.length > 0) {
|
527 | setTimeout(function () {
|
528 | callbackFuncsBound.forEach(function (func) { return func(); });
|
529 | }, 0);
|
530 | }
|
531 | };
|
532 | ClientSideRowModel.prototype.updateRowData = function (rowDataTran, rowNodeOrder) {
|
533 | this.valueCache.onDataChanged();
|
534 | var rowNodeTran = this.nodeManager.updateRowData(rowDataTran, rowNodeOrder);
|
535 | this.commonUpdateRowData([rowNodeTran], rowNodeOrder);
|
536 | return rowNodeTran;
|
537 | };
|
538 |
|
539 | ClientSideRowModel.prototype.commonUpdateRowData = function (rowNodeTrans, rowNodeOrder) {
|
540 | this.refreshModel({
|
541 | step: constants_1.Constants.STEP_EVERYTHING,
|
542 | rowNodeTransactions: rowNodeTrans,
|
543 | rowNodeOrder: rowNodeOrder,
|
544 | keepRenderedRows: true,
|
545 | animate: true,
|
546 | keepEditingRows: true
|
547 | });
|
548 | var event = {
|
549 | type: events_1.Events.EVENT_ROW_DATA_UPDATED,
|
550 | api: this.gridApi,
|
551 | columnApi: this.columnApi
|
552 | };
|
553 | this.eventService.dispatchEvent(event);
|
554 | };
|
555 | ClientSideRowModel.prototype.doRowsToDisplay = function () {
|
556 | this.rowsToDisplay = this.flattenStage.execute({ rowNode: this.rootNode });
|
557 | };
|
558 | ClientSideRowModel.prototype.onRowHeightChanged = function () {
|
559 | this.refreshModel({ step: constants_1.Constants.STEP_MAP, keepRenderedRows: true, keepEditingRows: true });
|
560 | };
|
561 | ClientSideRowModel.prototype.resetRowHeights = function () {
|
562 | this.forEachNode(function (rowNode) { return rowNode.setRowHeight(null); });
|
563 | this.onRowHeightChanged();
|
564 | };
|
565 | __decorate([
|
566 | context_1.Autowired('gridOptionsWrapper'),
|
567 | __metadata("design:type", gridOptionsWrapper_1.GridOptionsWrapper)
|
568 | ], ClientSideRowModel.prototype, "gridOptionsWrapper", void 0);
|
569 | __decorate([
|
570 | context_1.Autowired('columnController'),
|
571 | __metadata("design:type", columnController_1.ColumnController)
|
572 | ], ClientSideRowModel.prototype, "columnController", void 0);
|
573 | __decorate([
|
574 | context_1.Autowired('filterManager'),
|
575 | __metadata("design:type", filterManager_1.FilterManager)
|
576 | ], ClientSideRowModel.prototype, "filterManager", void 0);
|
577 | __decorate([
|
578 | context_1.Autowired('$scope'),
|
579 | __metadata("design:type", Object)
|
580 | ], ClientSideRowModel.prototype, "$scope", void 0);
|
581 | __decorate([
|
582 | context_1.Autowired('selectionController'),
|
583 | __metadata("design:type", selectionController_1.SelectionController)
|
584 | ], ClientSideRowModel.prototype, "selectionController", void 0);
|
585 | __decorate([
|
586 | context_1.Autowired('eventService'),
|
587 | __metadata("design:type", eventService_1.EventService)
|
588 | ], ClientSideRowModel.prototype, "eventService", void 0);
|
589 | __decorate([
|
590 | context_1.Autowired('context'),
|
591 | __metadata("design:type", context_1.Context)
|
592 | ], ClientSideRowModel.prototype, "context", void 0);
|
593 | __decorate([
|
594 | context_1.Autowired('valueService'),
|
595 | __metadata("design:type", valueService_1.ValueService)
|
596 | ], ClientSideRowModel.prototype, "valueService", void 0);
|
597 | __decorate([
|
598 | context_1.Autowired('valueCache'),
|
599 | __metadata("design:type", valueCache_1.ValueCache)
|
600 | ], ClientSideRowModel.prototype, "valueCache", void 0);
|
601 | __decorate([
|
602 | context_1.Autowired('columnApi'),
|
603 | __metadata("design:type", columnApi_1.ColumnApi)
|
604 | ], ClientSideRowModel.prototype, "columnApi", void 0);
|
605 | __decorate([
|
606 | context_1.Autowired('gridApi'),
|
607 | __metadata("design:type", gridApi_1.GridApi)
|
608 | ], ClientSideRowModel.prototype, "gridApi", void 0);
|
609 | __decorate([
|
610 | context_1.Autowired('filterStage'),
|
611 | __metadata("design:type", Object)
|
612 | ], ClientSideRowModel.prototype, "filterStage", void 0);
|
613 | __decorate([
|
614 | context_1.Autowired('sortStage'),
|
615 | __metadata("design:type", Object)
|
616 | ], ClientSideRowModel.prototype, "sortStage", void 0);
|
617 | __decorate([
|
618 | context_1.Autowired('flattenStage'),
|
619 | __metadata("design:type", Object)
|
620 | ], ClientSideRowModel.prototype, "flattenStage", void 0);
|
621 | __decorate([
|
622 | context_1.Optional('groupStage'),
|
623 | __metadata("design:type", Object)
|
624 | ], ClientSideRowModel.prototype, "groupStage", void 0);
|
625 | __decorate([
|
626 | context_1.Optional('aggregationStage'),
|
627 | __metadata("design:type", Object)
|
628 | ], ClientSideRowModel.prototype, "aggregationStage", void 0);
|
629 | __decorate([
|
630 | context_1.Optional('pivotStage'),
|
631 | __metadata("design:type", Object)
|
632 | ], ClientSideRowModel.prototype, "pivotStage", void 0);
|
633 | __decorate([
|
634 | context_1.PostConstruct,
|
635 | __metadata("design:type", Function),
|
636 | __metadata("design:paramtypes", []),
|
637 | __metadata("design:returntype", void 0)
|
638 | ], ClientSideRowModel.prototype, "init", null);
|
639 | ClientSideRowModel = __decorate([
|
640 | context_1.Bean('rowModel')
|
641 | ], ClientSideRowModel);
|
642 | return ClientSideRowModel;
|
643 | }());
|
644 | exports.ClientSideRowModel = ClientSideRowModel;
|