@itwin/tree-widget-react 4.0.0-alpha.7 → 4.0.0-alpha.9
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/lib/esm/tree-widget-react/TreeWidget.d.ts +6 -1
- package/lib/esm/tree-widget-react/TreeWidget.js +19 -2
- package/lib/esm/tree-widget-react/TreeWidget.js.map +1 -1
- package/lib/esm/tree-widget-react/components/TreeWidgetComponentImpl.d.ts +6 -0
- package/lib/esm/tree-widget-react/components/TreeWidgetComponentImpl.js +22 -23
- package/lib/esm/tree-widget-react/components/TreeWidgetComponentImpl.js.map +1 -1
- package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js +1 -1
- package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/esm/tree-widget-react/components/tree-header/ErrorState.js +1 -1
- package/lib/esm/tree-widget-react/components/tree-header/ErrorState.js.map +1 -1
- package/lib/esm/tree-widget-react/components/tree-header/SearchBox.d.ts +0 -1
- package/lib/esm/tree-widget-react/components/tree-header/SearchBox.js +3 -4
- package/lib/esm/tree-widget-react/components/tree-header/SearchBox.js.map +1 -1
- package/lib/esm/tree-widget-react/components/tree-header/WidgetHeader.css +1 -0
- package/lib/esm/tree-widget-react/components/tree-header/WidgetHeader.d.ts +12 -4
- package/lib/esm/tree-widget-react/components/tree-header/WidgetHeader.js +13 -9
- package/lib/esm/tree-widget-react/components/tree-header/WidgetHeader.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js +3 -3
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +36 -182
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +7 -11
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeVisibilityHandler.js +107 -191
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseFilteredPaths.d.ts +25 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseFilteredPaths.js +133 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseFilteredPaths.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseIdsCache.d.ts +8 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseIdsCache.js +48 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseIdsCache.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.d.ts +0 -2
- package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js +8 -4
- package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseNodeHighlighting.js +11 -10
- package/lib/esm/tree-widget-react/components/trees/common/UseNodeHighlighting.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/Utils.d.ts +5 -0
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js +5 -0
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/BaseTreeRenderer.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/BaseTreeRenderer.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/common/components/BaseTreeRenderer.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.d.ts +3 -3
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js +11 -2
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.d.ts +6 -4
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.js +20 -25
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js +10 -4
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/UseVisibilityButtonHandler.js +6 -3
- package/lib/esm/tree-widget-react/components/trees/common/components/UseVisibilityButtonHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js +12 -11
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/Tooltip.d.ts +3 -11
- package/lib/esm/tree-widget-react/components/trees/common/internal/Tooltip.js +3 -15
- package/lib/esm/tree-widget-react/components/trees/common/internal/Tooltip.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.d.ts +4 -23
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.js +33 -57
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js +8 -8
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js +11 -11
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.js +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js +6 -6
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js +36 -220
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +24 -87
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.d.ts +27 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.js +170 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseIdsCache.d.ts +8 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseIdsCache.js +47 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseIdsCache.js.map +1 -0
- package/lib/public/locales/en/TreeWidget.json +4 -95
- package/package.json +6 -6
- package/lib/esm/tree-widget-react/components/tree-header/SearchBox.css +0 -8
|
@@ -8,8 +8,8 @@ import { PerModelCategoryVisibility } from "@itwin/core-frontend";
|
|
|
8
8
|
import { HierarchyNode, HierarchyNodeKey } from "@itwin/presentation-hierarchies";
|
|
9
9
|
import { AlwaysAndNeverDrawnElementInfo } from "../../common/internal/AlwaysAndNeverDrawnElementInfo.js";
|
|
10
10
|
import { toVoidPromise } from "../../common/internal/Rxjs.js";
|
|
11
|
-
import { createVisibilityStatus
|
|
12
|
-
import { getClassesByView,
|
|
11
|
+
import { createVisibilityStatus } from "../../common/internal/Tooltip.js";
|
|
12
|
+
import { getClassesByView, releaseMainThreadOnItemsCount, setDifference, setIntersection } from "../../common/internal/Utils.js";
|
|
13
13
|
import { createVisibilityChangeEventListener } from "../../common/internal/VisibilityChangeEventListener.js";
|
|
14
14
|
import { changeElementStateNoChildrenOperator, enableCategoryDisplay, enableSubCategoryDisplay, filterSubModeledElementIds, getElementOverriddenVisibility, getElementVisibility, getSubModeledElementsVisibilityStatus, getVisibilityFromAlwaysAndNeverDrawnElementsImpl, mergeVisibilityStatuses, } from "../../common/internal/VisibilityUtils.js";
|
|
15
15
|
import { createVisibilityHandlerResult } from "../../common/UseHierarchyVisibility.js";
|
|
@@ -31,7 +31,7 @@ class CategoriesTreeVisibilityHandlerImpl {
|
|
|
31
31
|
this._eventListener = createVisibilityChangeEventListener({
|
|
32
32
|
viewport: _props.viewport,
|
|
33
33
|
listeners: {
|
|
34
|
-
models:
|
|
34
|
+
models: true,
|
|
35
35
|
categories: true,
|
|
36
36
|
elements: _props.hierarchyConfig.showElements,
|
|
37
37
|
displayStyle: true,
|
|
@@ -142,7 +142,7 @@ class CategoriesTreeVisibilityHandlerImpl {
|
|
|
142
142
|
return from(this.getVisibilityChangeTargets(props)).pipe(mergeMap(({ definitionContainerIds: definitionContainers, subCategories, modelIds: models, categories, elements }) => {
|
|
143
143
|
const observables = new Array();
|
|
144
144
|
if (definitionContainers?.size) {
|
|
145
|
-
observables.push(from(definitionContainers).pipe(mergeMap((definitionContainerId) => this.getDefinitionContainerDisplayStatus({ definitionContainerIds: [definitionContainerId]
|
|
145
|
+
observables.push(from(definitionContainers).pipe(mergeMap((definitionContainerId) => this.getDefinitionContainerDisplayStatus({ definitionContainerIds: [definitionContainerId] }))));
|
|
146
146
|
}
|
|
147
147
|
if (models?.size) {
|
|
148
148
|
observables.push(from(models).pipe(mergeMap((modelId) => this.getModelVisibilityStatus({ modelId }))));
|
|
@@ -150,110 +150,109 @@ class CategoriesTreeVisibilityHandlerImpl {
|
|
|
150
150
|
if (categories?.size) {
|
|
151
151
|
observables.push(from(categories).pipe(mergeMap((key) => {
|
|
152
152
|
const { modelId, categoryId } = parseCategoryKey(key);
|
|
153
|
-
return this.getCategoryDisplayStatus({
|
|
153
|
+
return this.getCategoryDisplayStatus({ ignoreSubCategories: !!modelId, modelId, categoryIds: [categoryId] });
|
|
154
154
|
})));
|
|
155
155
|
}
|
|
156
156
|
if (subCategories?.size) {
|
|
157
157
|
observables.push(from(subCategories).pipe(mergeMap((key) => {
|
|
158
158
|
const { subCategoryId, categoryId } = parseSubCategoryKey(key);
|
|
159
|
-
return this.getSubCategoryDisplayStatus({ subCategoryIds: [subCategoryId], categoryId
|
|
159
|
+
return this.getSubCategoryDisplayStatus({ subCategoryIds: [subCategoryId], categoryId });
|
|
160
160
|
})));
|
|
161
161
|
}
|
|
162
162
|
if (elements?.size) {
|
|
163
163
|
observables.push(from(elements).pipe(releaseMainThreadOnItemsCount(50), mergeMap(([categoryKey, elementIds]) => {
|
|
164
164
|
const { modelId, categoryId } = parseCategoryKey(categoryKey);
|
|
165
165
|
assert(modelId !== undefined);
|
|
166
|
-
return from(elementIds).pipe(releaseMainThreadOnItemsCount(1000), mergeMap((elementId) => this.getElementDisplayStatus({ modelId, categoryId, elementId
|
|
166
|
+
return from(elementIds).pipe(releaseMainThreadOnItemsCount(1000), mergeMap((elementId) => this.getElementDisplayStatus({ modelId, categoryId, elementId })));
|
|
167
167
|
})));
|
|
168
168
|
}
|
|
169
169
|
return merge(...observables);
|
|
170
|
-
}), mergeVisibilityStatuses
|
|
170
|
+
}), mergeVisibilityStatuses);
|
|
171
171
|
}
|
|
172
172
|
getModelVisibilityStatus({ modelId }) {
|
|
173
173
|
const result = defer(() => {
|
|
174
174
|
const viewport = this._props.viewport;
|
|
175
175
|
if (!viewport.view.viewsModel(modelId)) {
|
|
176
176
|
return from(this._idsCache.getModelCategoryIds(modelId)).pipe(mergeMap((categoryIds) => from(this._idsCache.getCategoriesModeledElements(modelId, categoryIds))), getSubModeledElementsVisibilityStatus({
|
|
177
|
-
ignoreTooltips: true,
|
|
178
|
-
tooltips: { visible: undefined, hidden: undefined, partial: undefined },
|
|
179
177
|
parentNodeVisibilityStatus: createVisibilityStatus("hidden"),
|
|
180
178
|
getModelVisibilityStatus: (modelProps) => this.getModelVisibilityStatus(modelProps),
|
|
181
179
|
}));
|
|
182
180
|
}
|
|
183
|
-
return from(this._idsCache.getModelCategoryIds(modelId)).pipe(mergeAll(), mergeMap((categoryId) => this.getCategoryDisplayStatus({ modelId, categoryIds: [categoryId], ignoreSubCategories: true
|
|
184
|
-
visible: undefined,
|
|
185
|
-
hidden: undefined,
|
|
186
|
-
partial: undefined,
|
|
187
|
-
}, true));
|
|
181
|
+
return from(this._idsCache.getModelCategoryIds(modelId)).pipe(mergeAll(), mergeMap((categoryId) => this.getCategoryDisplayStatus({ modelId, categoryIds: [categoryId], ignoreSubCategories: true })), mergeVisibilityStatuses);
|
|
188
182
|
});
|
|
189
183
|
return createVisibilityHandlerResult(this, { id: modelId }, result, undefined);
|
|
190
184
|
}
|
|
191
185
|
getDefinitionContainerDisplayStatus(props) {
|
|
192
186
|
const result = defer(() => {
|
|
193
|
-
return from(this._idsCache.getAllContainedCategories(props.definitionContainerIds)).pipe(mergeAll(), mergeMap((categoryId) => {
|
|
194
|
-
return this.getCategoryDisplayStatus({ categoryIds: [categoryId], ignoreTooltip: true });
|
|
195
|
-
}), mergeVisibilityStatuses({
|
|
196
|
-
visible: "categoriesTree.definitionContainer.visibleThroughCategories",
|
|
197
|
-
hidden: "categoriesTree.definitionContainer.hiddenThroughCategories",
|
|
198
|
-
partial: "categoriesTree.definitionContainer.partialThroughCategories",
|
|
199
|
-
}));
|
|
187
|
+
return from(this._idsCache.getAllContainedCategories(props.definitionContainerIds)).pipe(mergeAll(), mergeMap((categoryId) => this.getCategoryDisplayStatus({ categoryIds: [categoryId] })), mergeVisibilityStatuses);
|
|
200
188
|
});
|
|
201
189
|
return createVisibilityHandlerResult(this, props, result, undefined);
|
|
202
190
|
}
|
|
203
191
|
getSubCategoryDisplayStatus(props) {
|
|
204
|
-
const result = defer(() => {
|
|
205
|
-
const { categoryId, subCategoryIds
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
192
|
+
const result = defer(async () => {
|
|
193
|
+
const { categoryId, subCategoryIds } = props;
|
|
194
|
+
let visibility = "unknown";
|
|
195
|
+
const categoryModels = [...(await this._idsCache.getCategoriesElementModels([categoryId], true)).values()].flat();
|
|
196
|
+
let nonDefaultModelDisplayStatesCount = 0;
|
|
197
|
+
for (const modelId of categoryModels) {
|
|
198
|
+
if (!this._props.viewport.view.viewsModel(modelId)) {
|
|
199
|
+
if (visibility === "visible") {
|
|
200
|
+
return createVisibilityStatus("partial");
|
|
201
|
+
}
|
|
202
|
+
visibility = "hidden";
|
|
203
|
+
++nonDefaultModelDisplayStatesCount;
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
const override = this._props.viewport.perModelCategoryVisibility.getOverride(modelId, categoryId);
|
|
207
|
+
if (override === PerModelCategoryVisibility.Override.Show) {
|
|
208
|
+
if (visibility === "hidden") {
|
|
209
|
+
return createVisibilityStatus("partial");
|
|
210
|
+
}
|
|
211
|
+
visibility = "visible";
|
|
212
|
+
++nonDefaultModelDisplayStatesCount;
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
if (override === PerModelCategoryVisibility.Override.Hide) {
|
|
216
|
+
if (visibility === "visible") {
|
|
217
|
+
return createVisibilityStatus("partial");
|
|
218
|
+
}
|
|
219
|
+
visibility = "hidden";
|
|
220
|
+
++nonDefaultModelDisplayStatesCount;
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (categoryModels.length > 0 && nonDefaultModelDisplayStatesCount === categoryModels.length) {
|
|
225
|
+
assert(visibility === "visible" || visibility === "hidden");
|
|
226
|
+
return createVisibilityStatus(visibility);
|
|
209
227
|
}
|
|
210
228
|
if (!this._props.viewport.view.viewsCategory(categoryId)) {
|
|
211
|
-
return
|
|
229
|
+
return createVisibilityStatus(visibility === "visible" ? "partial" : "hidden");
|
|
212
230
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const isVisible = this._props.viewport.isSubCategoryVisible(subCategoryId);
|
|
217
|
-
if (isVisible) {
|
|
218
|
-
++visibleCount;
|
|
231
|
+
if (subCategoryIds.length === 0) {
|
|
232
|
+
if (visibility === "hidden") {
|
|
233
|
+
return createVisibilityStatus("partial");
|
|
219
234
|
}
|
|
220
|
-
|
|
221
|
-
|
|
235
|
+
return createVisibilityStatus("visible");
|
|
236
|
+
}
|
|
237
|
+
for (const subCategoryId of subCategoryIds) {
|
|
238
|
+
const isSubCategoryVisible = this._props.viewport.isSubCategoryVisible(subCategoryId);
|
|
239
|
+
if (isSubCategoryVisible && visibility === "hidden") {
|
|
240
|
+
return createVisibilityStatus("partial");
|
|
222
241
|
}
|
|
223
|
-
if (
|
|
224
|
-
return
|
|
242
|
+
if (!isSubCategoryVisible && visibility === "visible") {
|
|
243
|
+
return createVisibilityStatus("partial");
|
|
225
244
|
}
|
|
245
|
+
visibility = isSubCategoryVisible ? "visible" : "hidden";
|
|
226
246
|
}
|
|
227
|
-
|
|
247
|
+
assert(visibility === "visible" || visibility === "hidden");
|
|
248
|
+
return createVisibilityStatus(visibility);
|
|
228
249
|
});
|
|
229
250
|
return createVisibilityHandlerResult(this, props, result, undefined);
|
|
230
251
|
}
|
|
231
|
-
|
|
232
|
-
let showOverrides = 0;
|
|
233
|
-
let hideOverrides = 0;
|
|
234
|
-
for (const currentOverride of this._props.viewport.perModelCategoryVisibility) {
|
|
235
|
-
if (categoryIds.includes(currentOverride.categoryId)) {
|
|
236
|
-
if (currentOverride.visible) {
|
|
237
|
-
++showOverrides;
|
|
238
|
-
}
|
|
239
|
-
else {
|
|
240
|
-
++hideOverrides;
|
|
241
|
-
}
|
|
242
|
-
if (showOverrides > 0 && hideOverrides > 0) {
|
|
243
|
-
return createVisibilityStatus("partial", getTooltipOptions("categoriesTree.category.partialThroughOverrides", ignoreTooltip));
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
if (showOverrides === 0 && hideOverrides === 0) {
|
|
248
|
-
return "none";
|
|
249
|
-
}
|
|
250
|
-
const visibility = showOverrides > 0 ? "visible" : "hidden";
|
|
251
|
-
return createVisibilityStatus(visibility, getTooltipOptions(`categoriesTree.category.${visibility}ThroughOverrides`, ignoreTooltip));
|
|
252
|
-
}
|
|
253
|
-
getDefaultModelsCategoryVisibilityStatus({ modelId, categoryIds, ignoreTooltip, }) {
|
|
252
|
+
getDefaultModelsCategoryVisibilityStatus({ modelId, categoryIds }) {
|
|
254
253
|
const viewport = this._props.viewport;
|
|
255
254
|
if (!viewport.view.viewsModel(modelId)) {
|
|
256
|
-
return createVisibilityStatus("hidden"
|
|
255
|
+
return createVisibilityStatus("hidden");
|
|
257
256
|
}
|
|
258
257
|
let visibleCount = 0;
|
|
259
258
|
let hiddenCount = 0;
|
|
@@ -272,55 +271,26 @@ class CategoriesTreeVisibilityHandlerImpl {
|
|
|
272
271
|
continue;
|
|
273
272
|
}
|
|
274
273
|
if (visibleCount > 0 && hiddenCount > 0) {
|
|
275
|
-
return createVisibilityStatus("partial"
|
|
274
|
+
return createVisibilityStatus("partial");
|
|
276
275
|
}
|
|
277
276
|
}
|
|
278
277
|
if (hiddenCount + visibleCount > 0) {
|
|
279
|
-
|
|
280
|
-
return createVisibilityStatus(overridenVisibility, getTooltipOptions(`categoriesTree.category.${overridenVisibility}ThroughOverrides`, ignoreTooltip));
|
|
278
|
+
return createVisibilityStatus(hiddenCount > 0 ? "hidden" : "visible");
|
|
281
279
|
}
|
|
282
|
-
|
|
283
|
-
return createVisibilityStatus(visbility, getTooltipOptions(`categoriesTree.category.${visbility}ThroughCategorySelector`, ignoreTooltip));
|
|
280
|
+
return createVisibilityStatus(visibleThroughCategorySelectorCount > 0 ? "visible" : "hidden");
|
|
284
281
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
const isVisible = this._props.viewport.view.viewsCategory(categoryId);
|
|
293
|
-
if (!isVisible) {
|
|
294
|
-
++hiddenCount;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
if (hiddenCount > 0 || this._props.hierarchyConfig.hideSubCategories || ignoreSubCategories) {
|
|
298
|
-
const visibility = hiddenCount > 0 ? "hidden" : "visible";
|
|
299
|
-
return createVisibilityStatus(visibility, getTooltipOptions(`categoriesTree.category.${visibility}ThroughCategorySelector`, ignoreTooltip));
|
|
300
|
-
}
|
|
301
|
-
const subCategories = getDistinctMapValues(await this._idsCache.getSubCategories(categoryIds));
|
|
302
|
-
let visibleSubCategoryCount = 0;
|
|
303
|
-
let hiddenSubCategoryCount = 0;
|
|
304
|
-
for (const subCategory of subCategories) {
|
|
305
|
-
const isVisible = this._props.viewport.isSubCategoryVisible(subCategory);
|
|
306
|
-
if (isVisible) {
|
|
307
|
-
++visibleSubCategoryCount;
|
|
308
|
-
}
|
|
309
|
-
else {
|
|
310
|
-
++hiddenSubCategoryCount;
|
|
311
|
-
}
|
|
312
|
-
if (hiddenSubCategoryCount > 0 && visibleSubCategoryCount > 0) {
|
|
313
|
-
return createVisibilityStatus("partial", getTooltipOptions("categoriesTree.category.partialThroughSubCategories", ignoreTooltip));
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
const subCategoryVisiblity = hiddenSubCategoryCount > 0 ? "hidden" : "visible";
|
|
317
|
-
const reason = subCategories.size > 0 ? "ThroughSubCategories" : "ThroughCategorySelector";
|
|
318
|
-
return createVisibilityStatus(subCategoryVisiblity, getTooltipOptions(`categoriesTree.category.${subCategoryVisiblity}${reason}`, ignoreTooltip));
|
|
282
|
+
getDefaultCategoryVisibilityStatus({ categoryIds }) {
|
|
283
|
+
return from(this._idsCache.getSubCategories(categoryIds)).pipe(mergeMap((categoriesSubCategoriesMap) => {
|
|
284
|
+
return from(categoryIds).pipe(mergeMap((categoryId) => {
|
|
285
|
+
const subCategoryIds = categoriesSubCategoriesMap.get(categoryId);
|
|
286
|
+
return this.getSubCategoryDisplayStatus({ subCategoryIds: subCategoryIds ?? [], categoryId });
|
|
287
|
+
}), mergeVisibilityStatuses);
|
|
288
|
+
}));
|
|
319
289
|
}
|
|
320
|
-
getCategoryDisplayStatus(
|
|
290
|
+
getCategoryDisplayStatus(props) {
|
|
321
291
|
const result = defer(() => {
|
|
322
292
|
if (!this._props.hierarchyConfig.showElements) {
|
|
323
|
-
return from(this.getDefaultCategoryVisibilityStatus({ categoryIds: props.categoryIds
|
|
293
|
+
return from(this.getDefaultCategoryVisibilityStatus({ categoryIds: props.categoryIds }));
|
|
324
294
|
}
|
|
325
295
|
const modelsObservable = props.modelId
|
|
326
296
|
? of(new Map(props.categoryIds.map((id) => [id, [props.modelId]])))
|
|
@@ -331,57 +301,34 @@ class CategoriesTreeVisibilityHandlerImpl {
|
|
|
331
301
|
? modelsObservable.pipe(mergeMap((categoryModelsMap) => {
|
|
332
302
|
if (categoryModelsMap.size === 0) {
|
|
333
303
|
return props.modelId
|
|
334
|
-
? of(this.getDefaultModelsCategoryVisibilityStatus({ modelId: props.modelId, categoryIds: props.categoryIds
|
|
335
|
-
: from(this.getDefaultCategoryVisibilityStatus({ categoryIds: props.categoryIds
|
|
304
|
+
? of(this.getDefaultModelsCategoryVisibilityStatus({ modelId: props.modelId, categoryIds: props.categoryIds }))
|
|
305
|
+
: from(this.getDefaultCategoryVisibilityStatus({ categoryIds: props.categoryIds }));
|
|
336
306
|
}
|
|
337
307
|
return from(categoryModelsMap).pipe(mergeMap(([category, models]) => from(models).pipe(mergeMap((model) => {
|
|
338
308
|
if (this._props.viewport.view.viewsModel(model)) {
|
|
339
309
|
return this.getVisibilityFromAlwaysAndNeverDrawnElements({
|
|
340
310
|
queryProps: props,
|
|
341
|
-
|
|
342
|
-
allElementsInAlwaysDrawnList: "categoriesTree.category.allElementsVisible",
|
|
343
|
-
allElementsInNeverDrawnList: "categoriesTree.category.allElementsHidden",
|
|
344
|
-
elementsInBothAlwaysAndNeverDrawn: "categoriesTree.category.someElementsAreHidden",
|
|
345
|
-
noElementsInExclusiveAlwaysDrawnList: "categoriesTree.category.allElementsHidden",
|
|
346
|
-
},
|
|
347
|
-
defaultStatus: () => this.getDefaultModelsCategoryVisibilityStatus({ modelId: model, categoryIds: [category], ignoreTooltip }),
|
|
348
|
-
ignoreTooltip: true,
|
|
311
|
+
defaultStatus: () => this.getDefaultModelsCategoryVisibilityStatus({ modelId: model, categoryIds: [category] }),
|
|
349
312
|
}).pipe(mergeMap((visibilityStatusAlwaysAndNeverDraw) => {
|
|
350
313
|
return from(this._idsCache.getCategoriesModeledElements(model, [category])).pipe(getSubModeledElementsVisibilityStatus({
|
|
351
|
-
tooltips: {
|
|
352
|
-
visible: undefined,
|
|
353
|
-
hidden: undefined,
|
|
354
|
-
partial: undefined,
|
|
355
|
-
},
|
|
356
314
|
parentNodeVisibilityStatus: visibilityStatusAlwaysAndNeverDraw,
|
|
357
|
-
ignoreTooltips: true,
|
|
358
315
|
getModelVisibilityStatus: (modelProps) => this.getModelVisibilityStatus(modelProps),
|
|
359
316
|
}));
|
|
360
317
|
}));
|
|
361
318
|
}
|
|
362
319
|
return from(this._idsCache.getCategoriesModeledElements(model, [category])).pipe(getSubModeledElementsVisibilityStatus({
|
|
363
|
-
tooltips: {
|
|
364
|
-
visible: undefined,
|
|
365
|
-
hidden: undefined,
|
|
366
|
-
partial: undefined,
|
|
367
|
-
},
|
|
368
320
|
parentNodeVisibilityStatus: createVisibilityStatus("hidden"),
|
|
369
|
-
ignoreTooltips: true,
|
|
370
321
|
getModelVisibilityStatus: (modelProps) => this.getModelVisibilityStatus(modelProps),
|
|
371
322
|
}));
|
|
372
|
-
}), mergeVisibilityStatuses
|
|
373
|
-
visible: "categoriesTree.category.allElementsVisible",
|
|
374
|
-
hidden: "categoriesTree.category.allElementsHidden",
|
|
375
|
-
partial: "categoriesTree.category.someElementsHidden",
|
|
376
|
-
}, ignoreTooltip));
|
|
323
|
+
}), mergeVisibilityStatuses)), mergeVisibilityStatuses);
|
|
377
324
|
}), map((visibilityStatus) => {
|
|
378
325
|
return { visibilityStatus, type: 0 };
|
|
379
326
|
}))
|
|
380
327
|
: EMPTY,
|
|
381
328
|
// get category status
|
|
382
329
|
(props.modelId
|
|
383
|
-
? of(this.getDefaultModelsCategoryVisibilityStatus({ modelId: props.modelId, categoryIds: props.categoryIds
|
|
384
|
-
: from(this.getDefaultCategoryVisibilityStatus({ categoryIds: props.categoryIds
|
|
330
|
+
? of(this.getDefaultModelsCategoryVisibilityStatus({ modelId: props.modelId, categoryIds: props.categoryIds }))
|
|
331
|
+
: from(this.getDefaultCategoryVisibilityStatus({ categoryIds: props.categoryIds }))).pipe(map((visibilityStatus) => {
|
|
385
332
|
return { visibilityStatus, type: 1 };
|
|
386
333
|
}))).pipe(toArray(), mergeMap(async (visibilityStatusesInfo) => {
|
|
387
334
|
let defaultStatus;
|
|
@@ -409,28 +356,18 @@ class CategoriesTreeVisibilityHandlerImpl {
|
|
|
409
356
|
}
|
|
410
357
|
// In cases where
|
|
411
358
|
// a) SubCategories are hidden
|
|
412
|
-
// b) Category
|
|
413
|
-
// c) Category has model (it means that category is under hidden subModel)
|
|
359
|
+
// b) Category has model (it means that category is under hidden subModel)
|
|
414
360
|
// We dont need to look at default category status, it is already accounted for in always/never drawn visibility
|
|
415
|
-
if (this._props.hierarchyConfig.hideSubCategories || props.
|
|
361
|
+
if (this._props.hierarchyConfig.hideSubCategories || props.modelId) {
|
|
416
362
|
return alwaysNeverDrawStatus;
|
|
417
363
|
}
|
|
418
364
|
if ((await this._idsCache.getSubCategories(props.categoryIds)).size === 0) {
|
|
419
365
|
return alwaysNeverDrawStatus;
|
|
420
366
|
}
|
|
421
|
-
if (alwaysNeverDrawStatus.state === "partial") {
|
|
422
|
-
return createVisibilityStatus("partial"
|
|
367
|
+
if (alwaysNeverDrawStatus.state === "partial" || alwaysNeverDrawStatus.state !== defaultStatus.state) {
|
|
368
|
+
return createVisibilityStatus("partial");
|
|
423
369
|
}
|
|
424
|
-
|
|
425
|
-
if (defaultStatus.state === "hidden") {
|
|
426
|
-
return createVisibilityStatus("hidden", getTooltipOptions("categoriesTree.category.allChildrenHidden", ignoreTooltip));
|
|
427
|
-
}
|
|
428
|
-
return createVisibilityStatus("partial", getTooltipOptions("categoriesTree.category.partialThroughSubCategories", ignoreTooltip));
|
|
429
|
-
}
|
|
430
|
-
if (defaultStatus.state === "hidden") {
|
|
431
|
-
return createVisibilityStatus("partial", getTooltipOptions("categoriesTree.category.someChildrenVisible", ignoreTooltip));
|
|
432
|
-
}
|
|
433
|
-
return createVisibilityStatus("visible", getTooltipOptions("categoriesTree.category.allChildrenVisible", ignoreTooltip));
|
|
370
|
+
return alwaysNeverDrawStatus;
|
|
434
371
|
}));
|
|
435
372
|
});
|
|
436
373
|
return createVisibilityHandlerResult(this, props, result, undefined);
|
|
@@ -442,62 +379,33 @@ class CategoriesTreeVisibilityHandlerImpl {
|
|
|
442
379
|
return from(modelElementsMap).pipe(mergeMap(([modelId, elementIds]) => {
|
|
443
380
|
if (!this._props.viewport.view.viewsModel(modelId)) {
|
|
444
381
|
return of([...elementIds]).pipe(filterSubModeledElementIds({ doesSubModelExist: async (id) => this._idsCache.hasSubModel(id) }), getSubModeledElementsVisibilityStatus({
|
|
445
|
-
tooltips: {
|
|
446
|
-
visible: undefined,
|
|
447
|
-
hidden: undefined,
|
|
448
|
-
partial: undefined,
|
|
449
|
-
},
|
|
450
382
|
parentNodeVisibilityStatus: createVisibilityStatus("hidden"),
|
|
451
383
|
getModelVisibilityStatus: (modelProps) => this.getModelVisibilityStatus(modelProps),
|
|
452
384
|
}));
|
|
453
385
|
}
|
|
454
386
|
return this.getVisibilityFromAlwaysAndNeverDrawnElements({
|
|
455
387
|
elements: elementIds,
|
|
456
|
-
defaultStatus: () => {
|
|
457
|
-
const status = this.getDefaultModelsCategoryVisibilityStatus({ categoryIds: [categoryId], modelId, ignoreTooltip: true });
|
|
458
|
-
return createVisibilityStatus(status.state, getTooltipOptions(`categoriesTree.groupingNode.${status.state}ThroughCategory`));
|
|
459
|
-
},
|
|
460
|
-
tooltips: {
|
|
461
|
-
allElementsInAlwaysDrawnList: "categoriesTree.groupingNode.allElementsVisible",
|
|
462
|
-
allElementsInNeverDrawnList: "categoriesTree.groupingNode.allElementsHidden",
|
|
463
|
-
elementsInBothAlwaysAndNeverDrawn: "categoriesTree.groupingNode.someElementsAreHidden",
|
|
464
|
-
noElementsInExclusiveAlwaysDrawnList: "categoriesTree.groupingNode.allElementsHidden",
|
|
465
|
-
},
|
|
388
|
+
defaultStatus: () => this.getDefaultModelsCategoryVisibilityStatus({ categoryIds: [categoryId], modelId }),
|
|
466
389
|
}).pipe(mergeMap((visibilityStatusAlwaysAndNeverDraw) => {
|
|
467
390
|
return of([...elementIds]).pipe(filterSubModeledElementIds({ doesSubModelExist: async (id) => this._idsCache.hasSubModel(id) }), getSubModeledElementsVisibilityStatus({
|
|
468
|
-
tooltips: {
|
|
469
|
-
visible: undefined,
|
|
470
|
-
hidden: undefined,
|
|
471
|
-
partial: undefined,
|
|
472
|
-
},
|
|
473
391
|
parentNodeVisibilityStatus: visibilityStatusAlwaysAndNeverDraw,
|
|
474
392
|
getModelVisibilityStatus: (modelProps) => this.getModelVisibilityStatus(modelProps),
|
|
475
393
|
}));
|
|
476
394
|
}));
|
|
477
|
-
}), mergeVisibilityStatuses
|
|
478
|
-
visible: undefined,
|
|
479
|
-
hidden: undefined,
|
|
480
|
-
partial: undefined,
|
|
481
|
-
}, true));
|
|
395
|
+
}), mergeVisibilityStatuses);
|
|
482
396
|
});
|
|
483
397
|
return createVisibilityHandlerResult(this, { node }, result, undefined);
|
|
484
398
|
}
|
|
485
|
-
getElementDisplayStatus(
|
|
399
|
+
getElementDisplayStatus(props) {
|
|
486
400
|
const result = defer(() => {
|
|
487
401
|
const viewport = this._props.viewport;
|
|
488
402
|
const { elementId, modelId, categoryId } = props;
|
|
489
403
|
const viewsModel = viewport.view.viewsModel(modelId);
|
|
490
404
|
const elementStatus = getElementOverriddenVisibility({
|
|
491
405
|
elementId,
|
|
492
|
-
ignoreTooltip,
|
|
493
406
|
viewport,
|
|
494
|
-
tooltips: {
|
|
495
|
-
visibileThorughAlwaysDrawn: "categoriesTree.element.displayedThroughAlwaysDrawnList",
|
|
496
|
-
hiddenThroughAlwaysDrawnExclusive: "categoriesTree.element.hiddenDueToOtherElementsExclusivelyAlwaysDrawn",
|
|
497
|
-
hiddenThroughNeverDrawn: "categoriesTree.element.hiddenThroughNeverDrawnList",
|
|
498
|
-
},
|
|
499
407
|
});
|
|
500
|
-
return from(this._idsCache.hasSubModel(elementId)).pipe(mergeMap((hasSubModel) => (hasSubModel ? this.getModelVisibilityStatus({ modelId: elementId }) : of(undefined))), map((subModelVisibilityStatus) => getElementVisibility(
|
|
408
|
+
return from(this._idsCache.hasSubModel(elementId)).pipe(mergeMap((hasSubModel) => (hasSubModel ? this.getModelVisibilityStatus({ modelId: elementId }) : of(undefined))), map((subModelVisibilityStatus) => getElementVisibility(viewsModel, elementStatus, this.getDefaultModelsCategoryVisibilityStatus({ categoryIds: [categoryId], modelId }), subModelVisibilityStatus)));
|
|
501
409
|
});
|
|
502
410
|
return createVisibilityHandlerResult(this, props, result, undefined);
|
|
503
411
|
}
|
|
@@ -648,15 +556,25 @@ class CategoriesTreeVisibilityHandlerImpl {
|
|
|
648
556
|
changeSubCategoryState(props) {
|
|
649
557
|
const result = defer(() => {
|
|
650
558
|
return concat(
|
|
651
|
-
// make sure parent category
|
|
652
|
-
props.on
|
|
559
|
+
// make sure parent category and models are enabled
|
|
560
|
+
props.on
|
|
561
|
+
? concat(from(enableCategoryDisplay(this._props.viewport, [props.categoryId], props.on, false)), from(this.enableCategoriesElementModelsVisibility([props.categoryId])))
|
|
562
|
+
: EMPTY, from(props.subCategoryIds).pipe(map((subCategoryId) => enableSubCategoryDisplay(this._props.viewport, subCategoryId, props.on))));
|
|
653
563
|
});
|
|
654
564
|
return createVisibilityHandlerResult(this, props, result, undefined);
|
|
655
565
|
}
|
|
566
|
+
async enableCategoriesElementModelsVisibility(categoryIds) {
|
|
567
|
+
const categoriesModelsMap = await this._idsCache.getCategoriesElementModels(categoryIds, true);
|
|
568
|
+
const modelIds = [...categoriesModelsMap.values()].flat();
|
|
569
|
+
const hiddenModels = modelIds.filter((modelId) => !this._props.viewport.view.viewsModel(modelId));
|
|
570
|
+
if (hiddenModels.length > 0) {
|
|
571
|
+
this._props.viewport.changeModelDisplay(hiddenModels, true);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
656
574
|
changeDefinitionContainerState(props) {
|
|
657
575
|
const result = defer(() => {
|
|
658
|
-
return from(this._idsCache.getAllContainedCategories(props.definitionContainerIds)).pipe(
|
|
659
|
-
return this.changeCategoryState({ categoryIds
|
|
576
|
+
return from(this._idsCache.getAllContainedCategories(props.definitionContainerIds)).pipe(mergeMap((categoryIds) => {
|
|
577
|
+
return this.changeCategoryState({ categoryIds, on: props.on });
|
|
660
578
|
}));
|
|
661
579
|
});
|
|
662
580
|
return createVisibilityHandlerResult(this, props, result, undefined);
|
|
@@ -666,7 +584,7 @@ class CategoriesTreeVisibilityHandlerImpl {
|
|
|
666
584
|
const { modelId, categoryIds, on, ignoreSubCategories } = props;
|
|
667
585
|
const viewport = this._props.viewport;
|
|
668
586
|
if (!this._props.hierarchyConfig.showElements) {
|
|
669
|
-
return from(enableCategoryDisplay(viewport, categoryIds, on, on));
|
|
587
|
+
return concat(from(enableCategoryDisplay(viewport, categoryIds, on, on)), on ? from(this.enableCategoriesElementModelsVisibility(categoryIds)) : EMPTY);
|
|
670
588
|
}
|
|
671
589
|
const modelIdsObservable = modelId
|
|
672
590
|
? of(new Map(categoryIds.map((id) => [id, [modelId]])))
|
|
@@ -689,7 +607,7 @@ class CategoriesTreeVisibilityHandlerImpl {
|
|
|
689
607
|
const { modelId, categoryId, elementIds, on } = props;
|
|
690
608
|
const viewport = this._props.viewport;
|
|
691
609
|
return concat(on && !viewport.view.viewsModel(modelId) ? this.showModelWithoutAnyCategoriesOrElements(modelId) : EMPTY, defer(() => {
|
|
692
|
-
const categoryVisibility = this.getDefaultModelsCategoryVisibilityStatus({ categoryIds: [categoryId], modelId
|
|
610
|
+
const categoryVisibility = this.getDefaultModelsCategoryVisibilityStatus({ categoryIds: [categoryId], modelId });
|
|
693
611
|
const isDisplayedByDefault = categoryVisibility.state === "visible";
|
|
694
612
|
return this.queueElementsVisibilityChange(elementIds, on, isDisplayedByDefault);
|
|
695
613
|
}), from(elementIds).pipe(mergeMap(async (elementId) => ({ elementId, isSubModel: await this._idsCache.hasSubModel(elementId) })), filter(({ isSubModel }) => isSubModel), map(({ elementId }) => elementId), toArray(), mergeMap((subModelIds) => this.changeModelState({ ids: subModelIds, on }))));
|
|
@@ -736,11 +654,11 @@ class CategoriesTreeVisibilityHandlerImpl {
|
|
|
736
654
|
},
|
|
737
655
|
}), map(() => undefined));
|
|
738
656
|
}
|
|
739
|
-
getVisibilityFromAlwaysAndNeverDrawnElements(
|
|
657
|
+
getVisibilityFromAlwaysAndNeverDrawnElements(props) {
|
|
740
658
|
const viewport = this._props.viewport;
|
|
741
659
|
if (viewport.isAlwaysDrawnExclusive) {
|
|
742
660
|
if (!viewport?.alwaysDrawn?.size) {
|
|
743
|
-
return of(createVisibilityStatus("hidden"
|
|
661
|
+
return of(createVisibilityStatus("hidden"));
|
|
744
662
|
}
|
|
745
663
|
}
|
|
746
664
|
else if (!viewport?.neverDrawn?.size && !viewport?.alwaysDrawn?.size) {
|
|
@@ -752,7 +670,6 @@ class CategoriesTreeVisibilityHandlerImpl {
|
|
|
752
670
|
alwaysDrawn: viewport.alwaysDrawn?.size ? setIntersection(props.elements, viewport.alwaysDrawn) : undefined,
|
|
753
671
|
neverDrawn: viewport.neverDrawn?.size ? setIntersection(props.elements, viewport.neverDrawn) : undefined,
|
|
754
672
|
totalCount: props.elements.size,
|
|
755
|
-
ignoreTooltip,
|
|
756
673
|
viewport,
|
|
757
674
|
}));
|
|
758
675
|
}
|
|
@@ -770,7 +687,6 @@ class CategoriesTreeVisibilityHandlerImpl {
|
|
|
770
687
|
return getVisibilityFromAlwaysAndNeverDrawnElementsImpl({
|
|
771
688
|
...props,
|
|
772
689
|
...state,
|
|
773
|
-
ignoreTooltip,
|
|
774
690
|
viewport,
|
|
775
691
|
});
|
|
776
692
|
}));
|