@itwin/grouping-mapping-widget 0.9.3 → 0.10.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/lib/cjs/grouping-mapping-widget.d.ts +9 -3
- package/lib/cjs/grouping-mapping-widget.js +15 -3
- package/lib/cjs/grouping-mapping-widget.js.map +1 -1
- package/lib/cjs/test/GroupingMappingCustomUI.test.js +49 -86
- package/lib/cjs/test/GroupingMappingCustomUI.test.js.map +1 -1
- package/lib/cjs/test/test-utils.d.ts +0 -6
- package/lib/cjs/test/test-utils.js +8 -24
- package/lib/cjs/test/test-utils.js.map +1 -1
- package/lib/cjs/widget/components/ActionPanel.d.ts +1 -1
- package/lib/cjs/widget/components/ActionPanel.js +1 -1
- package/lib/cjs/widget/components/ActionPanel.js.map +1 -1
- package/lib/cjs/widget/components/ConfirmMappingsImport.js +1 -4
- package/lib/cjs/widget/components/ConfirmMappingsImport.js.map +1 -1
- package/lib/cjs/widget/components/GroupAction.d.ts +13 -9
- package/lib/cjs/widget/components/GroupAction.js +56 -58
- package/lib/cjs/widget/components/GroupAction.js.map +1 -1
- package/lib/cjs/widget/components/GroupPropertyAction.d.ts +1 -1
- package/lib/cjs/widget/components/GroupPropertyAction.js.map +1 -1
- package/lib/cjs/widget/components/GroupPropertyUtils.js +4 -0
- package/lib/cjs/widget/components/GroupPropertyUtils.js.map +1 -1
- package/lib/cjs/widget/components/Grouping.d.ts +8 -9
- package/lib/cjs/widget/components/Grouping.js +118 -273
- package/lib/cjs/widget/components/Grouping.js.map +1 -1
- package/lib/cjs/widget/components/Grouping.scss +2 -2
- package/lib/cjs/widget/components/GroupingMapping.d.ts +28 -21
- package/lib/cjs/widget/components/GroupingMapping.js +59 -38
- package/lib/cjs/widget/components/GroupingMapping.js.map +1 -1
- package/lib/cjs/widget/components/GroupingMappingContent.d.ts +8 -0
- package/lib/cjs/widget/components/GroupingMappingContent.js +47 -0
- package/lib/cjs/widget/components/GroupingMappingContent.js.map +1 -0
- package/lib/cjs/widget/components/GroupingMappingContext.d.ts +31 -0
- package/lib/cjs/widget/components/GroupingMappingContext.js +84 -0
- package/lib/cjs/widget/components/GroupingMappingContext.js.map +1 -0
- package/lib/cjs/widget/components/GroupingMappingHeader.d.ts +8 -0
- package/lib/cjs/widget/components/GroupingMappingHeader.js +17 -0
- package/lib/cjs/widget/components/GroupingMappingHeader.js.map +1 -0
- package/lib/cjs/widget/components/GroupingMappingRouter.d.ts +8 -0
- package/lib/cjs/widget/components/GroupingMappingRouter.js +87 -0
- package/lib/cjs/widget/components/GroupingMappingRouter.js.map +1 -0
- package/lib/cjs/widget/components/Mapping.d.ts +7 -2
- package/lib/cjs/widget/components/Mapping.js +53 -84
- package/lib/cjs/widget/components/Mapping.js.map +1 -1
- package/lib/cjs/widget/components/MappingAction.d.ts +9 -5
- package/lib/cjs/widget/components/MappingAction.js +19 -8
- package/lib/cjs/widget/components/MappingAction.js.map +1 -1
- package/lib/cjs/widget/components/QueryBuilder.js +2 -7
- package/lib/cjs/widget/components/QueryBuilder.js.map +1 -1
- package/lib/cjs/widget/components/context/GroupHilitedElementsContext.d.ts +15 -0
- package/lib/cjs/widget/components/context/GroupHilitedElementsContext.js +45 -0
- package/lib/cjs/widget/components/context/GroupHilitedElementsContext.js.map +1 -0
- package/lib/cjs/widget/components/context/GroupingApiConfigContext.d.ts +1 -0
- package/lib/cjs/widget/components/context/GroupingApiConfigContext.js +1 -0
- package/lib/cjs/widget/components/context/GroupingApiConfigContext.js.map +1 -1
- package/lib/cjs/widget/components/context/GroupingMappingCustomUIContext.d.ts +6 -2
- package/lib/cjs/widget/components/context/GroupingMappingCustomUIContext.js +5 -5
- package/lib/cjs/widget/components/context/GroupingMappingCustomUIContext.js.map +1 -1
- package/lib/cjs/widget/components/customUI/DefaultGroupingUI.d.ts +3 -0
- package/lib/cjs/widget/components/customUI/DefaultGroupingUI.js +40 -0
- package/lib/cjs/widget/components/customUI/DefaultGroupingUI.js.map +1 -0
- package/lib/cjs/widget/components/customUI/GroupQueryBuilderCustomUI.d.ts +5 -0
- package/lib/cjs/widget/components/{GroupQueryBuilderContainer.js → customUI/GroupQueryBuilderCustomUI.js} +36 -16
- package/lib/cjs/widget/components/customUI/GroupQueryBuilderCustomUI.js.map +1 -0
- package/lib/cjs/widget/components/customUI/GroupingMappingCustomUI.d.ts +3 -2
- package/lib/cjs/widget/components/customUI/GroupingMappingCustomUI.js.map +1 -1
- package/lib/cjs/widget/components/customUI/ManualGroupingCustomUI.d.ts +1 -2
- package/lib/cjs/widget/components/customUI/ManualGroupingCustomUI.js +2 -1
- package/lib/cjs/widget/components/customUI/ManualGroupingCustomUI.js.map +1 -1
- package/lib/cjs/widget/components/customUI/SearchGroupingCustomUI.d.ts +1 -2
- package/lib/cjs/widget/components/customUI/SearchGroupingCustomUI.js +2 -1
- package/lib/cjs/widget/components/customUI/SearchGroupingCustomUI.js.map +1 -1
- package/lib/cjs/widget/components/groupsHelpers.d.ts +7 -0
- package/lib/cjs/widget/components/groupsHelpers.js +84 -0
- package/lib/cjs/widget/components/groupsHelpers.js.map +1 -0
- package/lib/cjs/widget/components/property-grid/PropertyGridWrapper.d.ts +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyGridWrapper.js +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyGridWrapper.js.map +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyView.js +29 -15
- package/lib/cjs/widget/components/property-grid/PropertyView.js.map +1 -1
- package/lib/cjs/widget/components/utils.d.ts +1 -3
- package/lib/cjs/widget/components/utils.js +1 -26
- package/lib/cjs/widget/components/utils.js.map +1 -1
- package/lib/esm/grouping-mapping-widget.d.ts +9 -3
- package/lib/esm/grouping-mapping-widget.js +7 -1
- package/lib/esm/grouping-mapping-widget.js.map +1 -1
- package/lib/esm/test/GroupingMappingCustomUI.test.js +46 -83
- package/lib/esm/test/GroupingMappingCustomUI.test.js.map +1 -1
- package/lib/esm/test/test-utils.d.ts +0 -6
- package/lib/esm/test/test-utils.js +7 -22
- package/lib/esm/test/test-utils.js.map +1 -1
- package/lib/esm/widget/components/ActionPanel.d.ts +1 -1
- package/lib/esm/widget/components/ActionPanel.js +1 -1
- package/lib/esm/widget/components/ActionPanel.js.map +1 -1
- package/lib/esm/widget/components/ConfirmMappingsImport.js +1 -4
- package/lib/esm/widget/components/ConfirmMappingsImport.js.map +1 -1
- package/lib/esm/widget/components/GroupAction.d.ts +13 -9
- package/lib/esm/widget/components/GroupAction.js +57 -61
- package/lib/esm/widget/components/GroupAction.js.map +1 -1
- package/lib/esm/widget/components/GroupPropertyAction.d.ts +1 -1
- package/lib/esm/widget/components/GroupPropertyAction.js.map +1 -1
- package/lib/esm/widget/components/GroupPropertyUtils.js +4 -0
- package/lib/esm/widget/components/GroupPropertyUtils.js.map +1 -1
- package/lib/esm/widget/components/Grouping.d.ts +8 -9
- package/lib/esm/widget/components/Grouping.js +122 -277
- package/lib/esm/widget/components/Grouping.js.map +1 -1
- package/lib/esm/widget/components/Grouping.scss +2 -2
- package/lib/esm/widget/components/GroupingMapping.d.ts +28 -21
- package/lib/esm/widget/components/GroupingMapping.js +59 -39
- package/lib/esm/widget/components/GroupingMapping.js.map +1 -1
- package/lib/esm/widget/components/GroupingMappingContent.d.ts +8 -0
- package/lib/esm/widget/components/GroupingMappingContent.js +24 -0
- package/lib/esm/widget/components/GroupingMappingContent.js.map +1 -0
- package/lib/esm/widget/components/GroupingMappingContext.d.ts +31 -0
- package/lib/esm/widget/components/GroupingMappingContext.js +61 -0
- package/lib/esm/widget/components/GroupingMappingContext.js.map +1 -0
- package/lib/esm/widget/components/GroupingMappingHeader.d.ts +8 -0
- package/lib/esm/widget/components/GroupingMappingHeader.js +10 -0
- package/lib/esm/widget/components/GroupingMappingHeader.js.map +1 -0
- package/lib/esm/widget/components/GroupingMappingRouter.d.ts +8 -0
- package/lib/esm/widget/components/GroupingMappingRouter.js +80 -0
- package/lib/esm/widget/components/GroupingMappingRouter.js.map +1 -0
- package/lib/esm/widget/components/Mapping.d.ts +7 -2
- package/lib/esm/widget/components/Mapping.js +55 -86
- package/lib/esm/widget/components/Mapping.js.map +1 -1
- package/lib/esm/widget/components/MappingAction.d.ts +9 -5
- package/lib/esm/widget/components/MappingAction.js +18 -9
- package/lib/esm/widget/components/MappingAction.js.map +1 -1
- package/lib/esm/widget/components/QueryBuilder.js +2 -7
- package/lib/esm/widget/components/QueryBuilder.js.map +1 -1
- package/lib/esm/widget/components/context/GroupHilitedElementsContext.d.ts +15 -0
- package/lib/esm/widget/components/context/GroupHilitedElementsContext.js +22 -0
- package/lib/esm/widget/components/context/GroupHilitedElementsContext.js.map +1 -0
- package/lib/esm/widget/components/context/GroupingApiConfigContext.d.ts +1 -0
- package/lib/esm/widget/components/context/GroupingApiConfigContext.js +1 -0
- package/lib/esm/widget/components/context/GroupingApiConfigContext.js.map +1 -1
- package/lib/esm/widget/components/context/GroupingMappingCustomUIContext.d.ts +6 -2
- package/lib/esm/widget/components/context/GroupingMappingCustomUIContext.js +5 -5
- package/lib/esm/widget/components/context/GroupingMappingCustomUIContext.js.map +1 -1
- package/lib/esm/widget/components/customUI/DefaultGroupingUI.d.ts +3 -0
- package/lib/esm/widget/components/customUI/DefaultGroupingUI.js +34 -0
- package/lib/esm/widget/components/customUI/DefaultGroupingUI.js.map +1 -0
- package/lib/esm/widget/components/customUI/GroupQueryBuilderCustomUI.d.ts +5 -0
- package/lib/esm/widget/components/{GroupQueryBuilderContainer.js → customUI/GroupQueryBuilderCustomUI.js} +11 -7
- package/lib/esm/widget/components/customUI/GroupQueryBuilderCustomUI.js.map +1 -0
- package/lib/esm/widget/components/customUI/GroupingMappingCustomUI.d.ts +3 -2
- package/lib/esm/widget/components/customUI/GroupingMappingCustomUI.js.map +1 -1
- package/lib/esm/widget/components/customUI/ManualGroupingCustomUI.d.ts +1 -2
- package/lib/esm/widget/components/customUI/ManualGroupingCustomUI.js +1 -2
- package/lib/esm/widget/components/customUI/ManualGroupingCustomUI.js.map +1 -1
- package/lib/esm/widget/components/customUI/SearchGroupingCustomUI.d.ts +1 -2
- package/lib/esm/widget/components/customUI/SearchGroupingCustomUI.js +1 -2
- package/lib/esm/widget/components/customUI/SearchGroupingCustomUI.js.map +1 -1
- package/lib/esm/widget/components/groupsHelpers.d.ts +7 -0
- package/lib/esm/widget/components/groupsHelpers.js +77 -0
- package/lib/esm/widget/components/groupsHelpers.js.map +1 -0
- package/lib/esm/widget/components/property-grid/PropertyGridWrapper.d.ts +1 -1
- package/lib/esm/widget/components/property-grid/PropertyGridWrapper.js +1 -1
- package/lib/esm/widget/components/property-grid/PropertyGridWrapper.js.map +1 -1
- package/lib/esm/widget/components/property-grid/PropertyView.js +1 -3
- package/lib/esm/widget/components/property-grid/PropertyView.js.map +1 -1
- package/lib/esm/widget/components/utils.d.ts +1 -3
- package/lib/esm/widget/components/utils.js +0 -24
- package/lib/esm/widget/components/utils.js.map +1 -1
- package/package.json +3 -3
- package/lib/cjs/widget/components/GroupQueryBuilderContainer.d.ts +0 -5
- package/lib/cjs/widget/components/GroupQueryBuilderContainer.js.map +0 -1
- package/lib/esm/widget/components/GroupQueryBuilderContainer.d.ts +0 -5
- package/lib/esm/widget/components/GroupQueryBuilderContainer.js.map +0 -1
- /package/lib/cjs/widget/components/{GroupQueryBuilder.scss → customUI/GroupQueryBuilderCustomUI.scss} +0 -0
- /package/lib/esm/widget/components/{GroupQueryBuilder.scss → customUI/GroupQueryBuilderCustomUI.scss} +0 -0
|
@@ -3,55 +3,26 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { useActiveIModelConnection } from "@itwin/appui-react";
|
|
6
|
-
import React, { useCallback, useEffect,
|
|
7
|
-
import { Button, ButtonGroup, DropdownMenu, IconButton, MenuItem, ProgressRadial, Surface,
|
|
8
|
-
import { SvgAdd,
|
|
6
|
+
import React, { useCallback, useEffect, useState } from "react";
|
|
7
|
+
import { Button, ButtonGroup, DropdownMenu, IconButton, MenuItem, ProgressRadial, Surface, ToggleSwitch, } from "@itwin/itwinui-react";
|
|
8
|
+
import { SvgAdd, SvgDelete, SvgEdit, SvgMore, SvgRefresh, SvgVisibilityHide, SvgVisibilityShow, } from "@itwin/itwinui-icons-react";
|
|
9
9
|
import DeleteModal from "./DeleteModal";
|
|
10
10
|
import "./Grouping.scss";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { EmptyMessage, handleError, LoadingOverlay, WidgetHeader, } from "./utils";
|
|
14
|
-
import GroupAction from "./GroupAction";
|
|
11
|
+
import { clearEmphasizedElements, clearEmphasizedOverriddenElements, clearHiddenElements, hideElements, zoomToElements, } from "./viewerUtils";
|
|
12
|
+
import { EmptyMessage, handleError, LoadingOverlay, } from "./utils";
|
|
15
13
|
import { useMappingClient } from "./context/MappingClientContext";
|
|
16
|
-
import { FeatureOverrideType } from "@itwin/core-common";
|
|
17
14
|
import { HorizontalTile } from "./HorizontalTile";
|
|
18
15
|
import { useGroupingMappingApiConfig } from "./context/GroupingApiConfigContext";
|
|
19
16
|
import { useGroupingMappingCustomUI } from "./context/GroupingMappingCustomUIContext";
|
|
20
17
|
import { GroupingMappingCustomUIType } from "./customUI/GroupingMappingCustomUI";
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
{
|
|
24
|
-
name: "Selection",
|
|
25
|
-
displayLabel: "Selection",
|
|
26
|
-
icon: React.createElement(SvgCursor, null),
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
name: "Search",
|
|
30
|
-
displayLabel: "Query Keywords",
|
|
31
|
-
icon: React.createElement(SvgSearch, null),
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
name: "Manual",
|
|
35
|
-
displayLabel: "Manual Query",
|
|
36
|
-
icon: React.createElement(SvgDraw, null),
|
|
37
|
-
},
|
|
38
|
-
];
|
|
39
|
-
var GroupsView;
|
|
40
|
-
(function (GroupsView) {
|
|
41
|
-
GroupsView[GroupsView["Add"] = 0] = "Add";
|
|
42
|
-
GroupsView[GroupsView["Groups"] = 1] = "Groups";
|
|
43
|
-
GroupsView[GroupsView["CustomUI"] = 2] = "CustomUI";
|
|
44
|
-
GroupsView[GroupsView["Modifying"] = 3] = "Modifying";
|
|
45
|
-
GroupsView[GroupsView["Properties"] = 4] = "Properties";
|
|
46
|
-
})(GroupsView || (GroupsView = {}));
|
|
47
|
-
const goldenAngle = 180 * (3 - Math.sqrt(5));
|
|
18
|
+
import { useGroupHilitedElementsContext } from "./context/GroupHilitedElementsContext";
|
|
19
|
+
import { getGroupColor, getHiliteIdsFromGroups, hideGroups, visualizeGroupColors } from "./groupsHelpers";
|
|
48
20
|
const fetchGroups = async (setGroups, iModelId, mappingId, setIsLoading, getAccessToken, mappingsClient) => {
|
|
49
21
|
try {
|
|
50
22
|
setIsLoading(true);
|
|
51
23
|
const accessToken = await getAccessToken();
|
|
52
24
|
const groups = await mappingsClient.getGroups(accessToken, iModelId, mappingId);
|
|
53
25
|
setGroups(groups);
|
|
54
|
-
return groups;
|
|
55
26
|
}
|
|
56
27
|
catch (error) {
|
|
57
28
|
handleError(error.status);
|
|
@@ -59,104 +30,57 @@ const fetchGroups = async (setGroups, iModelId, mappingId, setIsLoading, getAcce
|
|
|
59
30
|
finally {
|
|
60
31
|
setIsLoading(false);
|
|
61
32
|
}
|
|
62
|
-
return undefined;
|
|
63
33
|
};
|
|
64
|
-
export const Groupings = ({ mapping,
|
|
65
|
-
var _a
|
|
34
|
+
export const Groupings = ({ mapping, onClickAddGroup, onClickGroupTitle, onClickGroupModify, onClickRenderContextCustomUI, emphasizeElements = true, }) => {
|
|
35
|
+
var _a;
|
|
66
36
|
const iModelConnection = useActiveIModelConnection();
|
|
67
|
-
const { getAccessToken } = useGroupingMappingApiConfig();
|
|
37
|
+
const { getAccessToken, iModelId } = useGroupingMappingApiConfig();
|
|
38
|
+
const { showGroupColor, setShowGroupColor, hiddenGroupsIds, setHiddenGroupsIds, hilitedElementsQueryCache, groups, setGroups } = useGroupHilitedElementsContext();
|
|
68
39
|
const mappingClient = useMappingClient();
|
|
69
|
-
const
|
|
70
|
-
const groupUIs = useGroupingMappingCustomUI()
|
|
40
|
+
const groupUIs = useGroupingMappingCustomUI().customUIs
|
|
71
41
|
.filter((p) => p.type === GroupingMappingCustomUIType.Grouping);
|
|
72
|
-
const contextUIs = useGroupingMappingCustomUI()
|
|
42
|
+
const contextUIs = useGroupingMappingCustomUI().customUIs
|
|
73
43
|
.filter((p) => p.type === GroupingMappingCustomUIType.Context);
|
|
74
44
|
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
|
75
45
|
const [isLoading, setIsLoading] = useState(true);
|
|
76
|
-
const [groupsView, setGroupsView] = useState(GroupsView.Groups);
|
|
77
46
|
const [selectedGroup, setSelectedGroup] = useState(undefined);
|
|
78
|
-
const hilitedElements = useRef(new Map());
|
|
79
47
|
const [isLoadingQuery, setLoadingQuery] = useState(false);
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
void fetchGroups(setGroups, iModelId, mapping.id, setIsLoading, getAccessToken, mappingClient);
|
|
87
|
-
}, [getAccessToken, mappingClient, iModelId, mapping.id]);
|
|
88
|
-
const getGroupColor = function (index) {
|
|
89
|
-
return `hsl(${index * goldenAngle + 60}, 100%, 50%)`;
|
|
90
|
-
};
|
|
91
|
-
const getHiliteIdsFromGroups = useCallback(async (groups) => {
|
|
92
|
-
var _a;
|
|
93
|
-
let allIds = [];
|
|
94
|
-
for (const group of groups) {
|
|
95
|
-
const query = group.query;
|
|
96
|
-
let currentIds = [];
|
|
97
|
-
if (hilitedElements.current.has(query)) {
|
|
98
|
-
currentIds = (_a = hilitedElements.current.get(query)) !== null && _a !== void 0 ? _a : [];
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
try {
|
|
102
|
-
const queryRowCount = await iModelConnection.queryRowCount(query);
|
|
103
|
-
if (queryRowCount === 0) {
|
|
104
|
-
toaster.warning(`${group.groupName}'s query is valid but produced no results.`);
|
|
105
|
-
}
|
|
106
|
-
currentIds = await getHiliteIds(query, iModelConnection);
|
|
107
|
-
hilitedElements.current.set(query, currentIds);
|
|
108
|
-
}
|
|
109
|
-
catch {
|
|
110
|
-
toaster.negative(`Could not hide/show ${group.groupName}. Query could not be resolved.`);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
allIds = allIds.concat(currentIds);
|
|
114
|
-
}
|
|
115
|
-
return allIds;
|
|
116
|
-
}, [iModelConnection, hilitedElements]);
|
|
117
|
-
const visualizeGroupColors = useCallback(async (viewGroups) => {
|
|
48
|
+
const getHiliteIdsFromGroupsWrapper = useCallback(async (groups) => iModelConnection
|
|
49
|
+
? getHiliteIdsFromGroups(iModelConnection, groups, hilitedElementsQueryCache)
|
|
50
|
+
: [], [iModelConnection, hilitedElementsQueryCache]);
|
|
51
|
+
const visualizeGroupColorsWrapper = useCallback(async (viewGroups) => {
|
|
52
|
+
if (!iModelConnection)
|
|
53
|
+
return;
|
|
118
54
|
setLoadingQuery(true);
|
|
119
|
-
|
|
120
|
-
let allIds = [];
|
|
121
|
-
for (const group of viewGroups) {
|
|
122
|
-
const index = viewGroups.length > groups.length
|
|
123
|
-
? viewGroups.findIndex((g) => g.id === group.id)
|
|
124
|
-
: groups.findIndex((g) => g.id === group.id);
|
|
125
|
-
const hilitedIds = await getHiliteIdsFromGroups([group]);
|
|
126
|
-
overrideElements(hilitedIds, getGroupColor(index), FeatureOverrideType.ColorAndAlpha);
|
|
127
|
-
emphasizeElements(hilitedIds, undefined);
|
|
128
|
-
if (!hiddenGroupsIds.includes(group.id)) {
|
|
129
|
-
allIds = allIds.concat(hilitedIds);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
await zoomToElements(allIds);
|
|
55
|
+
await visualizeGroupColors(iModelConnection, groups, viewGroups, hiddenGroupsIds, hilitedElementsQueryCache, emphasizeElements);
|
|
133
56
|
setLoadingQuery(false);
|
|
134
|
-
}, [groups, hiddenGroupsIds,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
57
|
+
}, [iModelConnection, groups, hiddenGroupsIds, hilitedElementsQueryCache, emphasizeElements]);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
const initialize = async () => {
|
|
60
|
+
await fetchGroups(setGroups, iModelId, mapping.id, setIsLoading, getAccessToken, mappingClient);
|
|
61
|
+
};
|
|
62
|
+
void initialize();
|
|
63
|
+
}, [getAccessToken, mappingClient, iModelId, mapping.id, setGroups]);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (isLoading)
|
|
66
|
+
return;
|
|
67
|
+
const visualize = async () => {
|
|
68
|
+
if (groups.length > 0 && showGroupColor) {
|
|
69
|
+
await visualizeGroupColorsWrapper(groups);
|
|
143
70
|
}
|
|
144
71
|
else {
|
|
145
|
-
|
|
146
|
-
const queryRowCount = await iModelConnection.queryRowCount(query);
|
|
147
|
-
if (queryRowCount === 0) {
|
|
148
|
-
toaster.warning(`${viewGroup.groupName}'s query is valid but produced no results.`);
|
|
149
|
-
}
|
|
150
|
-
const hiliteIds = await hideElementsByQuery(query, iModelConnection, false);
|
|
151
|
-
hilitedElements.current.set(query, hiliteIds);
|
|
152
|
-
}
|
|
153
|
-
catch {
|
|
154
|
-
toaster.negative(`Could not hide/show ${viewGroup.groupName}. Query could not be resolved.`);
|
|
155
|
-
}
|
|
72
|
+
clearEmphasizedOverriddenElements();
|
|
156
73
|
}
|
|
157
|
-
}
|
|
74
|
+
};
|
|
75
|
+
void visualize();
|
|
76
|
+
}, [groups, isLoading, showGroupColor, visualizeGroupColorsWrapper]);
|
|
77
|
+
const hideGroupsWrapper = useCallback(async (viewGroups) => {
|
|
78
|
+
if (!iModelConnection)
|
|
79
|
+
return;
|
|
80
|
+
setLoadingQuery(true);
|
|
81
|
+
await hideGroups(iModelConnection, viewGroups, hilitedElementsQueryCache);
|
|
158
82
|
setLoadingQuery(false);
|
|
159
|
-
}, [iModelConnection]);
|
|
83
|
+
}, [hilitedElementsQueryCache, iModelConnection]);
|
|
160
84
|
const showGroup = useCallback(async (viewGroup) => {
|
|
161
85
|
clearHiddenElements();
|
|
162
86
|
// hide group Ids filter
|
|
@@ -164,192 +88,113 @@ export const Groupings = ({ mapping, goBack }) => {
|
|
|
164
88
|
.map((id) => groups.find((g) => g.id === id))
|
|
165
89
|
.filter((g) => !!g && g.id !== viewGroup.id);
|
|
166
90
|
// view group Ids filter
|
|
167
|
-
const viewIds = await
|
|
168
|
-
let hiddenIds = await
|
|
91
|
+
const viewIds = await getHiliteIdsFromGroupsWrapper(groups.filter((g) => !newHiddenGroups.find((hg) => hg.id === g.id)));
|
|
92
|
+
let hiddenIds = await getHiliteIdsFromGroupsWrapper(newHiddenGroups);
|
|
169
93
|
hiddenIds = hiddenIds.filter((id) => !viewIds.includes(id));
|
|
170
94
|
hideElements(hiddenIds);
|
|
171
|
-
}, [groups, hiddenGroupsIds,
|
|
95
|
+
}, [groups, hiddenGroupsIds, getHiliteIdsFromGroupsWrapper]);
|
|
172
96
|
const addGroup = (type) => {
|
|
173
|
-
|
|
97
|
+
if (!onClickAddGroup)
|
|
98
|
+
return;
|
|
99
|
+
onClickAddGroup(type);
|
|
174
100
|
clearEmphasizedElements();
|
|
175
|
-
setGroupsView(GroupsView.Add);
|
|
176
101
|
};
|
|
177
102
|
const onModify = async (group, type) => {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
setGroupsView(GroupsView.Modifying);
|
|
103
|
+
if (!onClickGroupModify)
|
|
104
|
+
return;
|
|
181
105
|
if (group.id && hiddenGroupsIds.includes(group.id)) {
|
|
182
106
|
await showGroup(group);
|
|
183
107
|
setHiddenGroupsIds(hiddenGroupsIds.filter((id) => id !== group.id));
|
|
184
108
|
}
|
|
185
109
|
clearEmphasizedElements();
|
|
110
|
+
onClickGroupModify(group, type);
|
|
186
111
|
};
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
setGroupsView(GroupsView.Properties);
|
|
190
|
-
if (group.id && hiddenGroupsIds.includes(group.id)) {
|
|
112
|
+
const colorGroup = async (group) => {
|
|
113
|
+
if (showGroupColor && hiddenGroupsIds.includes(group.id)) {
|
|
191
114
|
await showGroup(group);
|
|
192
115
|
setHiddenGroupsIds(hiddenGroupsIds.filter((id) => id !== group.id));
|
|
193
116
|
}
|
|
194
117
|
};
|
|
195
118
|
const refresh = useCallback(async () => {
|
|
196
|
-
setGroupsView(GroupsView.Groups);
|
|
197
119
|
setSelectedGroup(undefined);
|
|
198
|
-
setSelectedContextCustomUI(undefined);
|
|
199
120
|
setGroups([]);
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (showGroupColor) {
|
|
203
|
-
await visualizeGroupColors(groups);
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
clearEmphasizedOverriddenElements();
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}, [
|
|
210
|
-
getAccessToken,
|
|
211
|
-
mappingClient,
|
|
212
|
-
iModelId,
|
|
213
|
-
mapping.id,
|
|
214
|
-
setGroups,
|
|
215
|
-
showGroupColor,
|
|
216
|
-
visualizeGroupColors,
|
|
217
|
-
]);
|
|
218
|
-
const resetView = async () => {
|
|
219
|
-
if (groups) {
|
|
220
|
-
if (showGroupColor) {
|
|
221
|
-
await visualizeGroupColors(groups);
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
clearOverriddenElements();
|
|
225
|
-
}
|
|
226
|
-
clearEmphasizedElements();
|
|
227
|
-
}
|
|
228
|
-
};
|
|
121
|
+
await fetchGroups(setGroups, iModelId, mapping.id, setIsLoading, getAccessToken, mappingClient);
|
|
122
|
+
}, [getAccessToken, mappingClient, iModelId, mapping.id, setGroups]);
|
|
229
123
|
const showAll = async () => {
|
|
230
124
|
setLoadingQuery(true);
|
|
231
125
|
clearHiddenElements();
|
|
232
126
|
setHiddenGroupsIds([]);
|
|
233
|
-
const allIds = await
|
|
127
|
+
const allIds = await getHiliteIdsFromGroupsWrapper(groups);
|
|
234
128
|
await zoomToElements(allIds);
|
|
235
129
|
setLoadingQuery(false);
|
|
236
130
|
};
|
|
237
131
|
const hideAll = useCallback(async () => {
|
|
238
|
-
await
|
|
132
|
+
await hideGroupsWrapper(groups);
|
|
239
133
|
setHiddenGroupsIds(groups.map((g) => g.id).filter((id) => !!id));
|
|
240
|
-
const allIds = await
|
|
134
|
+
const allIds = await getHiliteIdsFromGroupsWrapper(groups);
|
|
241
135
|
await zoomToElements(allIds);
|
|
242
|
-
}, [setHiddenGroupsIds, groups,
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
React.createElement(DropdownMenu, { className: 'gmw-custom-ui-dropdown', disabled: isLoadingQuery, menuItems: (close) => [
|
|
306
|
-
React.createElement(MenuItem, { key: 0, icon: React.createElement(SvgEdit, null), disabled: isLoadingQuery, "data-testid": "gmw-context-menu-item", subMenuItems: (groupUIs.length > 0
|
|
307
|
-
? groupUIs
|
|
308
|
-
: defaultUIMetadata)
|
|
309
|
-
.map((p, index) => (React.createElement(MenuItem, { key: index, className: 'gmw-menu-item', "data-testid": `gmw-edit-${index}`, onClick: async () => onModify(g, p.name), icon: p.icon }, p.displayLabel))) }, "Edit"),
|
|
310
|
-
React.createElement(MenuItem, { key: 1, onClick: async () => openProperties(g), icon: React.createElement(SvgList, null), "data-testid": "gmw-context-menu-item" }, "Properties"),
|
|
311
|
-
React.createElement(MenuItem, { key: 2, onClick: () => {
|
|
312
|
-
setSelectedGroup(g);
|
|
313
|
-
setShowDeleteModal(true);
|
|
314
|
-
close();
|
|
315
|
-
}, icon: React.createElement(SvgDelete, null), "data-testid": "gmw-context-menu-item" }, "Remove"),
|
|
316
|
-
].concat(contextUIs.map((p) => {
|
|
317
|
-
return React.createElement(MenuItem, { key: p.name, onClick: () => {
|
|
318
|
-
if (p.uiComponent) {
|
|
319
|
-
setSelectedGroup(g);
|
|
320
|
-
setSelectedContextCustomUI(p);
|
|
321
|
-
setGroupsView(GroupsView.CustomUI);
|
|
322
|
-
}
|
|
323
|
-
if (p.onClick) {
|
|
324
|
-
p.onClick(g.id, mapping.id, iModelId);
|
|
325
|
-
}
|
|
326
|
-
close();
|
|
327
|
-
}, icon: p.icon, "data-testid": "gmw-context-menu-item" }, p.displayLabel);
|
|
328
|
-
})) },
|
|
329
|
-
React.createElement(IconButton, { disabled: isLoadingQuery, styleType: 'borderless', "data-testid": "gmw-more-button" },
|
|
330
|
-
React.createElement(SvgMore, null)))), onClickTitle: isLoadingQuery
|
|
331
|
-
? undefined
|
|
332
|
-
: async () => openProperties(g) })))))),
|
|
333
|
-
React.createElement(DeleteModal, { entityName: (_b = selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.groupName) !== null && _b !== void 0 ? _b : "", show: showDeleteModal, setShow: setShowDeleteModal, onDelete: async () => {
|
|
334
|
-
var _a;
|
|
335
|
-
const accessToken = await getAccessToken();
|
|
336
|
-
await mappingClient.deleteGroup(accessToken, iModelId, mapping.id, (_a = selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.id) !== null && _a !== void 0 ? _a : "");
|
|
337
|
-
}, refresh: refresh })));
|
|
338
|
-
case GroupsView.CustomUI:
|
|
339
|
-
return selectedContextCustomUI && selectedContextCustomUI.uiComponent && selectedGroup
|
|
340
|
-
? (React.createElement(React.Fragment, null,
|
|
341
|
-
React.createElement(WidgetHeader, { title: selectedContextCustomUI.displayLabel, returnFn: async () => {
|
|
342
|
-
Presentation.selection.clearSelection("GroupingMappingWidget", iModelConnection);
|
|
343
|
-
await refresh();
|
|
344
|
-
} }),
|
|
345
|
-
React.createElement(selectedContextCustomUI.uiComponent, {
|
|
346
|
-
iModelId,
|
|
347
|
-
mappingId: mapping.id,
|
|
348
|
-
groupId: selectedGroup.id,
|
|
349
|
-
})))
|
|
350
|
-
: null;
|
|
351
|
-
default:
|
|
352
|
-
return (React.createElement(EmptyMessage, { message: "No given group view" }));
|
|
353
|
-
}
|
|
136
|
+
}, [setHiddenGroupsIds, groups, hideGroupsWrapper, getHiliteIdsFromGroupsWrapper]);
|
|
137
|
+
return (React.createElement(React.Fragment, null,
|
|
138
|
+
React.createElement(Surface, { className: 'gmw-groups-container' },
|
|
139
|
+
React.createElement("div", { className: 'gmw-toolbar' },
|
|
140
|
+
onClickAddGroup && groupUIs.length > 0 &&
|
|
141
|
+
React.createElement(DropdownMenu, { className: 'gmw-custom-ui-dropdown', disabled: isLoadingQuery, menuItems: () => groupUIs.map((p, index) => (React.createElement(MenuItem, { key: index, onClick: () => addGroup(p.name), icon: p.icon, className: 'gmw-menu-item', "data-testid": `gmw-add-${index}` }, p.displayLabel))) },
|
|
142
|
+
React.createElement(Button, { "data-testid": "gmw-add-group-button", className: 'add-load-button', startIcon: isLoadingQuery ? (React.createElement(ProgressRadial, { size: 'small', indeterminate: true })) : (React.createElement(SvgAdd, null)), styleType: 'high-visibility', disabled: isLoadingQuery }, isLoadingQuery ? "Loading" : "Add Group")),
|
|
143
|
+
iModelConnection &&
|
|
144
|
+
React.createElement(ButtonGroup, { className: 'gmw-toolbar-buttons' },
|
|
145
|
+
React.createElement(ToggleSwitch, { label: 'Color by Group', labelPosition: 'left', className: 'gmw-toggle', disabled: isLoadingQuery, checked: showGroupColor, onChange: () => setShowGroupColor((b) => !b) }),
|
|
146
|
+
React.createElement(IconButton, { title: 'Show All', onClick: showAll, disabled: isLoadingQuery, styleType: 'borderless', className: 'gmw-group-view-icon' },
|
|
147
|
+
React.createElement(SvgVisibilityShow, null)),
|
|
148
|
+
React.createElement(IconButton, { title: 'Hide All', onClick: hideAll, disabled: isLoadingQuery, styleType: 'borderless', className: 'gmw-group-view-icon' },
|
|
149
|
+
React.createElement(SvgVisibilityHide, null)),
|
|
150
|
+
React.createElement(IconButton, { title: "Refresh", onClick: refresh, disabled: isLoading || isLoadingQuery, styleType: 'borderless' },
|
|
151
|
+
React.createElement(SvgRefresh, null)))),
|
|
152
|
+
isLoading ? (React.createElement(LoadingOverlay, null)) : groups.length === 0 ? (React.createElement(EmptyMessage, { message: 'No Groups available.' })) : (React.createElement("div", { className: 'gmw-group-list' }, groups
|
|
153
|
+
.sort((a, b) => { var _a, _b, _c; return (_c = (_a = a.groupName) === null || _a === void 0 ? void 0 : _a.localeCompare((_b = b.groupName) !== null && _b !== void 0 ? _b : "")) !== null && _c !== void 0 ? _c : 1; })
|
|
154
|
+
.map((g) => (React.createElement(HorizontalTile, { key: g.id, title: g.groupName ? g.groupName : "Untitled", subText: g.description, actionGroup: React.createElement("div", { className: 'gmw-actions' },
|
|
155
|
+
iModelConnection && React.createElement(React.Fragment, null,
|
|
156
|
+
showGroupColor && (React.createElement(IconButton, { styleType: 'borderless', className: 'gmw-group-view-icon' },
|
|
157
|
+
React.createElement("div", { className: "gmw-color-legend", style: {
|
|
158
|
+
backgroundColor: getGroupColor(groups.findIndex((group) => g.id === group.id)),
|
|
159
|
+
} }))),
|
|
160
|
+
g.id && hiddenGroupsIds.includes(g.id) ? (React.createElement(IconButton, { disabled: isLoadingQuery, styleType: 'borderless', className: 'gmw-group-view-icon', onClick: async () => {
|
|
161
|
+
await showGroup(g);
|
|
162
|
+
setHiddenGroupsIds(hiddenGroupsIds.filter((id) => g.id !== id));
|
|
163
|
+
} },
|
|
164
|
+
React.createElement(SvgVisibilityHide, null))) : (React.createElement(IconButton, { disabled: isLoadingQuery, styleType: 'borderless', className: 'gmw-group-view-icon', onClick: async () => {
|
|
165
|
+
await hideGroupsWrapper([g]);
|
|
166
|
+
setHiddenGroupsIds(hiddenGroupsIds.concat(g.id ? [g.id] : []));
|
|
167
|
+
} },
|
|
168
|
+
React.createElement(SvgVisibilityShow, null)))),
|
|
169
|
+
React.createElement(DropdownMenu, { className: 'gmw-custom-ui-dropdown', disabled: isLoadingQuery, menuItems: (close) => [...(groupUIs.length > 0 && onClickGroupModify ?
|
|
170
|
+
[React.createElement(MenuItem, { key: 0, icon: React.createElement(SvgEdit, null), disabled: isLoadingQuery, "data-testid": "gmw-context-menu-item", subMenuItems: groupUIs.map((p, index) => (React.createElement(MenuItem, { key: index, className: 'gmw-menu-item', "data-testid": `gmw-edit-${index}`, onClick: async () => onModify(g, p.name), icon: p.icon }, p.displayLabel))) }, "Edit")] : []),
|
|
171
|
+
...contextUIs.map((p) => {
|
|
172
|
+
return React.createElement(MenuItem, { key: p.name, onClick: async () => {
|
|
173
|
+
showGroupColor && await showGroup(g);
|
|
174
|
+
if (p.uiComponent && onClickRenderContextCustomUI) {
|
|
175
|
+
onClickRenderContextCustomUI(p.uiComponent, g);
|
|
176
|
+
}
|
|
177
|
+
if (p.onClick) {
|
|
178
|
+
p.onClick(g, mapping, iModelId);
|
|
179
|
+
}
|
|
180
|
+
close();
|
|
181
|
+
}, icon: p.icon, "data-testid": "gmw-context-menu-item" }, p.displayLabel);
|
|
182
|
+
}), React.createElement(MenuItem, { key: 2, onClick: () => {
|
|
183
|
+
setSelectedGroup(g);
|
|
184
|
+
setShowDeleteModal(true);
|
|
185
|
+
close();
|
|
186
|
+
}, icon: React.createElement(SvgDelete, null), "data-testid": "gmw-context-menu-item" }, "Remove"),
|
|
187
|
+
] },
|
|
188
|
+
React.createElement(IconButton, { disabled: isLoadingQuery, styleType: 'borderless', "data-testid": "gmw-more-button" },
|
|
189
|
+
React.createElement(SvgMore, null)))), onClickTitle: onClickGroupTitle && !isLoadingQuery ?
|
|
190
|
+
async () => {
|
|
191
|
+
await colorGroup(g);
|
|
192
|
+
onClickGroupTitle(g);
|
|
193
|
+
} : undefined })))))),
|
|
194
|
+
React.createElement(DeleteModal, { entityName: (_a = selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.groupName) !== null && _a !== void 0 ? _a : "", show: showDeleteModal, setShow: setShowDeleteModal, onDelete: async () => {
|
|
195
|
+
var _a;
|
|
196
|
+
const accessToken = await getAccessToken();
|
|
197
|
+
await mappingClient.deleteGroup(accessToken, iModelId, mapping.id, (_a = selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.id) !== null && _a !== void 0 ? _a : "");
|
|
198
|
+
}, refresh: refresh })));
|
|
354
199
|
};
|
|
355
200
|
//# sourceMappingURL=Grouping.js.map
|