@deephaven/iris-grid 0.13.3-treemap.2 → 0.14.1-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AdvancedFilterCreator.d.ts +69 -63
- package/dist/AdvancedFilterCreator.d.ts.map +1 -1
- package/dist/AdvancedFilterCreator.js +79 -73
- package/dist/AdvancedFilterCreator.js.map +1 -1
- package/dist/AdvancedFilterCreatorSelectValue.d.ts +45 -45
- package/dist/AdvancedFilterCreatorSelectValue.d.ts.map +1 -1
- package/dist/AdvancedFilterCreatorSelectValue.js +32 -36
- package/dist/AdvancedFilterCreatorSelectValue.js.map +1 -1
- package/dist/AdvancedFilterCreatorSelectValueList.d.ts +47 -52
- package/dist/AdvancedFilterCreatorSelectValueList.d.ts.map +1 -1
- package/dist/AdvancedFilterCreatorSelectValueList.js +24 -39
- package/dist/AdvancedFilterCreatorSelectValueList.js.map +1 -1
- package/dist/ColumnStatistics.d.ts +34 -22
- package/dist/ColumnStatistics.d.ts.map +1 -1
- package/dist/ColumnStatistics.js +8 -12
- package/dist/ColumnStatistics.js.map +1 -1
- package/dist/CommonTypes.d.ts +58 -0
- package/dist/CommonTypes.d.ts.map +1 -0
- package/dist/CommonTypes.js +2 -0
- package/dist/CommonTypes.js.map +1 -0
- package/dist/CrossColumnSearch.d.ts +26 -24
- package/dist/CrossColumnSearch.d.ts.map +1 -1
- package/dist/CrossColumnSearch.js +9 -13
- package/dist/CrossColumnSearch.js.map +1 -1
- package/dist/FilterInputField.d.ts +48 -51
- package/dist/FilterInputField.d.ts.map +1 -1
- package/dist/FilterInputField.js +30 -27
- package/dist/FilterInputField.js.map +1 -1
- package/dist/IrisGrid.d.ts +410 -453
- package/dist/IrisGrid.d.ts.map +1 -1
- package/dist/IrisGrid.js +590 -526
- package/dist/IrisGrid.js.map +1 -1
- package/dist/IrisGridCellOverflowModal.d.ts +1 -1
- package/dist/IrisGridCellOverflowModal.d.ts.map +1 -1
- package/dist/IrisGridCellOverflowModal.js +1 -4
- package/dist/IrisGridCellOverflowModal.js.map +1 -1
- package/dist/IrisGridCopyHandler.d.ts +52 -46
- package/dist/IrisGridCopyHandler.d.ts.map +1 -1
- package/dist/IrisGridCopyHandler.js +22 -38
- package/dist/IrisGridCopyHandler.js.map +1 -1
- package/dist/IrisGridMetricCalculator.d.ts +5 -4
- package/dist/IrisGridMetricCalculator.d.ts.map +1 -1
- package/dist/IrisGridMetricCalculator.js +5 -1
- package/dist/IrisGridMetricCalculator.js.map +1 -1
- package/dist/IrisGridModel.d.ts +37 -35
- package/dist/IrisGridModel.d.ts.map +1 -1
- package/dist/IrisGridModel.js +19 -3
- package/dist/IrisGridModel.js.map +1 -1
- package/dist/IrisGridModelFactory.d.ts +7 -5
- package/dist/IrisGridModelFactory.d.ts.map +1 -1
- package/dist/IrisGridModelFactory.js +5 -5
- package/dist/IrisGridModelFactory.js.map +1 -1
- package/dist/IrisGridModelUpdater.d.ts +13 -11
- package/dist/IrisGridModelUpdater.d.ts.map +1 -1
- package/dist/IrisGridModelUpdater.js.map +1 -1
- package/dist/IrisGridPartitionSelector.d.ts +38 -39
- package/dist/IrisGridPartitionSelector.d.ts.map +1 -1
- package/dist/IrisGridPartitionSelector.js +18 -24
- package/dist/IrisGridPartitionSelector.js.map +1 -1
- package/dist/IrisGridProxyModel.d.ts +111 -32
- package/dist/IrisGridProxyModel.d.ts.map +1 -1
- package/dist/IrisGridProxyModel.js +212 -170
- package/dist/IrisGridProxyModel.js.map +1 -1
- package/dist/IrisGridRenderer.d.ts +59 -31
- package/dist/IrisGridRenderer.d.ts.map +1 -1
- package/dist/IrisGridRenderer.js +92 -46
- package/dist/IrisGridRenderer.js.map +1 -1
- package/dist/IrisGridTableModel.d.ts +48 -149
- package/dist/IrisGridTableModel.d.ts.map +1 -1
- package/dist/IrisGridTableModel.js +58 -1385
- package/dist/IrisGridTableModel.js.map +1 -1
- package/dist/IrisGridTableModelTemplate.d.ts +218 -0
- package/dist/IrisGridTableModelTemplate.d.ts.map +1 -0
- package/dist/IrisGridTableModelTemplate.js +1624 -0
- package/dist/IrisGridTableModelTemplate.js.map +1 -0
- package/dist/IrisGridTestUtils.d.ts +18 -14
- package/dist/IrisGridTestUtils.d.ts.map +1 -1
- package/dist/IrisGridTestUtils.js +29 -1
- package/dist/IrisGridTestUtils.js.map +1 -1
- package/dist/IrisGridTheme.d.ts +35 -3
- package/dist/IrisGridTheme.d.ts.map +1 -1
- package/dist/IrisGridTheme.js.map +1 -1
- package/dist/IrisGridTreeTableModel.d.ts +26 -7
- package/dist/IrisGridTreeTableModel.d.ts.map +1 -1
- package/dist/IrisGridTreeTableModel.js +24 -14
- package/dist/IrisGridTreeTableModel.js.map +1 -1
- package/dist/IrisGridUtils.d.ts +257 -162
- package/dist/IrisGridUtils.d.ts.map +1 -1
- package/dist/IrisGridUtils.js +132 -95
- package/dist/IrisGridUtils.js.map +1 -1
- package/dist/MissingKeyError.d.ts +5 -3
- package/dist/MissingKeyError.d.ts.map +1 -1
- package/dist/MissingKeyError.js.map +1 -1
- package/dist/PartitionSelectorSearch.d.ts +61 -40
- package/dist/PartitionSelectorSearch.d.ts.map +1 -1
- package/dist/PartitionSelectorSearch.js +25 -15
- package/dist/PartitionSelectorSearch.js.map +1 -1
- package/dist/PendingDataBottomBar.d.ts +3 -6
- package/dist/PendingDataBottomBar.d.ts.map +1 -1
- package/dist/PendingDataBottomBar.js.map +1 -1
- package/dist/TableViewportUpdater.d.ts +39 -55
- package/dist/TableViewportUpdater.d.ts.map +1 -1
- package/dist/TableViewportUpdater.js +42 -64
- package/dist/TableViewportUpdater.js.map +1 -1
- package/dist/TreeTableViewportUpdater.d.ts +29 -37
- package/dist/TreeTableViewportUpdater.d.ts.map +1 -1
- package/dist/TreeTableViewportUpdater.js +39 -50
- package/dist/TreeTableViewportUpdater.js.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/mousehandlers/IrisGridCellOverflowMouseHandler.d.ts.map +1 -1
- package/dist/mousehandlers/IrisGridCellOverflowMouseHandler.js.map +1 -1
- package/dist/mousehandlers/IrisGridColumnSelectMouseHandler.d.ts +1 -1
- package/dist/mousehandlers/IrisGridColumnSelectMouseHandler.d.ts.map +1 -1
- package/dist/mousehandlers/IrisGridColumnSelectMouseHandler.js +2 -0
- package/dist/mousehandlers/IrisGridColumnSelectMouseHandler.js.map +1 -1
- package/dist/mousehandlers/IrisGridColumnTooltipMouseHandler.d.ts +2 -2
- package/dist/mousehandlers/IrisGridColumnTooltipMouseHandler.d.ts.map +1 -1
- package/dist/mousehandlers/IrisGridColumnTooltipMouseHandler.js +32 -14
- package/dist/mousehandlers/IrisGridColumnTooltipMouseHandler.js.map +1 -1
- package/dist/mousehandlers/IrisGridContextMenuHandler.d.ts +41 -130
- package/dist/mousehandlers/IrisGridContextMenuHandler.d.ts.map +1 -1
- package/dist/mousehandlers/IrisGridContextMenuHandler.js +426 -317
- package/dist/mousehandlers/IrisGridContextMenuHandler.js.map +1 -1
- package/dist/mousehandlers/IrisGridFilterMouseHandler.d.ts.map +1 -1
- package/dist/mousehandlers/IrisGridFilterMouseHandler.js +2 -2
- package/dist/mousehandlers/IrisGridFilterMouseHandler.js.map +1 -1
- package/dist/mousehandlers/IrisGridSortMouseHandler.js +1 -1
- package/dist/mousehandlers/IrisGridSortMouseHandler.js.map +1 -1
- package/dist/mousehandlers/PendingMouseHandler.d.ts +8 -4
- package/dist/mousehandlers/PendingMouseHandler.d.ts.map +1 -1
- package/dist/mousehandlers/PendingMouseHandler.js +4 -5
- package/dist/mousehandlers/PendingMouseHandler.js.map +1 -1
- package/dist/sidebar/ChartBuilder.d.ts +48 -33
- package/dist/sidebar/ChartBuilder.d.ts.map +1 -1
- package/dist/sidebar/ChartBuilder.js +28 -27
- package/dist/sidebar/ChartBuilder.js.map +1 -1
- package/dist/sidebar/CustomColumnBuilder.d.ts +51 -41
- package/dist/sidebar/CustomColumnBuilder.d.ts.map +1 -1
- package/dist/sidebar/CustomColumnBuilder.js +22 -18
- package/dist/sidebar/CustomColumnBuilder.js.map +1 -1
- package/dist/sidebar/CustomColumnInput.d.ts +26 -36
- package/dist/sidebar/CustomColumnInput.d.ts.map +1 -1
- package/dist/sidebar/CustomColumnInput.js +11 -20
- package/dist/sidebar/CustomColumnInput.js.map +1 -1
- package/dist/sidebar/InputEditor.d.ts +34 -35
- package/dist/sidebar/InputEditor.d.ts.map +1 -1
- package/dist/sidebar/InputEditor.js +43 -24
- package/dist/sidebar/InputEditor.js.map +1 -1
- package/dist/sidebar/RollupRows.d.ts +67 -52
- package/dist/sidebar/RollupRows.d.ts.map +1 -1
- package/dist/sidebar/RollupRows.js +51 -53
- package/dist/sidebar/RollupRows.js.map +1 -1
- package/dist/sidebar/SelectDistinctBuilder.d.ts +27 -21
- package/dist/sidebar/SelectDistinctBuilder.d.ts.map +1 -1
- package/dist/sidebar/SelectDistinctBuilder.js +6 -10
- package/dist/sidebar/SelectDistinctBuilder.js.map +1 -1
- package/dist/sidebar/TableCsvExporter.d.ts +42 -39
- package/dist/sidebar/TableCsvExporter.d.ts.map +1 -1
- package/dist/sidebar/TableCsvExporter.js +12 -20
- package/dist/sidebar/TableCsvExporter.js.map +1 -1
- package/dist/sidebar/TableSaver.d.ts +59 -60
- package/dist/sidebar/TableSaver.d.ts.map +1 -1
- package/dist/sidebar/TableSaver.js +154 -68
- package/dist/sidebar/TableSaver.js.map +1 -1
- package/dist/sidebar/VisibilityOrderingBuilder.d.ts +56 -45
- package/dist/sidebar/VisibilityOrderingBuilder.d.ts.map +1 -1
- package/dist/sidebar/VisibilityOrderingBuilder.js +34 -29
- package/dist/sidebar/VisibilityOrderingBuilder.js.map +1 -1
- package/dist/sidebar/aggregations/Aggregations.d.ts.map +1 -1
- package/dist/sidebar/aggregations/Aggregations.js.map +1 -1
- package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.d.ts +2 -1
- package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.d.ts.map +1 -1
- package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.js.map +1 -1
- package/dist/sidebar/conditional-formatting/ConditionalFormattingUtils.d.ts +6 -5
- package/dist/sidebar/conditional-formatting/ConditionalFormattingUtils.d.ts.map +1 -1
- package/dist/sidebar/conditional-formatting/ConditionalFormattingUtils.js +5 -0
- package/dist/sidebar/conditional-formatting/ConditionalFormattingUtils.js.map +1 -1
- package/dist/sidebar/icons/index.d.ts +7 -7
- package/dist/sidebar/icons/index.d.ts.map +1 -1
- package/dist/sidebar/icons/index.js.map +1 -1
- package/dist/sidebar/index.d.ts +12 -12
- package/dist/sidebar/index.d.ts.map +1 -1
- package/dist/sidebar/index.js.map +1 -1
- package/package.json +18 -17
|
@@ -0,0 +1,1624 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
|
|
5
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
6
|
+
|
|
7
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
8
|
+
|
|
9
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
+
|
|
11
|
+
/* eslint class-methods-use-this: "off" */
|
|
12
|
+
import memoize from 'memoize-one';
|
|
13
|
+
import throttle from 'lodash.throttle';
|
|
14
|
+
import { GridRange, memoizeClear } from '@deephaven/grid';
|
|
15
|
+
import dh from '@deephaven/jsapi-shim';
|
|
16
|
+
import Log from '@deephaven/log';
|
|
17
|
+
import { EventShimCustomEvent, PromiseUtils, assertNotNull } from '@deephaven/utils';
|
|
18
|
+
import { TableUtils, Formatter, FormatterUtils } from '@deephaven/jsapi-utils';
|
|
19
|
+
import IrisGridModel from "./IrisGridModel.js";
|
|
20
|
+
import AggregationOperation from "./sidebar/aggregations/AggregationOperation.js";
|
|
21
|
+
import IrisGridUtils from "./IrisGridUtils.js";
|
|
22
|
+
import MissingKeyError from "./MissingKeyError.js";
|
|
23
|
+
var log = Log.module('IrisGridTableModel');
|
|
24
|
+
var SET_VIEWPORT_THROTTLE = 150;
|
|
25
|
+
var APPLY_VIEWPORT_THROTTLE = 0;
|
|
26
|
+
export function isIrisGridTableModelTemplate(model) {
|
|
27
|
+
return model.table !== undefined;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Template model for a grid
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
class IrisGridTableModelTemplate extends IrisGridModel {
|
|
34
|
+
export() {
|
|
35
|
+
throw new Error('Method not implemented.');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
columnStatistics(column) {
|
|
39
|
+
throw new Error('Method not implemented.');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get customColumns() {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
set customColumns(customColumns) {
|
|
47
|
+
throw new Error('Method not implemented.');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
get formatColumns() {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
set formatColumns(formatColumns) {
|
|
55
|
+
throw new Error('Method not implemented.');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
updateFrozenColumns(columns) {
|
|
59
|
+
throw new Error('Method not implemented.');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get rollupConfig() {
|
|
63
|
+
throw new Error('Method not implemented.');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
set rollupConfig(rollupConfig) {
|
|
67
|
+
throw new Error('Method not implemented.');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
get selectDistinctColumns() {
|
|
71
|
+
throw new Error('Method not implemented.');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
set selectDistinctColumns(names) {
|
|
75
|
+
throw new Error('Method not implemented.');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
get columns() {
|
|
79
|
+
return this.table.columns;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @param table Iris data table to be used in the model
|
|
84
|
+
* @param formatter The formatter to use when getting formats
|
|
85
|
+
* @param inputTable Iris input table associated with this table
|
|
86
|
+
*/
|
|
87
|
+
constructor(table) {
|
|
88
|
+
var _formatter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Formatter();
|
|
89
|
+
|
|
90
|
+
var inputTable = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
91
|
+
super();
|
|
92
|
+
|
|
93
|
+
_defineProperty(this, "irisFormatter", void 0);
|
|
94
|
+
|
|
95
|
+
_defineProperty(this, "inputTable", void 0);
|
|
96
|
+
|
|
97
|
+
_defineProperty(this, "subscription", void 0);
|
|
98
|
+
|
|
99
|
+
_defineProperty(this, "table", void 0);
|
|
100
|
+
|
|
101
|
+
_defineProperty(this, "viewport", void 0);
|
|
102
|
+
|
|
103
|
+
_defineProperty(this, "viewportData", void 0);
|
|
104
|
+
|
|
105
|
+
_defineProperty(this, "formattedStringData", void 0);
|
|
106
|
+
|
|
107
|
+
_defineProperty(this, "pendingStringData", void 0);
|
|
108
|
+
|
|
109
|
+
_defineProperty(this, "isSaveInProgress", void 0);
|
|
110
|
+
|
|
111
|
+
_defineProperty(this, "totalsTable", void 0);
|
|
112
|
+
|
|
113
|
+
_defineProperty(this, "totalsTablePromise", void 0);
|
|
114
|
+
|
|
115
|
+
_defineProperty(this, "totals", void 0);
|
|
116
|
+
|
|
117
|
+
_defineProperty(this, "totalsDataMap", void 0);
|
|
118
|
+
|
|
119
|
+
_defineProperty(this, "pendingNewDataMap", void 0);
|
|
120
|
+
|
|
121
|
+
_defineProperty(this, "pendingNewRowCount", 0);
|
|
122
|
+
|
|
123
|
+
_defineProperty(this, "pendingNewDataErrors", void 0);
|
|
124
|
+
|
|
125
|
+
_defineProperty(this, "getMemoizedColumnMap", memoize(tableColumns => {
|
|
126
|
+
var columnMap = new Map();
|
|
127
|
+
tableColumns.forEach(col => columnMap.set(col.name, col));
|
|
128
|
+
return columnMap;
|
|
129
|
+
}));
|
|
130
|
+
|
|
131
|
+
_defineProperty(this, "getColumnIndicesByNameMap", memoize(columns => {
|
|
132
|
+
var indices = new Map();
|
|
133
|
+
columns.forEach((_ref, i) => {
|
|
134
|
+
var {
|
|
135
|
+
name
|
|
136
|
+
} = _ref;
|
|
137
|
+
return indices.set(name, i);
|
|
138
|
+
});
|
|
139
|
+
return indices;
|
|
140
|
+
}));
|
|
141
|
+
|
|
142
|
+
_defineProperty(this, "setViewport", throttle((top, bottom, columns) => {
|
|
143
|
+
if (bottom < top) {
|
|
144
|
+
log.error('Invalid viewport', top, bottom);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
var {
|
|
149
|
+
viewport
|
|
150
|
+
} = this;
|
|
151
|
+
|
|
152
|
+
if (viewport != null && viewport.top === top && viewport.bottom === bottom && viewport.columns === columns) {
|
|
153
|
+
log.debug2('Ignoring duplicate viewport', viewport);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
this.viewport = {
|
|
158
|
+
top,
|
|
159
|
+
bottom,
|
|
160
|
+
columns
|
|
161
|
+
};
|
|
162
|
+
log.debug2('setViewport', this.viewport);
|
|
163
|
+
this.applyViewport();
|
|
164
|
+
}, SET_VIEWPORT_THROTTLE));
|
|
165
|
+
|
|
166
|
+
_defineProperty(this, "applyViewport", throttle(() => {
|
|
167
|
+
if (!this.viewport) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
log.debug2('applyViewport', this.viewport);
|
|
172
|
+
var {
|
|
173
|
+
top,
|
|
174
|
+
bottom,
|
|
175
|
+
columns
|
|
176
|
+
} = this.viewport;
|
|
177
|
+
var [viewportTop, viewportBottom] = this.getCachedViewportRowRange(top, bottom);
|
|
178
|
+
this.applyBufferedViewport(viewportTop, viewportBottom, columns);
|
|
179
|
+
}, APPLY_VIEWPORT_THROTTLE, {
|
|
180
|
+
leading: false
|
|
181
|
+
}));
|
|
182
|
+
|
|
183
|
+
_defineProperty(this, "getCachedFormattedString", memoizeClear((formatter, value, columnType, columnName, formatOverride) => formatter.getFormattedString(value, columnType, columnName, formatOverride), {
|
|
184
|
+
max: 10000
|
|
185
|
+
}));
|
|
186
|
+
|
|
187
|
+
_defineProperty(this, "getCachedCustomColumnFormatFlag", memoizeClear(FormatterUtils.isCustomColumnFormatDefined, {
|
|
188
|
+
max: 10000
|
|
189
|
+
}));
|
|
190
|
+
|
|
191
|
+
_defineProperty(this, "getCachedViewportRowRange", memoize((top, bottom) => {
|
|
192
|
+
var viewHeight = bottom - top;
|
|
193
|
+
var viewportTop = Math.max(0, top - viewHeight * IrisGridTableModelTemplate.ROW_BUFFER_PAGES);
|
|
194
|
+
var viewportBottom = bottom + viewHeight * IrisGridTableModelTemplate.ROW_BUFFER_PAGES;
|
|
195
|
+
return [viewportTop, viewportBottom];
|
|
196
|
+
}));
|
|
197
|
+
|
|
198
|
+
_defineProperty(this, "getCachedPendingErrors", memoize((pendingDataMap, columns, keyColumnCount) => {
|
|
199
|
+
var map = new Map();
|
|
200
|
+
pendingDataMap.forEach((row, rowIndex) => {
|
|
201
|
+
var {
|
|
202
|
+
data: rowData
|
|
203
|
+
} = row;
|
|
204
|
+
|
|
205
|
+
for (var i = 0; i < keyColumnCount; i += 1) {
|
|
206
|
+
if (!rowData.has(i)) {
|
|
207
|
+
var _map$get;
|
|
208
|
+
|
|
209
|
+
if (!map.has(rowIndex)) {
|
|
210
|
+
map.set(rowIndex, []);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
(_map$get = map.get(rowIndex)) === null || _map$get === void 0 ? void 0 : _map$get.push(new MissingKeyError(rowIndex, columns[i].name));
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
return map;
|
|
218
|
+
}));
|
|
219
|
+
|
|
220
|
+
this.handleTableDisconnect = this.handleTableDisconnect.bind(this);
|
|
221
|
+
this.handleTableReconnect = this.handleTableReconnect.bind(this);
|
|
222
|
+
this.handleTableUpdate = this.handleTableUpdate.bind(this);
|
|
223
|
+
this.handleTotalsUpdate = this.handleTotalsUpdate.bind(this);
|
|
224
|
+
this.handleRequestFailed = this.handleRequestFailed.bind(this);
|
|
225
|
+
this.handleCustomColumnsChanged = this.handleCustomColumnsChanged.bind(this);
|
|
226
|
+
this.irisFormatter = _formatter;
|
|
227
|
+
this.inputTable = inputTable;
|
|
228
|
+
this.subscription = null;
|
|
229
|
+
this.table = table;
|
|
230
|
+
this.viewport = null;
|
|
231
|
+
this.viewportData = null;
|
|
232
|
+
this.formattedStringData = [];
|
|
233
|
+
this.pendingStringData = [];
|
|
234
|
+
this.isSaveInProgress = false;
|
|
235
|
+
this.totalsTable = null;
|
|
236
|
+
this.totalsTablePromise = null;
|
|
237
|
+
this.totals = null;
|
|
238
|
+
this.totalsDataMap = null; // Map from new row index to their values. Only for input tables that can have new rows added.
|
|
239
|
+
// The index of these rows start at 0, and they are appended at the end of the regular table data.
|
|
240
|
+
// These rows can be sparse, so using a map instead of an array.
|
|
241
|
+
|
|
242
|
+
this.pendingNewDataMap = new Map();
|
|
243
|
+
this.pendingNewDataErrors = null;
|
|
244
|
+
this.pendingNewRowCount = 0;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
close() {
|
|
248
|
+
this.table.close();
|
|
249
|
+
|
|
250
|
+
if (this.totalsTable !== null) {
|
|
251
|
+
this.totalsTable.close();
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (this.totalsTablePromise !== null) {
|
|
255
|
+
this.totalsTablePromise.cancel();
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
startListening() {
|
|
260
|
+
super.startListening();
|
|
261
|
+
this.table.addEventListener(dh.Table.EVENT_DISCONNECT, this.handleTableDisconnect);
|
|
262
|
+
this.table.addEventListener(dh.Table.EVENT_RECONNECT, this.handleTableReconnect);
|
|
263
|
+
this.table.addEventListener(dh.Table.EVENT_UPDATED, this.handleTableUpdate);
|
|
264
|
+
this.table.addEventListener(dh.Client.EVENT_REQUEST_FAILED, this.handleRequestFailed);
|
|
265
|
+
this.table.addEventListener(dh.Table.EVENT_CUSTOMCOLUMNSCHANGED, this.handleCustomColumnsChanged);
|
|
266
|
+
|
|
267
|
+
if (this.totalsTable != null) {
|
|
268
|
+
this.addTotalsListeners(this.totalsTable);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
this.applyViewport();
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
stopListening() {
|
|
275
|
+
super.stopListening();
|
|
276
|
+
this.table.removeEventListener(dh.Table.EVENT_DISCONNECT, this.handleTableDisconnect);
|
|
277
|
+
this.table.removeEventListener(dh.Table.EVENT_RECONNECT, this.handleTableReconnect);
|
|
278
|
+
this.table.removeEventListener(dh.Table.EVENT_UPDATED, this.handleTableUpdate);
|
|
279
|
+
this.table.removeEventListener(dh.Client.EVENT_REQUEST_FAILED, this.handleRequestFailed);
|
|
280
|
+
this.table.removeEventListener(dh.Table.EVENT_CUSTOMCOLUMNSCHANGED, this.handleCustomColumnsChanged);
|
|
281
|
+
|
|
282
|
+
if (this.totalsTable != null) {
|
|
283
|
+
this.removeTotalsListeners(this.totalsTable);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
this.closeSubscription();
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
addTotalsListeners(totalsTable) {
|
|
290
|
+
totalsTable.addEventListener(dh.Table.EVENT_UPDATED, this.handleTotalsUpdate); // Totals table only has one row of data
|
|
291
|
+
|
|
292
|
+
totalsTable.setViewport(0, 0);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
removeTotalsListeners(totalsTable) {
|
|
296
|
+
totalsTable.removeEventListener(dh.Table.EVENT_UPDATED, this.handleTotalsUpdate);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
handleTableDisconnect() {
|
|
300
|
+
this.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.DISCONNECT));
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
handleTableReconnect() {
|
|
304
|
+
this.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.RECONNECT));
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
handleTableUpdate(event) {
|
|
308
|
+
this.copyViewportData(event.detail);
|
|
309
|
+
this.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.UPDATED));
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
handleTotalsUpdate(event) {
|
|
313
|
+
this.copyTotalsData(event.detail);
|
|
314
|
+
this.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.UPDATED));
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
handleRequestFailed(event) {
|
|
318
|
+
this.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.REQUEST_FAILED, event));
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
handleCustomColumnsChanged() {
|
|
322
|
+
this.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.COLUMNS_CHANGED, {
|
|
323
|
+
detail: this.columns
|
|
324
|
+
}));
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
get rowCount() {
|
|
328
|
+
var _this$totals$operatio, _this$totals, _this$totals$operatio2;
|
|
329
|
+
|
|
330
|
+
return this.table.size + this.pendingNewRowCount + ((_this$totals$operatio = (_this$totals = this.totals) === null || _this$totals === void 0 ? void 0 : (_this$totals$operatio2 = _this$totals.operationOrder) === null || _this$totals$operatio2 === void 0 ? void 0 : _this$totals$operatio2.length) !== null && _this$totals$operatio !== void 0 ? _this$totals$operatio : 0);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
get pendingDataErrors() {
|
|
334
|
+
var _this$inputTable$keyC, _this$inputTable;
|
|
335
|
+
|
|
336
|
+
return this.getCachedPendingErrors(this.pendingNewDataMap, this.columns, (_this$inputTable$keyC = (_this$inputTable = this.inputTable) === null || _this$inputTable === void 0 ? void 0 : _this$inputTable.keyColumns.length) !== null && _this$inputTable$keyC !== void 0 ? _this$inputTable$keyC : 0);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
get pendingDataMap() {
|
|
340
|
+
return this.pendingNewDataMap;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
set pendingDataMap(map) {
|
|
344
|
+
if (map === this.pendingNewDataMap) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
map.forEach((row, rowIndex) => {
|
|
349
|
+
if (!IrisGridUtils.isValidIndex(rowIndex)) {
|
|
350
|
+
throw new Error("Invalid rowIndex ".concat(rowIndex));
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
var {
|
|
354
|
+
data
|
|
355
|
+
} = row;
|
|
356
|
+
data.forEach((value, columnIndex) => {
|
|
357
|
+
if (!IrisGridUtils.isValidIndex(columnIndex)) {
|
|
358
|
+
throw new Error("Invalid columnIndex ".concat(columnIndex));
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
this.pendingNewDataMap = map;
|
|
363
|
+
this.pendingNewRowCount = Math.max(this.pendingNewRowCount, this.maxPendingDataRow);
|
|
364
|
+
this.formattedStringData = [];
|
|
365
|
+
this.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.PENDING_DATA_UPDATED));
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
get pendingRowCount() {
|
|
369
|
+
return this.pendingNewRowCount;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
set pendingRowCount(count) {
|
|
373
|
+
if (count === this.pendingNewRowCount) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
this.pendingNewRowCount = Math.max(0, count, this.maxPendingDataRow);
|
|
378
|
+
this.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.UPDATED));
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
get maxPendingDataRow() {
|
|
382
|
+
return this.pendingNewDataMap.size > 0 ? Math.max(...this.pendingNewDataMap.keys()) + 1 : 0;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
get columnCount() {
|
|
386
|
+
return this.columns.length;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
get floatingBottomRowCount() {
|
|
390
|
+
var _this$totals2, _this$totals$operatio3, _this$totals3, _this$totals3$operati;
|
|
391
|
+
|
|
392
|
+
return (_this$totals2 = this.totals) !== null && _this$totals2 !== void 0 && _this$totals2.showOnTop ? 0 : (_this$totals$operatio3 = (_this$totals3 = this.totals) === null || _this$totals3 === void 0 ? void 0 : (_this$totals3$operati = _this$totals3.operationOrder) === null || _this$totals3$operati === void 0 ? void 0 : _this$totals3$operati.length) !== null && _this$totals$operatio3 !== void 0 ? _this$totals$operatio3 : 0;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
get floatingTopRowCount() {
|
|
396
|
+
var _this$totals4, _this$totals$operatio4, _this$totals5, _this$totals5$operati;
|
|
397
|
+
|
|
398
|
+
return (_this$totals4 = this.totals) !== null && _this$totals4 !== void 0 && _this$totals4.showOnTop ? (_this$totals$operatio4 = (_this$totals5 = this.totals) === null || _this$totals5 === void 0 ? void 0 : (_this$totals5$operati = _this$totals5.operationOrder) === null || _this$totals5$operati === void 0 ? void 0 : _this$totals5$operati.length) !== null && _this$totals$operatio4 !== void 0 ? _this$totals$operatio4 : 0 : 0;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
get isChartBuilderAvailable() {
|
|
402
|
+
return true;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
get isTotalsAvailable() {
|
|
406
|
+
return this.table.getTotalsTable != null;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
get isEditable() {
|
|
410
|
+
return !this.isSaveInProgress && this.inputTable != null;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
cacheFormattedValue(x, y, text) {
|
|
414
|
+
if (this.formattedStringData[x] == null) {
|
|
415
|
+
this.formattedStringData[x] = [];
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
this.formattedStringData[x][y] = text;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
cachePendingValue(x, y, text) {
|
|
422
|
+
if (this.pendingStringData[x] == null) {
|
|
423
|
+
this.pendingStringData[x] = [];
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
this.pendingStringData[x][y] = text;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
clearPendingValue(x, y) {
|
|
430
|
+
var column = this.pendingStringData[x];
|
|
431
|
+
|
|
432
|
+
if (column != null) {
|
|
433
|
+
delete column[y];
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
textValueForCell(x, y) {
|
|
438
|
+
var _this$pendingStringDa, _this$formattedString;
|
|
439
|
+
|
|
440
|
+
// First check if there's any pending values we should read from
|
|
441
|
+
if (((_this$pendingStringDa = this.pendingStringData[x]) === null || _this$pendingStringDa === void 0 ? void 0 : _this$pendingStringDa[y]) !== undefined) {
|
|
442
|
+
return this.pendingStringData[x][y];
|
|
443
|
+
} // Use a separate cache from memoization just for the strings that are currently displayed
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
if (((_this$formattedString = this.formattedStringData[x]) === null || _this$formattedString === void 0 ? void 0 : _this$formattedString[y]) === undefined) {
|
|
447
|
+
var _this$totalsColumn;
|
|
448
|
+
|
|
449
|
+
var _value = this.valueForCell(x, y);
|
|
450
|
+
|
|
451
|
+
if (_value == null) {
|
|
452
|
+
return null;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
var _column = (_this$totalsColumn = this.totalsColumn(x, y)) !== null && _this$totalsColumn !== void 0 ? _this$totalsColumn : this.columns[x];
|
|
456
|
+
|
|
457
|
+
var hasCustomColumnFormat = this.getCachedCustomColumnFormatFlag(this.formatter, _column.name, _column.type);
|
|
458
|
+
var formatOverride;
|
|
459
|
+
|
|
460
|
+
if (!hasCustomColumnFormat) {
|
|
461
|
+
var formatForCell = this.formatForCell(x, y);
|
|
462
|
+
|
|
463
|
+
if ((formatForCell === null || formatForCell === void 0 ? void 0 : formatForCell.formatString) != null) {
|
|
464
|
+
formatOverride = formatForCell;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
var text = this.displayString(_value, _column.type, _column.name, formatOverride);
|
|
469
|
+
this.cacheFormattedValue(x, y, text);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
return this.formattedStringData[x][y];
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
textForCell(x, y) {
|
|
476
|
+
var text = this.textValueForCell(x, y);
|
|
477
|
+
|
|
478
|
+
if (text == null && this.isKeyColumn(x)) {
|
|
479
|
+
var pendingRow = this.pendingRow(y);
|
|
480
|
+
|
|
481
|
+
if (pendingRow != null && this.pendingDataMap.has(pendingRow)) {
|
|
482
|
+
// Asterisk to show a value is required for a key column on a row that has some data entered
|
|
483
|
+
return '*';
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
return text !== null && text !== void 0 ? text : '';
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
truncationCharForCell(x) {
|
|
491
|
+
var column = this.columns[x];
|
|
492
|
+
var {
|
|
493
|
+
type
|
|
494
|
+
} = column;
|
|
495
|
+
|
|
496
|
+
if (TableUtils.isNumberType(type) && this.formatter.truncateNumbersWithPound) {
|
|
497
|
+
return '#';
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
return undefined;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
colorForCell(x, y, theme) {
|
|
504
|
+
var data = this.dataForCell(x, y);
|
|
505
|
+
|
|
506
|
+
if (data) {
|
|
507
|
+
var {
|
|
508
|
+
format,
|
|
509
|
+
value: _value2
|
|
510
|
+
} = data;
|
|
511
|
+
|
|
512
|
+
if (_value2 == null || _value2 === '') {
|
|
513
|
+
assertNotNull(theme.nullStringColor);
|
|
514
|
+
return theme.nullStringColor;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
if (format && format.color) {
|
|
518
|
+
return format.color;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
if (this.isPendingRow(y)) {
|
|
522
|
+
// Data entered in a pending row
|
|
523
|
+
assertNotNull(theme.pendingTextColor);
|
|
524
|
+
return theme.pendingTextColor;
|
|
525
|
+
} // Fallback to formatting based on the value/type of the cell
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
if (_value2 != null) {
|
|
529
|
+
var _this$totalsColumn2;
|
|
530
|
+
|
|
531
|
+
var _column2 = (_this$totalsColumn2 = this.totalsColumn(x, y)) !== null && _this$totalsColumn2 !== void 0 ? _this$totalsColumn2 : this.columns[x];
|
|
532
|
+
|
|
533
|
+
if (TableUtils.isDateType(_column2.type) || _column2.name === 'Date') {
|
|
534
|
+
assertNotNull(theme.dateColor);
|
|
535
|
+
return theme.dateColor;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
if (TableUtils.isNumberType(_column2.type)) {
|
|
539
|
+
if (_value2 > 0) {
|
|
540
|
+
assertNotNull(theme.positiveNumberColor);
|
|
541
|
+
return theme.positiveNumberColor;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
if (_value2 < 0) {
|
|
545
|
+
assertNotNull(theme.negativeNumberColor);
|
|
546
|
+
return theme.negativeNumberColor;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
assertNotNull(theme.zeroNumberColor);
|
|
550
|
+
return theme.zeroNumberColor;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
} else if (this.isPendingRow(y) && this.isKeyColumn(x)) {
|
|
554
|
+
assertNotNull(theme.errorTextColor);
|
|
555
|
+
return theme.errorTextColor;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
return theme.textColor;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
backgroundColorForCell(x, y) {
|
|
562
|
+
var _this$formatForCell$b, _this$formatForCell;
|
|
563
|
+
|
|
564
|
+
return (_this$formatForCell$b = (_this$formatForCell = this.formatForCell(x, y)) === null || _this$formatForCell === void 0 ? void 0 : _this$formatForCell.backgroundColor) !== null && _this$formatForCell$b !== void 0 ? _this$formatForCell$b : null;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
textAlignForCell(x) {
|
|
568
|
+
var column = this.columns[x];
|
|
569
|
+
var {
|
|
570
|
+
type
|
|
571
|
+
} = column;
|
|
572
|
+
|
|
573
|
+
if (TableUtils.isNumberType(type)) {
|
|
574
|
+
return 'right';
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
if (TableUtils.isDateType(type) || column.name === 'Date') {
|
|
578
|
+
return 'center';
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
return 'left';
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
textForColumnHeader(x) {
|
|
585
|
+
var column = this.columns[x];
|
|
586
|
+
return "".concat(column.name);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
textForRowFooter(y) {
|
|
590
|
+
var totalsRow = this.totalsRow(y);
|
|
591
|
+
|
|
592
|
+
if (totalsRow != null && this.totals) {
|
|
593
|
+
return this.totals.operationOrder[totalsRow];
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
return '';
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
get columnMap() {
|
|
600
|
+
return this.getMemoizedColumnMap(this.table.columns);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
get groupedColumns() {
|
|
604
|
+
return [];
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
row(y) {
|
|
608
|
+
var _this$totals$operatio5, _this$totals6, _this$totals6$operati, _this$totals$showOnTo, _this$totals7, _this$viewportData$of, _this$viewportData, _this$viewportData$ro, _this$viewportData2, _this$viewportData2$r;
|
|
609
|
+
|
|
610
|
+
var totalsRowCount = (_this$totals$operatio5 = (_this$totals6 = this.totals) === null || _this$totals6 === void 0 ? void 0 : (_this$totals6$operati = _this$totals6.operationOrder) === null || _this$totals6$operati === void 0 ? void 0 : _this$totals6$operati.length) !== null && _this$totals$operatio5 !== void 0 ? _this$totals$operatio5 : 0;
|
|
611
|
+
var showOnTop = (_this$totals$showOnTo = (_this$totals7 = this.totals) === null || _this$totals7 === void 0 ? void 0 : _this$totals7.showOnTop) !== null && _this$totals$showOnTo !== void 0 ? _this$totals$showOnTo : false;
|
|
612
|
+
var totalsRow = this.totalsRow(y);
|
|
613
|
+
|
|
614
|
+
if (totalsRow != null) {
|
|
615
|
+
var _this$totals8, _this$totalsDataMap$g, _this$totalsDataMap;
|
|
616
|
+
|
|
617
|
+
var operation = (_this$totals8 = this.totals) === null || _this$totals8 === void 0 ? void 0 : _this$totals8.operationOrder[totalsRow];
|
|
618
|
+
assertNotNull(operation);
|
|
619
|
+
return (_this$totalsDataMap$g = (_this$totalsDataMap = this.totalsDataMap) === null || _this$totalsDataMap === void 0 ? void 0 : _this$totalsDataMap.get(operation)) !== null && _this$totalsDataMap$g !== void 0 ? _this$totalsDataMap$g : null;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
var pendingRow = this.pendingRow(y);
|
|
623
|
+
|
|
624
|
+
if (pendingRow != null) {
|
|
625
|
+
var _this$pendingNewDataM;
|
|
626
|
+
|
|
627
|
+
return (_this$pendingNewDataM = this.pendingNewDataMap.get(pendingRow)) !== null && _this$pendingNewDataM !== void 0 ? _this$pendingNewDataM : null;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
var offset = (_this$viewportData$of = (_this$viewportData = this.viewportData) === null || _this$viewportData === void 0 ? void 0 : _this$viewportData.offset) !== null && _this$viewportData$of !== void 0 ? _this$viewportData$of : 0;
|
|
631
|
+
var viewportY = (showOnTop ? y - totalsRowCount : y) - offset;
|
|
632
|
+
return (_this$viewportData$ro = (_this$viewportData2 = this.viewportData) === null || _this$viewportData2 === void 0 ? void 0 : (_this$viewportData2$r = _this$viewportData2.rows) === null || _this$viewportData2$r === void 0 ? void 0 : _this$viewportData2$r[viewportY]) !== null && _this$viewportData$ro !== void 0 ? _this$viewportData$ro : null;
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Retrieve the totals column if this is a totals row, or null otherwise
|
|
636
|
+
* @param x Column index to get the totals column from
|
|
637
|
+
* @param y Row index to get the totals column from
|
|
638
|
+
*/
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
totalsColumn(x, y) {
|
|
642
|
+
var _this$totals9, _this$totals$defaultO, _this$totals10, _this$totalsTable;
|
|
643
|
+
|
|
644
|
+
var totalsRow = this.totalsRow(y);
|
|
645
|
+
if (totalsRow == null) return null;
|
|
646
|
+
var operation = (_this$totals9 = this.totals) === null || _this$totals9 === void 0 ? void 0 : _this$totals9.operationOrder[totalsRow];
|
|
647
|
+
var defaultOperation = (_this$totals$defaultO = (_this$totals10 = this.totals) === null || _this$totals10 === void 0 ? void 0 : _this$totals10.defaultOperation) !== null && _this$totals$defaultO !== void 0 ? _this$totals$defaultO : AggregationOperation.SUM;
|
|
648
|
+
var tableColumn = this.columns[x]; // Find the matching totals table column for the operation
|
|
649
|
+
// When there are multiple aggregations, the column name will be the original name of the column with the operation appended afterward
|
|
650
|
+
// When the the operation is the default operation OR there is only one operation, then the totals column name is just the original column name
|
|
651
|
+
|
|
652
|
+
return (_this$totalsTable = this.totalsTable) === null || _this$totalsTable === void 0 ? void 0 : _this$totalsTable.columns.find(column => {
|
|
653
|
+
var _this$totals11;
|
|
654
|
+
|
|
655
|
+
return column.name === "".concat(tableColumn.name, "__").concat(operation) || (operation === defaultOperation || ((_this$totals11 = this.totals) === null || _this$totals11 === void 0 ? void 0 : _this$totals11.operationOrder.length) === 1) && column.name === tableColumn.name;
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Translate from the row in the model to a row in the totals table.
|
|
660
|
+
* If the row is not a totals row, return null
|
|
661
|
+
* @param y The row in the model to get the totals row for
|
|
662
|
+
* @returns The row within the totals table if it's a totals row, null otherwise
|
|
663
|
+
*/
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
totalsRow(y) {
|
|
667
|
+
var _this$totals$operatio6, _this$totals12, _this$totals12$operat, _this$totals$showOnTo2, _this$totals13;
|
|
668
|
+
|
|
669
|
+
var totalsRowCount = (_this$totals$operatio6 = (_this$totals12 = this.totals) === null || _this$totals12 === void 0 ? void 0 : (_this$totals12$operat = _this$totals12.operationOrder) === null || _this$totals12$operat === void 0 ? void 0 : _this$totals12$operat.length) !== null && _this$totals$operatio6 !== void 0 ? _this$totals$operatio6 : 0;
|
|
670
|
+
var showOnTop = (_this$totals$showOnTo2 = (_this$totals13 = this.totals) === null || _this$totals13 === void 0 ? void 0 : _this$totals13.showOnTop) !== null && _this$totals$showOnTo2 !== void 0 ? _this$totals$showOnTo2 : false;
|
|
671
|
+
var totalsRow = showOnTop ? y : y - this.table.size;
|
|
672
|
+
|
|
673
|
+
if (totalsRow >= 0 && totalsRow < totalsRowCount) {
|
|
674
|
+
return totalsRow;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
return null;
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* Translate from the row in the model to a pending input row.
|
|
681
|
+
* If the row is not a pending input row, return null
|
|
682
|
+
* @param y The row in the model to get the pending row for
|
|
683
|
+
* @returns The row within the pending input rows if it's a pending row, null otherwise
|
|
684
|
+
*/
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
pendingRow(y) {
|
|
688
|
+
var pendingRow = y - this.floatingTopRowCount - this.table.size;
|
|
689
|
+
|
|
690
|
+
if (pendingRow >= 0 && pendingRow < this.pendingNewRowCount) {
|
|
691
|
+
return pendingRow;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
return null;
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* Check if a row is a totals table row
|
|
698
|
+
* @param y The row in the model to check if it's a totals table row
|
|
699
|
+
* @returns True if the row is a totals row, false if not
|
|
700
|
+
*/
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
isTotalsRow(y) {
|
|
704
|
+
return this.totalsRow(y) != null;
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Check if a row is a pending input row
|
|
708
|
+
* @param y The row in the model to check if it's a pending new row
|
|
709
|
+
* @returns True if the row is a pending new row, false if not
|
|
710
|
+
*/
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
isPendingRow(y) {
|
|
714
|
+
return this.pendingRow(y) != null;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
dataForCell(x, y) {
|
|
718
|
+
var _this$row;
|
|
719
|
+
|
|
720
|
+
return (_this$row = this.row(y)) === null || _this$row === void 0 ? void 0 : _this$row.data.get(x);
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
formatForCell(x, y) {
|
|
724
|
+
var _this$dataForCell;
|
|
725
|
+
|
|
726
|
+
return (_this$dataForCell = this.dataForCell(x, y)) === null || _this$dataForCell === void 0 ? void 0 : _this$dataForCell.format;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
valueForCell(x, y) {
|
|
730
|
+
var data = this.dataForCell(x, y);
|
|
731
|
+
/* JS API current sets null values as undefined in some instances. This means
|
|
732
|
+
we need to nullish coaelesce so all undefined values from the API return null
|
|
733
|
+
since the data has been fetched. undefined is used to indicate the API has not
|
|
734
|
+
fetched data yet */
|
|
735
|
+
|
|
736
|
+
if (data) {
|
|
737
|
+
var _data$value;
|
|
738
|
+
|
|
739
|
+
return (_data$value = data.value) !== null && _data$value !== void 0 ? _data$value : null;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
return undefined;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
copyViewportData(data) {
|
|
746
|
+
if (!data) {
|
|
747
|
+
log.warn('invalid data!');
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
this.viewportData = this.extractViewportData(data);
|
|
752
|
+
this.formattedStringData = [];
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
copyTotalsData(totalsData) {
|
|
756
|
+
var _this$totals$defaultO2,
|
|
757
|
+
_this$totals14,
|
|
758
|
+
_this$totals15,
|
|
759
|
+
_this = this;
|
|
760
|
+
|
|
761
|
+
if (!totalsData) {
|
|
762
|
+
log.warn('invalid data!');
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
var {
|
|
767
|
+
columns,
|
|
768
|
+
rows
|
|
769
|
+
} = totalsData;
|
|
770
|
+
|
|
771
|
+
if (rows.length !== 1) {
|
|
772
|
+
log.error('Unexpected number of rows received for totals table, ignoring update');
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
var dataMap = new Map();
|
|
777
|
+
var row = rows[0];
|
|
778
|
+
var defaultOperation = (_this$totals$defaultO2 = (_this$totals14 = this.totals) === null || _this$totals14 === void 0 ? void 0 : _this$totals14.defaultOperation) !== null && _this$totals$defaultO2 !== void 0 ? _this$totals$defaultO2 : AggregationOperation.SUM;
|
|
779
|
+
var operationMap = (_this$totals15 = this.totals) === null || _this$totals15 === void 0 ? void 0 : _this$totals15.operationMap;
|
|
780
|
+
|
|
781
|
+
var _loop = function _loop(c) {
|
|
782
|
+
var _operationMap$name$, _operationMap$name;
|
|
783
|
+
|
|
784
|
+
var column = columns[c];
|
|
785
|
+
var [name, operation = (_operationMap$name$ = operationMap === null || operationMap === void 0 ? void 0 : (_operationMap$name = operationMap[name]) === null || _operationMap$name === void 0 ? void 0 : _operationMap$name[0]) !== null && _operationMap$name$ !== void 0 ? _operationMap$name$ : defaultOperation] = column.name.split('__');
|
|
786
|
+
|
|
787
|
+
if (!dataMap.has(operation)) {
|
|
788
|
+
dataMap.set(operation, {
|
|
789
|
+
data: new Map()
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
var {
|
|
794
|
+
data: rowData
|
|
795
|
+
} = dataMap.get(operation);
|
|
796
|
+
|
|
797
|
+
var columnIndex = _this.columns.findIndex(col => col.name === name);
|
|
798
|
+
|
|
799
|
+
rowData.set(columnIndex, {
|
|
800
|
+
value: row.get(column),
|
|
801
|
+
format: row.getFormat(column)
|
|
802
|
+
});
|
|
803
|
+
};
|
|
804
|
+
|
|
805
|
+
for (var c = 0; c < columns.length; c += 1) {
|
|
806
|
+
_loop(c);
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
log.debug2('copyTotalsData', dataMap);
|
|
810
|
+
this.totalsDataMap = dataMap;
|
|
811
|
+
this.formattedStringData = [];
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Use this as the canonical column index since things like layoutHints could have
|
|
815
|
+
* changed the column order.
|
|
816
|
+
*/
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
getColumnIndexByName(name) {
|
|
820
|
+
return this.getColumnIndicesByNameMap(this.columns).get(name);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* Copies all the viewport data into an object that we can reference later.
|
|
825
|
+
* @param data The data to copy from
|
|
826
|
+
*/
|
|
827
|
+
extractViewportData(data) {
|
|
828
|
+
var newData = {
|
|
829
|
+
offset: data.offset,
|
|
830
|
+
rows: []
|
|
831
|
+
};
|
|
832
|
+
var {
|
|
833
|
+
columns
|
|
834
|
+
} = data;
|
|
835
|
+
|
|
836
|
+
for (var r = 0; r < data.rows.length; r += 1) {
|
|
837
|
+
var _row = data.rows[r];
|
|
838
|
+
var newRow = this.extractViewportRow(_row, columns);
|
|
839
|
+
newData.rows.push(newRow);
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
return newData;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
extractViewportRow(row, columns) {
|
|
846
|
+
var data = new Map();
|
|
847
|
+
|
|
848
|
+
for (var c = 0; c < columns.length; c += 1) {
|
|
849
|
+
var _column3 = columns[c];
|
|
850
|
+
var index = this.getColumnIndexByName(_column3.name);
|
|
851
|
+
assertNotNull(index);
|
|
852
|
+
data.set(index, {
|
|
853
|
+
value: row.get(_column3),
|
|
854
|
+
format: row.getFormat(_column3)
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
return {
|
|
859
|
+
data
|
|
860
|
+
};
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
closeSubscription() {
|
|
864
|
+
log.debug2('closeSubscription', this.subscription);
|
|
865
|
+
|
|
866
|
+
if (this.subscription) {
|
|
867
|
+
this.subscription.close();
|
|
868
|
+
this.subscription = null;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
this.setViewport.cancel();
|
|
872
|
+
this.applyViewport.cancel();
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
get filter() {
|
|
876
|
+
return this.table.filter;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
set filter(filter) {
|
|
880
|
+
this.closeSubscription();
|
|
881
|
+
this.table.applyFilter(filter);
|
|
882
|
+
this.applyViewport();
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
get formatter() {
|
|
886
|
+
return this.irisFormatter;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
set formatter(formatter) {
|
|
890
|
+
this.irisFormatter = formatter;
|
|
891
|
+
this.formattedStringData = [];
|
|
892
|
+
this.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.FORMATTER_UPDATED));
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
displayString(value, columnType) {
|
|
896
|
+
var columnName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
897
|
+
var formatOverride = arguments.length > 3 ? arguments[3] : undefined;
|
|
898
|
+
return this.getCachedFormattedString(this.formatter, value, columnType, columnName, formatOverride);
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
get sort() {
|
|
902
|
+
return this.table.sort;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
set sort(sort) {
|
|
906
|
+
this.closeSubscription();
|
|
907
|
+
this.table.applySort(sort);
|
|
908
|
+
this.applyViewport();
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
set totalsConfig(totalsConfig) {
|
|
912
|
+
log.debug('set totalsConfig', totalsConfig);
|
|
913
|
+
|
|
914
|
+
if (totalsConfig === this.totals) {
|
|
915
|
+
// Totals already set, or it will be set when the next model actually gets set
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
this.totals = totalsConfig;
|
|
920
|
+
this.formattedStringData = [];
|
|
921
|
+
|
|
922
|
+
if (this.totalsTablePromise != null) {
|
|
923
|
+
this.totalsTablePromise.cancel();
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
this.setTotalsTable(null);
|
|
927
|
+
|
|
928
|
+
if (totalsConfig == null) {
|
|
929
|
+
this.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.UPDATED));
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
this.totalsTablePromise = PromiseUtils.makeCancelable(this.table.getTotalsTable(totalsConfig), table => table.close());
|
|
934
|
+
this.totalsTablePromise.then(totalsTable => {
|
|
935
|
+
this.totalsTablePromise = null;
|
|
936
|
+
this.setTotalsTable(totalsTable);
|
|
937
|
+
}).catch(err => {
|
|
938
|
+
if (PromiseUtils.isCanceled(err)) {
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
log.error('Unable to set next totalsTable', err);
|
|
943
|
+
this.totalsTablePromise = null;
|
|
944
|
+
this.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.REQUEST_FAILED, {
|
|
945
|
+
detail: err
|
|
946
|
+
}));
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
setTotalsTable(totalsTable) {
|
|
951
|
+
log.debug('setTotalsTable', totalsTable);
|
|
952
|
+
|
|
953
|
+
if (this.totalsTable !== null) {
|
|
954
|
+
if (this.listenerCount > 0) {
|
|
955
|
+
this.removeTotalsListeners(this.totalsTable);
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
this.totalsTable.close();
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
this.totalsTable = totalsTable;
|
|
962
|
+
this.totalsDataMap = null;
|
|
963
|
+
|
|
964
|
+
if (this.listenerCount > 0 && this.totalsTable != null) {
|
|
965
|
+
this.addTotalsListeners(this.totalsTable);
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
applyBufferedViewport(viewportTop, viewportBottom, columns) {
|
|
970
|
+
log.debug2('applyBufferedViewport', viewportTop, viewportBottom, columns);
|
|
971
|
+
|
|
972
|
+
if (this.subscription == null) {
|
|
973
|
+
log.debug2('applyBufferedViewport creating new subscription');
|
|
974
|
+
this.subscription = this.table.setViewport(viewportTop, viewportBottom, columns);
|
|
975
|
+
} else {
|
|
976
|
+
log.debug2('applyBufferedViewport using existing subscription');
|
|
977
|
+
this.subscription.setViewport(viewportTop, viewportBottom, columns);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
snapshot(ranges) {
|
|
982
|
+
var _arguments = arguments,
|
|
983
|
+
_this2 = this;
|
|
984
|
+
|
|
985
|
+
return _asyncToGenerator(function* () {
|
|
986
|
+
var includeHeaders = _arguments.length > 1 && _arguments[1] !== undefined ? _arguments[1] : false;
|
|
987
|
+
var formatValue = _arguments.length > 2 && _arguments[2] !== undefined ? _arguments[2] : value => value;
|
|
988
|
+
|
|
989
|
+
if (_this2.subscription == null) {
|
|
990
|
+
throw new Error('No subscription available');
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
var consolidated = GridRange.consolidate(ranges);
|
|
994
|
+
|
|
995
|
+
if (!IrisGridUtils.isValidSnapshotRanges(consolidated)) {
|
|
996
|
+
throw new Error("Invalid snapshot ranges ".concat(ranges));
|
|
997
|
+
} // Need to separate out the floating ranges as they're from a different source
|
|
998
|
+
|
|
999
|
+
|
|
1000
|
+
var topFloatingRowsSet = new Set();
|
|
1001
|
+
var tableRanges = [];
|
|
1002
|
+
var bottomFloatingRowsSet = new Set();
|
|
1003
|
+
|
|
1004
|
+
for (var i = 0; i < consolidated.length; i += 1) {
|
|
1005
|
+
var range = consolidated[i];
|
|
1006
|
+
assertNotNull(range.endRow);
|
|
1007
|
+
assertNotNull(range.startRow); // Get the rows that are in the top aggregations section
|
|
1008
|
+
|
|
1009
|
+
for (var r = range.startRow; r <= range.endRow && r < _this2.floatingTopRowCount; r += 1) {
|
|
1010
|
+
topFloatingRowsSet.add(r);
|
|
1011
|
+
} // Separate out the range that is part of the actual table (ie. not the floating ranges, not aggregations)
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
if (range.endRow >= _this2.floatingTopRowCount && range.startRow <= _this2.floatingTopRowCount + _this2.table.size) {
|
|
1015
|
+
tableRanges.push(new GridRange(range.startColumn, Math.min(Math.max(0, range.startRow - _this2.floatingTopRowCount)), range.endColumn, Math.min(Math.max(0, range.endRow - _this2.floatingTopRowCount), _this2.table.size - _this2.floatingTopRowCount)));
|
|
1016
|
+
} // Get the rows that are in the bottom aggregations section
|
|
1017
|
+
|
|
1018
|
+
|
|
1019
|
+
for (var _r = Math.max(range.startRow, _this2.floatingTopRowCount + _this2.table.size); _r <= range.endRow && _r < _this2.floatingTopRowCount + _this2.table.size + _this2.floatingBottomRowCount; _r += 1) {
|
|
1020
|
+
bottomFloatingRowsSet.add(_r);
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
var columns = IrisGridUtils.columnsFromRanges(consolidated, _this2.columns);
|
|
1025
|
+
var result = [];
|
|
1026
|
+
|
|
1027
|
+
if (includeHeaders) {
|
|
1028
|
+
result.push(columns.map(c => c.name));
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
var topFloatingRows = [...topFloatingRowsSet].sort();
|
|
1032
|
+
|
|
1033
|
+
var _loop2 = function _loop2(_i) {
|
|
1034
|
+
var row = topFloatingRows[_i];
|
|
1035
|
+
var rowData = columns.map(column => {
|
|
1036
|
+
var index = _this2.getColumnIndexByName(column.name);
|
|
1037
|
+
|
|
1038
|
+
assertNotNull(index);
|
|
1039
|
+
return formatValue(_this2.valueForCell(index, row), column);
|
|
1040
|
+
});
|
|
1041
|
+
|
|
1042
|
+
if (includeHeaders) {
|
|
1043
|
+
rowData.push(_this2.textForRowFooter(row));
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
result.push(rowData);
|
|
1047
|
+
};
|
|
1048
|
+
|
|
1049
|
+
for (var _i = 0; _i < topFloatingRows.length; _i += 1) {
|
|
1050
|
+
_loop2(_i);
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
if (tableRanges.length > 0) {
|
|
1054
|
+
var rangeSet = IrisGridUtils.rangeSetFromRanges(tableRanges);
|
|
1055
|
+
var snapshot = yield _this2.subscription.snapshot(rangeSet, columns);
|
|
1056
|
+
result.push(...snapshot.rows.map(rowData => columns.map(column => formatValue(rowData.get(column), column))));
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
var bottomFloatingRows = [...bottomFloatingRowsSet].sort();
|
|
1060
|
+
|
|
1061
|
+
var _loop3 = function _loop3(_i2) {
|
|
1062
|
+
var row = bottomFloatingRows[_i2];
|
|
1063
|
+
var rowData = columns.map(column => {
|
|
1064
|
+
var index = _this2.getColumnIndexByName(column.name);
|
|
1065
|
+
|
|
1066
|
+
assertNotNull(index);
|
|
1067
|
+
return formatValue(_this2.valueForCell(index, row), column);
|
|
1068
|
+
});
|
|
1069
|
+
|
|
1070
|
+
if (includeHeaders) {
|
|
1071
|
+
rowData.push(_this2.textForRowFooter(row));
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
result.push(rowData);
|
|
1075
|
+
};
|
|
1076
|
+
|
|
1077
|
+
for (var _i2 = 0; _i2 < bottomFloatingRows.length; _i2 += 1) {
|
|
1078
|
+
_loop3(_i2);
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
return result;
|
|
1082
|
+
})();
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Get a text snapshot of the provided ranges
|
|
1086
|
+
* @param ranges The ranges to get the snapshot for
|
|
1087
|
+
* @param includeHeaders Whether to include the headers in the snapshot or not
|
|
1088
|
+
* @param formatValue Function for formatting the raw value into a string
|
|
1089
|
+
* @returns A formatted string of all the data, columns separated by `\t` and rows separated by `\n`
|
|
1090
|
+
*/
|
|
1091
|
+
|
|
1092
|
+
|
|
1093
|
+
textSnapshot(ranges) {
|
|
1094
|
+
var _arguments2 = arguments,
|
|
1095
|
+
_this3 = this;
|
|
1096
|
+
|
|
1097
|
+
return _asyncToGenerator(function* () {
|
|
1098
|
+
var includeHeaders = _arguments2.length > 1 && _arguments2[1] !== undefined ? _arguments2[1] : false;
|
|
1099
|
+
var formatValue = _arguments2.length > 2 && _arguments2[2] !== undefined ? _arguments2[2] : value => "".concat(value);
|
|
1100
|
+
log.debug2('textSnapshot', ranges, includeHeaders);
|
|
1101
|
+
var data = yield _this3.snapshot(ranges, includeHeaders, formatValue);
|
|
1102
|
+
return data.map(row => row.join('\t')).join('\n');
|
|
1103
|
+
})();
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
valuesTable(column) {
|
|
1107
|
+
var _this4 = this;
|
|
1108
|
+
|
|
1109
|
+
return _asyncToGenerator(function* () {
|
|
1110
|
+
var table = null;
|
|
1111
|
+
|
|
1112
|
+
try {
|
|
1113
|
+
table = yield _this4.table.copy();
|
|
1114
|
+
table.applyFilter([]);
|
|
1115
|
+
table.applySort([]);
|
|
1116
|
+
return table.selectDistinct([column]);
|
|
1117
|
+
} finally {
|
|
1118
|
+
if (table != null) {
|
|
1119
|
+
table.close();
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
})();
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
isKeyColumn(x) {
|
|
1126
|
+
var _this$inputTable$keyC2, _this$inputTable2;
|
|
1127
|
+
|
|
1128
|
+
return x < ((_this$inputTable$keyC2 = (_this$inputTable2 = this.inputTable) === null || _this$inputTable2 === void 0 ? void 0 : _this$inputTable2.keyColumns.length) !== null && _this$inputTable$keyC2 !== void 0 ? _this$inputTable$keyC2 : 0);
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
isRowMovable() {
|
|
1132
|
+
return false;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
isEditableRange(range) {
|
|
1136
|
+
return this.inputTable != null && GridRange.isBounded(range) && (this.isPendingRow(range.startRow) && this.isPendingRow(range.endRow) || range.startColumn >= this.inputTable.keyColumns.length && range.endColumn >= this.inputTable.keyColumns.length) && range.startRow >= this.floatingTopRowCount && range.startRow < this.floatingTopRowCount + this.table.size + this.pendingRowCount && range.endRow < this.floatingTopRowCount + this.table.size + this.pendingRowCount;
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
isDeletableRange(range) {
|
|
1140
|
+
return this.inputTable != null && range.startRow != null && range.endRow != null && range.startRow >= this.floatingTopRowCount && range.startRow < this.floatingTopRowCount + this.table.size + this.pendingRowCount && range.endRow < this.floatingTopRowCount + this.table.size + this.pendingRowCount;
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
isEditableRanges(ranges) {
|
|
1144
|
+
return ranges.every(range => this.isEditableRange(range));
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
isDeletableRanges(ranges) {
|
|
1148
|
+
return ranges.every(range => this.isDeletableRange(range));
|
|
1149
|
+
}
|
|
1150
|
+
/**
|
|
1151
|
+
* @returns A range corresponding to the underlying table
|
|
1152
|
+
*/
|
|
1153
|
+
|
|
1154
|
+
|
|
1155
|
+
getTableAreaRange() {
|
|
1156
|
+
return new GridRange(null, this.floatingTopRowCount, null, this.floatingTopRowCount + this.table.size - 1);
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* @returns {GridRange} A range corresponding to the pending new rows
|
|
1160
|
+
*/
|
|
1161
|
+
|
|
1162
|
+
|
|
1163
|
+
getPendingAreaRange() {
|
|
1164
|
+
return new GridRange(null, this.floatingTopRowCount + this.table.size, null, this.floatingTopRowCount + this.table.size + this.pendingNewRowCount - 1);
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Set value in an editable table
|
|
1168
|
+
* @param x The column to set
|
|
1169
|
+
* @param y The row to set
|
|
1170
|
+
* @param value The value to set
|
|
1171
|
+
* @returns A promise that resolves successfully when the operation is complete, or rejects if there's an error
|
|
1172
|
+
*/
|
|
1173
|
+
|
|
1174
|
+
|
|
1175
|
+
setValueForCell(x, y, text) {
|
|
1176
|
+
var _this5 = this;
|
|
1177
|
+
|
|
1178
|
+
return _asyncToGenerator(function* () {
|
|
1179
|
+
// Cache the value in our pending string cache so that it stays displayed until our edit has been completed
|
|
1180
|
+
return _this5.setValueForRanges([new GridRange(x, y, x, y)], text);
|
|
1181
|
+
})();
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
* Set value in an editable table
|
|
1185
|
+
* @param ranges The ranges to set
|
|
1186
|
+
* @param value The values to set
|
|
1187
|
+
* @returns A promise that resolves successfully when the operation is complete, or rejects if there's an error
|
|
1188
|
+
*/
|
|
1189
|
+
|
|
1190
|
+
|
|
1191
|
+
setValueForRanges(ranges, text) {
|
|
1192
|
+
var _this6 = this;
|
|
1193
|
+
|
|
1194
|
+
return _asyncToGenerator(function* () {
|
|
1195
|
+
if (!_this6.isEditableRanges(ranges)) {
|
|
1196
|
+
throw new Error("Uneditable ranges ".concat(ranges));
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
try {
|
|
1200
|
+
// Cache the value in our pending string cache so that it stays displayed until our edit has been completed
|
|
1201
|
+
var columnSet = new Set(); // Formatted text for each column
|
|
1202
|
+
// Since there could be different formatting for each column, but the value will be the same across rows
|
|
1203
|
+
|
|
1204
|
+
var formattedText = [];
|
|
1205
|
+
GridRange.forEachCell(ranges, (x, y) => {
|
|
1206
|
+
var column = _this6.columns[x];
|
|
1207
|
+
columnSet.add(column);
|
|
1208
|
+
|
|
1209
|
+
if (formattedText[x] === undefined) {
|
|
1210
|
+
var _value3 = TableUtils.makeValue(column.type, text, _this6.formatter.timeZone);
|
|
1211
|
+
|
|
1212
|
+
formattedText[x] = _value3 != null ? _this6.displayString(_value3, column.type, column.name) : null;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
_this6.cachePendingValue(x, y, formattedText[x]);
|
|
1216
|
+
}); // Take care of updates to the pending new area first, as they can be updated synchronously
|
|
1217
|
+
|
|
1218
|
+
var pendingAreaRange = _this6.getPendingAreaRange();
|
|
1219
|
+
|
|
1220
|
+
var pendingRanges = ranges.map(range => GridRange.intersection(pendingAreaRange, range)).filter(range => range != null).map(range => {
|
|
1221
|
+
assertNotNull(range);
|
|
1222
|
+
return GridRange.offset(range, 0, -(_this6.floatingTopRowCount + _this6.table.size));
|
|
1223
|
+
});
|
|
1224
|
+
|
|
1225
|
+
if (pendingRanges.length > 0) {
|
|
1226
|
+
var newDataMap = new Map(_this6.pendingNewDataMap);
|
|
1227
|
+
GridRange.forEachCell(pendingRanges, (columnIndex, rowIndex) => {
|
|
1228
|
+
if (!newDataMap.has(rowIndex)) {
|
|
1229
|
+
newDataMap.set(rowIndex, {
|
|
1230
|
+
data: new Map()
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
var column = _this6.columns[columnIndex];
|
|
1235
|
+
var row = newDataMap.get(rowIndex);
|
|
1236
|
+
assertNotNull(row);
|
|
1237
|
+
var {
|
|
1238
|
+
data: rowData
|
|
1239
|
+
} = row;
|
|
1240
|
+
var newRowData = new Map(rowData);
|
|
1241
|
+
var value = TableUtils.makeValue(column.type, text, _this6.formatter.timeZone);
|
|
1242
|
+
|
|
1243
|
+
if (value != null) {
|
|
1244
|
+
newRowData.set(columnIndex, {
|
|
1245
|
+
value
|
|
1246
|
+
});
|
|
1247
|
+
} else {
|
|
1248
|
+
newRowData.delete(columnIndex);
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
if (newRowData.size > 0) {
|
|
1252
|
+
newDataMap.set(rowIndex, _objectSpread(_objectSpread({}, row), {}, {
|
|
1253
|
+
data: newRowData
|
|
1254
|
+
}));
|
|
1255
|
+
} else {
|
|
1256
|
+
newDataMap.delete(rowIndex);
|
|
1257
|
+
}
|
|
1258
|
+
});
|
|
1259
|
+
_this6.pendingDataMap = newDataMap;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
_this6.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.UPDATED));
|
|
1263
|
+
|
|
1264
|
+
var tableAreaRange = _this6.getTableAreaRange();
|
|
1265
|
+
|
|
1266
|
+
var tableRanges = ranges.map(range => GridRange.intersection(tableAreaRange, range)).filter(range => range != null);
|
|
1267
|
+
|
|
1268
|
+
if (tableRanges.length > 0) {
|
|
1269
|
+
var _this6$inputTable;
|
|
1270
|
+
|
|
1271
|
+
// Get a snapshot of the full rows, as we need to write a full row when editing
|
|
1272
|
+
var data = yield _this6.snapshot(tableRanges.map(range => {
|
|
1273
|
+
var _range$startRow, _range$endRow;
|
|
1274
|
+
|
|
1275
|
+
return new GridRange(null, (_range$startRow = range === null || range === void 0 ? void 0 : range.startRow) !== null && _range$startRow !== void 0 ? _range$startRow : null, null, (_range$endRow = range === null || range === void 0 ? void 0 : range.endRow) !== null && _range$endRow !== void 0 ? _range$endRow : null);
|
|
1276
|
+
}));
|
|
1277
|
+
var newRows = data.map(row => {
|
|
1278
|
+
var newRow = {};
|
|
1279
|
+
|
|
1280
|
+
for (var c = 0; c < _this6.columns.length; c += 1) {
|
|
1281
|
+
newRow[_this6.columns[c].name] = row[c];
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
columnSet.forEach(column => {
|
|
1285
|
+
newRow[column.name] = TableUtils.makeValue(column.type, text, _this6.formatter.timeZone);
|
|
1286
|
+
});
|
|
1287
|
+
return newRow;
|
|
1288
|
+
});
|
|
1289
|
+
var result = yield (_this6$inputTable = _this6.inputTable) === null || _this6$inputTable === void 0 ? void 0 : _this6$inputTable.addRows(newRows);
|
|
1290
|
+
log.debug('setValueForRanges(', ranges, ',', text, ') set tableRanges', tableRanges, 'result', result);
|
|
1291
|
+
} // Add the changes to the formatted cache so it's still displayed until the update event is received
|
|
1292
|
+
// The update event could be received on the next tick, after the input rows have been committed,
|
|
1293
|
+
// so make sure we don't display stale data
|
|
1294
|
+
|
|
1295
|
+
|
|
1296
|
+
GridRange.forEachCell(ranges, (x, y) => {
|
|
1297
|
+
var cellText = formattedText[x];
|
|
1298
|
+
assertNotNull(cellText);
|
|
1299
|
+
|
|
1300
|
+
_this6.cacheFormattedValue(x, y, cellText);
|
|
1301
|
+
});
|
|
1302
|
+
} catch (err) {
|
|
1303
|
+
log.error('Unable to set ranges', ranges, text, err);
|
|
1304
|
+
} finally {
|
|
1305
|
+
GridRange.forEachCell(ranges, (x, y) => {
|
|
1306
|
+
_this6.clearPendingValue(x, y);
|
|
1307
|
+
});
|
|
1308
|
+
}
|
|
1309
|
+
})();
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
setValues() {
|
|
1313
|
+
var _arguments3 = arguments,
|
|
1314
|
+
_this7 = this;
|
|
1315
|
+
|
|
1316
|
+
return _asyncToGenerator(function* () {
|
|
1317
|
+
var edits = _arguments3.length > 0 && _arguments3[0] !== undefined ? _arguments3[0] : [];
|
|
1318
|
+
log.debug('setValues(', edits, ')');
|
|
1319
|
+
|
|
1320
|
+
if (!edits.every(edit => {
|
|
1321
|
+
var _edit$column, _edit$row;
|
|
1322
|
+
|
|
1323
|
+
return _this7.isEditableRange(GridRange.makeCell((_edit$column = edit.column) !== null && _edit$column !== void 0 ? _edit$column : edit.x, (_edit$row = edit.row) !== null && _edit$row !== void 0 ? _edit$row : edit.y));
|
|
1324
|
+
})) {
|
|
1325
|
+
throw new Error("Uneditable ranges ".concat(edits));
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
try {
|
|
1329
|
+
var newDataMap = new Map(_this7.pendingNewDataMap); // Cache the display values
|
|
1330
|
+
|
|
1331
|
+
edits.forEach(edit => {
|
|
1332
|
+
var _edit$column2, _edit$row2;
|
|
1333
|
+
|
|
1334
|
+
var {
|
|
1335
|
+
text
|
|
1336
|
+
} = edit;
|
|
1337
|
+
var x = (_edit$column2 = edit.column) !== null && _edit$column2 !== void 0 ? _edit$column2 : edit.x;
|
|
1338
|
+
var y = (_edit$row2 = edit.row) !== null && _edit$row2 !== void 0 ? _edit$row2 : edit.y;
|
|
1339
|
+
var column = _this7.columns[x];
|
|
1340
|
+
var value = TableUtils.makeValue(column.type, text, _this7.formatter.timeZone);
|
|
1341
|
+
var formattedText = value != null ? _this7.displayString(value, column.type, column.name) : null;
|
|
1342
|
+
|
|
1343
|
+
_this7.cachePendingValue(x, y, formattedText); // Take care of updates to the pending new area as well, as that can be updated synchronously
|
|
1344
|
+
|
|
1345
|
+
|
|
1346
|
+
var pendingRow = _this7.pendingRow(y);
|
|
1347
|
+
|
|
1348
|
+
if (pendingRow != null) {
|
|
1349
|
+
if (!newDataMap.has(pendingRow)) {
|
|
1350
|
+
newDataMap.set(pendingRow, {
|
|
1351
|
+
data: new Map()
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
var _row2 = newDataMap.get(pendingRow);
|
|
1356
|
+
|
|
1357
|
+
assertNotNull(_row2);
|
|
1358
|
+
var {
|
|
1359
|
+
data: rowData
|
|
1360
|
+
} = _row2;
|
|
1361
|
+
var newRowData = new Map(rowData);
|
|
1362
|
+
|
|
1363
|
+
if (value != null) {
|
|
1364
|
+
newRowData.set(x, {
|
|
1365
|
+
value
|
|
1366
|
+
});
|
|
1367
|
+
} else {
|
|
1368
|
+
newRowData.delete(x);
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
if (newRowData.size > 0) {
|
|
1372
|
+
newDataMap.set(pendingRow, _objectSpread(_objectSpread({}, _row2), {}, {
|
|
1373
|
+
data: newRowData
|
|
1374
|
+
}));
|
|
1375
|
+
} else {
|
|
1376
|
+
newDataMap.delete(pendingRow);
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
});
|
|
1380
|
+
_this7.pendingDataMap = newDataMap; // Send an update right after setting the pending map so the values are displayed immediately
|
|
1381
|
+
|
|
1382
|
+
_this7.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.UPDATED)); // Need to group by row...
|
|
1383
|
+
|
|
1384
|
+
|
|
1385
|
+
var rowEditMap = edits.reduce((rowMap, edit) => {
|
|
1386
|
+
var _edit$row3, _rowMap$get;
|
|
1387
|
+
|
|
1388
|
+
var y = (_edit$row3 = edit.row) !== null && _edit$row3 !== void 0 ? _edit$row3 : edit.y;
|
|
1389
|
+
|
|
1390
|
+
if (!rowMap.has(y)) {
|
|
1391
|
+
rowMap.set(y, []);
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
(_rowMap$get = rowMap.get(y)) === null || _rowMap$get === void 0 ? void 0 : _rowMap$get.push(edit);
|
|
1395
|
+
return rowMap;
|
|
1396
|
+
}, new Map());
|
|
1397
|
+
var ranges = GridRange.consolidate(edits.map(edit => {
|
|
1398
|
+
var _edit$column3, _edit$row4;
|
|
1399
|
+
|
|
1400
|
+
return GridRange.makeCell((_edit$column3 = edit.column) !== null && _edit$column3 !== void 0 ? _edit$column3 : edit.x, (_edit$row4 = edit.row) !== null && _edit$row4 !== void 0 ? _edit$row4 : edit.y);
|
|
1401
|
+
}));
|
|
1402
|
+
|
|
1403
|
+
var tableAreaRange = _this7.getTableAreaRange();
|
|
1404
|
+
|
|
1405
|
+
var tableRanges = ranges.map(range => GridRange.intersection(tableAreaRange, range)).filter(range => range != null);
|
|
1406
|
+
|
|
1407
|
+
if (tableRanges.length > 0) {
|
|
1408
|
+
var _this7$inputTable;
|
|
1409
|
+
|
|
1410
|
+
// Get a snapshot of the full rows, as we need to write a full row when editing
|
|
1411
|
+
var data = yield _this7.snapshot(tableRanges.map(range => {
|
|
1412
|
+
assertNotNull(range);
|
|
1413
|
+
return new GridRange(null, range.startRow, null, range.endRow);
|
|
1414
|
+
}));
|
|
1415
|
+
var newRows = data.map((row, dataIndex) => {
|
|
1416
|
+
var rowIndex = null;
|
|
1417
|
+
var r = dataIndex;
|
|
1418
|
+
|
|
1419
|
+
for (var i = 0; i < tableRanges.length; i += 1) {
|
|
1420
|
+
var range = tableRanges[i];
|
|
1421
|
+
assertNotNull(range);
|
|
1422
|
+
var rangeRowCount = GridRange.rowCount([range]);
|
|
1423
|
+
|
|
1424
|
+
if (r < rangeRowCount) {
|
|
1425
|
+
assertNotNull(range.startRow);
|
|
1426
|
+
rowIndex = range.startRow + r;
|
|
1427
|
+
break;
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
r -= rangeRowCount;
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
var newRow = {};
|
|
1434
|
+
|
|
1435
|
+
for (var c = 0; c < _this7.columns.length; c += 1) {
|
|
1436
|
+
newRow[_this7.columns[c].name] = row[c];
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
assertNotNull(rowIndex);
|
|
1440
|
+
var rowEdits = rowEditMap.get(rowIndex);
|
|
1441
|
+
|
|
1442
|
+
if (rowEdits != null) {
|
|
1443
|
+
rowEdits.forEach(edit => {
|
|
1444
|
+
var _edit$column4;
|
|
1445
|
+
|
|
1446
|
+
var column = _this7.columns[(_edit$column4 = edit.column) !== null && _edit$column4 !== void 0 ? _edit$column4 : edit.x];
|
|
1447
|
+
newRow[column.name] = TableUtils.makeValue(column.type, edit.text, _this7.formatter.timeZone);
|
|
1448
|
+
});
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
return newRow;
|
|
1452
|
+
});
|
|
1453
|
+
log.info('setValues setting tableRanges', tableRanges);
|
|
1454
|
+
var result = yield (_this7$inputTable = _this7.inputTable) === null || _this7$inputTable === void 0 ? void 0 : _this7$inputTable.addRows(newRows);
|
|
1455
|
+
log.info('setValues set tableRanges', tableRanges, 'SUCCESS', result);
|
|
1456
|
+
} // We've sent the changes to the server, but have not yet got an update with those changes committed
|
|
1457
|
+
// Add the changes to the formatted cache so it's still displayed until the update event is received
|
|
1458
|
+
// The update event could be received on the next tick, after the input rows have been committed,
|
|
1459
|
+
// so make sure we don't display stale data
|
|
1460
|
+
|
|
1461
|
+
|
|
1462
|
+
edits.forEach(edit => {
|
|
1463
|
+
var _edit$column5, _edit$row5;
|
|
1464
|
+
|
|
1465
|
+
var {
|
|
1466
|
+
text
|
|
1467
|
+
} = edit;
|
|
1468
|
+
var x = (_edit$column5 = edit.column) !== null && _edit$column5 !== void 0 ? _edit$column5 : edit.x;
|
|
1469
|
+
var y = (_edit$row5 = edit.row) !== null && _edit$row5 !== void 0 ? _edit$row5 : edit.y;
|
|
1470
|
+
var column = _this7.columns[x];
|
|
1471
|
+
var value = TableUtils.makeValue(column.type, text, _this7.formatter.timeZone);
|
|
1472
|
+
var formattedText = value != null ? _this7.displayString(value, column.type, column.name) : null;
|
|
1473
|
+
|
|
1474
|
+
_this7.cacheFormattedValue(x, y, formattedText);
|
|
1475
|
+
});
|
|
1476
|
+
} finally {
|
|
1477
|
+
edits.forEach(edit => {
|
|
1478
|
+
_this7.clearPendingValue(edit.column, edit.row);
|
|
1479
|
+
});
|
|
1480
|
+
}
|
|
1481
|
+
})();
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
commitPending() {
|
|
1485
|
+
var _this8 = this;
|
|
1486
|
+
|
|
1487
|
+
return _asyncToGenerator(function* () {
|
|
1488
|
+
if (_this8.pendingNewDataMap.size <= 0) {
|
|
1489
|
+
throw new Error('No pending changes to commit');
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
try {
|
|
1493
|
+
var _this8$inputTable, _this8$viewport$botto, _this8$viewport;
|
|
1494
|
+
|
|
1495
|
+
_this8.isSaveInProgress = true;
|
|
1496
|
+
var newRows = [];
|
|
1497
|
+
|
|
1498
|
+
_this8.pendingNewDataMap.forEach(row => {
|
|
1499
|
+
var newRow = {};
|
|
1500
|
+
row.data.forEach((_ref2, columnIndex) => {
|
|
1501
|
+
var {
|
|
1502
|
+
value
|
|
1503
|
+
} = _ref2;
|
|
1504
|
+
var column = _this8.columns[columnIndex];
|
|
1505
|
+
newRow[column.name] = value;
|
|
1506
|
+
});
|
|
1507
|
+
newRows.push(newRow);
|
|
1508
|
+
});
|
|
1509
|
+
|
|
1510
|
+
var result = yield (_this8$inputTable = _this8.inputTable) === null || _this8$inputTable === void 0 ? void 0 : _this8$inputTable.addRows(newRows);
|
|
1511
|
+
log.debug('commitPending()', _this8.pendingNewDataMap, 'result', result);
|
|
1512
|
+
_this8.pendingNewDataMap = new Map();
|
|
1513
|
+
_this8.pendingNewDataErrors = new Map();
|
|
1514
|
+
_this8.pendingNewRowCount = Math.max(0, ((_this8$viewport$botto = (_this8$viewport = _this8.viewport) === null || _this8$viewport === void 0 ? void 0 : _this8$viewport.bottom) !== null && _this8$viewport$botto !== void 0 ? _this8$viewport$botto : 0) - _this8.table.size);
|
|
1515
|
+
_this8.formattedStringData = [];
|
|
1516
|
+
|
|
1517
|
+
_this8.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.PENDING_DATA_UPDATED));
|
|
1518
|
+
} finally {
|
|
1519
|
+
_this8.isSaveInProgress = false;
|
|
1520
|
+
}
|
|
1521
|
+
})();
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
editValueForCell(x, y) {
|
|
1525
|
+
return this.textValueForCell(x, y);
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
delete(ranges) {
|
|
1529
|
+
var _this9 = this;
|
|
1530
|
+
|
|
1531
|
+
return _asyncToGenerator(function* () {
|
|
1532
|
+
if (!_this9.isDeletableRanges(ranges)) {
|
|
1533
|
+
throw new Error("Undeletable ranges ".concat(ranges));
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
assertNotNull(_this9.inputTable);
|
|
1537
|
+
var {
|
|
1538
|
+
keyColumns
|
|
1539
|
+
} = _this9.inputTable;
|
|
1540
|
+
|
|
1541
|
+
if (keyColumns.length === 0) {
|
|
1542
|
+
throw new Error('No key columns to allow deletion');
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
var pendingAreaRange = _this9.getPendingAreaRange();
|
|
1546
|
+
|
|
1547
|
+
var pendingRanges = ranges.map(range => GridRange.intersection(pendingAreaRange, range)).filter(range => range != null).map(range => {
|
|
1548
|
+
assertNotNull(range);
|
|
1549
|
+
return GridRange.offset(range, 0, -(_this9.floatingTopRowCount + _this9.table.size));
|
|
1550
|
+
});
|
|
1551
|
+
|
|
1552
|
+
if (pendingRanges.length > 0) {
|
|
1553
|
+
var newDataMap = new Map(_this9.pendingNewDataMap);
|
|
1554
|
+
|
|
1555
|
+
for (var i = 0; i < pendingRanges.length; i += 1) {
|
|
1556
|
+
var pendingRange = pendingRanges[i];
|
|
1557
|
+
assertNotNull(pendingRange.startRow);
|
|
1558
|
+
assertNotNull(pendingRange.endRow);
|
|
1559
|
+
|
|
1560
|
+
for (var r = pendingRange.startRow; r <= pendingRange.endRow; r += 1) {
|
|
1561
|
+
newDataMap.delete(r);
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
_this9.pendingNewDataMap = newDataMap;
|
|
1566
|
+
_this9.formattedStringData = [];
|
|
1567
|
+
|
|
1568
|
+
_this9.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.PENDING_DATA_UPDATED));
|
|
1569
|
+
|
|
1570
|
+
_this9.dispatchEvent(new EventShimCustomEvent(IrisGridModel.EVENT.UPDATED));
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
var tableAreaRange = _this9.getTableAreaRange();
|
|
1574
|
+
|
|
1575
|
+
var tableRanges = ranges.map(range => GridRange.intersection(tableAreaRange, range)).filter(range => range != null);
|
|
1576
|
+
|
|
1577
|
+
if (tableRanges.length <= 0) {
|
|
1578
|
+
return;
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
var [data, deleteTable] = yield Promise.all([// Need to get the key values of each row
|
|
1582
|
+
_this9.snapshot(tableRanges.map(range => {
|
|
1583
|
+
assertNotNull(range);
|
|
1584
|
+
return new GridRange(0, range.startRow, keyColumns.length - 1, range.endRow);
|
|
1585
|
+
})), _this9.table.copy()]); // Now copy the existing table and filter it on the values in the snapshot for the key columns in the input table
|
|
1586
|
+
|
|
1587
|
+
var filters = data.map(row => {
|
|
1588
|
+
var columnFilters = [];
|
|
1589
|
+
|
|
1590
|
+
for (var c = 0; c < keyColumns.length; c += 1) {
|
|
1591
|
+
var _column4 = keyColumns[c];
|
|
1592
|
+
var _value4 = row[c];
|
|
1593
|
+
var filterValue = TableUtils.makeFilterRawValue(_column4.type, _value4);
|
|
1594
|
+
|
|
1595
|
+
var _filter = _column4.filter().eq(filterValue);
|
|
1596
|
+
|
|
1597
|
+
columnFilters.push(_filter);
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
return columnFilters.reduce((agg, curr) => agg ? agg.and(curr) : curr);
|
|
1601
|
+
});
|
|
1602
|
+
var filter = filters.reduce((agg, curr) => agg ? agg.or(curr) : curr);
|
|
1603
|
+
deleteTable.applyFilter([filter]); // await this.inputTable?.deleteTable(deleteTable);
|
|
1604
|
+
|
|
1605
|
+
deleteTable.close();
|
|
1606
|
+
})();
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
isValidForCell(x, y, value) {
|
|
1610
|
+
try {
|
|
1611
|
+
var _column5 = this.columns[x];
|
|
1612
|
+
TableUtils.makeValue(_column5.type, value, this.formatter.timeZone);
|
|
1613
|
+
return true;
|
|
1614
|
+
} catch (e) {
|
|
1615
|
+
return false;
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
_defineProperty(IrisGridTableModelTemplate, "ROW_BUFFER_PAGES", 1);
|
|
1622
|
+
|
|
1623
|
+
export default IrisGridTableModelTemplate;
|
|
1624
|
+
//# sourceMappingURL=IrisGridTableModelTemplate.js.map
|