@airtable/blocks 1.3.0 → 1.5.1
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/CHANGELOG.md +30 -1
- package/dist/cjs/index.js +30 -11
- package/dist/cjs/injected/airtable_interface.js +2 -1
- package/dist/cjs/models/cursor.js +4 -6
- package/dist/cjs/models/field.js +24 -0
- package/dist/cjs/models/grouped_record_query_result.js +475 -0
- package/dist/cjs/models/models.js +30 -0
- package/dist/cjs/models/mutations.js +41 -9
- package/dist/cjs/models/record_query_result.js +37 -12
- package/dist/cjs/models/session.js +65 -23
- package/dist/cjs/models/table_or_view_query_result.js +306 -97
- package/dist/cjs/models/view.js +71 -1
- package/dist/cjs/models/view_data_store.js +62 -20
- package/dist/cjs/models/view_metadata_query_result.js +41 -8
- package/dist/cjs/sdk.js +2 -2
- package/dist/cjs/testing/mock_airtable_interface.js +1 -110
- package/dist/cjs/types/airtable_interface.js +19 -1
- package/dist/cjs/types/mutations.js +2 -1
- package/dist/cjs/types/view.js +1 -0
- package/dist/cjs/ui/confirmation_dialog.js +12 -4
- package/dist/cjs/ui/expand_record.js +5 -5
- package/dist/cjs/ui/expand_record_list.js +2 -5
- package/dist/cjs/ui/expand_record_picker_async.js +9 -16
- package/dist/cjs/ui/form_field.js +2 -2
- package/dist/cjs/ui/icon_config.js +11 -4
- package/dist/cjs/ui/initialize_block.js +62 -10
- package/dist/cjs/ui/ui.js +9 -2
- package/dist/cjs/ui/use_loadable.js +2 -2
- package/dist/cjs/ui/use_records.js +54 -40
- package/dist/cjs/ui/use_view_metadata.js +1 -1
- package/dist/cjs/unstable_testing_utils.js +163 -0
- package/dist/types/src/color_utils.d.ts +4 -4
- package/dist/types/src/color_utils.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/injected/airtable_interface.d.ts.map +1 -1
- package/dist/types/src/models/cursor.d.ts +4 -6
- package/dist/types/src/models/cursor.d.ts.map +1 -1
- package/dist/types/src/models/field.d.ts +17 -1
- package/dist/types/src/models/field.d.ts.map +1 -1
- package/dist/types/src/models/grouped_record_query_result.d.ts +61 -0
- package/dist/types/src/models/grouped_record_query_result.d.ts.map +1 -0
- package/dist/types/src/models/models.d.ts +4 -1
- package/dist/types/src/models/models.d.ts.map +1 -1
- package/dist/types/src/models/mutations.d.ts.map +1 -1
- package/dist/types/src/models/record.d.ts +0 -2
- package/dist/types/src/models/record.d.ts.map +1 -1
- package/dist/types/src/models/record_query_result.d.ts +22 -0
- package/dist/types/src/models/record_query_result.d.ts.map +1 -1
- package/dist/types/src/models/session.d.ts +65 -23
- package/dist/types/src/models/session.d.ts.map +1 -1
- package/dist/types/src/models/table_or_view_query_result.d.ts +21 -0
- package/dist/types/src/models/table_or_view_query_result.d.ts.map +1 -1
- package/dist/types/src/models/view.d.ts +26 -1
- package/dist/types/src/models/view.d.ts.map +1 -1
- package/dist/types/src/models/view_data_store.d.ts +2 -0
- package/dist/types/src/models/view_data_store.d.ts.map +1 -1
- package/dist/types/src/models/view_metadata_query_result.d.ts +21 -0
- package/dist/types/src/models/view_metadata_query_result.d.ts.map +1 -1
- package/dist/types/src/sdk.d.ts +3 -0
- package/dist/types/src/sdk.d.ts.map +1 -1
- package/dist/types/src/testing/mock_airtable_interface.d.ts +79 -0
- package/dist/types/src/testing/mock_airtable_interface.d.ts.map +1 -1
- package/dist/types/src/types/airtable_interface.d.ts +28 -1
- package/dist/types/src/types/airtable_interface.d.ts.map +1 -1
- package/dist/types/src/types/field.d.ts +241 -1
- package/dist/types/src/types/field.d.ts.map +1 -1
- package/dist/types/src/types/mutations.d.ts +19 -3
- package/dist/types/src/types/mutations.d.ts.map +1 -1
- package/dist/types/src/types/view.d.ts +26 -1
- package/dist/types/src/types/view.d.ts.map +1 -1
- package/dist/types/src/ui/confirmation_dialog.d.ts +8 -0
- package/dist/types/src/ui/confirmation_dialog.d.ts.map +1 -1
- package/dist/types/src/ui/expand_record.d.ts +1 -0
- package/dist/types/src/ui/expand_record.d.ts.map +1 -1
- package/dist/types/src/ui/expand_record_list.d.ts.map +1 -1
- package/dist/types/src/ui/expand_record_picker_async.d.ts +0 -3
- package/dist/types/src/ui/expand_record_picker_async.d.ts.map +1 -1
- package/dist/types/src/ui/icon_config.d.ts +15 -8
- package/dist/types/src/ui/icon_config.d.ts.map +1 -1
- package/dist/types/src/ui/initialize_block.d.ts +19 -2
- package/dist/types/src/ui/initialize_block.d.ts.map +1 -1
- package/dist/types/src/ui/ui.d.ts +2 -2
- package/dist/types/src/ui/ui.d.ts.map +1 -1
- package/dist/types/src/ui/use_loadable.d.ts +2 -2
- package/dist/types/src/ui/use_records.d.ts +11 -1
- package/dist/types/src/ui/use_records.d.ts.map +1 -1
- package/dist/types/src/unstable_testing_utils.d.ts +13 -0
- package/dist/types/src/unstable_testing_utils.d.ts.map +1 -0
- package/dist/types/test/airtable_interface_mocks/linked_records.d.ts.map +1 -1
- package/dist/types/test/airtable_interface_mocks/mock_airtable_interface_internal.d.ts +32 -1
- package/dist/types/test/airtable_interface_mocks/mock_airtable_interface_internal.d.ts.map +1 -1
- package/dist/types/test/airtable_interface_mocks/project_tracker.d.ts.map +1 -1
- package/dist/types/test/ui/expand_record.test.d.ts +2 -0
- package/dist/types/test/ui/expand_record.test.d.ts.map +1 -0
- package/dist/types/test/ui/expand_record_list.test.d.ts +2 -0
- package/dist/types/test/ui/expand_record_list.test.d.ts.map +1 -0
- package/dist/types/test/ui/expand_record_picker_async.test.d.ts +2 -0
- package/dist/types/test/ui/expand_record_picker_async.test.d.ts.map +1 -0
- package/index.d.ts +4 -2
- package/package.json +4 -4
- package/types.d.ts +3 -0
- package/unstable_testing_utils.d.ts +1 -0
- package/unstable_testing_utils.js +1 -0
- package/dist/cjs/testing/inject_mock_airtable_interface.js +0 -63
- package/dist/cjs/testing/mock_airtable_interface_external.js +0 -741
- package/dist/cjs/testing/test_driver.js +0 -260
- package/dist/cjs/types/test_mutations.js +0 -32
- package/dist/cjs/unstable_testing.js +0 -17
- package/dist/types/src/testing/inject_mock_airtable_interface.d.ts +0 -2
- package/dist/types/src/testing/inject_mock_airtable_interface.d.ts.map +0 -1
- package/dist/types/src/testing/mock_airtable_interface_external.d.ts +0 -107
- package/dist/types/src/testing/mock_airtable_interface_external.d.ts.map +0 -1
- package/dist/types/src/testing/test_driver.d.ts +0 -90
- package/dist/types/src/testing/test_driver.d.ts.map +0 -1
- package/dist/types/src/types/test_mutations.d.ts +0 -27
- package/dist/types/src/types/test_mutations.d.ts.map +0 -1
- package/dist/types/src/unstable_testing.d.ts +0 -3
- package/dist/types/src/unstable_testing.d.ts.map +0 -1
- package/dist/types/test/testing/mock_airtable_interface_external.test.d.ts +0 -2
- package/dist/types/test/testing/mock_airtable_interface_external.test.d.ts.map +0 -1
- package/dist/types/test/testing/test_driver.test.d.ts +0 -2
- package/dist/types/test/testing/test_driver.test.d.ts.map +0 -1
- package/unstable_testing.d.ts +0 -1
- package/unstable_testing.js +0 -1
|
@@ -16,6 +16,8 @@ require("core-js/modules/es.array.iterator");
|
|
|
16
16
|
|
|
17
17
|
require("core-js/modules/es.array.map");
|
|
18
18
|
|
|
19
|
+
require("core-js/modules/es.object.get-own-property-descriptors");
|
|
20
|
+
|
|
19
21
|
require("core-js/modules/es.object.to-string");
|
|
20
22
|
|
|
21
23
|
require("core-js/modules/es.promise");
|
|
@@ -24,6 +26,8 @@ require("core-js/modules/es.set");
|
|
|
24
26
|
|
|
25
27
|
require("core-js/modules/es.string.starts-with");
|
|
26
28
|
|
|
29
|
+
require("core-js/modules/web.dom-collections.for-each");
|
|
30
|
+
|
|
27
31
|
require("core-js/modules/web.dom-collections.iterator");
|
|
28
32
|
|
|
29
33
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -61,13 +65,17 @@ var _record_query_result = _interopRequireDefault(require("./record_query_result
|
|
|
61
65
|
|
|
62
66
|
var _record_coloring = require("./record_coloring");
|
|
63
67
|
|
|
68
|
+
var _object_pool = _interopRequireDefault(require("./object_pool"));
|
|
69
|
+
|
|
64
70
|
var _record_store = require("./record_store");
|
|
65
71
|
|
|
66
72
|
var _view_data_store = _interopRequireWildcard(require("./view_data_store"));
|
|
67
73
|
|
|
68
|
-
|
|
74
|
+
var _grouped_record_query_result = _interopRequireDefault(require("./grouped_record_query_result"));
|
|
69
75
|
|
|
70
|
-
|
|
76
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
77
|
+
|
|
78
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
71
79
|
|
|
72
80
|
/**
|
|
73
81
|
* Represents a set of records directly from a view or table. See {@link RecordQueryResult} for main
|
|
@@ -92,16 +100,27 @@ function (_RecordQueryResult) {
|
|
|
92
100
|
/** @internal */
|
|
93
101
|
|
|
94
102
|
/** @internal */
|
|
95
|
-
// If custom sorts are specified, we'll use a VisList to handle sorting.
|
|
103
|
+
// If custom sorts or groups are specified, we'll use a VisList to handle sorting.
|
|
96
104
|
// If no sorts are specified, we'll use the underlying row order of the source model.
|
|
97
105
|
// Note: we're currently handling visibility tracking for view query results within this class,
|
|
98
106
|
// not in the VisList. In other words, only visible records are added to the visList.
|
|
99
107
|
|
|
100
108
|
/** @internal */
|
|
101
109
|
|
|
110
|
+
/** @internal */
|
|
111
|
+
// These is the groupLevels provided to us by the user when executing a query
|
|
112
|
+
|
|
102
113
|
/** @internal */
|
|
103
114
|
// This is the ordered list of record ids.
|
|
104
115
|
|
|
116
|
+
/** @internal */
|
|
117
|
+
// This is the ordered list of groups.
|
|
118
|
+
|
|
119
|
+
/** @internal */
|
|
120
|
+
// An ordered list of group levels returned to us from hyperbase, this should not be
|
|
121
|
+
// read from directly, but instead via this.data.groupLevels (Writing to this on hyperbase updates).
|
|
122
|
+
// (which check's that this model has not been not deleted)
|
|
123
|
+
|
|
105
124
|
/** @internal */
|
|
106
125
|
// lazily generated set of record ids
|
|
107
126
|
|
|
@@ -118,6 +137,8 @@ function (_RecordQueryResult) {
|
|
|
118
137
|
|
|
119
138
|
/** @internal */
|
|
120
139
|
|
|
140
|
+
/** @internal */
|
|
141
|
+
|
|
121
142
|
/** @internal */
|
|
122
143
|
function TableOrViewQueryResult(sdk, sourceModel, normalizedOpts) {
|
|
123
144
|
var _this;
|
|
@@ -130,22 +151,24 @@ function (_RecordQueryResult) {
|
|
|
130
151
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_fieldIdsSetToLoadOrNullIfAllFields", void 0);
|
|
131
152
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_visList", void 0);
|
|
132
153
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_sorts", void 0);
|
|
154
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_groupLevels", void 0);
|
|
133
155
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_orderedRecordIds", void 0);
|
|
156
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_orderedGroups", void 0);
|
|
157
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_loadedGroupLevels", void 0);
|
|
134
158
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_recordIdsSet", null);
|
|
135
159
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_cellValueKeyWatchCounts", void 0);
|
|
160
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "__groupedRecordQueryResultPool", void 0);
|
|
136
161
|
_this._sourceModel = sourceModel;
|
|
137
162
|
_this._mostRecentSourceModelLoadPromise = null;
|
|
138
163
|
_this._table = normalizedOpts.table;
|
|
139
164
|
var sorts = _this._normalizedOpts.sorts;
|
|
165
|
+
_this._sorts = sorts !== null && sorts !== void 0 ? sorts : null; // TODO (SeanKeenan): Placeholder until we support groups from normalizedOpts
|
|
140
166
|
|
|
141
|
-
|
|
142
|
-
_this._sorts = sorts;
|
|
143
|
-
} else {
|
|
144
|
-
_this._sorts = null;
|
|
145
|
-
}
|
|
146
|
-
|
|
167
|
+
_this._groupLevels = null;
|
|
147
168
|
_this._visList = null;
|
|
148
169
|
_this._orderedRecordIds = null;
|
|
170
|
+
_this._orderedGroups = null;
|
|
171
|
+
_this._loadedGroupLevels = null;
|
|
149
172
|
_this._cellValueKeyWatchCounts = {};
|
|
150
173
|
var fieldIdsSetToLoadOrNullIfAllFields = null;
|
|
151
174
|
|
|
@@ -201,7 +224,14 @@ function (_RecordQueryResult) {
|
|
|
201
224
|
}
|
|
202
225
|
}
|
|
203
226
|
}
|
|
204
|
-
}
|
|
227
|
+
} // TODO (SeanKeenan): Comment back in when enabling groups
|
|
228
|
+
// Same for group configs
|
|
229
|
+
// if (this._groupLevels !== null) {
|
|
230
|
+
// for (const group of this._groupLevels) {
|
|
231
|
+
// fieldIdsSetToLoadOrNullIfAllFields[group.fieldId] = true;
|
|
232
|
+
// }
|
|
233
|
+
// }
|
|
234
|
+
|
|
205
235
|
|
|
206
236
|
var recordColorMode = _this._normalizedOpts.recordColorMode;
|
|
207
237
|
|
|
@@ -211,6 +241,7 @@ function (_RecordQueryResult) {
|
|
|
211
241
|
}
|
|
212
242
|
|
|
213
243
|
_this._fieldIdsSetToLoadOrNullIfAllFields = fieldIdsSetToLoadOrNullIfAllFields;
|
|
244
|
+
_this.__groupedRecordQueryResultPool = new _object_pool.default(_grouped_record_query_result.default);
|
|
214
245
|
Object.seal((0, _assertThisInitialized2.default)(_this));
|
|
215
246
|
return _this;
|
|
216
247
|
}
|
|
@@ -445,12 +476,49 @@ function (_RecordQueryResult) {
|
|
|
445
476
|
}
|
|
446
477
|
}, null, this);
|
|
447
478
|
}
|
|
479
|
+
/**
|
|
480
|
+
* @internal
|
|
481
|
+
*/
|
|
482
|
+
|
|
483
|
+
}, {
|
|
484
|
+
key: "_getChangedKeysOnLoad",
|
|
485
|
+
value: function _getChangedKeysOnLoad() {
|
|
486
|
+
var changedKeys = [_record_query_result.default.WatchableKeys.records, _record_query_result.default.WatchableKeys.recordIds, _record_query_result.default.WatchableKeys.cellValues, _record_query_result.default.WatchableKeys.groups, _record_query_result.default.WatchableKeys.groupLevels];
|
|
487
|
+
|
|
488
|
+
var fieldIds = this._normalizedOpts.fieldIdsOrNullIfAllFields || this._table.fields.map(field => field.id);
|
|
489
|
+
|
|
490
|
+
var _iteratorNormalCompletion6 = true;
|
|
491
|
+
var _didIteratorError6 = false;
|
|
492
|
+
var _iteratorError6 = undefined;
|
|
493
|
+
|
|
494
|
+
try {
|
|
495
|
+
for (var _iterator6 = fieldIds[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
|
|
496
|
+
var fieldId = _step6.value;
|
|
497
|
+
changedKeys.push(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix + fieldId);
|
|
498
|
+
}
|
|
499
|
+
} catch (err) {
|
|
500
|
+
_didIteratorError6 = true;
|
|
501
|
+
_iteratorError6 = err;
|
|
502
|
+
} finally {
|
|
503
|
+
try {
|
|
504
|
+
if (!_iteratorNormalCompletion6 && _iterator6.return != null) {
|
|
505
|
+
_iterator6.return();
|
|
506
|
+
}
|
|
507
|
+
} finally {
|
|
508
|
+
if (_didIteratorError6) {
|
|
509
|
+
throw _iteratorError6;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
return changedKeys;
|
|
515
|
+
}
|
|
448
516
|
/** @internal */
|
|
449
517
|
|
|
450
518
|
}, {
|
|
451
519
|
key: "_loadDataAsync",
|
|
452
520
|
value: function _loadDataAsync() {
|
|
453
|
-
var
|
|
521
|
+
var viewDataStore, _iteratorNormalCompletion7, _didIteratorError7, _iteratorError7, _iterator7, _step7, sort, field;
|
|
454
522
|
|
|
455
523
|
return _regenerator.default.async(function _loadDataAsync$(_context2) {
|
|
456
524
|
while (1) {
|
|
@@ -468,29 +536,37 @@ function (_RecordQueryResult) {
|
|
|
468
536
|
}
|
|
469
537
|
|
|
470
538
|
this._orderedRecordIds = this._generateOrderedRecordIds();
|
|
539
|
+
this._orderedGroups = this._generateAndLoadOrderedGroups(); // The server provided value and developer supplied value are the same, no conversion needed
|
|
540
|
+
|
|
541
|
+
this._loadedGroupLevels = this._sourceModelGroupLevels;
|
|
471
542
|
|
|
472
543
|
if (this._sourceModel instanceof _table.default) {
|
|
473
544
|
this._recordStore.watch(_record_store.WatchableRecordStoreKeys.records, this._onRecordsChanged, this);
|
|
474
545
|
} else {
|
|
475
|
-
this._recordStore.getViewDataStore(this._sourceModel.id)
|
|
546
|
+
viewDataStore = this._recordStore.getViewDataStore(this._sourceModel.id);
|
|
547
|
+
viewDataStore.watch(_view_data_store.WatchableViewDataStoreKeys.visibleRecords, this._onRecordsChanged, this);
|
|
548
|
+
viewDataStore.watch(_view_data_store.WatchableViewDataStoreKeys.groups, this._onGroupsChanged, this);
|
|
549
|
+
viewDataStore.watch(_view_data_store.WatchableViewDataStoreKeys.groupLevels, this._onGroupLevelsChanged, this);
|
|
476
550
|
}
|
|
477
551
|
|
|
478
552
|
this._recordStore.watch(this._cellValuesForSortWatchKeys, this._onCellValuesForSortChanged, this);
|
|
479
553
|
|
|
554
|
+
this._recordStore.watch(this._cellValuesForGroupWatchKeys, this._onCellValuesForGroupChanged, this);
|
|
555
|
+
|
|
480
556
|
this._table.watch(_table.WatchableTableKeys.fields, this._onTableFieldsChanged, this);
|
|
481
557
|
|
|
482
558
|
if (!this._sorts) {
|
|
483
|
-
_context2.next =
|
|
559
|
+
_context2.next = 32;
|
|
484
560
|
break;
|
|
485
561
|
}
|
|
486
562
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
_context2.prev =
|
|
563
|
+
_iteratorNormalCompletion7 = true;
|
|
564
|
+
_didIteratorError7 = false;
|
|
565
|
+
_iteratorError7 = undefined;
|
|
566
|
+
_context2.prev = 16;
|
|
491
567
|
|
|
492
|
-
for (
|
|
493
|
-
sort =
|
|
568
|
+
for (_iterator7 = this._sorts[Symbol.iterator](); !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
|
|
569
|
+
sort = _step7.value;
|
|
494
570
|
field = this._table.getFieldByIdIfExists(sort.fieldId);
|
|
495
571
|
|
|
496
572
|
if (field) {
|
|
@@ -499,94 +575,48 @@ function (_RecordQueryResult) {
|
|
|
499
575
|
}
|
|
500
576
|
}
|
|
501
577
|
|
|
502
|
-
_context2.next =
|
|
578
|
+
_context2.next = 24;
|
|
503
579
|
break;
|
|
504
580
|
|
|
505
|
-
case
|
|
506
|
-
_context2.prev =
|
|
507
|
-
_context2.t0 = _context2["catch"](
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
case 21:
|
|
512
|
-
_context2.prev = 21;
|
|
513
|
-
_context2.prev = 22;
|
|
514
|
-
|
|
515
|
-
if (!_iteratorNormalCompletion6 && _iterator6.return != null) {
|
|
516
|
-
_iterator6.return();
|
|
517
|
-
}
|
|
581
|
+
case 20:
|
|
582
|
+
_context2.prev = 20;
|
|
583
|
+
_context2.t0 = _context2["catch"](16);
|
|
584
|
+
_didIteratorError7 = true;
|
|
585
|
+
_iteratorError7 = _context2.t0;
|
|
518
586
|
|
|
519
587
|
case 24:
|
|
520
588
|
_context2.prev = 24;
|
|
521
|
-
|
|
522
|
-
if (!_didIteratorError6) {
|
|
523
|
-
_context2.next = 27;
|
|
524
|
-
break;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
throw _iteratorError6;
|
|
528
|
-
|
|
529
|
-
case 27:
|
|
530
|
-
return _context2.finish(24);
|
|
531
|
-
|
|
532
|
-
case 28:
|
|
533
|
-
return _context2.finish(21);
|
|
534
|
-
|
|
535
|
-
case 29:
|
|
536
|
-
changedKeys = [_record_query_result.default.WatchableKeys.records, _record_query_result.default.WatchableKeys.recordIds, _record_query_result.default.WatchableKeys.cellValues];
|
|
537
|
-
fieldIds = this._normalizedOpts.fieldIdsOrNullIfAllFields || this._table.fields.map(field => field.id);
|
|
538
|
-
_iteratorNormalCompletion7 = true;
|
|
539
|
-
_didIteratorError7 = false;
|
|
540
|
-
_iteratorError7 = undefined;
|
|
541
|
-
_context2.prev = 34;
|
|
542
|
-
|
|
543
|
-
for (_iterator7 = fieldIds[Symbol.iterator](); !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
|
|
544
|
-
fieldId = _step7.value;
|
|
545
|
-
changedKeys.push(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix + fieldId);
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
_context2.next = 42;
|
|
549
|
-
break;
|
|
550
|
-
|
|
551
|
-
case 38:
|
|
552
|
-
_context2.prev = 38;
|
|
553
|
-
_context2.t1 = _context2["catch"](34);
|
|
554
|
-
_didIteratorError7 = true;
|
|
555
|
-
_iteratorError7 = _context2.t1;
|
|
556
|
-
|
|
557
|
-
case 42:
|
|
558
|
-
_context2.prev = 42;
|
|
559
|
-
_context2.prev = 43;
|
|
589
|
+
_context2.prev = 25;
|
|
560
590
|
|
|
561
591
|
if (!_iteratorNormalCompletion7 && _iterator7.return != null) {
|
|
562
592
|
_iterator7.return();
|
|
563
593
|
}
|
|
564
594
|
|
|
565
|
-
case
|
|
566
|
-
_context2.prev =
|
|
595
|
+
case 27:
|
|
596
|
+
_context2.prev = 27;
|
|
567
597
|
|
|
568
598
|
if (!_didIteratorError7) {
|
|
569
|
-
_context2.next =
|
|
599
|
+
_context2.next = 30;
|
|
570
600
|
break;
|
|
571
601
|
}
|
|
572
602
|
|
|
573
603
|
throw _iteratorError7;
|
|
574
604
|
|
|
575
|
-
case
|
|
576
|
-
return _context2.finish(
|
|
605
|
+
case 30:
|
|
606
|
+
return _context2.finish(27);
|
|
577
607
|
|
|
578
|
-
case
|
|
579
|
-
return _context2.finish(
|
|
608
|
+
case 31:
|
|
609
|
+
return _context2.finish(24);
|
|
580
610
|
|
|
581
|
-
case
|
|
582
|
-
return _context2.abrupt("return",
|
|
611
|
+
case 32:
|
|
612
|
+
return _context2.abrupt("return", this._getChangedKeysOnLoad());
|
|
583
613
|
|
|
584
|
-
case
|
|
614
|
+
case 33:
|
|
585
615
|
case "end":
|
|
586
616
|
return _context2.stop();
|
|
587
617
|
}
|
|
588
618
|
}
|
|
589
|
-
}, null, this, [[
|
|
619
|
+
}, null, this, [[16, 20, 24, 32], [25,, 27, 31]]);
|
|
590
620
|
}
|
|
591
621
|
/** @inheritdoc */
|
|
592
622
|
|
|
@@ -625,12 +655,18 @@ function (_RecordQueryResult) {
|
|
|
625
655
|
this._recordStore.unwatch(_record_store.WatchableRecordStoreKeys.records, this._onRecordsChanged, this);
|
|
626
656
|
} else {
|
|
627
657
|
if (!this._sourceModel.isDeleted) {
|
|
628
|
-
this._recordStore.getViewDataStore(this._sourceModel.id)
|
|
658
|
+
var viewDataStore = this._recordStore.getViewDataStore(this._sourceModel.id);
|
|
659
|
+
|
|
660
|
+
viewDataStore.unwatch(_view_data_store.WatchableViewDataStoreKeys.visibleRecords, this._onRecordsChanged, this);
|
|
661
|
+
viewDataStore.unwatch(_view_data_store.WatchableViewDataStoreKeys.groups, this._onGroupsChanged, this);
|
|
662
|
+
viewDataStore.unwatch(_view_data_store.WatchableViewDataStoreKeys.groupLevels, this._onGroupLevelsChanged, this);
|
|
629
663
|
}
|
|
630
664
|
}
|
|
631
665
|
|
|
632
666
|
this._recordStore.unwatch(this._cellValuesForSortWatchKeys, this._onCellValuesForSortChanged, this);
|
|
633
667
|
|
|
668
|
+
this._recordStore.unwatch(this._cellValuesForGroupWatchKeys, this._onCellValuesForGroupChanged, this);
|
|
669
|
+
|
|
634
670
|
this._table.unwatch(_table.WatchableTableKeys.fields, this._onTableFieldsChanged, this); // If the table is deleted, can't call getFieldById on it below.
|
|
635
671
|
|
|
636
672
|
|
|
@@ -666,6 +702,8 @@ function (_RecordQueryResult) {
|
|
|
666
702
|
}
|
|
667
703
|
}
|
|
668
704
|
|
|
705
|
+
this._unloadOrderedGroupsIfNeeded();
|
|
706
|
+
|
|
669
707
|
this._visList = null;
|
|
670
708
|
this._orderedRecordIds = null;
|
|
671
709
|
this._recordIdsSet = null;
|
|
@@ -709,6 +747,24 @@ function (_RecordQueryResult) {
|
|
|
709
747
|
}
|
|
710
748
|
/** @internal */
|
|
711
749
|
|
|
750
|
+
}, {
|
|
751
|
+
key: "_onGroupLevelsChanged",
|
|
752
|
+
value: function _onGroupLevelsChanged(model, key, updates) {
|
|
753
|
+
this._loadedGroupLevels = this._sourceModelGroupLevels;
|
|
754
|
+
|
|
755
|
+
this._unloadRemovedGroupsAndLoadNewGroupsAndTriggerWatches();
|
|
756
|
+
|
|
757
|
+
this._onChange(_record_query_result.default.WatchableKeys.groupLevels);
|
|
758
|
+
}
|
|
759
|
+
/** @internal */
|
|
760
|
+
|
|
761
|
+
}, {
|
|
762
|
+
key: "_onGroupsChanged",
|
|
763
|
+
value: function _onGroupsChanged(model, key, updates) {
|
|
764
|
+
this._unloadRemovedGroupsAndLoadNewGroupsAndTriggerWatches();
|
|
765
|
+
}
|
|
766
|
+
/** @internal */
|
|
767
|
+
|
|
712
768
|
}, {
|
|
713
769
|
key: "_onRecordsChanged",
|
|
714
770
|
value: function _onRecordsChanged(model, key, updates) {
|
|
@@ -812,6 +868,17 @@ function (_RecordQueryResult) {
|
|
|
812
868
|
this._onChange(_record_query_result.default.WatchableKeys.recordIds, updates);
|
|
813
869
|
}
|
|
814
870
|
/** @internal */
|
|
871
|
+
// istanbul ignore next
|
|
872
|
+
|
|
873
|
+
}, {
|
|
874
|
+
key: "_onCellValuesForGroupChanged",
|
|
875
|
+
value: function _onCellValuesForGroupChanged(recordStore, key, recordIds, fieldId) {} // TODO(SeanKeenan): This isn't yet required as we don't yet support
|
|
876
|
+
// specifying groups for a custom query, and this will only be called
|
|
877
|
+
// if we specify groups (same as _onCellValuesForSortChanged)
|
|
878
|
+
// This functionality and _onCellValuesForSortChanged should be
|
|
879
|
+
// identical, but testing, validation, and careful thought is required.
|
|
880
|
+
|
|
881
|
+
/** @internal */
|
|
815
882
|
|
|
816
883
|
}, {
|
|
817
884
|
key: "_onCellValuesForSortChanged",
|
|
@@ -936,7 +1003,9 @@ function (_RecordQueryResult) {
|
|
|
936
1003
|
|
|
937
1004
|
this._onChange(_record_query_result.default.WatchableKeys.records, changeData);
|
|
938
1005
|
|
|
939
|
-
this._onChange(_record_query_result.default.WatchableKeys.recordIds, changeData);
|
|
1006
|
+
this._onChange(_record_query_result.default.WatchableKeys.recordIds, changeData); // We do not unload/reload groupQueryResults if it's field is deleted as
|
|
1007
|
+
// it is responsible for failing to load if the field doesn't exist
|
|
1008
|
+
|
|
940
1009
|
}
|
|
941
1010
|
}
|
|
942
1011
|
/** @internal */
|
|
@@ -981,6 +1050,85 @@ function (_RecordQueryResult) {
|
|
|
981
1050
|
}
|
|
982
1051
|
/** @internal */
|
|
983
1052
|
|
|
1053
|
+
}, {
|
|
1054
|
+
key: "_generateAndLoadOrderedGroups",
|
|
1055
|
+
value: function _generateAndLoadOrderedGroups() {
|
|
1056
|
+
// istanbul ignore next
|
|
1057
|
+
if (this._groupLevels) {
|
|
1058
|
+
(0, _error_utils.invariant)(this._visList, 'Cannot generate record ids without a vis list');
|
|
1059
|
+
throw (0, _error_utils.spawnError)('custom group configs not supported');
|
|
1060
|
+
} else {
|
|
1061
|
+
// Get the group from the view itself
|
|
1062
|
+
var groupLevels = this._sourceModelGroupLevels;
|
|
1063
|
+
|
|
1064
|
+
if (!this._sourceModelGroups || !groupLevels) {
|
|
1065
|
+
return null;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
return this._sourceModelGroups.map(groupData => {
|
|
1069
|
+
var group = this.__groupedRecordQueryResultPool.getObjectForReuse(this, groupData, groupLevels, this._normalizedOpts, this._sdk); // Don't await the loading, let others check isDataLoaded.
|
|
1070
|
+
// (it doesn't take any time anyway). Loading also strong retains.
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
group.loadDataAsync();
|
|
1074
|
+
return group;
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
/** @internal */
|
|
1079
|
+
|
|
1080
|
+
}, {
|
|
1081
|
+
key: "_unloadOrderedGroupsIfNeeded",
|
|
1082
|
+
value: function _unloadOrderedGroupsIfNeeded() {
|
|
1083
|
+
if (this._orderedGroups) {
|
|
1084
|
+
var _iteratorNormalCompletion13 = true;
|
|
1085
|
+
var _didIteratorError13 = false;
|
|
1086
|
+
var _iteratorError13 = undefined;
|
|
1087
|
+
|
|
1088
|
+
try {
|
|
1089
|
+
for (var _iterator13 = this._orderedGroups[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {
|
|
1090
|
+
var group = _step13.value;
|
|
1091
|
+
group.unloadData();
|
|
1092
|
+
}
|
|
1093
|
+
} catch (err) {
|
|
1094
|
+
_didIteratorError13 = true;
|
|
1095
|
+
_iteratorError13 = err;
|
|
1096
|
+
} finally {
|
|
1097
|
+
try {
|
|
1098
|
+
if (!_iteratorNormalCompletion13 && _iterator13.return != null) {
|
|
1099
|
+
_iterator13.return();
|
|
1100
|
+
}
|
|
1101
|
+
} finally {
|
|
1102
|
+
if (_didIteratorError13) {
|
|
1103
|
+
throw _iteratorError13;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
/**
|
|
1110
|
+
* If groupings change then some groups will need to be created, and some removed
|
|
1111
|
+
* This (TODO: will) handle the diffing necessary to unload, and reload only the changed groups.
|
|
1112
|
+
* Also triggers the WatchableKeys.group, as by necessity this will have changed.
|
|
1113
|
+
*
|
|
1114
|
+
* @internal
|
|
1115
|
+
*/
|
|
1116
|
+
// TODO: (SeanKeenan) Properly diff and only unload groups that need to be unloaded
|
|
1117
|
+
// In the meantime it's not too expensive to just unload everything, and GroupedRecordQueryResults
|
|
1118
|
+
// don't yet properly watch changes relevant to updating, so this isn't too bad.
|
|
1119
|
+
// (They do invalidate their recordId caches, which is some very cheap work that we could remove)
|
|
1120
|
+
|
|
1121
|
+
}, {
|
|
1122
|
+
key: "_unloadRemovedGroupsAndLoadNewGroupsAndTriggerWatches",
|
|
1123
|
+
value: function _unloadRemovedGroupsAndLoadNewGroupsAndTriggerWatches() {
|
|
1124
|
+
this._unloadOrderedGroupsIfNeeded();
|
|
1125
|
+
|
|
1126
|
+
this._orderedGroups = this._generateAndLoadOrderedGroups();
|
|
1127
|
+
|
|
1128
|
+
this._onChange(_record_query_result.default.WatchableKeys.groups);
|
|
1129
|
+
}
|
|
1130
|
+
/** @internal */
|
|
1131
|
+
|
|
984
1132
|
}, {
|
|
985
1133
|
key: "_replaceVisList",
|
|
986
1134
|
value: function _replaceVisList() {
|
|
@@ -1027,7 +1175,9 @@ function (_RecordQueryResult) {
|
|
|
1027
1175
|
}
|
|
1028
1176
|
|
|
1029
1177
|
return {
|
|
1030
|
-
recordIds: this._orderedRecordIds
|
|
1178
|
+
recordIds: this._orderedRecordIds,
|
|
1179
|
+
groups: this._orderedGroups,
|
|
1180
|
+
groupLevels: this._loadedGroupLevels
|
|
1031
1181
|
};
|
|
1032
1182
|
}
|
|
1033
1183
|
/** @internal */
|
|
@@ -1084,6 +1234,42 @@ function (_RecordQueryResult) {
|
|
|
1084
1234
|
(0, _error_utils.invariant)(recordIds, 'No recordIds');
|
|
1085
1235
|
return recordIds;
|
|
1086
1236
|
}
|
|
1237
|
+
/**
|
|
1238
|
+
* The ordered GroupedRecordQueryResult's in this RecordQueryResult.
|
|
1239
|
+
* Throws if data is not loaded yet.
|
|
1240
|
+
* Can be watched.
|
|
1241
|
+
*
|
|
1242
|
+
* @hidden
|
|
1243
|
+
*/
|
|
1244
|
+
|
|
1245
|
+
}, {
|
|
1246
|
+
key: "groups",
|
|
1247
|
+
get: function get() {
|
|
1248
|
+
// The following statements have been carefully sequenced to ensure
|
|
1249
|
+
// that when this method fails, it reports the most salient error.
|
|
1250
|
+
var groups = this._data.groups; // Throws when the model has been deleted.
|
|
1251
|
+
|
|
1252
|
+
(0, _error_utils.invariant)(this.isDataLoaded, 'RecordQueryResult data is not loaded');
|
|
1253
|
+
return groups !== null && groups !== void 0 ? groups : null;
|
|
1254
|
+
}
|
|
1255
|
+
/**
|
|
1256
|
+
* The GroupLevels in this RecordQueryResult.
|
|
1257
|
+
* Throws if data is not loaded yet.
|
|
1258
|
+
* Can be watched.
|
|
1259
|
+
*
|
|
1260
|
+
* @hidden
|
|
1261
|
+
*/
|
|
1262
|
+
|
|
1263
|
+
}, {
|
|
1264
|
+
key: "groupLevels",
|
|
1265
|
+
get: function get() {
|
|
1266
|
+
var groupLevels = this._data.groupLevels; // Throws when the model has been deleted.
|
|
1267
|
+
|
|
1268
|
+
(0, _error_utils.invariant)(this.isDataLoaded, 'RecordQueryResult data is not loaded');
|
|
1269
|
+
return groupLevels ? groupLevels.map(singleLevel => _objectSpread({}, singleLevel, {
|
|
1270
|
+
field: this.parentTable.getFieldById(singleLevel.fieldId)
|
|
1271
|
+
})) : null;
|
|
1272
|
+
}
|
|
1087
1273
|
}, {
|
|
1088
1274
|
key: "fields",
|
|
1089
1275
|
get: function get() {
|
|
@@ -1095,13 +1281,13 @@ function (_RecordQueryResult) {
|
|
|
1095
1281
|
// using RecordQueryResult) if the user had to manually watch for deletion
|
|
1096
1282
|
// on all the fields and recreate the RecordQueryResult.
|
|
1097
1283
|
|
|
1098
|
-
var
|
|
1099
|
-
var
|
|
1100
|
-
var
|
|
1284
|
+
var _iteratorNormalCompletion14 = true;
|
|
1285
|
+
var _didIteratorError14 = false;
|
|
1286
|
+
var _iteratorError14 = undefined;
|
|
1101
1287
|
|
|
1102
1288
|
try {
|
|
1103
|
-
for (var
|
|
1104
|
-
var fieldId =
|
|
1289
|
+
for (var _iterator14 = fieldIdsOrNullIfAllFields[Symbol.iterator](), _step14; !(_iteratorNormalCompletion14 = (_step14 = _iterator14.next()).done); _iteratorNormalCompletion14 = true) {
|
|
1290
|
+
var fieldId = _step14.value;
|
|
1105
1291
|
|
|
1106
1292
|
var field = this._table.getFieldByIdIfExists(fieldId);
|
|
1107
1293
|
|
|
@@ -1110,16 +1296,16 @@ function (_RecordQueryResult) {
|
|
|
1110
1296
|
}
|
|
1111
1297
|
}
|
|
1112
1298
|
} catch (err) {
|
|
1113
|
-
|
|
1114
|
-
|
|
1299
|
+
_didIteratorError14 = true;
|
|
1300
|
+
_iteratorError14 = err;
|
|
1115
1301
|
} finally {
|
|
1116
1302
|
try {
|
|
1117
|
-
if (!
|
|
1118
|
-
|
|
1303
|
+
if (!_iteratorNormalCompletion14 && _iterator14.return != null) {
|
|
1304
|
+
_iterator14.return();
|
|
1119
1305
|
}
|
|
1120
1306
|
} finally {
|
|
1121
|
-
if (
|
|
1122
|
-
throw
|
|
1307
|
+
if (_didIteratorError14) {
|
|
1308
|
+
throw _iteratorError14;
|
|
1123
1309
|
}
|
|
1124
1310
|
}
|
|
1125
1311
|
}
|
|
@@ -1138,6 +1324,15 @@ function (_RecordQueryResult) {
|
|
|
1138
1324
|
}
|
|
1139
1325
|
/** @internal */
|
|
1140
1326
|
|
|
1327
|
+
}, {
|
|
1328
|
+
key: "_cellValuesForGroupWatchKeys",
|
|
1329
|
+
get: function get() {
|
|
1330
|
+
// _groupLevels can not be specified by the user during the query yet
|
|
1331
|
+
// istanbul ignore next
|
|
1332
|
+
return this._groupLevels ? this._groupLevels.map(group => "cellValuesInField:".concat(group.fieldId)) : [];
|
|
1333
|
+
}
|
|
1334
|
+
/** @internal */
|
|
1335
|
+
|
|
1141
1336
|
}, {
|
|
1142
1337
|
key: "_sourceModelRecordIds",
|
|
1143
1338
|
get: function get() {
|
|
@@ -1145,6 +1340,20 @@ function (_RecordQueryResult) {
|
|
|
1145
1340
|
}
|
|
1146
1341
|
/** @internal */
|
|
1147
1342
|
|
|
1343
|
+
}, {
|
|
1344
|
+
key: "_sourceModelGroups",
|
|
1345
|
+
get: function get() {
|
|
1346
|
+
return this._sourceModel instanceof _table.default ? null : this._recordStore.getViewDataStore(this._sourceModel.id).groups;
|
|
1347
|
+
}
|
|
1348
|
+
/** @internal */
|
|
1349
|
+
|
|
1350
|
+
}, {
|
|
1351
|
+
key: "_sourceModelGroupLevels",
|
|
1352
|
+
get: function get() {
|
|
1353
|
+
return this._sourceModel instanceof _table.default ? null : this._recordStore.getViewDataStore(this._sourceModel.id).groupLevels;
|
|
1354
|
+
}
|
|
1355
|
+
/** @internal */
|
|
1356
|
+
|
|
1148
1357
|
}, {
|
|
1149
1358
|
key: "_sourceModelRecords",
|
|
1150
1359
|
get: function get() {
|