@itwin/presentation-frontend 4.5.0-dev.0 → 4.5.0-dev.16
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 +20 -1
- package/LICENSE.md +1 -1
- package/README.md +1 -1
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js +10 -6
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/Diagnostics.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/Diagnostics.js +18 -13
- package/lib/cjs/presentation-frontend/Diagnostics.js.map +1 -1
- package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js +3 -3
- package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.js +3 -3
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/cjs/presentation-frontend/LocalizationHelper.js +3 -3
- package/lib/cjs/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.js +24 -14
- package/lib/cjs/presentation-frontend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.js +57 -30
- package/lib/cjs/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetManager.js +11 -7
- package/lib/cjs/presentation-frontend/RulesetManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.js +53 -31
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +111 -66
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +54 -25
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/HiliteRules.json +172 -172
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js +16 -10
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js +3 -3
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js +3 -3
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.js +15 -9
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.js +7 -5
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js +31 -16
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js +25 -14
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend.js +3 -3
- package/lib/cjs/presentation-frontend.js.map +1 -1
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js +10 -6
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/Diagnostics.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/Diagnostics.js +18 -13
- package/lib/esm/presentation-frontend/Diagnostics.js.map +1 -1
- package/lib/esm/presentation-frontend/FrontendLoggerCategory.js +3 -3
- package/lib/esm/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
- package/lib/esm/presentation-frontend/IpcRequestsHandler.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/IpcRequestsHandler.js +3 -3
- package/lib/esm/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/esm/presentation-frontend/LocalizationHelper.js +3 -3
- package/lib/esm/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.js +24 -14
- package/lib/esm/presentation-frontend/Presentation.js.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.js +57 -30
- package/lib/esm/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/esm/presentation-frontend/RulesetManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/RulesetManager.js +11 -7
- package/lib/esm/presentation-frontend/RulesetManager.js.map +1 -1
- package/lib/esm/presentation-frontend/RulesetVariablesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/RulesetVariablesManager.js +53 -31
- package/lib/esm/presentation-frontend/RulesetVariablesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +111 -66
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +54 -25
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/HiliteRules.json +172 -172
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js +17 -11
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.js +3 -3
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js +3 -3
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHandler.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHandler.js +15 -9
- package/lib/esm/presentation-frontend/selection/SelectionHandler.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHelper.js +7 -5
- package/lib/esm/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.js +31 -16
- package/lib/esm/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js +25 -14
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/esm/presentation-frontend.js +3 -3
- package/lib/esm/presentation-frontend.js.map +1 -1
- package/package.json +19 -16
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
/** @packageDocumentation
|
|
7
7
|
* @module Core
|
|
8
8
|
*/
|
|
@@ -36,17 +36,18 @@ class FavoritePropertiesManager {
|
|
|
36
36
|
this.initializeConnection = async (imodel) => {
|
|
37
37
|
const imodelId = imodel.iModelId;
|
|
38
38
|
const iTwinId = imodel.iTwinId;
|
|
39
|
-
if (this._globalProperties === undefined)
|
|
40
|
-
this._globalProperties = await this._storage.loadProperties() || new Set();
|
|
39
|
+
if (this._globalProperties === undefined) {
|
|
40
|
+
this._globalProperties = (await this._storage.loadProperties()) || new Set();
|
|
41
|
+
}
|
|
41
42
|
if (!this._iTwinProperties.has(iTwinId)) {
|
|
42
|
-
const iTwinProperties = await this._storage.loadProperties(iTwinId) || new Set();
|
|
43
|
+
const iTwinProperties = (await this._storage.loadProperties(iTwinId)) || new Set();
|
|
43
44
|
this._iTwinProperties.set(iTwinId, iTwinProperties);
|
|
44
45
|
}
|
|
45
46
|
if (!this._imodelProperties.has(getiModelInfo(iTwinId, imodelId))) {
|
|
46
|
-
const imodelProperties = await this._storage.loadProperties(iTwinId, imodelId) || new Set();
|
|
47
|
+
const imodelProperties = (await this._storage.loadProperties(iTwinId, imodelId)) || new Set();
|
|
47
48
|
this._imodelProperties.set(getiModelInfo(iTwinId, imodelId), imodelProperties);
|
|
48
49
|
}
|
|
49
|
-
const propertiesOrder = await this._storage.loadPropertiesOrder(iTwinId, imodelId) || [];
|
|
50
|
+
const propertiesOrder = (await this._storage.loadPropertiesOrder(iTwinId, imodelId)) || [];
|
|
50
51
|
this._propertiesOrder.set(getiModelInfo(iTwinId, imodelId), propertiesOrder);
|
|
51
52
|
await this._adjustPropertyOrderInfos(iTwinId, imodelId);
|
|
52
53
|
};
|
|
@@ -62,10 +63,12 @@ class FavoritePropertiesManager {
|
|
|
62
63
|
// favorite property infos that need to be added to the propertiesOrder array
|
|
63
64
|
const infosToAdd = new Set([...globalProperties, ...iTwinProperties, ...imodelProperties]);
|
|
64
65
|
for (let i = propertiesOrder.length - 1; i >= 0; i--) {
|
|
65
|
-
if (infosToAdd.has(propertiesOrder[i].name))
|
|
66
|
+
if (infosToAdd.has(propertiesOrder[i].name)) {
|
|
66
67
|
infosToAdd.delete(propertiesOrder[i].name);
|
|
67
|
-
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
68
70
|
propertiesOrder.splice(i, 1);
|
|
71
|
+
}
|
|
69
72
|
}
|
|
70
73
|
infosToAdd.forEach((info) => propertiesOrder.push({
|
|
71
74
|
name: info,
|
|
@@ -74,7 +77,7 @@ class FavoritePropertiesManager {
|
|
|
74
77
|
priority: 0,
|
|
75
78
|
}));
|
|
76
79
|
let priority = propertiesOrder.length;
|
|
77
|
-
propertiesOrder.forEach((oi) => oi.priority = priority--);
|
|
80
|
+
propertiesOrder.forEach((oi) => (oi.priority = priority--));
|
|
78
81
|
};
|
|
79
82
|
/**
|
|
80
83
|
* Sorts an array of fields with respect to favorite property order.
|
|
@@ -92,11 +95,15 @@ class FavoritePropertiesManager {
|
|
|
92
95
|
const sortFunction = (left, right) => {
|
|
93
96
|
const lp = fieldPriority.get(left);
|
|
94
97
|
const rp = fieldPriority.get(right);
|
|
95
|
-
return lp < rp
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
return lp < rp
|
|
99
|
+
? 1
|
|
100
|
+
: lp > rp
|
|
101
|
+
? -1
|
|
102
|
+
: left.priority < right.priority
|
|
103
|
+
? 1 // if favorite fields have equal priorities, sort by field priority
|
|
104
|
+
: left.priority > right.priority
|
|
105
|
+
? -1
|
|
106
|
+
: left.name.localeCompare(right.name);
|
|
100
107
|
};
|
|
101
108
|
return fields.sort(sortFunction);
|
|
102
109
|
};
|
|
@@ -105,30 +112,35 @@ class FavoritePropertiesManager {
|
|
|
105
112
|
const imodelId = imodel.iModelId;
|
|
106
113
|
const imodelInfo = getiModelInfo(iTwinId, imodelId);
|
|
107
114
|
let baseClasses;
|
|
108
|
-
if (this._imodelBaseClassesByClass.has(imodelInfo))
|
|
115
|
+
if (this._imodelBaseClassesByClass.has(imodelInfo)) {
|
|
109
116
|
baseClasses = this._imodelBaseClassesByClass.get(imodelInfo);
|
|
110
|
-
|
|
111
|
-
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
this._imodelBaseClassesByClass.set(imodelInfo, (baseClasses = {}));
|
|
120
|
+
}
|
|
112
121
|
const missingClasses = new Set();
|
|
113
122
|
neededClasses.forEach((className) => {
|
|
114
|
-
if (!baseClasses.hasOwnProperty(className))
|
|
123
|
+
if (!baseClasses.hasOwnProperty(className)) {
|
|
115
124
|
missingClasses.add(className);
|
|
125
|
+
}
|
|
116
126
|
});
|
|
117
|
-
if (missingClasses.size === 0)
|
|
127
|
+
if (missingClasses.size === 0) {
|
|
118
128
|
return baseClasses;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
INNER JOIN ECDbMeta.
|
|
124
|
-
INNER JOIN ECDbMeta.
|
|
125
|
-
INNER JOIN ECDbMeta.
|
|
129
|
+
}
|
|
130
|
+
const query = `
|
|
131
|
+
SELECT (derivedSchema.Name || ':' || derivedClass.Name) AS "ClassFullName", (baseSchema.Name || ':' || baseClass.Name) AS "BaseClassFullName"
|
|
132
|
+
FROM ECDbMeta.ClassHasAllBaseClasses baseClassRels
|
|
133
|
+
INNER JOIN ECDbMeta.ECClassDef derivedClass ON derivedClass.ECInstanceId = baseClassRels.SourceECInstanceId
|
|
134
|
+
INNER JOIN ECDbMeta.ECSchemaDef derivedSchema ON derivedSchema.ECInstanceId = derivedClass.Schema.Id
|
|
135
|
+
INNER JOIN ECDbMeta.ECClassDef baseClass ON baseClass.ECInstanceId = baseClassRels.TargetECInstanceId
|
|
136
|
+
INNER JOIN ECDbMeta.ECSchemaDef baseSchema ON baseSchema.ECInstanceId = baseClass.Schema.Id
|
|
126
137
|
WHERE (derivedSchema.Name || ':' || derivedClass.Name) IN (${[...missingClasses].map((className) => `'${className}'`).join(",")})`;
|
|
127
138
|
const reader = imodel.createQueryReader(query, undefined, { rowFormat: core_common_1.QueryRowFormat.UseJsPropertyNames });
|
|
128
139
|
while (await reader.step()) {
|
|
129
140
|
const row = reader.current.toRow();
|
|
130
|
-
if (!(row.classFullName in baseClasses))
|
|
141
|
+
if (!(row.classFullName in baseClasses)) {
|
|
131
142
|
baseClasses[row.classFullName] = [];
|
|
143
|
+
}
|
|
132
144
|
baseClasses[row.classFullName].push(row.baseClassFullName);
|
|
133
145
|
}
|
|
134
146
|
return baseClasses;
|
|
@@ -141,14 +153,16 @@ class FavoritePropertiesManager {
|
|
|
141
153
|
}
|
|
142
154
|
dispose() {
|
|
143
155
|
// istanbul ignore else
|
|
144
|
-
if ((0, core_bentley_1.isIDisposable)(this._storage))
|
|
156
|
+
if ((0, core_bentley_1.isIDisposable)(this._storage)) {
|
|
145
157
|
this._storage.dispose();
|
|
158
|
+
}
|
|
146
159
|
}
|
|
147
160
|
validateInitialization(imodel) {
|
|
148
161
|
const iTwinId = imodel.iTwinId;
|
|
149
162
|
const imodelId = imodel.iModelId;
|
|
150
|
-
if (!this._imodelProperties.has(getiModelInfo(iTwinId, imodelId)))
|
|
163
|
+
if (!this._imodelProperties.has(getiModelInfo(iTwinId, imodelId))) {
|
|
151
164
|
throw Error(`Favorite properties are not initialized for iModel: '${imodelId}', in iTwin: '${iTwinId}'. Call initializeConnection() with an IModelConnection to initialize.`);
|
|
165
|
+
}
|
|
152
166
|
}
|
|
153
167
|
/**
|
|
154
168
|
* Adds favorite properties into a certain scope.
|
|
@@ -228,8 +242,9 @@ class FavoritePropertiesManager {
|
|
|
228
242
|
favoritesChanged = true;
|
|
229
243
|
}
|
|
230
244
|
}
|
|
231
|
-
if (!favoritesChanged)
|
|
245
|
+
if (!favoritesChanged) {
|
|
232
246
|
return;
|
|
247
|
+
}
|
|
233
248
|
const propertiesOrder = this._propertiesOrder.get(getiModelInfo(iTwinId, imodelId));
|
|
234
249
|
removeOrderInfos(propertiesOrder, (0, exports.createFieldOrderInfos)(field));
|
|
235
250
|
saves.push(this._storage.savePropertiesOrder(propertiesOrder, iTwinId, imodelId));
|
|
@@ -261,8 +276,9 @@ class FavoritePropertiesManager {
|
|
|
261
276
|
favoriteProperties = this._imodelProperties.get(getiModelInfo(iTwinId, imodelId));
|
|
262
277
|
saveProperties = async () => this._storage.saveProperties(new Set(), iTwinId, imodelId);
|
|
263
278
|
}
|
|
264
|
-
if (favoriteProperties.size === 0)
|
|
279
|
+
if (favoriteProperties.size === 0) {
|
|
265
280
|
return;
|
|
281
|
+
}
|
|
266
282
|
favoriteProperties.clear();
|
|
267
283
|
const saves = [];
|
|
268
284
|
saves.push(saveProperties());
|
|
@@ -282,15 +298,16 @@ class FavoritePropertiesManager {
|
|
|
282
298
|
const iTwinId = imodel.iTwinId;
|
|
283
299
|
const imodelId = imodel.iModelId;
|
|
284
300
|
const fieldInfos = (0, exports.getFieldInfos)(field);
|
|
285
|
-
return setHasAny(this._globalProperties, fieldInfos) ||
|
|
301
|
+
return (setHasAny(this._globalProperties, fieldInfos) ||
|
|
286
302
|
(scope !== FavoritePropertiesScope.Global && setHasAny(this._iTwinProperties.get(iTwinId), fieldInfos)) ||
|
|
287
|
-
(scope === FavoritePropertiesScope.IModel && setHasAny(this._imodelProperties.get(getiModelInfo(iTwinId, imodelId)), fieldInfos));
|
|
303
|
+
(scope === FavoritePropertiesScope.IModel && setHasAny(this._imodelProperties.get(getiModelInfo(iTwinId, imodelId)), fieldInfos)));
|
|
288
304
|
}
|
|
289
305
|
getFieldPriority(field, iTwinId, imodelId) {
|
|
290
306
|
const orderInfos = this._propertiesOrder.get(getiModelInfo(iTwinId, imodelId));
|
|
291
307
|
const fieldOrderInfos = getFieldOrderInfos(field, orderInfos);
|
|
292
|
-
if (fieldOrderInfos.length === 0)
|
|
308
|
+
if (fieldOrderInfos.length === 0) {
|
|
293
309
|
return -1;
|
|
310
|
+
}
|
|
294
311
|
const mostRecent = getMostRecentOrderInfo(fieldOrderInfos);
|
|
295
312
|
return mostRecent.priority;
|
|
296
313
|
}
|
|
@@ -317,20 +334,23 @@ class FavoritePropertiesManager {
|
|
|
317
334
|
this.validateInitialization(imodel);
|
|
318
335
|
const iTwinId = imodel.iTwinId;
|
|
319
336
|
const imodelId = imodel.iModelId;
|
|
320
|
-
if (field === afterField)
|
|
337
|
+
if (field === afterField) {
|
|
321
338
|
throw Error("`field` can not be the same as `afterField`.");
|
|
339
|
+
}
|
|
322
340
|
const allOrderInfos = this._propertiesOrder.get(getiModelInfo(iTwinId, imodelId));
|
|
323
341
|
const findFieldOrderInfoData = (f) => {
|
|
324
|
-
if (!visibleFields.includes(f))
|
|
342
|
+
if (!visibleFields.includes(f)) {
|
|
325
343
|
throw Error("Field is not contained in visible fields.");
|
|
344
|
+
}
|
|
326
345
|
const infos = getFieldOrderInfos(f, allOrderInfos);
|
|
327
|
-
if (infos.length === 0)
|
|
346
|
+
if (infos.length === 0) {
|
|
328
347
|
throw Error("Field has no property order information.");
|
|
348
|
+
}
|
|
329
349
|
const info = getMostRecentOrderInfo(infos);
|
|
330
350
|
const index = allOrderInfos.indexOf(info);
|
|
331
351
|
return { infos, mostRecent: { info, index } };
|
|
332
352
|
};
|
|
333
|
-
const { infos: movingOrderInfos, mostRecent: { index: orderInfoIndex } } = findFieldOrderInfoData(field);
|
|
353
|
+
const { infos: movingOrderInfos, mostRecent: { index: orderInfoIndex }, } = findFieldOrderInfoData(field);
|
|
334
354
|
let afterOrderInfo;
|
|
335
355
|
let afterOrderInfoIndex;
|
|
336
356
|
if (afterField === undefined) {
|
|
@@ -338,7 +358,9 @@ class FavoritePropertiesManager {
|
|
|
338
358
|
afterOrderInfoIndex = -1;
|
|
339
359
|
}
|
|
340
360
|
else {
|
|
341
|
-
({
|
|
361
|
+
({
|
|
362
|
+
mostRecent: { info: afterOrderInfo, index: afterOrderInfoIndex },
|
|
363
|
+
} = findFieldOrderInfoData(afterField));
|
|
342
364
|
}
|
|
343
365
|
let direction; // where to go from `afterOrderInfo` to `orderInfo`
|
|
344
366
|
let startIndex;
|
|
@@ -351,8 +373,9 @@ class FavoritePropertiesManager {
|
|
|
351
373
|
startIndex = afterOrderInfoIndex + 1;
|
|
352
374
|
}
|
|
353
375
|
const neededClassNames = allOrderInfos.reduce((classNames, oi) => {
|
|
354
|
-
if (oi.parentClassName)
|
|
376
|
+
if (oi.parentClassName) {
|
|
355
377
|
classNames.add(oi.parentClassName);
|
|
378
|
+
}
|
|
356
379
|
return classNames;
|
|
357
380
|
}, new Set());
|
|
358
381
|
const baseClassesByClass = await this._getBaseClassesByClass(imodel, neededClassNames);
|
|
@@ -362,20 +385,24 @@ class FavoritePropertiesManager {
|
|
|
362
385
|
for (let i = startIndex; i !== orderInfoIndex; i += direction) {
|
|
363
386
|
const currOrderInfo = allOrderInfos[i];
|
|
364
387
|
// primitive properties are always relevant, because we can't determine their relevance based on the class hierarchy
|
|
365
|
-
if (currOrderInfo.parentClassName === undefined)
|
|
388
|
+
if (currOrderInfo.parentClassName === undefined) {
|
|
366
389
|
continue;
|
|
390
|
+
}
|
|
367
391
|
const visible = visibleOrderInfos.includes(currOrderInfo);
|
|
368
392
|
if (visible) {
|
|
369
393
|
relevantClasses.add(currOrderInfo.parentClassName);
|
|
370
394
|
continue;
|
|
371
395
|
}
|
|
372
396
|
const hasBaseClasses = baseClassesByClass[currOrderInfo.parentClassName].some((classId) => relevantClasses.has(classId));
|
|
373
|
-
if (hasBaseClasses)
|
|
397
|
+
if (hasBaseClasses) {
|
|
374
398
|
continue;
|
|
375
|
-
|
|
399
|
+
}
|
|
400
|
+
if (direction === Direction.Down) {
|
|
376
401
|
irrelevantOrderInfos.push(currOrderInfo);
|
|
377
|
-
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
378
404
|
irrelevantOrderInfos.unshift(currOrderInfo);
|
|
405
|
+
}
|
|
379
406
|
}
|
|
380
407
|
// remove irrelevantOrderInfo's to add them after the `orderInfo`
|
|
381
408
|
irrelevantOrderInfos.forEach((foi) => {
|
|
@@ -387,13 +414,13 @@ class FavoritePropertiesManager {
|
|
|
387
414
|
const index = allOrderInfos.findIndex((oi) => oi.parentClassName === foi.parentClassName && oi.name === foi.name);
|
|
388
415
|
allOrderInfos.splice(index, 1);
|
|
389
416
|
});
|
|
390
|
-
movingOrderInfos.forEach((oi) => oi.orderedTimestamp = new Date());
|
|
417
|
+
movingOrderInfos.forEach((oi) => (oi.orderedTimestamp = new Date()));
|
|
391
418
|
afterOrderInfoIndex = afterOrderInfo === undefined ? -1 : allOrderInfos.indexOf(afterOrderInfo);
|
|
392
419
|
allOrderInfos.splice(afterOrderInfoIndex + 1, 0, ...movingOrderInfos);
|
|
393
420
|
allOrderInfos.splice(afterOrderInfoIndex + 1 + (direction === Direction.Up ? movingOrderInfos.length : 0), 0, ...irrelevantOrderInfos);
|
|
394
421
|
// reassign priority numbers
|
|
395
422
|
let priority = allOrderInfos.length;
|
|
396
|
-
allOrderInfos.forEach((oi) => oi.priority = priority--);
|
|
423
|
+
allOrderInfos.forEach((oi) => (oi.priority = priority--));
|
|
397
424
|
await this._storage.savePropertiesOrder(allOrderInfos, iTwinId, imodelId);
|
|
398
425
|
this.onFavoritesChanged.raiseEvent();
|
|
399
426
|
}
|
|
@@ -429,37 +456,46 @@ const getNestingPrefix = (field) => {
|
|
|
429
456
|
});
|
|
430
457
|
curr = curr.parent;
|
|
431
458
|
}
|
|
432
|
-
if (path.length === 0)
|
|
459
|
+
if (path.length === 0) {
|
|
433
460
|
return "";
|
|
461
|
+
}
|
|
434
462
|
path.reverse();
|
|
435
463
|
return `${path.join("-")}-`;
|
|
436
464
|
};
|
|
437
465
|
const getPropertyClassName = (propertyName) => {
|
|
438
466
|
const propertyNameStart = propertyName.split("-")[0];
|
|
439
467
|
const parts = propertyNameStart.split(":").length;
|
|
440
|
-
if (parts === 1)
|
|
468
|
+
if (parts === 1) {
|
|
469
|
+
// primitive
|
|
441
470
|
return undefined;
|
|
442
|
-
|
|
471
|
+
}
|
|
472
|
+
if (parts === 2) {
|
|
473
|
+
// nested property OR nested property parent class OR regular property parent class
|
|
443
474
|
return propertyNameStart;
|
|
475
|
+
}
|
|
444
476
|
// regular property without parent class
|
|
445
477
|
return propertyNameStart.substring(0, propertyName.lastIndexOf(":"));
|
|
446
478
|
};
|
|
447
479
|
/** @internal */
|
|
448
480
|
const getFieldInfos = (field) => {
|
|
449
481
|
const fieldInfos = new Set();
|
|
450
|
-
if (field.isPropertiesField())
|
|
482
|
+
if (field.isPropertiesField()) {
|
|
451
483
|
getPropertiesFieldPropertyNames(field).forEach((info) => fieldInfos.add(info));
|
|
452
|
-
|
|
484
|
+
}
|
|
485
|
+
else if (field.isNestedContentField()) {
|
|
453
486
|
fieldInfos.add(getNestedContentFieldPropertyName(field));
|
|
454
|
-
|
|
487
|
+
}
|
|
488
|
+
else {
|
|
455
489
|
fieldInfos.add(`${FavoritePropertiesManager.FAVORITES_IDENTIFIER_PREFIX}${field.name}`);
|
|
490
|
+
}
|
|
456
491
|
return fieldInfos;
|
|
457
492
|
};
|
|
458
493
|
exports.getFieldInfos = getFieldInfos;
|
|
459
494
|
const setHasAny = (set, lookup) => {
|
|
460
495
|
for (const key of lookup) {
|
|
461
|
-
if (set.has(key))
|
|
496
|
+
if (set.has(key)) {
|
|
462
497
|
return true;
|
|
498
|
+
}
|
|
463
499
|
}
|
|
464
500
|
return false;
|
|
465
501
|
};
|
|
@@ -472,26 +508,29 @@ const addOrderInfos = (dest, source) => {
|
|
|
472
508
|
}
|
|
473
509
|
});
|
|
474
510
|
let priority = dest.length;
|
|
475
|
-
dest.forEach((info) => info.priority = priority--);
|
|
511
|
+
dest.forEach((info) => (info.priority = priority--));
|
|
476
512
|
};
|
|
477
513
|
const removeOrderInfos = (container, toRemove) => {
|
|
478
514
|
toRemove.forEach((roi) => {
|
|
479
515
|
const index = container.findIndex((oi) => oi.name === roi.name);
|
|
480
516
|
/* istanbul ignore else */
|
|
481
|
-
if (index >= 0)
|
|
517
|
+
if (index >= 0) {
|
|
482
518
|
container.splice(index, 1);
|
|
519
|
+
}
|
|
483
520
|
});
|
|
484
521
|
};
|
|
485
522
|
/** @internal */
|
|
486
523
|
const createFieldOrderInfos = (field) => {
|
|
487
524
|
if (field.isNestedContentField()) {
|
|
488
525
|
const propertyName = getNestedContentFieldPropertyName(field);
|
|
489
|
-
return [
|
|
526
|
+
return [
|
|
527
|
+
{
|
|
490
528
|
parentClassName: getPropertyClassName(propertyName),
|
|
491
529
|
name: propertyName,
|
|
492
530
|
priority: 0,
|
|
493
531
|
orderedTimestamp: new Date(),
|
|
494
|
-
}
|
|
532
|
+
},
|
|
533
|
+
];
|
|
495
534
|
}
|
|
496
535
|
if (field.isPropertiesField()) {
|
|
497
536
|
return getPropertiesFieldPropertyNames(field).map((propertyName) => ({
|
|
@@ -501,28 +540,34 @@ const createFieldOrderInfos = (field) => {
|
|
|
501
540
|
orderedTimestamp: new Date(),
|
|
502
541
|
}));
|
|
503
542
|
}
|
|
504
|
-
return [
|
|
543
|
+
return [
|
|
544
|
+
{
|
|
505
545
|
parentClassName: undefined,
|
|
506
546
|
name: field.name,
|
|
507
547
|
priority: 0,
|
|
508
548
|
orderedTimestamp: new Date(),
|
|
509
|
-
}
|
|
549
|
+
},
|
|
550
|
+
];
|
|
510
551
|
};
|
|
511
552
|
exports.createFieldOrderInfos = createFieldOrderInfos;
|
|
512
553
|
const getFieldOrderInfos = (field, orderInfos) => {
|
|
513
554
|
const fieldOrderInfos = [];
|
|
514
555
|
const tryAddOrderInfo = (name) => {
|
|
515
556
|
const fieldOrderInfo = orderInfos.find((oi) => oi.name === name);
|
|
516
|
-
if (fieldOrderInfo !== undefined)
|
|
557
|
+
if (fieldOrderInfo !== undefined) {
|
|
517
558
|
fieldOrderInfos.push(fieldOrderInfo);
|
|
559
|
+
}
|
|
518
560
|
};
|
|
519
|
-
if (field.isPropertiesField())
|
|
561
|
+
if (field.isPropertiesField()) {
|
|
520
562
|
getPropertiesFieldPropertyNames(field).forEach(tryAddOrderInfo);
|
|
521
|
-
|
|
563
|
+
}
|
|
564
|
+
else if (field.isNestedContentField()) {
|
|
522
565
|
tryAddOrderInfo(getNestedContentFieldPropertyName(field));
|
|
523
|
-
|
|
566
|
+
}
|
|
567
|
+
else {
|
|
524
568
|
tryAddOrderInfo(field.name);
|
|
569
|
+
}
|
|
525
570
|
return fieldOrderInfos;
|
|
526
571
|
};
|
|
527
|
-
const getMostRecentOrderInfo = (orderInfos) => orderInfos.reduce((recent, curr) => (recent && recent.orderedTimestamp >= curr.orderedTimestamp
|
|
572
|
+
const getMostRecentOrderInfo = (orderInfos) => orderInfos.reduce((recent, curr) => (recent && recent.orderedTimestamp >= curr.orderedTimestamp ? recent : curr));
|
|
528
573
|
//# sourceMappingURL=FavoritePropertiesManager.js.map
|