@itwin/tree-widget-react 3.0.2 → 3.1.0
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 +25 -2
- package/lib/cjs/components/tree-header/TreeHeader.js +1 -1
- package/lib/cjs/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.js +3 -3
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesVisibilityHandler.js +2 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesVisibilityHandler.js.map +1 -1
- package/lib/cjs/components/trees/{models-tree/internal → common}/Tooltip.d.ts +7 -3
- package/lib/cjs/components/trees/{models-tree/internal → common}/Tooltip.js +5 -5
- package/lib/cjs/components/trees/common/Tooltip.js.map +1 -0
- package/lib/cjs/components/trees/common/UseActiveViewport.js.map +1 -1
- package/lib/cjs/components/trees/common/UseHierarchyVisibility.js +6 -3
- package/lib/cjs/components/trees/common/UseHierarchyVisibility.js.map +1 -1
- package/lib/cjs/components/trees/common/Utils.js +1 -1
- package/lib/cjs/components/trees/common/Utils.js.map +1 -1
- package/lib/cjs/components/trees/common/components/TreeNodeCheckbox.js +5 -5
- package/lib/cjs/components/trees/common/components/TreeNodeCheckbox.js.map +1 -1
- package/lib/cjs/components/trees/common/components/TreeRenderer.d.ts +1 -1
- package/lib/cjs/components/trees/common/components/TreeRenderer.js +4 -3
- package/lib/cjs/components/trees/common/components/TreeRenderer.js.map +1 -1
- package/lib/cjs/components/trees/common/components/TreeRenderer.scss +0 -6
- package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.js +13 -13
- package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.js +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/UseModelsTree.d.ts +1 -1
- package/lib/cjs/components/trees/models-tree/UseModelsTree.js +23 -12
- package/lib/cjs/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.d.ts +5 -0
- package/lib/cjs/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js +28 -7
- package/lib/cjs/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/internal/FilteredTree.d.ts +25 -0
- package/lib/cjs/components/trees/models-tree/internal/FilteredTree.js +178 -0
- package/lib/cjs/components/trees/models-tree/internal/FilteredTree.js.map +1 -0
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +2 -1
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeIdsCache.js +55 -23
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeNode.js +1 -1
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeNode.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +8 -8
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +162 -207
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/internal/VisibilityChangeEventListener.d.ts +2 -0
- package/lib/cjs/components/trees/models-tree/internal/VisibilityChangeEventListener.js +11 -1
- package/lib/cjs/components/trees/models-tree/internal/VisibilityChangeEventListener.js.map +1 -1
- package/lib/esm/components/tree-header/TreeHeader.js +1 -1
- package/lib/esm/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.js +3 -3
- package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/CategoriesVisibilityHandler.js +2 -1
- package/lib/esm/components/trees/categories-tree/CategoriesVisibilityHandler.js.map +1 -1
- package/lib/esm/components/trees/{models-tree/internal → common}/Tooltip.d.ts +7 -3
- package/lib/esm/components/trees/{models-tree/internal → common}/Tooltip.js +5 -5
- package/lib/esm/components/trees/common/Tooltip.js.map +1 -0
- package/lib/esm/components/trees/common/UseActiveViewport.js.map +1 -1
- package/lib/esm/components/trees/common/UseHierarchyVisibility.js +7 -4
- package/lib/esm/components/trees/common/UseHierarchyVisibility.js.map +1 -1
- package/lib/esm/components/trees/common/Utils.js +1 -1
- package/lib/esm/components/trees/common/Utils.js.map +1 -1
- package/lib/esm/components/trees/common/components/TreeNodeCheckbox.js +6 -6
- package/lib/esm/components/trees/common/components/TreeNodeCheckbox.js.map +1 -1
- package/lib/esm/components/trees/common/components/TreeRenderer.d.ts +1 -1
- package/lib/esm/components/trees/common/components/TreeRenderer.js +4 -3
- package/lib/esm/components/trees/common/components/TreeRenderer.js.map +1 -1
- package/lib/esm/components/trees/common/components/TreeRenderer.scss +0 -6
- package/lib/esm/components/trees/models-tree/ModelsTreeButtons.js +14 -14
- package/lib/esm/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/esm/components/trees/models-tree/UseModelsTree.d.ts +1 -1
- package/lib/esm/components/trees/models-tree/UseModelsTree.js +24 -13
- package/lib/esm/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/esm/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.d.ts +5 -0
- package/lib/esm/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js +29 -8
- package/lib/esm/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -1
- package/lib/esm/components/trees/models-tree/internal/FilteredTree.d.ts +25 -0
- package/lib/esm/components/trees/models-tree/internal/FilteredTree.js +173 -0
- package/lib/esm/components/trees/models-tree/internal/FilteredTree.js.map +1 -0
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +2 -1
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeIdsCache.js +55 -23
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +8 -8
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +161 -206
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/components/trees/models-tree/internal/VisibilityChangeEventListener.d.ts +2 -0
- package/lib/esm/components/trees/models-tree/internal/VisibilityChangeEventListener.js +11 -1
- package/lib/esm/components/trees/models-tree/internal/VisibilityChangeEventListener.js.map +1 -1
- package/lib/public/locales/en/TreeWidget.json +47 -43
- package/package.json +11 -11
- package/lib/cjs/components/trees/models-tree/internal/Tooltip.js.map +0 -1
- package/lib/esm/components/trees/models-tree/internal/Tooltip.js.map +0 -1
|
@@ -4,36 +4,19 @@
|
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.areAllModelsVisible = exports.toggleModels = exports.invertAllModels = exports.hideAllModels = exports.showAllModels = exports.createModelsTreeVisibilityHandler =
|
|
7
|
+
exports.areAllModelsVisible = exports.toggleModels = exports.invertAllModels = exports.hideAllModels = exports.showAllModels = exports.createModelsTreeVisibilityHandler = void 0;
|
|
8
8
|
const rxjs_1 = require("rxjs");
|
|
9
9
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
10
10
|
const core_frontend_1 = require("@itwin/core-frontend");
|
|
11
11
|
const presentation_hierarchies_1 = require("@itwin/presentation-hierarchies");
|
|
12
12
|
const CategoriesVisibilityUtils_1 = require("../../common/CategoriesVisibilityUtils");
|
|
13
13
|
const Rxjs_1 = require("../../common/Rxjs");
|
|
14
|
+
const Tooltip_1 = require("../../common/Tooltip");
|
|
14
15
|
const UseHierarchyVisibility_1 = require("../../common/UseHierarchyVisibility");
|
|
15
16
|
const AlwaysAndNeverDrawnElementInfo_1 = require("./AlwaysAndNeverDrawnElementInfo");
|
|
17
|
+
const FilteredTree_1 = require("./FilteredTree");
|
|
16
18
|
const ModelsTreeNode_1 = require("./ModelsTreeNode");
|
|
17
|
-
const Tooltip_1 = require("./Tooltip");
|
|
18
19
|
const VisibilityChangeEventListener_1 = require("./VisibilityChangeEventListener");
|
|
19
|
-
exports.SUBJECT_CLASS_NAME = "BisCore.Subject";
|
|
20
|
-
exports.MODEL_CLASS_NAME = "BisCore.GeometricModel3d";
|
|
21
|
-
exports.CATEGORY_CLASS_NAME = "BisCore.SpatialCategory";
|
|
22
|
-
exports.ELEMENT_CLASS_NAME = "BisCore.GeometricElement3d";
|
|
23
|
-
function createCategoryKey(modelId, categoryId) {
|
|
24
|
-
return `${modelId}-${categoryId}`;
|
|
25
|
-
}
|
|
26
|
-
function parseCategoryKey(key) {
|
|
27
|
-
const [modelId, categoryId] = key.split("-");
|
|
28
|
-
return { modelId, categoryId };
|
|
29
|
-
}
|
|
30
|
-
function createElementKey(modelId, categoryId, elementId) {
|
|
31
|
-
return `${modelId}-${categoryId}-${elementId}`;
|
|
32
|
-
}
|
|
33
|
-
function parseElementKey(key) {
|
|
34
|
-
const [modelId, categoryId, elementId] = key.split("-");
|
|
35
|
-
return { modelId, categoryId, elementId };
|
|
36
|
-
}
|
|
37
20
|
/**
|
|
38
21
|
* Creates an instance if `ModelsTreeVisibilityHandler`.
|
|
39
22
|
* @internal
|
|
@@ -45,30 +28,55 @@ exports.createModelsTreeVisibilityHandler = createModelsTreeVisibilityHandler;
|
|
|
45
28
|
class ModelsTreeVisibilityHandlerImpl {
|
|
46
29
|
constructor(_props) {
|
|
47
30
|
this._props = _props;
|
|
31
|
+
this._elementChangeQueue = new rxjs_1.Subject();
|
|
32
|
+
this._subscriptions = [];
|
|
33
|
+
this._changeRequest = new rxjs_1.Subject();
|
|
48
34
|
this._eventListener = (0, VisibilityChangeEventListener_1.createVisibilityChangeEventListener)(_props.viewport);
|
|
49
35
|
this._alwaysAndNeverDrawnElements = new AlwaysAndNeverDrawnElementInfo_1.AlwaysAndNeverDrawnElementInfo(_props.viewport);
|
|
50
36
|
this._idsCache = this._props.idsCache;
|
|
37
|
+
this._filteredTree = _props.filteredPaths ? (0, FilteredTree_1.createFilteredTree)(this._props.imodelAccess, _props.filteredPaths) : undefined;
|
|
38
|
+
this._subscriptions.push(this._elementChangeQueue.pipe((0, rxjs_1.concatAll)()).subscribe());
|
|
51
39
|
}
|
|
52
40
|
// istanbul ignore next
|
|
53
41
|
get onVisibilityChange() {
|
|
54
42
|
return this._eventListener.onVisibilityChange;
|
|
55
43
|
}
|
|
56
44
|
async getVisibilityStatus(node) {
|
|
57
|
-
return (0, rxjs_1.firstValueFrom)(this.getVisibilityStatusObs(node)
|
|
45
|
+
return (0, rxjs_1.firstValueFrom)(this.getVisibilityStatusObs(node).pipe(
|
|
46
|
+
// unsubscribe from the observable if the change request for this node is received
|
|
47
|
+
(0, rxjs_1.takeUntil)(this._changeRequest.pipe((0, rxjs_1.filter)(({ key, depth }) => depth === node.parentKeys.length && presentation_hierarchies_1.HierarchyNodeKey.equals(node.key, key)))),
|
|
48
|
+
// unsubscribe if visibility changes
|
|
49
|
+
(0, rxjs_1.takeUntil)((0, rxjs_1.fromEventPattern)((handler) => {
|
|
50
|
+
this._eventListener.onVisibilityChange.addListener(handler);
|
|
51
|
+
}, (handler) => {
|
|
52
|
+
this._eventListener.onVisibilityChange.removeListener(handler);
|
|
53
|
+
}))));
|
|
58
54
|
}
|
|
59
55
|
async changeVisibility(node, shouldDisplay) {
|
|
60
|
-
|
|
56
|
+
// notify about new change request
|
|
57
|
+
this._changeRequest.next({ key: node.key, depth: node.parentKeys.length });
|
|
58
|
+
const changeObservable = this.changeVisibilityObs(node, shouldDisplay).pipe(
|
|
59
|
+
// unsubscribe from the observable if the change request for this node is received
|
|
60
|
+
(0, rxjs_1.takeUntil)(this._changeRequest.pipe((0, rxjs_1.filter)(({ key, depth }) => depth === node.parentKeys.length && presentation_hierarchies_1.HierarchyNodeKey.equals(node.key, key)))), (0, rxjs_1.tap)({
|
|
61
|
+
subscribe: () => {
|
|
62
|
+
this._eventListener.suppressChangeEvents();
|
|
63
|
+
this._alwaysAndNeverDrawnElements.suppressChangeEvents();
|
|
64
|
+
},
|
|
65
|
+
finalize: () => {
|
|
66
|
+
this._eventListener.resumeChangeEvents();
|
|
67
|
+
this._alwaysAndNeverDrawnElements.resumeChangeEvents();
|
|
68
|
+
},
|
|
69
|
+
}));
|
|
70
|
+
return (0, Rxjs_1.toVoidPromise)(changeObservable);
|
|
61
71
|
}
|
|
62
72
|
dispose() {
|
|
63
73
|
this._eventListener.dispose();
|
|
64
74
|
this._alwaysAndNeverDrawnElements.dispose();
|
|
75
|
+
this._subscriptions.forEach((x) => x.unsubscribe());
|
|
65
76
|
}
|
|
66
77
|
getVisibilityStatusObs(node) {
|
|
67
78
|
if (node.filtering?.filteredChildrenIdentifierPaths?.length && !node.filtering.isFilterTarget) {
|
|
68
|
-
return this.getFilteredNodeVisibility({
|
|
69
|
-
parentKeys: [...node.parentKeys, node.key],
|
|
70
|
-
filterPaths: node.filtering.filteredChildrenIdentifierPaths,
|
|
71
|
-
});
|
|
79
|
+
return this.getFilteredNodeVisibility({ node });
|
|
72
80
|
}
|
|
73
81
|
if (presentation_hierarchies_1.HierarchyNode.isClassGroupingNode(node)) {
|
|
74
82
|
return this.getClassGroupingNodeDisplayStatus(node);
|
|
@@ -78,10 +86,10 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
78
86
|
}
|
|
79
87
|
if (ModelsTreeNode_1.ModelsTreeNode.isSubjectNode(node)) {
|
|
80
88
|
// note: subject nodes may be merged to represent multiple subject instances
|
|
81
|
-
return this.getSubjectNodeVisibilityStatus(node.key.instanceKeys.map((key) => key.id));
|
|
89
|
+
return this.getSubjectNodeVisibilityStatus({ subjectIds: node.key.instanceKeys.map((key) => key.id) });
|
|
82
90
|
}
|
|
83
91
|
if (ModelsTreeNode_1.ModelsTreeNode.isModelNode(node)) {
|
|
84
|
-
return this.getModelVisibilityStatus(node.key.instanceKeys[0].id);
|
|
92
|
+
return this.getModelVisibilityStatus({ modelId: node.key.instanceKeys[0].id });
|
|
85
93
|
}
|
|
86
94
|
const modelId = ModelsTreeNode_1.ModelsTreeNode.getModelId(node);
|
|
87
95
|
if (!modelId) {
|
|
@@ -103,25 +111,25 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
103
111
|
categoryId,
|
|
104
112
|
});
|
|
105
113
|
}
|
|
106
|
-
getFilteredNodeVisibility(
|
|
107
|
-
return (0, rxjs_1.from)(this.
|
|
114
|
+
getFilteredNodeVisibility(props) {
|
|
115
|
+
return (0, rxjs_1.from)(this.getVisibilityChangeTargets(props)).pipe((0, rxjs_1.mergeMap)(({ subjects, models, categories, elements }) => {
|
|
108
116
|
const observables = new Array();
|
|
109
117
|
if (subjects?.size) {
|
|
110
|
-
observables.push(this.getSubjectNodeVisibilityStatus([...subjects]));
|
|
118
|
+
observables.push(this.getSubjectNodeVisibilityStatus({ subjectIds: [...subjects], ignoreTooltip: true }));
|
|
111
119
|
}
|
|
112
120
|
if (models?.size) {
|
|
113
|
-
observables.push((0, rxjs_1.from)(models).pipe((0, rxjs_1.mergeMap)((modelId) => this.getModelVisibilityStatus(modelId))));
|
|
121
|
+
observables.push((0, rxjs_1.from)(models).pipe((0, rxjs_1.mergeMap)((modelId) => this.getModelVisibilityStatus({ modelId, ignoreTooltip: true }))));
|
|
114
122
|
}
|
|
115
123
|
if (categories?.size) {
|
|
116
124
|
observables.push((0, rxjs_1.from)(categories).pipe((0, rxjs_1.mergeMap)((key) => {
|
|
117
|
-
const { modelId, categoryId } = parseCategoryKey(key);
|
|
118
|
-
return this.getCategoryDisplayStatus({ modelId, categoryId });
|
|
125
|
+
const { modelId, categoryId } = (0, FilteredTree_1.parseCategoryKey)(key);
|
|
126
|
+
return this.getCategoryDisplayStatus({ modelId, categoryId, ignoreTooltip: true });
|
|
119
127
|
})));
|
|
120
128
|
}
|
|
121
129
|
if (elements?.size) {
|
|
122
|
-
observables.push((0, rxjs_1.from)(elements).pipe((0, rxjs_1.mergeMap)((
|
|
123
|
-
const { modelId, categoryId
|
|
124
|
-
return this.getElementDisplayStatus({ modelId, categoryId, elementId });
|
|
130
|
+
observables.push((0, rxjs_1.from)(elements).pipe(releaseMainThreadOnItemsCount(50), (0, rxjs_1.mergeMap)(([categoryKey, elementIds]) => {
|
|
131
|
+
const { modelId, categoryId } = (0, FilteredTree_1.parseCategoryKey)(categoryKey);
|
|
132
|
+
return (0, rxjs_1.from)(elementIds).pipe(releaseMainThreadOnItemsCount(1000), (0, rxjs_1.mergeMap)((elementId) => this.getElementDisplayStatus({ modelId, categoryId, elementId, ignoreTooltip: true })));
|
|
125
133
|
})));
|
|
126
134
|
}
|
|
127
135
|
return (0, rxjs_1.merge)(...observables);
|
|
@@ -130,65 +138,66 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
130
138
|
return (0, Tooltip_1.createVisibilityStatus)(x);
|
|
131
139
|
}));
|
|
132
140
|
}
|
|
133
|
-
getSubjectNodeVisibilityStatus(subjectIds) {
|
|
141
|
+
getSubjectNodeVisibilityStatus({ subjectIds, ignoreTooltip }) {
|
|
134
142
|
const result = (0, rxjs_1.defer)(() => {
|
|
135
143
|
if (!this._props.viewport.view.isSpatialView()) {
|
|
136
|
-
return (0, rxjs_1.of)((0, Tooltip_1.createVisibilityStatus)("disabled", "subject.nonSpatialView"));
|
|
144
|
+
return (0, rxjs_1.of)((0, Tooltip_1.createVisibilityStatus)("disabled", getTooltipOptions("modelsTree.subject.nonSpatialView", ignoreTooltip)));
|
|
137
145
|
}
|
|
138
|
-
return (0, rxjs_1.from)(this._idsCache.getSubjectModelIds(subjectIds)).pipe((0, rxjs_1.concatAll)(), (0, rxjs_1.distinct)(), (0, rxjs_1.mergeMap)((modelId) => this.getModelVisibilityStatus(modelId)), (0, rxjs_1.map)((x) => x.state), getVisibilityStatusFromTreeNodeChildren({
|
|
139
|
-
visible: "subject.allModelsVisible",
|
|
140
|
-
hidden: "subject.allModelsHidden",
|
|
141
|
-
partial: "subject.someModelsHidden",
|
|
142
|
-
}));
|
|
146
|
+
return (0, rxjs_1.from)(this._idsCache.getSubjectModelIds(subjectIds)).pipe((0, rxjs_1.concatAll)(), (0, rxjs_1.distinct)(), (0, rxjs_1.mergeMap)((modelId) => this.getModelVisibilityStatus({ modelId, ignoreTooltip: true })), (0, rxjs_1.map)((x) => x.state), getVisibilityStatusFromTreeNodeChildren({
|
|
147
|
+
visible: "modelsTree.subject.allModelsVisible",
|
|
148
|
+
hidden: "modelsTree.subject.allModelsHidden",
|
|
149
|
+
partial: "modelsTree.subject.someModelsHidden",
|
|
150
|
+
}, ignoreTooltip));
|
|
143
151
|
});
|
|
144
152
|
return (0, UseHierarchyVisibility_1.createVisibilityHandlerResult)(this, { ids: subjectIds }, result, this._props.overrides?.getSubjectNodeVisibility);
|
|
145
153
|
}
|
|
146
|
-
getModelVisibilityStatus(modelId) {
|
|
154
|
+
getModelVisibilityStatus({ modelId, ignoreTooltip }) {
|
|
147
155
|
const result = (0, rxjs_1.defer)(() => {
|
|
148
156
|
const viewport = this._props.viewport;
|
|
149
157
|
if (!viewport.view.isSpatialView()) {
|
|
150
|
-
return (0, rxjs_1.of)((0, Tooltip_1.createVisibilityStatus)("disabled", "model.nonSpatialView"));
|
|
158
|
+
return (0, rxjs_1.of)((0, Tooltip_1.createVisibilityStatus)("disabled", getTooltipOptions("modelsTree.model.nonSpatialView", ignoreTooltip)));
|
|
151
159
|
}
|
|
152
160
|
if (!viewport.view.viewsModel(modelId)) {
|
|
153
|
-
return (0, rxjs_1.of)((0, Tooltip_1.createVisibilityStatus)("hidden", "model.hiddenThroughModelSelector"));
|
|
161
|
+
return (0, rxjs_1.of)((0, Tooltip_1.createVisibilityStatus)("hidden", getTooltipOptions("modelsTree.model.hiddenThroughModelSelector", ignoreTooltip)));
|
|
154
162
|
}
|
|
155
|
-
return (0, rxjs_1.from)(this._idsCache.getModelCategories(modelId)).pipe((0, rxjs_1.concatAll)(), (0, rxjs_1.mergeMap)((categoryId) => this.getCategoryDisplayStatus({ modelId, categoryId })), (0, rxjs_1.map)((x) => x.state), getVisibilityFromTreeNodeChildren, (0, rxjs_1.map)((visibilityByCategories) => {
|
|
163
|
+
return (0, rxjs_1.from)(this._idsCache.getModelCategories(modelId)).pipe((0, rxjs_1.concatAll)(), (0, rxjs_1.mergeMap)((categoryId) => this.getCategoryDisplayStatus({ modelId, categoryId, ignoreTooltip: true })), (0, rxjs_1.map)((x) => x.state), getVisibilityFromTreeNodeChildren, (0, rxjs_1.map)((visibilityByCategories) => {
|
|
156
164
|
const state = visibilityByCategories === "empty" ? "visible" : visibilityByCategories;
|
|
157
|
-
return (0, Tooltip_1.createVisibilityStatus)(state, state === "partial" ? "model.someCategoriesHidden" : `model.allCategories${state ? "Visible" : "Hidden"}
|
|
165
|
+
return (0, Tooltip_1.createVisibilityStatus)(state, getTooltipOptions(state === "partial" ? "modelsTree.model.someCategoriesHidden" : `modelsTree.model.allCategories${state ? "Visible" : "Hidden"}`, ignoreTooltip));
|
|
158
166
|
}));
|
|
159
167
|
});
|
|
160
168
|
return (0, UseHierarchyVisibility_1.createVisibilityHandlerResult)(this, { id: modelId }, result, this._props.overrides?.getModelDisplayStatus);
|
|
161
169
|
}
|
|
162
|
-
getDefaultCategoryVisibilityStatus({ modelId, categoryId }) {
|
|
170
|
+
getDefaultCategoryVisibilityStatus({ modelId, categoryId, ignoreTooltip, }) {
|
|
163
171
|
const viewport = this._props.viewport;
|
|
164
172
|
if (!viewport.view.viewsModel(modelId)) {
|
|
165
|
-
return (0, Tooltip_1.createVisibilityStatus)("hidden", "category.hiddenThroughModel");
|
|
173
|
+
return (0, Tooltip_1.createVisibilityStatus)("hidden", getTooltipOptions("modelsTree.category.hiddenThroughModel", ignoreTooltip));
|
|
166
174
|
}
|
|
167
175
|
switch (this._props.viewport.perModelCategoryVisibility.getOverride(modelId, categoryId)) {
|
|
168
176
|
case core_frontend_1.PerModelCategoryVisibility.Override.Show:
|
|
169
|
-
return (0, Tooltip_1.createVisibilityStatus)("visible", "category.displayedThroughPerModelOverride");
|
|
177
|
+
return (0, Tooltip_1.createVisibilityStatus)("visible", getTooltipOptions("modelsTree.category.displayedThroughPerModelOverride", ignoreTooltip));
|
|
170
178
|
case core_frontend_1.PerModelCategoryVisibility.Override.Hide:
|
|
171
|
-
return (0, Tooltip_1.createVisibilityStatus)("hidden", "category.hiddenThroughPerModelOverride");
|
|
179
|
+
return (0, Tooltip_1.createVisibilityStatus)("hidden", getTooltipOptions("modelsTree.category.hiddenThroughPerModelOverride", ignoreTooltip));
|
|
172
180
|
}
|
|
173
181
|
const isVisible = viewport.view.viewsCategory(categoryId);
|
|
174
182
|
return isVisible
|
|
175
|
-
? (0, Tooltip_1.createVisibilityStatus)("visible", "category.displayedThroughCategorySelector")
|
|
176
|
-
: (0, Tooltip_1.createVisibilityStatus)("hidden", "category.hiddenThroughCategorySelector");
|
|
183
|
+
? (0, Tooltip_1.createVisibilityStatus)("visible", getTooltipOptions("modelsTree.category.displayedThroughCategorySelector", ignoreTooltip))
|
|
184
|
+
: (0, Tooltip_1.createVisibilityStatus)("hidden", getTooltipOptions("modelsTree.category.hiddenThroughCategorySelector", ignoreTooltip));
|
|
177
185
|
}
|
|
178
|
-
getCategoryDisplayStatus(props) {
|
|
186
|
+
getCategoryDisplayStatus({ ignoreTooltip, ...props }) {
|
|
179
187
|
const result = (0, rxjs_1.defer)(() => {
|
|
180
188
|
if (!this._props.viewport.view.viewsModel(props.modelId)) {
|
|
181
|
-
return (0, rxjs_1.of)((0, Tooltip_1.createVisibilityStatus)("hidden", "category.hiddenThroughModel"));
|
|
189
|
+
return (0, rxjs_1.of)((0, Tooltip_1.createVisibilityStatus)("hidden", getTooltipOptions("modelsTree.category.hiddenThroughModel", ignoreTooltip)));
|
|
182
190
|
}
|
|
183
191
|
return this.getVisibilityFromAlwaysAndNeverDrawnElements({
|
|
184
192
|
queryProps: props,
|
|
185
193
|
tooltips: {
|
|
186
|
-
allElementsInAlwaysDrawnList: "category.allElementsVisible",
|
|
187
|
-
allElementsInNeverDrawnList: "category.allElementsHidden",
|
|
188
|
-
elementsInBothAlwaysAndNeverDrawn: "category.someElementsAreHidden",
|
|
189
|
-
noElementsInExclusiveAlwaysDrawnList: "category.allElementsHidden",
|
|
194
|
+
allElementsInAlwaysDrawnList: "modelsTree.category.allElementsVisible",
|
|
195
|
+
allElementsInNeverDrawnList: "modelsTree.category.allElementsHidden",
|
|
196
|
+
elementsInBothAlwaysAndNeverDrawn: "modelsTree.category.someElementsAreHidden",
|
|
197
|
+
noElementsInExclusiveAlwaysDrawnList: "modelsTree.category.allElementsHidden",
|
|
190
198
|
},
|
|
191
199
|
defaultStatus: () => this.getDefaultCategoryVisibilityStatus(props),
|
|
200
|
+
ignoreTooltip,
|
|
192
201
|
});
|
|
193
202
|
});
|
|
194
203
|
return (0, UseHierarchyVisibility_1.createVisibilityHandlerResult)(this, props, result, this._props.overrides?.getCategoryDisplayStatus);
|
|
@@ -203,58 +212,54 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
203
212
|
return this.getVisibilityFromAlwaysAndNeverDrawnElements({
|
|
204
213
|
elements: elementIds,
|
|
205
214
|
defaultStatus: () => {
|
|
206
|
-
const status = this.getDefaultCategoryVisibilityStatus({ categoryId, modelId });
|
|
207
|
-
return (0, Tooltip_1.createVisibilityStatus)(status.state, `groupingNode.${status.state}ThroughCategory`);
|
|
215
|
+
const status = this.getDefaultCategoryVisibilityStatus({ categoryId, modelId, ignoreTooltip: true });
|
|
216
|
+
return (0, Tooltip_1.createVisibilityStatus)(status.state, getTooltipOptions(`modelsTree.groupingNode.${status.state}ThroughCategory`));
|
|
208
217
|
},
|
|
209
218
|
tooltips: {
|
|
210
|
-
allElementsInAlwaysDrawnList: "groupingNode.allElementsVisible",
|
|
211
|
-
allElementsInNeverDrawnList: "groupingNode.allElementsHidden",
|
|
212
|
-
elementsInBothAlwaysAndNeverDrawn: "groupingNode.someElementsAreHidden",
|
|
213
|
-
noElementsInExclusiveAlwaysDrawnList: "groupingNode.allElementsHidden",
|
|
219
|
+
allElementsInAlwaysDrawnList: "modelsTree.groupingNode.allElementsVisible",
|
|
220
|
+
allElementsInNeverDrawnList: "modelsTree.groupingNode.allElementsHidden",
|
|
221
|
+
elementsInBothAlwaysAndNeverDrawn: "modelsTree.groupingNode.someElementsAreHidden",
|
|
222
|
+
noElementsInExclusiveAlwaysDrawnList: "modelsTree.groupingNode.allElementsHidden",
|
|
214
223
|
},
|
|
215
224
|
});
|
|
216
225
|
});
|
|
217
226
|
return (0, UseHierarchyVisibility_1.createVisibilityHandlerResult)(this, { node }, result, this._props.overrides?.getElementGroupingNodeDisplayStatus);
|
|
218
227
|
}
|
|
219
|
-
getElementOverriddenVisibility(elementId) {
|
|
228
|
+
getElementOverriddenVisibility(elementId, ignoreTooltip) {
|
|
220
229
|
const viewport = this._props.viewport;
|
|
221
230
|
if (viewport.neverDrawn?.has(elementId)) {
|
|
222
|
-
return (0, Tooltip_1.createVisibilityStatus)("hidden", "element.hiddenThroughNeverDrawnList");
|
|
231
|
+
return (0, Tooltip_1.createVisibilityStatus)("hidden", getTooltipOptions("modelsTree.element.hiddenThroughNeverDrawnList", ignoreTooltip));
|
|
223
232
|
}
|
|
224
233
|
if (viewport.alwaysDrawn?.size) {
|
|
225
234
|
if (viewport.alwaysDrawn.has(elementId)) {
|
|
226
|
-
return (0, Tooltip_1.createVisibilityStatus)("visible", "element.displayedThroughAlwaysDrawnList");
|
|
235
|
+
return (0, Tooltip_1.createVisibilityStatus)("visible", getTooltipOptions("modelsTree.element.displayedThroughAlwaysDrawnList", ignoreTooltip));
|
|
227
236
|
}
|
|
228
237
|
if (viewport.isAlwaysDrawnExclusive) {
|
|
229
|
-
return (0, Tooltip_1.createVisibilityStatus)("hidden", "element.hiddenDueToOtherElementsExclusivelyAlwaysDrawn");
|
|
238
|
+
return (0, Tooltip_1.createVisibilityStatus)("hidden", getTooltipOptions("modelsTree.element.hiddenDueToOtherElementsExclusivelyAlwaysDrawn", ignoreTooltip));
|
|
230
239
|
}
|
|
231
240
|
}
|
|
232
241
|
return undefined;
|
|
233
242
|
}
|
|
234
|
-
getElementDisplayStatus(props) {
|
|
243
|
+
getElementDisplayStatus({ ignoreTooltip, ...props }) {
|
|
235
244
|
const result = (0, rxjs_1.defer)(() => {
|
|
236
245
|
const viewport = this._props.viewport;
|
|
237
246
|
const { elementId, modelId, categoryId } = props;
|
|
238
247
|
if (!viewport.view.viewsModel(modelId)) {
|
|
239
|
-
return (0, rxjs_1.of)((0, Tooltip_1.createVisibilityStatus)("hidden", "element.hiddenThroughModel"));
|
|
248
|
+
return (0, rxjs_1.of)((0, Tooltip_1.createVisibilityStatus)("hidden", getTooltipOptions("modelsTree.element.hiddenThroughModel", ignoreTooltip)));
|
|
240
249
|
}
|
|
241
|
-
let status = this.getElementOverriddenVisibility(elementId);
|
|
250
|
+
let status = this.getElementOverriddenVisibility(elementId, ignoreTooltip);
|
|
242
251
|
if (status) {
|
|
243
252
|
return (0, rxjs_1.of)(status);
|
|
244
253
|
}
|
|
245
|
-
status = this.getDefaultCategoryVisibilityStatus({ categoryId, modelId });
|
|
246
|
-
return (0, rxjs_1.of)((0, Tooltip_1.createVisibilityStatus)(status.state, status.state === "visible" ? undefined : "element.hiddenThroughCategory"));
|
|
254
|
+
status = this.getDefaultCategoryVisibilityStatus({ categoryId, modelId, ignoreTooltip: true });
|
|
255
|
+
return (0, rxjs_1.of)((0, Tooltip_1.createVisibilityStatus)(status.state, getTooltipOptions(status.state === "visible" ? undefined : "modelsTree.element.hiddenThroughCategory", ignoreTooltip)));
|
|
247
256
|
});
|
|
248
257
|
return (0, UseHierarchyVisibility_1.createVisibilityHandlerResult)(this, props, result, this._props.overrides?.getElementDisplayStatus);
|
|
249
258
|
}
|
|
250
259
|
/** Changes visibility of the items represented by the tree node. */
|
|
251
260
|
changeVisibilityObs(node, on) {
|
|
252
261
|
if (node.filtering?.filteredChildrenIdentifierPaths?.length && !node.filtering.isFilterTarget) {
|
|
253
|
-
return this.changeFilteredNodeVisibility({
|
|
254
|
-
parentKeys: [...node.parentKeys, node.key],
|
|
255
|
-
filterPaths: node.filtering.filteredChildrenIdentifierPaths,
|
|
256
|
-
on,
|
|
257
|
-
});
|
|
262
|
+
return this.changeFilteredNodeVisibility({ node, on });
|
|
258
263
|
}
|
|
259
264
|
if (presentation_hierarchies_1.HierarchyNode.isClassGroupingNode(node)) {
|
|
260
265
|
return this.changeElementGroupingNodeState(node, on);
|
|
@@ -287,62 +292,19 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
287
292
|
// istanbul ignore next
|
|
288
293
|
return rxjs_1.EMPTY;
|
|
289
294
|
}
|
|
290
|
-
return this.
|
|
291
|
-
|
|
295
|
+
return this.changeElementsState({
|
|
296
|
+
elementIds: new Set([...node.key.instanceKeys.map(({ id }) => id)]),
|
|
292
297
|
modelId,
|
|
293
298
|
categoryId,
|
|
294
299
|
on,
|
|
295
300
|
});
|
|
296
301
|
}
|
|
297
|
-
async
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
(filterTargets[targetType] ??= new Set()).add(value);
|
|
301
|
-
}
|
|
302
|
-
const imodelAccess = this._props.imodelAccess;
|
|
303
|
-
// Remove all paths such that there are paths to any of the ancestors of the filter target.
|
|
304
|
-
const paths = reduceFilterPaths(filterPaths);
|
|
305
|
-
await Promise.all(paths.map(async (path) => {
|
|
306
|
-
const target = path[path.length - 1];
|
|
307
|
-
if (!presentation_hierarchies_1.HierarchyNodeIdentifier.isInstanceNodeIdentifier(target)) {
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
const previousPath = path.slice(0, path.length - 1);
|
|
311
|
-
if (await imodelAccess.classDerivesFrom(target.className, exports.SUBJECT_CLASS_NAME)) {
|
|
312
|
-
addFilterTarget("subjects", target.id);
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
if (await imodelAccess.classDerivesFrom(target.className, exports.MODEL_CLASS_NAME)) {
|
|
316
|
-
addFilterTarget("models", target.id);
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
if (await imodelAccess.classDerivesFrom(target.className, exports.CATEGORY_CLASS_NAME)) {
|
|
320
|
-
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
321
|
-
const modelId = await this.findClassIdInFilterPath(previousPath, parentKeys, exports.MODEL_CLASS_NAME);
|
|
322
|
-
addFilterTarget("categories", createCategoryKey(modelId, target.id));
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
const [modelId, categoryId] = await Promise.all([
|
|
326
|
-
this.findClassIdInFilterPath(previousPath, parentKeys, exports.MODEL_CLASS_NAME),
|
|
327
|
-
this.findClassIdInFilterPath(previousPath, parentKeys, exports.CATEGORY_CLASS_NAME),
|
|
328
|
-
]);
|
|
329
|
-
addFilterTarget("elements", createElementKey(modelId, categoryId, target.id));
|
|
330
|
-
// Add parent elements to the filter targets as well
|
|
331
|
-
for (let idx = path.length - 1; idx >= 0; --idx) {
|
|
332
|
-
const pathIdentifier = path[idx];
|
|
333
|
-
if (!presentation_hierarchies_1.HierarchyNodeIdentifier.isInstanceNodeIdentifier(pathIdentifier)) {
|
|
334
|
-
continue;
|
|
335
|
-
}
|
|
336
|
-
if (!(await imodelAccess.classDerivesFrom(pathIdentifier.className, exports.ELEMENT_CLASS_NAME))) {
|
|
337
|
-
break;
|
|
338
|
-
}
|
|
339
|
-
addFilterTarget("elements", createElementKey(modelId, categoryId, pathIdentifier.id));
|
|
340
|
-
}
|
|
341
|
-
}));
|
|
342
|
-
return filterTargets;
|
|
302
|
+
async getVisibilityChangeTargets({ node }) {
|
|
303
|
+
const filteredTree = await this._filteredTree;
|
|
304
|
+
return filteredTree ? filteredTree.getVisibilityChangeTargets(node) : {};
|
|
343
305
|
}
|
|
344
306
|
changeFilteredNodeVisibility({ on, ...props }) {
|
|
345
|
-
return (0, rxjs_1.from)(this.
|
|
307
|
+
return (0, rxjs_1.from)(this.getVisibilityChangeTargets(props)).pipe((0, rxjs_1.mergeMap)(({ subjects, models, categories, elements }) => {
|
|
346
308
|
const observables = new Array();
|
|
347
309
|
if (subjects?.size) {
|
|
348
310
|
observables.push(this.changeSubjectNodeState([...subjects], on));
|
|
@@ -352,14 +314,14 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
352
314
|
}
|
|
353
315
|
if (categories?.size) {
|
|
354
316
|
observables.push((0, rxjs_1.from)(categories).pipe((0, rxjs_1.mergeMap)((key) => {
|
|
355
|
-
const { modelId, categoryId } = parseCategoryKey(key);
|
|
317
|
+
const { modelId, categoryId } = (0, FilteredTree_1.parseCategoryKey)(key);
|
|
356
318
|
return this.changeCategoryState({ modelId, categoryId, on });
|
|
357
319
|
})));
|
|
358
320
|
}
|
|
359
321
|
if (elements?.size) {
|
|
360
|
-
observables.push((0, rxjs_1.from)(elements).pipe((0, rxjs_1.mergeMap)((
|
|
361
|
-
const { modelId, categoryId
|
|
362
|
-
return this.
|
|
322
|
+
observables.push((0, rxjs_1.from)(elements).pipe((0, rxjs_1.mergeMap)(([categoryKey, elementIds]) => {
|
|
323
|
+
const { modelId, categoryId } = (0, FilteredTree_1.parseCategoryKey)(categoryKey);
|
|
324
|
+
return this.changeElementsState({ modelId, categoryId, elementIds, on });
|
|
363
325
|
})));
|
|
364
326
|
}
|
|
365
327
|
return (0, rxjs_1.merge)(...observables);
|
|
@@ -448,9 +410,9 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
448
410
|
const { modelId, categoryId, elementIds } = info;
|
|
449
411
|
const viewport = this._props.viewport;
|
|
450
412
|
return (0, rxjs_1.concat)(on && !viewport.view.viewsModel(modelId) ? this.showModelWithoutAnyCategoriesOrElements(modelId) : rxjs_1.EMPTY, (0, rxjs_1.defer)(() => {
|
|
451
|
-
const categoryVisibility = this.getDefaultCategoryVisibilityStatus({ categoryId, modelId });
|
|
413
|
+
const categoryVisibility = this.getDefaultCategoryVisibilityStatus({ categoryId, modelId, ignoreTooltip: true });
|
|
452
414
|
const isDisplayedByDefault = categoryVisibility.state === "visible";
|
|
453
|
-
return
|
|
415
|
+
return this.queueElementsVisibilityChange(elementIds, on, isDisplayedByDefault);
|
|
454
416
|
}));
|
|
455
417
|
});
|
|
456
418
|
return (0, UseHierarchyVisibility_1.createVisibilityHandlerResult)(this, { node, on }, result, this._props.overrides?.changeElementGroupingNodeState);
|
|
@@ -459,23 +421,49 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
459
421
|
* Updates visibility of an element and all its child elements by adding them to the always/never drawn list.
|
|
460
422
|
* @note If element is to be enabled and model is hidden, it will be enabled.
|
|
461
423
|
*/
|
|
462
|
-
|
|
424
|
+
changeElementsState(props) {
|
|
463
425
|
const result = (0, rxjs_1.defer)(() => {
|
|
464
|
-
const {
|
|
426
|
+
const { elementIds, on, modelId, categoryId } = props;
|
|
465
427
|
const viewport = this._props.viewport;
|
|
466
428
|
return (0, rxjs_1.concat)(props.on && !viewport.view.viewsModel(modelId) ? this.showModelWithoutAnyCategoriesOrElements(modelId) : rxjs_1.EMPTY, (0, rxjs_1.defer)(() => {
|
|
467
|
-
const categoryVisibility = this.getDefaultCategoryVisibilityStatus({ categoryId, modelId });
|
|
429
|
+
const categoryVisibility = this.getDefaultCategoryVisibilityStatus({ categoryId, modelId, ignoreTooltip: true });
|
|
468
430
|
const isDisplayedByDefault = categoryVisibility.state === "visible";
|
|
469
|
-
return
|
|
431
|
+
return this.queueElementsVisibilityChange(elementIds, on, isDisplayedByDefault);
|
|
470
432
|
}));
|
|
471
433
|
});
|
|
472
|
-
return (0, UseHierarchyVisibility_1.createVisibilityHandlerResult)(this, props, result, this._props.overrides?.
|
|
434
|
+
return (0, UseHierarchyVisibility_1.createVisibilityHandlerResult)(this, props, result, this._props.overrides?.changeElementsState);
|
|
435
|
+
}
|
|
436
|
+
queueElementsVisibilityChange(elementIds, on, visibleByDefault) {
|
|
437
|
+
const finishedSubject = new rxjs_1.Subject();
|
|
438
|
+
// observable to track if visibility change is finished/cancelled
|
|
439
|
+
const changeFinished = finishedSubject.pipe((0, rxjs_1.startWith)(false), (0, rxjs_1.shareReplay)(1), (0, rxjs_1.filter)((finished) => finished));
|
|
440
|
+
const changeObservable = (0, rxjs_1.from)(elementIds).pipe(
|
|
441
|
+
// check if visibility change is not finished (cancelled) due to change overall change request being cancelled
|
|
442
|
+
(0, rxjs_1.takeUntil)(changeFinished), this.changeElementStateNoChildrenOperator({ on, isDisplayedByDefault: visibleByDefault }), (0, rxjs_1.tap)({
|
|
443
|
+
next: () => {
|
|
444
|
+
// notify that visibility change is finished
|
|
445
|
+
finishedSubject.next(true);
|
|
446
|
+
},
|
|
447
|
+
}));
|
|
448
|
+
// queue visibility change. `changeObservable` will be subscribed to when other queue changes are finished
|
|
449
|
+
this._elementChangeQueue.next(changeObservable);
|
|
450
|
+
// return observable that will emit when visibility change is finished
|
|
451
|
+
return changeFinished.pipe((0, rxjs_1.take)(1), (0, rxjs_1.tap)({
|
|
452
|
+
unsubscribe: () => {
|
|
453
|
+
// if this observable is unsubscribed before visibility change is finished, we have to notify that it queued change request is cancelled
|
|
454
|
+
finishedSubject.next(true);
|
|
455
|
+
},
|
|
456
|
+
}), (0, rxjs_1.map)(() => undefined));
|
|
473
457
|
}
|
|
474
458
|
changeElementStateNoChildrenOperator(props) {
|
|
475
459
|
return (elementIds) => {
|
|
476
460
|
const { on, isDisplayedByDefault } = props;
|
|
477
461
|
const isAlwaysDrawnExclusive = this._props.viewport.isAlwaysDrawnExclusive;
|
|
478
|
-
return elementIds.pipe((0, rxjs_1.reduce)((acc, elementId) => {
|
|
462
|
+
return elementIds.pipe(releaseMainThreadOnItemsCount(500), (0, rxjs_1.reduce)((acc, elementId) => {
|
|
463
|
+
if (acc.alwaysDrawn === undefined || acc.neverDrawn === undefined) {
|
|
464
|
+
acc.alwaysDrawn = new Set(this._props.viewport.alwaysDrawn || []);
|
|
465
|
+
acc.neverDrawn = new Set(this._props.viewport.neverDrawn || []);
|
|
466
|
+
}
|
|
479
467
|
if (on) {
|
|
480
468
|
const wasRemoved = acc.neverDrawn.delete(elementId);
|
|
481
469
|
acc.changedNeverDrawn ||= wasRemoved;
|
|
@@ -498,39 +486,39 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
498
486
|
}, {
|
|
499
487
|
changedNeverDrawn: false,
|
|
500
488
|
changedAlwaysDrawn: false,
|
|
501
|
-
neverDrawn:
|
|
502
|
-
alwaysDrawn:
|
|
489
|
+
neverDrawn: undefined,
|
|
490
|
+
alwaysDrawn: undefined,
|
|
503
491
|
}), (0, rxjs_1.map)((state) => {
|
|
504
|
-
state.changedNeverDrawn && this._props.viewport.setNeverDrawn(state.neverDrawn);
|
|
505
|
-
state.changedAlwaysDrawn && this._props.viewport.setAlwaysDrawn(state.alwaysDrawn, this._props.viewport.isAlwaysDrawnExclusive);
|
|
492
|
+
state.changedNeverDrawn && state.neverDrawn && this._props.viewport.setNeverDrawn(state.neverDrawn);
|
|
493
|
+
state.changedAlwaysDrawn && state.alwaysDrawn && this._props.viewport.setAlwaysDrawn(state.alwaysDrawn, this._props.viewport.isAlwaysDrawnExclusive);
|
|
506
494
|
}));
|
|
507
495
|
};
|
|
508
496
|
}
|
|
509
497
|
getVisibilityFromAlwaysAndNeverDrawnElementsImpl(props) {
|
|
510
|
-
const { alwaysDrawn, neverDrawn, totalCount } = props;
|
|
498
|
+
const { alwaysDrawn, neverDrawn, totalCount, ignoreTooltip } = props;
|
|
511
499
|
if (neverDrawn?.size === totalCount) {
|
|
512
|
-
return (0, Tooltip_1.createVisibilityStatus)("hidden", props.tooltips.allElementsInNeverDrawnList);
|
|
500
|
+
return (0, Tooltip_1.createVisibilityStatus)("hidden", getTooltipOptions(props.tooltips.allElementsInNeverDrawnList, ignoreTooltip));
|
|
513
501
|
}
|
|
514
502
|
if (alwaysDrawn?.size === totalCount) {
|
|
515
|
-
return (0, Tooltip_1.createVisibilityStatus)("visible", props.tooltips.allElementsInAlwaysDrawnList);
|
|
503
|
+
return (0, Tooltip_1.createVisibilityStatus)("visible", getTooltipOptions(props.tooltips.allElementsInAlwaysDrawnList, ignoreTooltip));
|
|
516
504
|
}
|
|
517
505
|
const viewport = this._props.viewport;
|
|
518
506
|
if (viewport.isAlwaysDrawnExclusive && viewport.alwaysDrawn?.size) {
|
|
519
507
|
return alwaysDrawn?.size
|
|
520
|
-
? (0, Tooltip_1.createVisibilityStatus)("partial", props.tooltips.elementsInBothAlwaysAndNeverDrawn)
|
|
521
|
-
: (0, Tooltip_1.createVisibilityStatus)("hidden", props.tooltips.noElementsInExclusiveAlwaysDrawnList);
|
|
508
|
+
? (0, Tooltip_1.createVisibilityStatus)("partial", getTooltipOptions(props.tooltips.elementsInBothAlwaysAndNeverDrawn, ignoreTooltip))
|
|
509
|
+
: (0, Tooltip_1.createVisibilityStatus)("hidden", getTooltipOptions(props.tooltips.noElementsInExclusiveAlwaysDrawnList, ignoreTooltip));
|
|
522
510
|
}
|
|
523
511
|
const status = props.defaultStatus();
|
|
524
512
|
if ((status.state === "visible" && neverDrawn?.size) || (status.state === "hidden" && alwaysDrawn?.size)) {
|
|
525
|
-
return (0, Tooltip_1.createVisibilityStatus)("partial");
|
|
513
|
+
return (0, Tooltip_1.createVisibilityStatus)("partial", getTooltipOptions(undefined, ignoreTooltip));
|
|
526
514
|
}
|
|
527
515
|
return status;
|
|
528
516
|
}
|
|
529
|
-
getVisibilityFromAlwaysAndNeverDrawnElements(props) {
|
|
517
|
+
getVisibilityFromAlwaysAndNeverDrawnElements({ ignoreTooltip, ...props }) {
|
|
530
518
|
const viewport = this._props.viewport;
|
|
531
519
|
if (viewport.isAlwaysDrawnExclusive) {
|
|
532
520
|
if (!viewport?.alwaysDrawn?.size) {
|
|
533
|
-
return (0, rxjs_1.of)((0, Tooltip_1.createVisibilityStatus)("hidden", props.tooltips.noElementsInExclusiveAlwaysDrawnList));
|
|
521
|
+
return (0, rxjs_1.of)((0, Tooltip_1.createVisibilityStatus)("hidden", getTooltipOptions(props.tooltips.noElementsInExclusiveAlwaysDrawnList, ignoreTooltip)));
|
|
534
522
|
}
|
|
535
523
|
}
|
|
536
524
|
else if (!viewport?.neverDrawn?.size && !viewport?.alwaysDrawn?.size) {
|
|
@@ -542,6 +530,7 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
542
530
|
alwaysDrawn: viewport.alwaysDrawn?.size ? setIntersection(props.elements, viewport.alwaysDrawn) : undefined,
|
|
543
531
|
neverDrawn: viewport.neverDrawn?.size ? setIntersection(props.elements, viewport.neverDrawn) : undefined,
|
|
544
532
|
totalCount: props.elements.size,
|
|
533
|
+
ignoreTooltip,
|
|
545
534
|
}));
|
|
546
535
|
}
|
|
547
536
|
const { modelId, categoryId } = props.queryProps;
|
|
@@ -554,6 +543,7 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
554
543
|
return this.getVisibilityFromAlwaysAndNeverDrawnElementsImpl({
|
|
555
544
|
...props,
|
|
556
545
|
...state,
|
|
546
|
+
ignoreTooltip,
|
|
557
547
|
});
|
|
558
548
|
}));
|
|
559
549
|
}
|
|
@@ -584,28 +574,6 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
584
574
|
const elementIds = new Set(node.groupedInstanceKeys.map((key) => key.id));
|
|
585
575
|
return { modelId, categoryId, elementIds };
|
|
586
576
|
}
|
|
587
|
-
async findClassIdInFilterPath(path, parentKeys, className) {
|
|
588
|
-
function* keysToCheck() {
|
|
589
|
-
for (let i = path.length - 1; i >= 0; --i) {
|
|
590
|
-
const id = path[i];
|
|
591
|
-
if (presentation_hierarchies_1.HierarchyNodeIdentifier.isInstanceNodeIdentifier(id)) {
|
|
592
|
-
yield id;
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
for (let i = parentKeys.length - 1; i >= 0; --i) {
|
|
596
|
-
const key = parentKeys[i];
|
|
597
|
-
if (presentation_hierarchies_1.HierarchyNodeKey.isInstances(key)) {
|
|
598
|
-
yield* key.instanceKeys;
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
for (const parentKey of keysToCheck()) {
|
|
603
|
-
if (await this._props.imodelAccess.classDerivesFrom(parentKey.className, className)) {
|
|
604
|
-
return parentKey.id;
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
(0, core_bentley_1.assert)(false, () => `Cannot find an instance of ${className} in instance keys: ${JSON.stringify([...keysToCheck()], undefined, 2)}`);
|
|
608
|
-
}
|
|
609
577
|
}
|
|
610
578
|
function getVisibilityFromTreeNodeChildren(obs) {
|
|
611
579
|
return obs.pipe((0, Rxjs_1.reduceWhile)((x) => x.allVisible || x.allHidden, (acc, val) => {
|
|
@@ -619,13 +587,13 @@ function getVisibilityFromTreeNodeChildren(obs) {
|
|
|
619
587
|
return x.allVisible ? "visible" : x.allHidden ? "hidden" : "partial";
|
|
620
588
|
}));
|
|
621
589
|
}
|
|
622
|
-
function getVisibilityStatusFromTreeNodeChildren(tooltipMap) {
|
|
590
|
+
function getVisibilityStatusFromTreeNodeChildren(tooltipMap, ignoreTooltip) {
|
|
623
591
|
return (obs) => {
|
|
624
592
|
return getVisibilityFromTreeNodeChildren(obs).pipe((0, rxjs_1.map)((visibility) => {
|
|
625
593
|
if (visibility === "empty") {
|
|
626
594
|
visibility = "visible";
|
|
627
595
|
}
|
|
628
|
-
return (0, Tooltip_1.createVisibilityStatus)(visibility, tooltipMap[visibility]);
|
|
596
|
+
return (0, Tooltip_1.createVisibilityStatus)(visibility, getTooltipOptions(tooltipMap[visibility], ignoreTooltip));
|
|
629
597
|
}));
|
|
630
598
|
};
|
|
631
599
|
}
|
|
@@ -639,35 +607,6 @@ function setIntersection(lhs, rhs) {
|
|
|
639
607
|
lhs.forEach((x) => rhs.has(x) && result.add(x));
|
|
640
608
|
return result;
|
|
641
609
|
}
|
|
642
|
-
function reduceFilterPaths(filteringPaths) {
|
|
643
|
-
let paths = filteringPaths.map((filteringPath) => presentation_hierarchies_1.HierarchyFilteringPath.normalize(filteringPath).path);
|
|
644
|
-
const sorted = [...paths].sort((a, b) => a.length - b.length);
|
|
645
|
-
paths = [];
|
|
646
|
-
for (const path of sorted) {
|
|
647
|
-
if (!arraySortedByLengthContainsPrefix(paths, path)) {
|
|
648
|
-
paths.push(path);
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
return paths;
|
|
652
|
-
}
|
|
653
|
-
function arraySortedByLengthContainsPrefix(targetArray, source) {
|
|
654
|
-
for (const targetVal of targetArray) {
|
|
655
|
-
if (targetVal.length >= source.length) {
|
|
656
|
-
break;
|
|
657
|
-
}
|
|
658
|
-
let isPrefix = true;
|
|
659
|
-
for (let i = 0; i < targetVal.length; ++i) {
|
|
660
|
-
if (!presentation_hierarchies_1.HierarchyNodeIdentifier.equal(targetVal[i], source[i])) {
|
|
661
|
-
isPrefix = false;
|
|
662
|
-
break;
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
if (isPrefix) {
|
|
666
|
-
return true;
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
return false;
|
|
670
|
-
}
|
|
671
610
|
/**
|
|
672
611
|
* Enables display of all given models. Also enables display of all categories and clears always and
|
|
673
612
|
* never drawn lists in the viewport.
|
|
@@ -732,4 +671,20 @@ function areAllModelsVisible(models, viewport) {
|
|
|
732
671
|
return models.length !== 0 ? models.every((id) => viewport.viewsModel(id)) : false;
|
|
733
672
|
}
|
|
734
673
|
exports.areAllModelsVisible = areAllModelsVisible;
|
|
674
|
+
function releaseMainThreadOnItemsCount(elementCount) {
|
|
675
|
+
return (obs) => {
|
|
676
|
+
return obs.pipe((0, rxjs_1.bufferCount)(elementCount), (0, rxjs_1.concatMap)((buff, i) => {
|
|
677
|
+
const out = (0, rxjs_1.of)(buff);
|
|
678
|
+
if (i === 0 && buff.length < elementCount) {
|
|
679
|
+
return out;
|
|
680
|
+
}
|
|
681
|
+
return out.pipe((0, rxjs_1.delay)(0));
|
|
682
|
+
}), (0, rxjs_1.concatAll)());
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
function getTooltipOptions(key, ignoreTooltip) {
|
|
686
|
+
return {
|
|
687
|
+
useTooltip: ignoreTooltip ? false : key,
|
|
688
|
+
};
|
|
689
|
+
}
|
|
735
690
|
//# sourceMappingURL=ModelsTreeVisibilityHandler.js.map
|