@itwin/grouping-mapping-widget 0.32.0 → 0.34.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/WidgetShell/GroupingMapping.d.ts +1 -0
- package/lib/cjs/WidgetShell/GroupingMapping.js +1 -1
- package/lib/cjs/WidgetShell/GroupingMapping.js.map +1 -1
- package/lib/cjs/WidgetShell/GroupingMappingContent.d.ts +2 -1
- package/lib/cjs/WidgetShell/GroupingMappingContent.js +2 -2
- package/lib/cjs/WidgetShell/GroupingMappingContent.js.map +1 -1
- package/lib/cjs/WidgetShell/Router/GroupingMappingRouter.d.ts +2 -1
- package/lib/cjs/WidgetShell/Router/GroupingMappingRouter.js +2 -2
- package/lib/cjs/WidgetShell/Router/GroupingMappingRouter.js.map +1 -1
- package/lib/cjs/components/Groups/Groups.d.ts +2 -1
- package/lib/cjs/components/Groups/Groups.js +2 -2
- package/lib/cjs/components/Groups/Groups.js.map +1 -1
- package/lib/cjs/components/Groups/GroupsView.d.ts +2 -1
- package/lib/cjs/components/Groups/GroupsView.js +4 -3
- package/lib/cjs/components/Groups/GroupsView.js.map +1 -1
- package/lib/cjs/components/Groups/GroupsVisualization.d.ts +1 -2
- package/lib/cjs/components/Groups/GroupsVisualization.js +2 -2
- package/lib/cjs/components/Groups/GroupsVisualization.js.map +1 -1
- package/lib/cjs/components/Groups/QueryBuilder/QueryBuilder.d.ts +7 -3
- package/lib/cjs/components/Groups/QueryBuilder/QueryBuilder.js +41 -12
- package/lib/cjs/components/Groups/QueryBuilder/QueryBuilder.js.map +1 -1
- package/lib/cjs/components/Properties/PropertyAction.js +7 -2
- package/lib/cjs/components/Properties/PropertyAction.js.map +1 -1
- package/lib/cjs/components/customUI/GroupQueryBuilderCustomUI.js +1 -1
- package/lib/cjs/components/customUI/GroupQueryBuilderCustomUI.js.map +1 -1
- package/lib/cjs/test/QueryBuilder.test.js +17 -6
- package/lib/cjs/test/QueryBuilder.test.js.map +1 -1
- package/lib/cjs/test/QueryBuilder.testdata.js +46 -0
- package/lib/cjs/test/QueryBuilder.testdata.js.map +1 -1
- package/lib/cjs/test/QueryBuilderTestData.d.ts +2 -2
- package/lib/cjs/test/QueryBuilderTestData.js.map +1 -1
- package/lib/esm/WidgetShell/GroupingMapping.d.ts +1 -0
- package/lib/esm/WidgetShell/GroupingMapping.js +1 -1
- package/lib/esm/WidgetShell/GroupingMapping.js.map +1 -1
- package/lib/esm/WidgetShell/GroupingMappingContent.d.ts +2 -1
- package/lib/esm/WidgetShell/GroupingMappingContent.js +2 -2
- package/lib/esm/WidgetShell/GroupingMappingContent.js.map +1 -1
- package/lib/esm/WidgetShell/Router/GroupingMappingRouter.d.ts +2 -1
- package/lib/esm/WidgetShell/Router/GroupingMappingRouter.js +2 -2
- package/lib/esm/WidgetShell/Router/GroupingMappingRouter.js.map +1 -1
- package/lib/esm/components/Groups/Groups.d.ts +2 -1
- package/lib/esm/components/Groups/Groups.js +2 -2
- package/lib/esm/components/Groups/Groups.js.map +1 -1
- package/lib/esm/components/Groups/GroupsView.d.ts +2 -1
- package/lib/esm/components/Groups/GroupsView.js +4 -3
- package/lib/esm/components/Groups/GroupsView.js.map +1 -1
- package/lib/esm/components/Groups/GroupsVisualization.d.ts +1 -2
- package/lib/esm/components/Groups/GroupsVisualization.js +2 -2
- package/lib/esm/components/Groups/GroupsVisualization.js.map +1 -1
- package/lib/esm/components/Groups/QueryBuilder/QueryBuilder.d.ts +7 -3
- package/lib/esm/components/Groups/QueryBuilder/QueryBuilder.js +41 -12
- package/lib/esm/components/Groups/QueryBuilder/QueryBuilder.js.map +1 -1
- package/lib/esm/components/Properties/PropertyAction.js +7 -2
- package/lib/esm/components/Properties/PropertyAction.js.map +1 -1
- package/lib/esm/components/customUI/GroupQueryBuilderCustomUI.js +1 -1
- package/lib/esm/components/customUI/GroupQueryBuilderCustomUI.js.map +1 -1
- package/lib/esm/test/QueryBuilder.test.js +17 -6
- package/lib/esm/test/QueryBuilder.test.js.map +1 -1
- package/lib/esm/test/QueryBuilder.testdata.js +46 -0
- package/lib/esm/test/QueryBuilder.testdata.js.map +1 -1
- package/lib/esm/test/QueryBuilderTestData.d.ts +2 -2
- package/lib/esm/test/QueryBuilderTestData.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Groups.js","sourceRoot":"","sources":["../../../../src/components/Groups/Groups.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAI3C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"Groups.js","sourceRoot":"","sources":["../../../../src/components/Groups/Groups.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAI3C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAuB7C;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EACrB,OAAO,EACP,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,4BAA4B,EAC5B,cAAc,EACd,cAAc,EACd,KAAK,EACL,eAAe,EACf,YAAY,EACZ,gCAAgC,EAChC,mBAAmB,GACP,EAAE,EAAE;IAChB,MAAM,EACJ,MAAM,EACN,SAAS,EACT,OAAO,EACP,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,eAAe,EACf,2BAA2B,EAC3B,8BAA8B,EA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AAE,sBAAsB,EAC9C,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,EAC1B,gCAAgC,EAAE,gCAAgC,EAClE,mBAAmB,EAAE,mBAAmB,GACxC,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nimport React, { useCallback } from \"react\";\nimport type { GroupMinimal, Mapping } from \"@itwin/insights-client\";\nimport type { ContextCustomUI } from \"../customUI/GroupingMappingCustomUI\";\nimport type { ActionButtonRenderer, ProgressConfig } from \"./GroupsView\";\nimport { GroupsView } from \"./GroupsView\";\nimport { useGroupsOperations } from \"./hooks/useGroupsOperations\";\nimport { Alert } from \"@itwin/itwinui-react\";\n\n/**\n * Props for the {@link Groups} component.\n * @public\n */\nexport interface GroupsProps {\n mapping: Mapping;\n actionButtonRenderers?: ActionButtonRenderer[];\n onClickAddGroup?: (queryGenerationType: string) => void;\n onClickGroupTitle?: (group: GroupMinimal) => void;\n onClickGroupModify?: (group: GroupMinimal, queryGenerationType: string) => void;\n onClickRenderContextCustomUI?: (contextCustomUI: Exclude<ContextCustomUI[\"uiComponent\"], undefined>, group: GroupMinimal, displayLabel: string) => void;\n disableActions?: boolean;\n isVisualizing?: boolean;\n progressConfig?: ProgressConfig;\n alert?: React.ReactElement<typeof Alert>;\n hideRefreshIcon?: boolean;\n groupsAction?: JSX.Element;\n deleteConfirmationContentFactory?: (group: GroupMinimal) => JSX.Element;\n groupDeleteCallback?: (group: GroupMinimal) => void;\n}\n\n/**\n * Component to list groups and handle basic operations.\n * @public\n */\nexport const Groups = ({\n mapping,\n actionButtonRenderers,\n onClickAddGroup,\n onClickGroupTitle,\n onClickGroupModify,\n onClickRenderContextCustomUI,\n disableActions,\n progressConfig,\n alert,\n hideRefreshIcon,\n groupsAction,\n deleteConfirmationContentFactory,\n groupDeleteCallback,\n}: GroupsProps) => {\n const {\n groups,\n isLoading,\n refresh,\n onDeleteGroup,\n setShowDeleteModal,\n showDeleteModal,\n groupUIs,\n contextUIs,\n errorMessage,\n setErrorMessage,\n activeOverlapInfoPanelGroup,\n setActiveOverlapInfoPanelGroup,\n overlappedElementsInfo,\n } = useGroupsOperations({ mappingId: mapping.id });\n\n const addGroup = useCallback(\n (type: string) => {\n if (!onClickAddGroup) return;\n onClickAddGroup(type);\n },\n [onClickAddGroup],\n );\n\n const renderAlert = useCallback(() => {\n if (!errorMessage) {\n return alert;\n }\n return (\n <Alert type=\"negative\" onClose={() => setErrorMessage(undefined)}>\n {errorMessage}\n </Alert>\n );\n }, [alert, errorMessage, setErrorMessage]);\n\n return (\n <GroupsView\n mapping={mapping}\n groups={groups ?? []}\n isLoading={isLoading}\n onRefresh={refresh}\n groupUIs={groupUIs}\n actionButtonRenderers={actionButtonRenderers}\n onClickAddGroup={addGroup}\n onClickGroupTitle={onClickGroupTitle}\n onClickGroupModify={onClickGroupModify}\n onClickRenderContextCustomUI={onClickRenderContextCustomUI}\n disableActions={disableActions}\n selectedGroupForDeletion={showDeleteModal}\n setSelectedGroupForDeletion={setShowDeleteModal}\n onDeleteGroup={onDeleteGroup}\n onCloseDeleteModal={() => setShowDeleteModal(undefined)}\n contextUIs={contextUIs}\n progressConfig={progressConfig}\n alert={renderAlert()}\n setActiveOverlapInfoPanelGroup={setActiveOverlapInfoPanelGroup}\n activeOverlapInfoPanelGroup={activeOverlapInfoPanelGroup}\n overlappedElementsInfo={overlappedElementsInfo}\n hideRefreshIcon={hideRefreshIcon}\n groupsAction={groupsAction}\n deleteConfirmationContentFactory={deleteConfirmationContentFactory}\n groupDeleteCallback={groupDeleteCallback}\n />\n );\n};\n"]}
|
|
@@ -43,6 +43,7 @@ export interface GroupsViewProps {
|
|
|
43
43
|
overlappedElementsInfo?: Map<string, OverlappedInfo[]>;
|
|
44
44
|
progressConfig?: ProgressConfig;
|
|
45
45
|
hideRefreshIcon?: boolean;
|
|
46
|
+
groupsAction?: JSX.Element;
|
|
46
47
|
deleteConfirmationContentFactory?: (group: GroupMinimal) => JSX.Element;
|
|
47
48
|
groupDeleteCallback?: (group: GroupMinimal) => void;
|
|
48
49
|
}
|
|
@@ -50,5 +51,5 @@ export interface GroupsViewProps {
|
|
|
50
51
|
* Component to list groups.
|
|
51
52
|
* @internal
|
|
52
53
|
*/
|
|
53
|
-
export declare const GroupsView: ({ mapping, groups, isLoading, onRefresh, groupUIs, actionButtonRenderers, onClickAddGroup, onClickGroupTitle, onClickGroupModify, onClickRenderContextCustomUI, disableActions, selectedGroupForDeletion, onDeleteGroup, onCloseDeleteModal, setSelectedGroupForDeletion, contextUIs, alert, setActiveOverlapInfoPanelGroup, activeOverlapInfoPanelGroup, overlappedElementsInfo, progressConfig, hideRefreshIcon, deleteConfirmationContentFactory, groupDeleteCallback, }: GroupsViewProps) => JSX.Element;
|
|
54
|
+
export declare const GroupsView: ({ mapping, groups, isLoading, onRefresh, groupUIs, actionButtonRenderers, onClickAddGroup, onClickGroupTitle, onClickGroupModify, onClickRenderContextCustomUI, disableActions, selectedGroupForDeletion, onDeleteGroup, onCloseDeleteModal, setSelectedGroupForDeletion, contextUIs, alert, setActiveOverlapInfoPanelGroup, activeOverlapInfoPanelGroup, overlappedElementsInfo, progressConfig, hideRefreshIcon, groupsAction, deleteConfirmationContentFactory, groupDeleteCallback, }: GroupsViewProps) => JSX.Element;
|
|
54
55
|
//# sourceMappingURL=GroupsView.d.ts.map
|
|
@@ -16,7 +16,7 @@ import { OverlappedElementsInformationPanel } from "./OverlappedElementsInformat
|
|
|
16
16
|
* Component to list groups.
|
|
17
17
|
* @internal
|
|
18
18
|
*/
|
|
19
|
-
export const GroupsView = ({ mapping, groups, isLoading, onRefresh, groupUIs, actionButtonRenderers, onClickAddGroup, onClickGroupTitle, onClickGroupModify, onClickRenderContextCustomUI, disableActions, selectedGroupForDeletion, onDeleteGroup, onCloseDeleteModal, setSelectedGroupForDeletion, contextUIs, alert, setActiveOverlapInfoPanelGroup, activeOverlapInfoPanelGroup, overlappedElementsInfo, progressConfig, hideRefreshIcon, deleteConfirmationContentFactory, groupDeleteCallback, }) => {
|
|
19
|
+
export const GroupsView = ({ mapping, groups, isLoading, onRefresh, groupUIs, actionButtonRenderers, onClickAddGroup, onClickGroupTitle, onClickGroupModify, onClickRenderContextCustomUI, disableActions, selectedGroupForDeletion, onDeleteGroup, onCloseDeleteModal, setSelectedGroupForDeletion, contextUIs, alert, setActiveOverlapInfoPanelGroup, activeOverlapInfoPanelGroup, overlappedElementsInfo, progressConfig, hideRefreshIcon, groupsAction, deleteConfirmationContentFactory, groupDeleteCallback, }) => {
|
|
20
20
|
/**
|
|
21
21
|
* UX Progress Bar Logic:
|
|
22
22
|
* - Start non-zero for immediate feedback.
|
|
@@ -28,8 +28,9 @@ export const GroupsView = ({ mapping, groups, isLoading, onRefresh, groupUIs, ac
|
|
|
28
28
|
return (React.createElement(InformationPanelWrapper, { className: "gmw-groups-container" },
|
|
29
29
|
React.createElement("div", { className: "gmw-toolbar" },
|
|
30
30
|
onClickAddGroup && groupUIs.length > 0 && React.createElement(GroupsAddButton, { disabled: disableActions, groupUIs: groupUIs, onClickAddGroup: onClickAddGroup }),
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
React.createElement(ButtonGroup, { className: "gmw-toolbar-buttons" },
|
|
32
|
+
groupsAction,
|
|
33
|
+
!hideRefreshIcon && (React.createElement(IconButton, { title: "Refresh", onClick: onRefresh, disabled: isLoading || disableActions, styleType: "borderless" },
|
|
33
34
|
React.createElement(SvgRefresh, null))))),
|
|
34
35
|
alert,
|
|
35
36
|
React.createElement("div", { className: "gmw-groups-border" }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupsView.js","sourceRoot":"","sources":["../../../../src/components/Groups/GroupsView.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAA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C,CAAC,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CACxB,oBAAC,YAAY,IAAC,OAAO,EAAC,sBAAsB,GAAG,CAChD,CAAC,CAAC,CAAC,CACF,oBAAC,IAAI,IAAC,SAAS,EAAC,gBAAgB,IAC7B,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACrB,oBAAC,aAAa,IACZ,GAAG,EAAE,KAAK,CAAC,EAAE,EACb,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,qBAAqB,EAAE,qBAAqB,EAC5C,iBAAiB,EAAE,iBAAiB,EACpC,kBAAkB,EAAE,kBAAkB,EACtC,4BAA4B,EAAE,4BAA4B,EAC1D,cAAc,EAAE,cAAc,EAC9B,kBAAkB,EAAE,2BAA2B,EAC/C,UAAU,EAAE,UAAU,EACtB,8BAA8B,EAAE,8BAA8B,GAC9D,CACH,CAAC,CACG,CACR;QACA,sBAAsB,IAAI,8BAA8B,IAAI,CAC3D,oBAAC,kCAAkC,IACjC,KAAK,EAAE,2BAA2B,EAClC,OAAO,EAAE,GAAG,EAAE,CAAC,8BAA8B,CAAC,SAAS,CAAC,EACxD,sBAAsB,EAAE,sBAAsB,EAC9C,MAAM,EAAE,MAAM,GACd,CACH;QACA,wBAAwB,IAAI,CAC3B,oBAAC,WAAW,IACV,UAAU,EAAE,wBAAwB,CAAC,SAAS,EAC9C,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,KAAK,IAAI,EAAE;gBACnB,MAAM,aAAa,CAAC,wBAAwB,CAAC,CAAC;gBAC9C,mBAAmB,EAAE,CAAC,wBAAwB,CAAC,CAAC;YAClD,CAAC,EACD,mBAAmB,EAAE,gCAAgC,EAAE,CAAC,wBAAwB,CAAC,GACjF,CACH,CACuB,CAC3B,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nimport React from \"react\";\nimport type { Alert } from \"@itwin/itwinui-react\";\nimport { ButtonGroup, IconButton, InformationPanelWrapper, List, ProgressLinear } from \"@itwin/itwinui-react\";\nimport { SvgRefresh } from \"@itwin/itwinui-icons-react\";\nimport DeleteModal from \"../SharedComponents/DeleteModal\";\nimport \"./GroupsView.scss\";\nimport { EmptyMessage } from \"../SharedComponents/EmptyMessage\";\nimport { LoadingOverlay } from \"../SharedComponents/LoadingOverlay\";\nimport type { GroupMinimal, Mapping } from \"@itwin/insights-client\";\nimport { GroupListItem } from \"./GroupListItem\";\nimport type { ContextCustomUI, GroupingCustomUI } from \"../customUI/GroupingMappingCustomUI\";\nimport { GroupsAddButton } from \"./GroupsAddButton\";\nimport { OverlappedElementsInformationPanel } from \"./OverlappedElementsInformationPanel\";\nimport type { OverlappedInfo } from \"../context/GroupHilitedElementsContext\";\n\nexport interface ActionButtonRendererProps {\n group: GroupMinimal;\n}\n\nexport type ActionButtonRenderer = (props: ActionButtonRendererProps) => React.ReactNode;\n\nexport interface ProgressConfig {\n hilitedGroupsProgress?: {\n currentHilitedGroups: number;\n totalNumberOfGroups: number;\n };\n baseProgress?: number;\n maxDynamicProgress?: number;\n}\n\n/**\n * Props for the {@link GroupsView} component.\n * @internal\n */\nexport interface GroupsViewProps {\n mapping: Mapping;\n groups: GroupMinimal[];\n isLoading: boolean;\n onRefresh: () => Promise<void>;\n groupUIs: GroupingCustomUI[];\n actionButtonRenderers?: ActionButtonRenderer[];\n contextUIs: ContextCustomUI[];\n onClickAddGroup?: (queryGenerationType: string) => void;\n onClickGroupTitle?: (group: GroupMinimal) => void;\n onClickGroupModify?: (group: GroupMinimal, queryGenerationType: string) => void;\n onClickRenderContextCustomUI?: (contextCustomUI: Exclude<ContextCustomUI[\"uiComponent\"], undefined>, group: GroupMinimal, displayLabel: string) => void;\n disableActions?: boolean;\n selectedGroupForDeletion?: GroupMinimal;\n setSelectedGroupForDeletion: (group: GroupMinimal) => void;\n onDeleteGroup: (group: GroupMinimal) => Promise<void>;\n onCloseDeleteModal: () => void;\n alert?: React.ReactElement<typeof Alert>;\n setActiveOverlapInfoPanelGroup?: (activeOverlapInfoPanelGroup: GroupMinimal | undefined) => void;\n activeOverlapInfoPanelGroup?: GroupMinimal | undefined;\n overlappedElementsInfo?: Map<string, OverlappedInfo[]>;\n progressConfig?: ProgressConfig;\n hideRefreshIcon?: boolean;\n groupsAction?: JSX.Element;\n deleteConfirmationContentFactory?: (group: GroupMinimal) => JSX.Element;\n groupDeleteCallback?: (group: GroupMinimal) => void;\n}\n\n/**\n * Component to list groups.\n * @internal\n */\nexport const GroupsView = ({\n mapping,\n groups,\n isLoading,\n onRefresh,\n groupUIs,\n actionButtonRenderers,\n onClickAddGroup,\n onClickGroupTitle,\n onClickGroupModify,\n onClickRenderContextCustomUI,\n disableActions,\n selectedGroupForDeletion,\n onDeleteGroup,\n onCloseDeleteModal,\n setSelectedGroupForDeletion,\n contextUIs,\n alert,\n setActiveOverlapInfoPanelGroup,\n activeOverlapInfoPanelGroup,\n overlappedElementsInfo,\n progressConfig,\n hideRefreshIcon,\n groupsAction,\n deleteConfirmationContentFactory,\n groupDeleteCallback,\n}: GroupsViewProps) => {\n /**\n * UX Progress Bar Logic:\n * - Start non-zero for immediate feedback.\n * - Restrict motion to a range (e.g., 25-90%) for perceived continuity.\n * - Disappear when complete.\n * Goal: Smooth experience for unpredictable durations.\n */\n const { baseProgress = 25, maxDynamicProgress = 65, hilitedGroupsProgress } = progressConfig || {};\n\n return (\n <InformationPanelWrapper className=\"gmw-groups-container\">\n <div className=\"gmw-toolbar\">\n {onClickAddGroup && groupUIs.length > 0 && <GroupsAddButton disabled={disableActions} groupUIs={groupUIs} onClickAddGroup={onClickAddGroup} />}\n {\n <ButtonGroup className=\"gmw-toolbar-buttons\">\n {groupsAction}\n {!hideRefreshIcon && (\n <IconButton title=\"Refresh\" onClick={onRefresh} disabled={isLoading || disableActions} styleType=\"borderless\">\n <SvgRefresh />\n </IconButton>\n )}\n </ButtonGroup>\n }\n </div>\n {alert}\n <div className=\"gmw-groups-border\" />\n {!!hilitedGroupsProgress && (\n <div className=\"gmw-group-progress-bar\" title=\"Getting visualization ready\">\n <ProgressLinear\n value={baseProgress + (hilitedGroupsProgress.currentHilitedGroups / hilitedGroupsProgress.totalNumberOfGroups) * maxDynamicProgress}\n />\n </div>\n )}\n {isLoading ? (\n <LoadingOverlay />\n ) : groups.length === 0 ? (\n <EmptyMessage message=\"No Groups available.\" />\n ) : (\n <List className=\"gmw-group-list\">\n {groups.map((group) => (\n <GroupListItem\n key={group.id}\n mapping={mapping}\n group={group}\n groupUIs={groupUIs}\n actionButtonRenderers={actionButtonRenderers}\n onClickGroupTitle={onClickGroupTitle}\n onClickGroupModify={onClickGroupModify}\n onClickRenderContextCustomUI={onClickRenderContextCustomUI}\n disableActions={disableActions}\n setShowDeleteModal={setSelectedGroupForDeletion}\n contextUIs={contextUIs}\n setActiveOverlapInfoPanelGroup={setActiveOverlapInfoPanelGroup}\n />\n ))}\n </List>\n )}\n {overlappedElementsInfo && setActiveOverlapInfoPanelGroup && (\n <OverlappedElementsInformationPanel\n group={activeOverlapInfoPanelGroup}\n onClose={() => setActiveOverlapInfoPanelGroup(undefined)}\n overlappedElementsInfo={overlappedElementsInfo}\n groups={groups}\n />\n )}\n {selectedGroupForDeletion && (\n <DeleteModal\n entityName={selectedGroupForDeletion.groupName}\n onClose={onCloseDeleteModal}\n onDelete={async () => {\n await onDeleteGroup(selectedGroupForDeletion);\n groupDeleteCallback?.(selectedGroupForDeletion);\n }}\n confirmationMessage={deleteConfirmationContentFactory?.(selectedGroupForDeletion)}\n />\n )}\n </InformationPanelWrapper>\n );\n};\n"]}
|
|
@@ -10,7 +10,6 @@ export interface GroupsVisualizationProps extends GroupsProps {
|
|
|
10
10
|
isNonEmphasizedSelectable?: boolean;
|
|
11
11
|
emphasizeElements?: boolean;
|
|
12
12
|
hideVisualizationToggle?: boolean;
|
|
13
|
-
hideRefreshIcon?: boolean;
|
|
14
13
|
deleteConfirmationContentFactory?: (group: GroupMinimal) => JSX.Element;
|
|
15
14
|
groupDeleteCallback?: (group: GroupMinimal) => void;
|
|
16
15
|
disableZoom?: boolean;
|
|
@@ -19,5 +18,5 @@ export interface GroupsVisualizationProps extends GroupsProps {
|
|
|
19
18
|
* Component to visualize groups and their elements.
|
|
20
19
|
* @public
|
|
21
20
|
*/
|
|
22
|
-
export declare const GroupsVisualization: ({ emphasizeElements, isNonEmphasizedSelectable, onClickGroupModify, onClickAddGroup, mapping, hideVisualizationToggle, hideRefreshIcon, deleteConfirmationContentFactory, groupDeleteCallback, disableZoom, ...rest }: GroupsVisualizationProps) => JSX.Element;
|
|
21
|
+
export declare const GroupsVisualization: ({ emphasizeElements, isNonEmphasizedSelectable, onClickGroupModify, onClickAddGroup, mapping, hideVisualizationToggle, hideRefreshIcon, groupsAction, deleteConfirmationContentFactory, groupDeleteCallback, disableZoom, ...rest }: GroupsVisualizationProps) => JSX.Element;
|
|
23
22
|
//# sourceMappingURL=GroupsVisualization.d.ts.map
|
|
@@ -19,7 +19,7 @@ import { useGroupsClient } from "../context/GroupsClientContext";
|
|
|
19
19
|
* Component to visualize groups and their elements.
|
|
20
20
|
* @public
|
|
21
21
|
*/
|
|
22
|
-
export const GroupsVisualization = ({ emphasizeElements = true, isNonEmphasizedSelectable = false, onClickGroupModify, onClickAddGroup, mapping, hideVisualizationToggle, hideRefreshIcon, deleteConfirmationContentFactory, groupDeleteCallback, disableZoom, ...rest }) => {
|
|
22
|
+
export const GroupsVisualization = ({ emphasizeElements = true, isNonEmphasizedSelectable = false, onClickGroupModify, onClickAddGroup, mapping, hideVisualizationToggle, hideRefreshIcon, groupsAction, deleteConfirmationContentFactory, groupDeleteCallback, disableZoom, ...rest }) => {
|
|
23
23
|
const { iModelConnection } = useGroupingMappingApiConfig();
|
|
24
24
|
if (!iModelConnection) {
|
|
25
25
|
throw new Error("This component requires an active iModelConnection.");
|
|
@@ -202,6 +202,6 @@ export const GroupsVisualization = ({ emphasizeElements = true, isNonEmphasizedS
|
|
|
202
202
|
: undefined, [groupQueriesProgressCount, groups, isResolvingGroupQueries, isVisualizationsEnabled]);
|
|
203
203
|
return (React.createElement("div", { className: "gmw-groups-vis-container" },
|
|
204
204
|
React.createElement(GroupVisualizationActions, { disabled: !(isVisualizationsEnabled && isGroupsFetched && isGroupsQueriesReady), isVisualizationEnabled: isVisualizationsEnabled, onClickVisualizationButton: () => setIsVisualizationsEnabled((b) => !b), showAll: showAll, hideAll: hideAll, hideVisualizationToggle: hideVisualizationToggle }),
|
|
205
|
-
React.createElement(Groups, { onClickGroupModify: onModify, onClickAddGroup: onAddGroup, actionButtonRenderers: groupActionButtonRenderers, mapping: mapping, ...rest, progressConfig: progressConfig, alert: overlappedAlert, hideRefreshIcon: hideRefreshIcon, deleteConfirmationContentFactory: deleteConfirmationContentFactory, groupDeleteCallback: groupDeleteCallback })));
|
|
205
|
+
React.createElement(Groups, { onClickGroupModify: onModify, onClickAddGroup: onAddGroup, actionButtonRenderers: groupActionButtonRenderers, mapping: mapping, ...rest, progressConfig: progressConfig, alert: overlappedAlert, hideRefreshIcon: hideRefreshIcon, groupsAction: groupsAction, deleteConfirmationContentFactory: deleteConfirmationContentFactory, groupDeleteCallback: groupDeleteCallback })));
|
|
206
206
|
};
|
|
207
207
|
//# sourceMappingURL=GroupsVisualization.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupsVisualization.js","sourceRoot":"","sources":["../../../../src/components/Groups/GroupsVisualization.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AACxF,OAAO,EAAE,wBAAwB,EAAE,a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,EAAE,CAAC,CAAC,uBAAuB,IAAI,eAAe,IAAI,oBAAoB,CAAC,EAC/E,sBAAsB,EAAE,uBAAuB,EAC/C,0BAA0B,EAAE,GAAG,EAAE,CAAC,0BAA0B,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EACvE,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,uBAAuB,EAAE,uBAAuB,GAChD;QACF,oBAAC,MAAM,IACL,kBAAkB,EAAE,QAAQ,EAC5B,eAAe,EAAE,UAAU,EAC3B,qBAAqB,EAAE,0BAA0B,EACjD,OAAO,EAAE,OAAO,KACZ,IAAI,EACR,cAAc,EAAE,cAAc,EAC9B,KAAK,EAAE,eAAe,EACtB,eAAe,EAAE,eAAe,EAChC,gCAAgC,EAAE,gCAAgC,EAClE,mBAAmB,EAAE,mBAAmB,GACxC,CACE,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nimport type { GroupMinimal } from \"@itwin/insights-client\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport type { OverlappedElementGroupPairs } from \"../context/GroupHilitedElementsContext\";\nimport { useGroupHilitedElementsContext } from \"../context/GroupHilitedElementsContext\";\nimport { generateOverlappedGroups, getGroupColor, hideGroupConsideringOverlaps, hideGroupIds, visualizeGroupColors } from \"./groupsHelpers\";\nimport { clearEmphasizedElements, clearEmphasizedOverriddenElements, clearHiddenElements, hideElements, zoomToElements } from \"../../common/viewerUtils\";\nimport type { GroupsProps } from \"./Groups\";\nimport { Groups } from \"./Groups\";\nimport { GroupColorLegend } from \"./GroupColorLegend\";\nimport { GroupVisualizationActions } from \"./GroupsVisualizationActions\";\nimport { GroupsShowHideButtons } from \"./GroupsShowHideButtons\";\nimport \"./GroupsVisualization.scss\";\nimport { useGroupingMappingApiConfig } from \"../context/GroupingApiConfigContext\";\nimport type { ActionButtonRenderer, ActionButtonRendererProps } from \"./GroupsView\";\nimport { Alert, Icon, Text } from \"@itwin/itwinui-react\";\nimport { SvgMore } from \"@itwin/itwinui-icons-react\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useIsMounted } from \"../../common/hooks/useIsMounted\";\nimport { useFetchGroups } from \"./hooks/useFetchGroups\";\nimport { useKeySetHiliteQueries } from \"./hooks/useKeySetHiliteQueries\";\nimport { useGroupsClient } from \"../context/GroupsClientContext\";\n\n/**\n * Props for the {@link GroupsVisualization} component.\n * @public\n */\nexport interface GroupsVisualizationProps extends GroupsProps {\n isNonEmphasizedSelectable?: boolean;\n emphasizeElements?: boolean;\n hideVisualizationToggle?: boolean;\n hideRefreshIcon?: boolean;\n deleteConfirmationContentFactory?: (group: GroupMinimal) => JSX.Element;\n groupDeleteCallback?: (group: GroupMinimal) => void;\n disableZoom?: boolean;\n}\n\n/**\n * Component to visualize groups and their elements.\n * @public\n */\nexport const GroupsVisualization = ({\n emphasizeElements = true,\n isNonEmphasizedSelectable = false,\n onClickGroupModify,\n onClickAddGroup,\n mapping,\n hideVisualizationToggle,\n hideRefreshIcon,\n deleteConfirmationContentFactory,\n groupDeleteCallback,\n disableZoom,\n ...rest\n}: GroupsVisualizationProps) => {\n const { iModelConnection } = useGroupingMappingApiConfig();\n if (!iModelConnection) {\n throw new Error(\"This component requires an active iModelConnection.\");\n }\n const [isAlertClosed, setIsAlertClosed] = useState<boolean>(true);\n const [isAlertExpanded, setIsAlertExpanded] = useState<boolean>(false);\n const {\n hiddenGroupsIds,\n showGroupColor,\n setShowGroupColor,\n isOverlappedColored,\n setHiddenGroupsIds,\n setNumberOfVisualizedGroups,\n isVisualizationsEnabled,\n setIsVisualizationsEnabled,\n overlappedElementsMetadata,\n setOverlappedElementsMetadata,\n groupColors,\n setGroupColors,\n } = useGroupHilitedElementsContext();\n const { getAccessToken } = useGroupingMappingApiConfig();\n const groupsClient = useGroupsClient();\n const { data: groups, isFetched: isGroupsFetched, isFetching: isGroupsFetching } = useFetchGroups(mapping.id, getAccessToken, groupsClient);\n const isMounted = useIsMounted();\n const [enableGroupQueries, setEnableGroupQueries] = useState<boolean>(false);\n const { groupQueries } = useKeySetHiliteQueries(groups ?? [], enableGroupQueries, iModelConnection);\n\n const triggerVisualization = useCallback(\n async (groupsWithGroupedOverlaps: OverlappedElementGroupPairs[]) =>\n visualizeGroupColors(hiddenGroupsIds, groupsWithGroupedOverlaps, setNumberOfVisualizedGroups, emphasizeElements),\n [emphasizeElements, hiddenGroupsIds, setNumberOfVisualizedGroups],\n );\n\n const zoomToElementsMutation = useMutation({\n mutationFn: zoomToElements,\n onSuccess: () => {\n if (isMounted) {\n isNonEmphasizedSelectable && clearEmphasizedElements();\n }\n },\n });\n\n const visualizationMutation = useMutation({\n mutationFn: triggerVisualization,\n onSuccess: (allIds) => {\n if (isMounted && !disableZoom) {\n zoomToElementsMutation.mutate(allIds);\n }\n },\n });\n\n const isGroupsQueriesReady = useMemo(() => groupQueries.every((query) => query.isFetched && query.data) && groupQueries.length > 0, [groupQueries]);\n const groupQueriesProgressCount = useMemo(() => groupQueries.filter((query) => query.isFetched).length, [groupQueries]);\n const isResolvingGroupQueries = useMemo(() => groupQueries.some((query) => query.isFetching), [groupQueries]);\n\n const hiliteIds = useMemo(() => {\n if (!isGroupsQueriesReady || !groups) return [];\n\n // Map to track which groups have been processed for each query to ensure unique associations between groups and queries\n const processedGroupIds = new Map<string, string[]>();\n\n return groupQueries.flatMap((query) => {\n // Find all groups that match the current query and haven't been processed yet for this query\n const matchingGroups = groups.filter((group) => {\n const isMatch = group.query === query.data!.query;\n const isProcessed = processedGroupIds.get(query.data!.query)?.includes(group.id);\n return isMatch && !isProcessed;\n });\n\n matchingGroups.forEach((group) => {\n const existingGroupIds = processedGroupIds.get(query.data!.query);\n if (existingGroupIds) {\n existingGroupIds.push(group.id);\n } else {\n processedGroupIds.set(query.data!.query, [group.id]);\n }\n });\n\n // Map each matching group to an object with groupId and elementIds\n return matchingGroups.map((group) => ({\n groupId: group.id,\n elementIds: query.data!.result.ids,\n }));\n });\n }, [groupQueries, isGroupsQueriesReady, groups]);\n\n const getHiliteIdsFromGroupsWrapper = useCallback(\n (groups: GroupMinimal[]) => hiliteIds.filter((id) => groups.some((group) => group.id === id.groupId)).flatMap((id) => id.elementIds),\n [hiliteIds],\n );\n\n useEffect(() => {\n const processOverlappedGroups = async () => {\n const results = generateOverlappedGroups(hiliteIds);\n const { groupsWithGroupedOverlaps, overlappedElementsInfo, numberOfElementsInGroups } = results;\n\n setOverlappedElementsMetadata({\n overlappedElementsInfo,\n groupElementsInfo: numberOfElementsInGroups,\n overlappedElementGroupPairs: groupsWithGroupedOverlaps,\n });\n\n if (showGroupColor) {\n await visualizationMutation.mutateAsync(groupsWithGroupedOverlaps);\n } else {\n clearEmphasizedOverriddenElements();\n }\n\n clearHiddenElements();\n hideGroupIds(hiddenGroupsIds, groupsWithGroupedOverlaps);\n };\n\n const shouldProcessOverlappedGroups = () => !isOverlappedColored && hiliteIds.length > 0 && !isGroupsFetching;\n\n if (shouldProcessOverlappedGroups()) {\n void processOverlappedGroups();\n }\n // We don't want to trigger full visualization when toggling individual groups.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [showGroupColor, isOverlappedColored, hiliteIds]);\n\n useEffect(() => {\n if (isVisualizationsEnabled) {\n setEnableGroupQueries(true);\n } else {\n setShowGroupColor(false);\n clearHiddenElements();\n setHiddenGroupsIds(new Set());\n }\n }, [isVisualizationsEnabled, setHiddenGroupsIds, setIsVisualizationsEnabled, setShowGroupColor]);\n\n useEffect(() => {\n if (hideVisualizationToggle) {\n setIsVisualizationsEnabled(true);\n }\n }, [hideVisualizationToggle, setIsVisualizationsEnabled]);\n\n const hideAllGroups = useCallback(() => {\n if (!groups) return;\n hideElements(getHiliteIdsFromGroupsWrapper(groups));\n }, [getHiliteIdsFromGroupsWrapper, groups]);\n\n const hideSingleGroupWrapper = useCallback(\n (groupToHide: GroupMinimal) => {\n hideGroupConsideringOverlaps(overlappedElementsMetadata.overlappedElementGroupPairs, groupToHide.id, hiddenGroupsIds);\n },\n [hiddenGroupsIds, overlappedElementsMetadata.overlappedElementGroupPairs],\n );\n\n const showGroup = useCallback(\n (viewGroup: GroupMinimal) => {\n if (!groups) return;\n clearHiddenElements();\n\n // hide group Ids filter\n const newHiddenGroups: GroupMinimal[] = groups.filter((g) => hiddenGroupsIds.has(g.id) && g.id !== viewGroup.id);\n\n // view group Ids filter\n const viewGroups = groups.filter((g) => !hiddenGroupsIds.has(g.id) || g.id === viewGroup.id);\n const viewIds = getHiliteIdsFromGroupsWrapper(viewGroups);\n\n let hiddenIds = getHiliteIdsFromGroupsWrapper(newHiddenGroups);\n hiddenIds = hiddenIds.filter((id) => !viewIds.includes(id));\n hideElements(hiddenIds);\n },\n [groups, hiddenGroupsIds, getHiliteIdsFromGroupsWrapper],\n );\n\n const showAll = useCallback(() => {\n clearHiddenElements();\n setHiddenGroupsIds(new Set());\n }, [setHiddenGroupsIds]);\n\n const hideAll = useCallback(() => {\n if (!groups) return;\n hideAllGroups();\n setHiddenGroupsIds(new Set(groups.map((g) => g.id)));\n }, [setHiddenGroupsIds, groups, hideAllGroups]);\n\n const onModify = useCallback(\n (group: GroupMinimal, type: string) => {\n if (!onClickGroupModify) return;\n if (group.id && hiddenGroupsIds.has(group.id)) {\n showGroup(group);\n setHiddenGroupsIds(new Set([...hiddenGroupsIds].filter((id) => id !== group.id)));\n }\n clearEmphasizedElements();\n onClickGroupModify(group, type);\n },\n [hiddenGroupsIds, onClickGroupModify, setHiddenGroupsIds, showGroup],\n );\n\n const onAddGroup = useCallback(\n (type: string) => {\n if (!onClickAddGroup) return;\n onClickAddGroup(type);\n clearEmphasizedElements();\n },\n [onClickAddGroup],\n );\n\n useEffect(() => {\n if (isGroupsFetched) {\n setGroupColors(new Map(groups?.map((g, i) => [g.id, getGroupColor(i)]) ?? []));\n }\n }, [groups, isGroupsFetched, setGroupColors]);\n\n const groupActionButtonRenderers: ActionButtonRenderer[] = useMemo(\n () =>\n isVisualizationsEnabled\n ? [\n (props: ActionButtonRendererProps) => (showGroupColor ? <GroupColorLegend backgroundColor={groupColors.get(props.group.id) ?? \"\"} /> : []),\n (props: ActionButtonRendererProps) => (\n <GroupsShowHideButtons\n {...props}\n isLoadingQuery={!(isVisualizationsEnabled && isGroupsFetched && isGroupsQueriesReady)}\n showGroup={showGroup}\n hideGroup={hideSingleGroupWrapper}\n />\n ),\n ].flat()\n : [],\n [hideSingleGroupWrapper, isGroupsFetched, isGroupsQueriesReady, isVisualizationsEnabled, showGroup, showGroupColor, groupColors],\n );\n\n const overlappedAlert = useMemo(\n () =>\n overlappedElementsMetadata.overlappedElementsInfo.size > 0 && isAlertClosed && showGroupColor ? (\n <Alert\n onClose={() => setIsAlertClosed(false)}\n clickableText={isAlertExpanded ? \"Less Details\" : \"More Details\"}\n clickableTextProps={{ onClick: () => setIsAlertExpanded(!isAlertExpanded) }}\n >\n Overlapping elements are colored <Text className=\"gmw-red-text\">red</Text> in the viewer.\n {isAlertExpanded ? (\n <>\n <br />\n To get overlap info in detail, click the{\" \"}\n <Icon>\n <SvgMore />\n </Icon>{\" \"}\n button then “Overlap Info”\n </>\n ) : undefined}\n </Alert>\n ) : undefined,\n [isAlertClosed, isAlertExpanded, overlappedElementsMetadata.overlappedElementsInfo.size, showGroupColor],\n );\n\n const progressConfig = useMemo(\n () =>\n isVisualizationsEnabled && isResolvingGroupQueries\n ? {\n hilitedGroupsProgress: {\n currentHilitedGroups: groupQueriesProgressCount,\n totalNumberOfGroups: groups?.length ?? 0,\n },\n }\n : undefined,\n [groupQueriesProgressCount, groups, isResolvingGroupQueries, isVisualizationsEnabled],\n );\n\n return (\n <div className=\"gmw-groups-vis-container\">\n <GroupVisualizationActions\n disabled={!(isVisualizationsEnabled && isGroupsFetched && isGroupsQueriesReady)}\n isVisualizationEnabled={isVisualizationsEnabled}\n onClickVisualizationButton={() => setIsVisualizationsEnabled((b) => !b)}\n showAll={showAll}\n hideAll={hideAll}\n hideVisualizationToggle={hideVisualizationToggle}\n />\n <Groups\n onClickGroupModify={onModify}\n onClickAddGroup={onAddGroup}\n actionButtonRenderers={groupActionButtonRenderers}\n mapping={mapping}\n {...rest}\n progressConfig={progressConfig}\n alert={overlappedAlert}\n hideRefreshIcon={hideRefreshIcon}\n deleteConfirmationContentFactory={deleteConfirmationContentFactory}\n groupDeleteCallback={groupDeleteCallback}\n />\n </div>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"GroupsVisualization.js","sourceRoot":"","sources":["../../../../src/components/Groups/GroupsVisualization.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AACxF,OAAO,EAAE,wBAAwB,EAAE,aAAa,EAAE,4BAA4B,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5I,OAAO,EAAE,uBAAuB,EAAE,iCAAiC,EAAE,mBAAmB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEzJ,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAElF,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,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CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nimport type { GroupMinimal } from \"@itwin/insights-client\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport type { OverlappedElementGroupPairs } from \"../context/GroupHilitedElementsContext\";\nimport { useGroupHilitedElementsContext } from \"../context/GroupHilitedElementsContext\";\nimport { generateOverlappedGroups, getGroupColor, hideGroupConsideringOverlaps, hideGroupIds, visualizeGroupColors } from \"./groupsHelpers\";\nimport { clearEmphasizedElements, clearEmphasizedOverriddenElements, clearHiddenElements, hideElements, zoomToElements } from \"../../common/viewerUtils\";\nimport type { GroupsProps } from \"./Groups\";\nimport { Groups } from \"./Groups\";\nimport { GroupColorLegend } from \"./GroupColorLegend\";\nimport { GroupVisualizationActions } from \"./GroupsVisualizationActions\";\nimport { GroupsShowHideButtons } from \"./GroupsShowHideButtons\";\nimport \"./GroupsVisualization.scss\";\nimport { useGroupingMappingApiConfig } from \"../context/GroupingApiConfigContext\";\nimport type { ActionButtonRenderer, ActionButtonRendererProps } from \"./GroupsView\";\nimport { Alert, Icon, Text } from \"@itwin/itwinui-react\";\nimport { SvgMore } from \"@itwin/itwinui-icons-react\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useIsMounted } from \"../../common/hooks/useIsMounted\";\nimport { useFetchGroups } from \"./hooks/useFetchGroups\";\nimport { useKeySetHiliteQueries } from \"./hooks/useKeySetHiliteQueries\";\nimport { useGroupsClient } from \"../context/GroupsClientContext\";\n\n/**\n * Props for the {@link GroupsVisualization} component.\n * @public\n */\nexport interface GroupsVisualizationProps extends GroupsProps {\n isNonEmphasizedSelectable?: boolean;\n emphasizeElements?: boolean;\n hideVisualizationToggle?: boolean;\n deleteConfirmationContentFactory?: (group: GroupMinimal) => JSX.Element;\n groupDeleteCallback?: (group: GroupMinimal) => void;\n disableZoom?: boolean;\n}\n\n/**\n * Component to visualize groups and their elements.\n * @public\n */\nexport const GroupsVisualization = ({\n emphasizeElements = true,\n isNonEmphasizedSelectable = false,\n onClickGroupModify,\n onClickAddGroup,\n mapping,\n hideVisualizationToggle,\n hideRefreshIcon,\n groupsAction,\n deleteConfirmationContentFactory,\n groupDeleteCallback,\n disableZoom,\n ...rest\n}: GroupsVisualizationProps) => {\n const { iModelConnection } = useGroupingMappingApiConfig();\n if (!iModelConnection) {\n throw new Error(\"This component requires an active iModelConnection.\");\n }\n const [isAlertClosed, setIsAlertClosed] = useState<boolean>(true);\n const [isAlertExpanded, setIsAlertExpanded] = useState<boolean>(false);\n const {\n hiddenGroupsIds,\n showGroupColor,\n setShowGroupColor,\n isOverlappedColored,\n setHiddenGroupsIds,\n setNumberOfVisualizedGroups,\n isVisualizationsEnabled,\n setIsVisualizationsEnabled,\n overlappedElementsMetadata,\n setOverlappedElementsMetadata,\n groupColors,\n setGroupColors,\n } = useGroupHilitedElementsContext();\n const { getAccessToken } = useGroupingMappingApiConfig();\n const groupsClient = useGroupsClient();\n const { data: groups, isFetched: isGroupsFetched, isFetching: isGroupsFetching } = useFetchGroups(mapping.id, getAccessToken, groupsClient);\n const isMounted = useIsMounted();\n const [enableGroupQueries, setEnableGroupQueries] = useState<boolean>(false);\n const { groupQueries } = useKeySetHiliteQueries(groups ?? [], enableGroupQueries, iModelConnection);\n\n const triggerVisualization = useCallback(\n async (groupsWithGroupedOverlaps: OverlappedElementGroupPairs[]) =>\n visualizeGroupColors(hiddenGroupsIds, groupsWithGroupedOverlaps, setNumberOfVisualizedGroups, emphasizeElements),\n [emphasizeElements, hiddenGroupsIds, setNumberOfVisualizedGroups],\n );\n\n const zoomToElementsMutation = useMutation({\n mutationFn: zoomToElements,\n onSuccess: () => {\n if (isMounted) {\n isNonEmphasizedSelectable && clearEmphasizedElements();\n }\n },\n });\n\n const visualizationMutation = useMutation({\n mutationFn: triggerVisualization,\n onSuccess: (allIds) => {\n if (isMounted && !disableZoom) {\n zoomToElementsMutation.mutate(allIds);\n }\n },\n });\n\n const isGroupsQueriesReady = useMemo(() => groupQueries.every((query) => query.isFetched && query.data) && groupQueries.length > 0, [groupQueries]);\n const groupQueriesProgressCount = useMemo(() => groupQueries.filter((query) => query.isFetched).length, [groupQueries]);\n const isResolvingGroupQueries = useMemo(() => groupQueries.some((query) => query.isFetching), [groupQueries]);\n\n const hiliteIds = useMemo(() => {\n if (!isGroupsQueriesReady || !groups) return [];\n\n // Map to track which groups have been processed for each query to ensure unique associations between groups and queries\n const processedGroupIds = new Map<string, string[]>();\n\n return groupQueries.flatMap((query) => {\n // Find all groups that match the current query and haven't been processed yet for this query\n const matchingGroups = groups.filter((group) => {\n const isMatch = group.query === query.data!.query;\n const isProcessed = processedGroupIds.get(query.data!.query)?.includes(group.id);\n return isMatch && !isProcessed;\n });\n\n matchingGroups.forEach((group) => {\n const existingGroupIds = processedGroupIds.get(query.data!.query);\n if (existingGroupIds) {\n existingGroupIds.push(group.id);\n } else {\n processedGroupIds.set(query.data!.query, [group.id]);\n }\n });\n\n // Map each matching group to an object with groupId and elementIds\n return matchingGroups.map((group) => ({\n groupId: group.id,\n elementIds: query.data!.result.ids,\n }));\n });\n }, [groupQueries, isGroupsQueriesReady, groups]);\n\n const getHiliteIdsFromGroupsWrapper = useCallback(\n (groups: GroupMinimal[]) => hiliteIds.filter((id) => groups.some((group) => group.id === id.groupId)).flatMap((id) => id.elementIds),\n [hiliteIds],\n );\n\n useEffect(() => {\n const processOverlappedGroups = async () => {\n const results = generateOverlappedGroups(hiliteIds);\n const { groupsWithGroupedOverlaps, overlappedElementsInfo, numberOfElementsInGroups } = results;\n\n setOverlappedElementsMetadata({\n overlappedElementsInfo,\n groupElementsInfo: numberOfElementsInGroups,\n overlappedElementGroupPairs: groupsWithGroupedOverlaps,\n });\n\n if (showGroupColor) {\n await visualizationMutation.mutateAsync(groupsWithGroupedOverlaps);\n } else {\n clearEmphasizedOverriddenElements();\n }\n\n clearHiddenElements();\n hideGroupIds(hiddenGroupsIds, groupsWithGroupedOverlaps);\n };\n\n const shouldProcessOverlappedGroups = () => !isOverlappedColored && hiliteIds.length > 0 && !isGroupsFetching;\n\n if (shouldProcessOverlappedGroups()) {\n void processOverlappedGroups();\n }\n // We don't want to trigger full visualization when toggling individual groups.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [showGroupColor, isOverlappedColored, hiliteIds]);\n\n useEffect(() => {\n if (isVisualizationsEnabled) {\n setEnableGroupQueries(true);\n } else {\n setShowGroupColor(false);\n clearHiddenElements();\n setHiddenGroupsIds(new Set());\n }\n }, [isVisualizationsEnabled, setHiddenGroupsIds, setIsVisualizationsEnabled, setShowGroupColor]);\n\n useEffect(() => {\n if (hideVisualizationToggle) {\n setIsVisualizationsEnabled(true);\n }\n }, [hideVisualizationToggle, setIsVisualizationsEnabled]);\n\n const hideAllGroups = useCallback(() => {\n if (!groups) return;\n hideElements(getHiliteIdsFromGroupsWrapper(groups));\n }, [getHiliteIdsFromGroupsWrapper, groups]);\n\n const hideSingleGroupWrapper = useCallback(\n (groupToHide: GroupMinimal) => {\n hideGroupConsideringOverlaps(overlappedElementsMetadata.overlappedElementGroupPairs, groupToHide.id, hiddenGroupsIds);\n },\n [hiddenGroupsIds, overlappedElementsMetadata.overlappedElementGroupPairs],\n );\n\n const showGroup = useCallback(\n (viewGroup: GroupMinimal) => {\n if (!groups) return;\n clearHiddenElements();\n\n // hide group Ids filter\n const newHiddenGroups: GroupMinimal[] = groups.filter((g) => hiddenGroupsIds.has(g.id) && g.id !== viewGroup.id);\n\n // view group Ids filter\n const viewGroups = groups.filter((g) => !hiddenGroupsIds.has(g.id) || g.id === viewGroup.id);\n const viewIds = getHiliteIdsFromGroupsWrapper(viewGroups);\n\n let hiddenIds = getHiliteIdsFromGroupsWrapper(newHiddenGroups);\n hiddenIds = hiddenIds.filter((id) => !viewIds.includes(id));\n hideElements(hiddenIds);\n },\n [groups, hiddenGroupsIds, getHiliteIdsFromGroupsWrapper],\n );\n\n const showAll = useCallback(() => {\n clearHiddenElements();\n setHiddenGroupsIds(new Set());\n }, [setHiddenGroupsIds]);\n\n const hideAll = useCallback(() => {\n if (!groups) return;\n hideAllGroups();\n setHiddenGroupsIds(new Set(groups.map((g) => g.id)));\n }, [setHiddenGroupsIds, groups, hideAllGroups]);\n\n const onModify = useCallback(\n (group: GroupMinimal, type: string) => {\n if (!onClickGroupModify) return;\n if (group.id && hiddenGroupsIds.has(group.id)) {\n showGroup(group);\n setHiddenGroupsIds(new Set([...hiddenGroupsIds].filter((id) => id !== group.id)));\n }\n clearEmphasizedElements();\n onClickGroupModify(group, type);\n },\n [hiddenGroupsIds, onClickGroupModify, setHiddenGroupsIds, showGroup],\n );\n\n const onAddGroup = useCallback(\n (type: string) => {\n if (!onClickAddGroup) return;\n onClickAddGroup(type);\n clearEmphasizedElements();\n },\n [onClickAddGroup],\n );\n\n useEffect(() => {\n if (isGroupsFetched) {\n setGroupColors(new Map(groups?.map((g, i) => [g.id, getGroupColor(i)]) ?? []));\n }\n }, [groups, isGroupsFetched, setGroupColors]);\n\n const groupActionButtonRenderers: ActionButtonRenderer[] = useMemo(\n () =>\n isVisualizationsEnabled\n ? [\n (props: ActionButtonRendererProps) => (showGroupColor ? <GroupColorLegend backgroundColor={groupColors.get(props.group.id) ?? \"\"} /> : []),\n (props: ActionButtonRendererProps) => (\n <GroupsShowHideButtons\n {...props}\n isLoadingQuery={!(isVisualizationsEnabled && isGroupsFetched && isGroupsQueriesReady)}\n showGroup={showGroup}\n hideGroup={hideSingleGroupWrapper}\n />\n ),\n ].flat()\n : [],\n [hideSingleGroupWrapper, isGroupsFetched, isGroupsQueriesReady, isVisualizationsEnabled, showGroup, showGroupColor, groupColors],\n );\n\n const overlappedAlert = useMemo(\n () =>\n overlappedElementsMetadata.overlappedElementsInfo.size > 0 && isAlertClosed && showGroupColor ? (\n <Alert\n onClose={() => setIsAlertClosed(false)}\n clickableText={isAlertExpanded ? \"Less Details\" : \"More Details\"}\n clickableTextProps={{ onClick: () => setIsAlertExpanded(!isAlertExpanded) }}\n >\n Overlapping elements are colored <Text className=\"gmw-red-text\">red</Text> in the viewer.\n {isAlertExpanded ? (\n <>\n <br />\n To get overlap info in detail, click the{\" \"}\n <Icon>\n <SvgMore />\n </Icon>{\" \"}\n button then “Overlap Info”\n </>\n ) : undefined}\n </Alert>\n ) : undefined,\n [isAlertClosed, isAlertExpanded, overlappedElementsMetadata.overlappedElementsInfo.size, showGroupColor],\n );\n\n const progressConfig = useMemo(\n () =>\n isVisualizationsEnabled && isResolvingGroupQueries\n ? {\n hilitedGroupsProgress: {\n currentHilitedGroups: groupQueriesProgressCount,\n totalNumberOfGroups: groups?.length ?? 0,\n },\n }\n : undefined,\n [groupQueriesProgressCount, groups, isResolvingGroupQueries, isVisualizationsEnabled],\n );\n\n return (\n <div className=\"gmw-groups-vis-container\">\n <GroupVisualizationActions\n disabled={!(isVisualizationsEnabled && isGroupsFetched && isGroupsQueriesReady)}\n isVisualizationEnabled={isVisualizationsEnabled}\n onClickVisualizationButton={() => setIsVisualizationsEnabled((b) => !b)}\n showAll={showAll}\n hideAll={hideAll}\n hideVisualizationToggle={hideVisualizationToggle}\n />\n <Groups\n onClickGroupModify={onModify}\n onClickAddGroup={onAddGroup}\n actionButtonRenderers={groupActionButtonRenderers}\n mapping={mapping}\n {...rest}\n progressConfig={progressConfig}\n alert={overlappedAlert}\n hideRefreshIcon={hideRefreshIcon}\n groupsAction={groupsAction}\n deleteConfirmationContentFactory={deleteConfirmationContentFactory}\n groupDeleteCallback={groupDeleteCallback}\n />\n </div>\n );\n};\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PresentationPropertyDataProvider } from "@itwin/presentation-components";
|
|
2
2
|
import type { PropertiesField } from "@itwin/presentation-common";
|
|
3
3
|
import type { Primitives, PropertyRecord } from "@itwin/appui-abstract";
|
|
4
|
+
import type { IModelConnection } from "@itwin/core-frontend";
|
|
4
5
|
export interface Query {
|
|
5
6
|
unions: QueryUnion[];
|
|
6
7
|
}
|
|
@@ -21,6 +22,7 @@ export interface QueryProperty {
|
|
|
21
22
|
className: string;
|
|
22
23
|
classProperties: ClassProperty[];
|
|
23
24
|
isCategory: boolean;
|
|
25
|
+
modeledElementClass?: string;
|
|
24
26
|
isAspect: boolean;
|
|
25
27
|
}
|
|
26
28
|
export interface ClassProperty {
|
|
@@ -33,13 +35,15 @@ export interface AddedProperty {
|
|
|
33
35
|
propertiesField: PropertiesField;
|
|
34
36
|
}
|
|
35
37
|
export declare class QueryBuilder {
|
|
38
|
+
private readonly dataProvider;
|
|
39
|
+
private readonly iModelConnection;
|
|
36
40
|
private static readonly MULTI_ASPECT_PRIMARY_CLASS;
|
|
37
41
|
private static readonly UNIQUE_ASPECT_PRIMARY_CLASS;
|
|
38
42
|
private static readonly DEFAULT_DOUBLE_PRECISION;
|
|
39
|
-
private dataProvider;
|
|
40
43
|
private query;
|
|
41
|
-
constructor(
|
|
44
|
+
constructor(dataProvider: PresentationPropertyDataProvider, iModelConnection: IModelConnection);
|
|
42
45
|
private isCategory;
|
|
46
|
+
private getPotentialModeledElement;
|
|
43
47
|
private _propertyMap;
|
|
44
48
|
resetQueryBuilder: () => void;
|
|
45
49
|
private regenerateQuery;
|
|
@@ -50,7 +54,7 @@ export declare class QueryBuilder {
|
|
|
50
54
|
private addRelatedToQuery;
|
|
51
55
|
private addClassToQuery;
|
|
52
56
|
private addPropertyToQuery;
|
|
53
|
-
buildQueryString(): string
|
|
57
|
+
buildQueryString(): Promise<string>;
|
|
54
58
|
private selectClause;
|
|
55
59
|
private relationalJoinSegments;
|
|
56
60
|
private propertyQuerySegment;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { PropertyValueFormat } from "@itwin/appui-abstract";
|
|
2
2
|
import { toaster } from "@itwin/itwinui-react";
|
|
3
|
+
import { QueryBinder } from "@itwin/core-common";
|
|
3
4
|
/* This class is to build adaptive and dynamic query for find similar property selections */
|
|
4
5
|
export class QueryBuilder {
|
|
5
|
-
constructor(
|
|
6
|
+
constructor(dataProvider, iModelConnection) {
|
|
7
|
+
this.dataProvider = dataProvider;
|
|
8
|
+
this.iModelConnection = iModelConnection;
|
|
6
9
|
this._propertyMap = new Map();
|
|
7
10
|
this.resetQueryBuilder = () => {
|
|
8
11
|
this._propertyMap = new Map();
|
|
9
12
|
};
|
|
10
|
-
this.regenerateQuery = () => {
|
|
13
|
+
this.regenerateQuery = async () => {
|
|
11
14
|
this.query = undefined;
|
|
12
15
|
for (const property of this._propertyMap.values()) {
|
|
13
|
-
this.buildProperty(property.propertyRecord, property.propertiesField);
|
|
16
|
+
await this.buildProperty(property.propertyRecord, property.propertiesField);
|
|
14
17
|
}
|
|
15
18
|
};
|
|
16
19
|
this.relationalJoinSegments = (classes, querySegments) => {
|
|
@@ -33,12 +36,27 @@ export class QueryBuilder {
|
|
|
33
36
|
const propertyValue = needsQuote ? `'${property.value}'` : property.value;
|
|
34
37
|
return `${className}.${property.name} = ${propertyValue}`;
|
|
35
38
|
};
|
|
36
|
-
this.dataProvider = provider;
|
|
37
39
|
}
|
|
38
40
|
isCategory(propertyField) {
|
|
39
41
|
const classInfo = propertyField.properties[0].property.navigationPropertyInfo?.classInfo;
|
|
40
42
|
return classInfo?.name === "BisCore:GeometricElement3dIsInCategory";
|
|
41
43
|
}
|
|
44
|
+
async getPotentialModeledElement(propertyField, propertyRecord) {
|
|
45
|
+
const classInfo = propertyField.properties[0].property.navigationPropertyInfo?.classInfo;
|
|
46
|
+
if (propertyRecord.value?.valueFormat !== PropertyValueFormat.Primitive)
|
|
47
|
+
return;
|
|
48
|
+
const navigationPropertyValue = propertyRecord.value.value;
|
|
49
|
+
if (classInfo?.name === "BisCore:ModelContainsElements") {
|
|
50
|
+
// https://www.itwinjs.org/bis/guide/fundamentals/model-fundamentals/#model-identity
|
|
51
|
+
// Lookup the modeled element as they share the same ECInstanceId
|
|
52
|
+
const modeledElementQuery = `SELECT ec_classname(ecclassid) FROM biscore.element WHERE ecinstanceid = ? LIMIT 1`;
|
|
53
|
+
const queryBinder = new QueryBinder();
|
|
54
|
+
queryBinder.bindString(1, navigationPropertyValue.id);
|
|
55
|
+
const modeledElement = (await this.iModelConnection.createQueryReader(modeledElementQuery, queryBinder).next()).value[0];
|
|
56
|
+
return modeledElement.replace(":", ".");
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
42
60
|
async addProperty(prop) {
|
|
43
61
|
// TODO: only handle primitive properties now
|
|
44
62
|
if (prop.value?.valueFormat !== PropertyValueFormat.Primitive) {
|
|
@@ -60,7 +78,7 @@ export class QueryBuilder {
|
|
|
60
78
|
const propertyField = (await this.dataProvider.getFieldByPropertyRecord(prop));
|
|
61
79
|
this._propertyMap.delete(JSON.stringify(propertyField.getFieldDescriptor()));
|
|
62
80
|
}
|
|
63
|
-
buildProperty(prop, propertiesField) {
|
|
81
|
+
async buildProperty(prop, propertiesField) {
|
|
64
82
|
if (prop.value?.valueFormat !== PropertyValueFormat.Primitive || prop.value.value === undefined) {
|
|
65
83
|
toaster.negative("Error. An unexpected error has occured while building a query.");
|
|
66
84
|
return;
|
|
@@ -76,17 +94,22 @@ export class QueryBuilder {
|
|
|
76
94
|
// get the special cases
|
|
77
95
|
const isNavigation = prop.property.typename.toLowerCase() === "navigation";
|
|
78
96
|
const isCategory = isNavigation && this.isCategory(propertiesField);
|
|
97
|
+
const modeledElement = await this.getPotentialModeledElement(propertiesField, prop);
|
|
79
98
|
const isAspect = pathToPrimaryClass?.find((a) => a.relationshipInfo?.name === QueryBuilder.UNIQUE_ASPECT_PRIMARY_CLASS || a.relationshipInfo?.name === QueryBuilder.MULTI_ASPECT_PRIMARY_CLASS) !== undefined;
|
|
80
99
|
for (let i = 0; i < propertiesField.properties.length; i++) {
|
|
81
100
|
const property = propertiesField.properties[i].property;
|
|
82
101
|
const className = property.classInfo.name.replace(":", ".");
|
|
83
|
-
const propertyName = isNavigation ? (isCategory ? `${property.name}.CodeValue` : `${property.name}.id`) : property.name;
|
|
84
|
-
const propertyValue = isNavigation
|
|
102
|
+
const propertyName = isNavigation ? (isCategory || modeledElement ? `${property.name}.CodeValue` : `${property.name}.id`) : property.name;
|
|
103
|
+
const propertyValue = isNavigation
|
|
104
|
+
? isCategory || modeledElement
|
|
105
|
+
? prop.value.displayValue ?? ""
|
|
106
|
+
: prop.value.value.id
|
|
107
|
+
: prop.value.value;
|
|
85
108
|
if (!isAspect && pathToPrimaryClass && pathToPrimaryClass.length > 0) {
|
|
86
109
|
this.addRelatedToQuery(i, propertiesField, propertyName, propertyValue);
|
|
87
110
|
}
|
|
88
111
|
else {
|
|
89
|
-
this.addPropertyToQuery(i, className, propertyName, propertyValue, this.needsQuote(propertiesField), isCategory, isAspect);
|
|
112
|
+
this.addPropertyToQuery(i, className, propertyName, propertyValue, this.needsQuote(propertiesField), isCategory, modeledElement, isAspect);
|
|
90
113
|
}
|
|
91
114
|
}
|
|
92
115
|
return true;
|
|
@@ -107,7 +130,7 @@ export class QueryBuilder {
|
|
|
107
130
|
this.addClassToQuery(unionIndex, targetClassName, `ECInstanceId`, relClassName, relPropertyValue);
|
|
108
131
|
this.addClassToQuery(unionIndex, relClassName, relClassProperty, sourceClassName, `ECInstanceId`);
|
|
109
132
|
if (path.sourceClassInfo?.name === propertyField.parent?.contentClassInfo.name) {
|
|
110
|
-
this.addPropertyToQuery(unionIndex, sourceClassName, propertyName, propertyValue, this.needsQuote(propertyField), false, false);
|
|
133
|
+
this.addPropertyToQuery(unionIndex, sourceClassName, propertyName, propertyValue, this.needsQuote(propertyField), false, "", false);
|
|
111
134
|
}
|
|
112
135
|
});
|
|
113
136
|
}
|
|
@@ -140,7 +163,7 @@ export class QueryBuilder {
|
|
|
140
163
|
}
|
|
141
164
|
this.query.unions[unionIndex].classes.push(queryClass);
|
|
142
165
|
}
|
|
143
|
-
addPropertyToQuery(unionIndex, className, propertyName, propertyValue, needsQuote, isCategory, isAspect) {
|
|
166
|
+
addPropertyToQuery(unionIndex, className, propertyName, propertyValue, needsQuote, isCategory, modeledElementClass, isAspect) {
|
|
144
167
|
if (this.query === undefined) {
|
|
145
168
|
this.query = { unions: [] };
|
|
146
169
|
}
|
|
@@ -152,6 +175,7 @@ export class QueryBuilder {
|
|
|
152
175
|
const queryProperty = {
|
|
153
176
|
className,
|
|
154
177
|
isCategory,
|
|
178
|
+
modeledElementClass,
|
|
155
179
|
isAspect,
|
|
156
180
|
classProperties: [queryJoin],
|
|
157
181
|
};
|
|
@@ -174,8 +198,8 @@ export class QueryBuilder {
|
|
|
174
198
|
}
|
|
175
199
|
this.query.unions[unionIndex].properties.push(queryProperty);
|
|
176
200
|
}
|
|
177
|
-
buildQueryString() {
|
|
178
|
-
this.regenerateQuery();
|
|
201
|
+
async buildQueryString() {
|
|
202
|
+
await this.regenerateQuery();
|
|
179
203
|
if (this.query === undefined || this.query.unions.find((u) => u.classes.length === 0 && u.properties.length === 0)) {
|
|
180
204
|
return "";
|
|
181
205
|
}
|
|
@@ -197,6 +221,11 @@ export class QueryBuilder {
|
|
|
197
221
|
whereSegments.push(this.categoryWhereQuery(property.classProperties[0].value.toString()));
|
|
198
222
|
continue;
|
|
199
223
|
}
|
|
224
|
+
else if (property.modeledElementClass) {
|
|
225
|
+
querySegments.set(property.modeledElementClass, [`${property.modeledElementClass}.ECInstanceId = BisCore.Element.Model.id`]);
|
|
226
|
+
whereSegments.push(`${property.modeledElementClass}.UserLabel = '${property.classProperties[0].value.toString()}' OR ${property.modeledElementClass}.CodeValue = '${property.classProperties[0].value.toString()}'`);
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
200
229
|
const joinIdName = property.isAspect ? `${property.className}.Element.id` : `${property.className}.ECInstanceId`;
|
|
201
230
|
if (!querySegments.has(property.className) && property.className !== baseClassName)
|
|
202
231
|
querySegments.set(property.className, [`${joinIdName} = ${baseIdName}`]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryBuilder.js","sourceRoot":"","sources":["../../../../../src/components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C;IAC5G,CAAC;IAEO,OAAO,CAAC,CAAU;QACxB,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;;AA1TuB,uCAA0B,GAAG,iCAAiC,CAAC;AAC/D,wCAA2B,GAAG,iCAAiC,CAAC;AAChE,qCAAwB,GAAG,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nimport type { PresentationPropertyDataProvider } from \"@itwin/presentation-components\";\nimport type { InstanceKey, PropertiesField } from \"@itwin/presentation-common\";\nimport type { Primitives, PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { toaster } from \"@itwin/itwinui-react\";\n\nexport interface Query {\n unions: QueryUnion[];\n}\n\nexport interface QueryUnion {\n classes: QueryClass[];\n properties: QueryProperty[];\n}\n\nexport interface QueryClass {\n // schemaName.className\n className: string;\n classJoins: ClassJoin[];\n}\n\nexport interface ClassJoin {\n classProperty: string;\n joinClassName: string;\n joinClassProperty: string;\n}\n\nexport interface QueryProperty {\n className: string;\n classProperties: ClassProperty[];\n isCategory: boolean;\n isAspect: boolean;\n}\n\nexport interface ClassProperty {\n name: string;\n value: Primitives.Value;\n needsQuote: boolean;\n}\n\nexport interface AddedProperty {\n propertyRecord: PropertyRecord;\n propertiesField: PropertiesField;\n}\n\n/* This class is to build adaptive and dynamic query for find similar property selections */\nexport class QueryBuilder {\n private static readonly MULTI_ASPECT_PRIMARY_CLASS = \"BisCore:ElementOwnsMultiAspects\";\n private static readonly UNIQUE_ASPECT_PRIMARY_CLASS = \"BisCore:ElementOwnsUniqueAspect\";\n private static readonly DEFAULT_DOUBLE_PRECISION = 4;\n\n private dataProvider: PresentationPropertyDataProvider;\n private query: Query | undefined;\n\n constructor(provider: PresentationPropertyDataProvider) {\n this.dataProvider = provider;\n }\n\n private isCategory(propertyField: PropertiesField): boolean {\n const classInfo = propertyField.properties[0].property.navigationPropertyInfo?.classInfo;\n return classInfo?.name === \"BisCore:GeometricElement3dIsInCategory\";\n }\n\n private _propertyMap: Map<string, AddedProperty> = new Map();\n\n public resetQueryBuilder = () => {\n this._propertyMap = new Map();\n };\n\n private regenerateQuery = () => {\n this.query = undefined;\n\n for (const property of this._propertyMap.values()) {\n this.buildProperty(property.propertyRecord, property.propertiesField);\n }\n };\n\n public async addProperty(prop: PropertyRecord): Promise<boolean> {\n // TODO: only handle primitive properties now\n if (prop.value?.valueFormat !== PropertyValueFormat.Primitive) {\n toaster.warning(\"Only primitive types are supported for now.\");\n return false;\n }\n if (prop.value.value === undefined) {\n return false;\n }\n\n const propertyField = (await this.dataProvider.getFieldByPropertyRecord(prop)) as PropertiesField;\n\n if (!propertyField) {\n toaster.negative(\"Error. Failed to fetch field for this property record.\");\n return false;\n }\n\n this._propertyMap.set(JSON.stringify(propertyField.getFieldDescriptor()), { propertyRecord: prop, propertiesField: propertyField });\n return true;\n }\n\n public async removeProperty(prop: PropertyRecord) {\n const propertyField = (await this.dataProvider.getFieldByPropertyRecord(prop)) as PropertiesField;\n\n this._propertyMap.delete(JSON.stringify(propertyField.getFieldDescriptor()));\n }\n\n private buildProperty(prop: PropertyRecord, propertiesField: PropertiesField) {\n if (prop.value?.valueFormat !== PropertyValueFormat.Primitive || prop.value.value === undefined) {\n toaster.negative(\"Error. An unexpected error has occured while building a query.\");\n return;\n }\n\n function replaceAll(str: string, match: string, replacement: string) {\n return str.split(match).join(replacement);\n }\n // if property value has single quote, escape\n if ((typeof prop.value.value === \"string\" || prop.value.value instanceof String) && String(prop.value.value).indexOf(\"'\") >= 0) {\n prop.value.value = replaceAll(prop.value.value.toString(), \"'\", \"''\");\n }\n\n const pathToPrimaryClass = propertiesField.parent?.pathToPrimaryClass;\n\n // get the special cases\n const isNavigation: boolean = prop.property.typename.toLowerCase() === \"navigation\";\n const isCategory: boolean = isNavigation && this.isCategory(propertiesField);\n\n const isAspect: boolean =\n pathToPrimaryClass?.find(\n (a) => a.relationshipInfo?.name === QueryBuilder.UNIQUE_ASPECT_PRIMARY_CLASS || a.relationshipInfo?.name === QueryBuilder.MULTI_ASPECT_PRIMARY_CLASS,\n ) !== undefined;\n\n for (let i = 0; i < propertiesField.properties.length; i++) {\n const property = propertiesField.properties[i].property;\n\n const className = property.classInfo.name.replace(\":\", \".\");\n const propertyName = isNavigation ? (isCategory ? `${property.name}.CodeValue` : `${property.name}.id`) : property.name;\n const propertyValue = isNavigation ? (isCategory ? prop.value.displayValue ?? \"\" : (prop.value.value as InstanceKey).id) : prop.value.value;\n\n if (!isAspect && pathToPrimaryClass && pathToPrimaryClass.length > 0) {\n this.addRelatedToQuery(i, propertiesField, propertyName, propertyValue);\n } else {\n this.addPropertyToQuery(i, className, propertyName, propertyValue, this.needsQuote(propertiesField), isCategory, isAspect);\n }\n }\n return true;\n }\n\n private needsQuote(propertyField: PropertiesField): boolean {\n // list of property types that need quote around property value\n const typeName = propertyField.type.typeName.toLowerCase();\n return \"string\" === typeName || \"uri\" === typeName;\n }\n\n private addRelatedToQuery(unionIndex: number, propertyField: PropertiesField, propertyName: string, propertyValue: Primitives.Value) {\n const paths = [...(propertyField.parent?.pathToPrimaryClass ?? [])];\n paths.reverse().forEach((path) => {\n const sourceClassName = path.sourceClassInfo?.name.replace(\":\", \".\");\n const targetClassName = path.targetClassInfo?.name.replace(\":\", \".\");\n const relClassName = path.relationshipInfo?.name.replace(\":\", \".\");\n\n const relClassProperty = path.isForwardRelationship ? `SourceECInstanceId` : `TargetECInstanceId`;\n\n const relPropertyValue = path.isForwardRelationship ? `TargetECInstanceId` : `SourceECInstanceId`;\n\n this.addClassToQuery(unionIndex, targetClassName, `ECInstanceId`, relClassName, relPropertyValue);\n\n this.addClassToQuery(unionIndex, relClassName, relClassProperty, sourceClassName, `ECInstanceId`);\n\n if (path.sourceClassInfo?.name === propertyField.parent?.contentClassInfo.name) {\n this.addPropertyToQuery(unionIndex, sourceClassName, propertyName, propertyValue, this.needsQuote(propertyField), false, false);\n }\n });\n }\n\n private addClassToQuery(unionIndex: number, className: string, classProperty: string, joinClassName: string, joinClassProperty: string) {\n if (this.query === undefined) {\n this.query = { unions: [] };\n }\n\n const classJoin: ClassJoin = {\n classProperty,\n joinClassName,\n joinClassProperty,\n };\n\n const queryClass: QueryClass = {\n className,\n classJoins: [classJoin],\n };\n\n if (this.query.unions.length <= unionIndex) {\n this.query.unions.push({\n classes: [queryClass],\n properties: [],\n });\n return;\n }\n\n const foundClass = this.query.unions[unionIndex].classes.find((c) => c.className === className);\n\n if (foundClass) {\n const foundJoin = foundClass.classJoins.find(\n (join) => join.classProperty === classProperty && join.joinClassName === joinClassName && join.joinClassProperty === joinClassProperty,\n );\n\n if (!foundJoin) foundClass.classJoins.push(classJoin);\n return;\n }\n\n this.query.unions[unionIndex].classes.push(queryClass);\n }\n\n private addPropertyToQuery(\n unionIndex: number,\n className: string,\n propertyName: string,\n propertyValue: Primitives.Value,\n needsQuote: boolean,\n isCategory: boolean,\n isAspect: boolean,\n ) {\n if (this.query === undefined) {\n this.query = { unions: [] };\n }\n\n const queryJoin: ClassProperty = {\n name: propertyName,\n value: propertyValue,\n needsQuote,\n };\n\n const queryProperty: QueryProperty = {\n className,\n isCategory,\n isAspect,\n classProperties: [queryJoin],\n };\n\n if (this.query.unions.length <= unionIndex) {\n this.query.unions.push({\n classes: [],\n properties: [queryProperty],\n });\n return;\n }\n\n const foundPropertyClass = this.query.unions[unionIndex].properties.find((p) => p.className === className);\n\n if (foundPropertyClass) {\n const foundJoin = foundPropertyClass?.classProperties.find((join) => join.name === propertyName);\n\n if (foundJoin) {\n foundJoin.value = propertyValue;\n return;\n }\n\n foundPropertyClass.classProperties.push(queryJoin);\n return;\n }\n\n this.query.unions[unionIndex].properties.push(queryProperty);\n }\n\n public buildQueryString() {\n this.regenerateQuery();\n if (this.query === undefined || this.query.unions.find((u) => u.classes.length === 0 && u.properties.length === 0)) {\n return \"\";\n }\n\n const unionSegments: string[] = [];\n for (const union of this.query.unions) {\n const baseClass = union.classes[0];\n const baseProperty = union.properties[0];\n const baseClassName = baseClass ? baseClass.className : baseProperty?.className;\n const baseIdName = `${baseClassName}.ECInstanceId`;\n\n const selectClause = this.selectClause(baseProperty, baseClass);\n\n let querySegments: Map<string, string[]> = new Map();\n querySegments = this.relationalJoinSegments(union.classes, querySegments);\n\n const whereSegments: string[] = [];\n for (const property of union.properties) {\n if (property.isCategory) {\n if (property.className !== baseClassName)\n querySegments.set(\"BisCore.GeometricElement3d\", [`BisCore.GeometricElement3d.ECInstanceId = ${baseIdName}`]);\n\n querySegments.set(\"BisCore.Category\", [`BisCore.Category.ECInstanceId = BisCore.GeometricElement3d.category.id`]);\n whereSegments.push(this.categoryWhereQuery(property.classProperties[0].value.toString()));\n continue;\n }\n\n const joinIdName = property.isAspect ? `${property.className}.Element.id` : `${property.className}.ECInstanceId`;\n\n if (!querySegments.has(property.className) && property.className !== baseClassName)\n querySegments.set(property.className, [`${joinIdName} = ${baseIdName}`]);\n\n for (const prop of property.classProperties) {\n whereSegments.push(this.propertyQuerySegment(property.className, prop, prop.needsQuote));\n }\n }\n\n const joinClauses: string[] = [];\n for (const key of querySegments.keys()) {\n joinClauses.push(`JOIN ${key} ON ${querySegments.get(key)?.join(\" AND \")}`);\n }\n\n const whereClause = `WHERE ${whereSegments.join(\" AND \")}`;\n\n unionSegments.push([selectClause, ...joinClauses, whereClause].join(\" \"));\n }\n\n return unionSegments.join(\" UNION \");\n }\n\n private selectClause(baseProperty: QueryProperty | undefined, baseClass: QueryClass | undefined) {\n if (baseClass) {\n return `SELECT ${baseClass.className}.ECInstanceId, ${baseClass.className}.ECClassId FROM ${baseClass.className}`;\n }\n\n if (baseProperty) {\n const baseIdName = baseProperty.isAspect\n ? `${baseProperty.className}.Element.id ECInstanceId`\n : `${baseProperty.className}.ECInstanceId, ${baseProperty.className}.ECClassId`;\n\n return `SELECT ${baseIdName} FROM ${baseProperty.className}`;\n }\n\n return \"\";\n }\n\n private relationalJoinSegments = (classes: QueryClass[], querySegments: Map<string, string[]>): Map<string, string[]> => {\n for (const queryClass of classes) {\n for (const classJoin of queryClass.classJoins) {\n const querySegment = [\n ...(querySegments.get(classJoin.joinClassName) ?? []),\n `${queryClass.className}.${classJoin.classProperty} = ${classJoin.joinClassName}.${classJoin.joinClassProperty}`,\n ];\n querySegments.set(classJoin.joinClassName, querySegment);\n }\n }\n\n return querySegments;\n };\n\n private propertyQuerySegment = (className: string, property: ClassProperty, needsQuote: boolean): string => {\n if (this.isFloat(property.value))\n return (\n `ROUND(${className}.${property.name}, ` +\n `${QueryBuilder.DEFAULT_DOUBLE_PRECISION}) = ` +\n `${Number(property.value).toFixed(QueryBuilder.DEFAULT_DOUBLE_PRECISION)}`\n );\n\n const propertyValue = needsQuote ? `'${property.value}'` : property.value;\n return `${className}.${property.name} = ${propertyValue}`;\n };\n\n private categoryWhereQuery(codeValue: string): string {\n return `((BisCore.Category.CodeValue = '${codeValue}') OR (BisCore.Category.UserLabel = '${codeValue}'))`;\n }\n\n private isFloat(n: unknown): boolean {\n return Number(n) === n && n % 1 !== 0;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"QueryBuilder.js","sourceRoot":"","sources":["../../../../../src/components/Groups/QueryBuilder/QueryBuilder.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AA0CjD,4FAA4F;AAC5F,MAAM,OAAO,YAAY;IAMvB,YACmB,YAA8C,EAC9C,gBAAkC;QADlC,iBAAY,GAAZ,YAAY,CAAkC;QAC9C,qBAAgB,GAAhB,gBAAgB,CAAkB;QAwB7C,iBAAY,GAA+B,IAAI,GAAG,E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KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;;AAtVuB,uCAA0B,GAAG,iCAAiC,CAAC;AAC/D,wCAA2B,GAAG,iCAAiC,CAAC;AAChE,qCAAwB,GAAG,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nimport type { PresentationPropertyDataProvider } from \"@itwin/presentation-components\";\nimport type { InstanceKey, NavigationPropertyValue, PropertiesField } from \"@itwin/presentation-common\";\nimport type { Primitives, PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { toaster } from \"@itwin/itwinui-react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport { QueryBinder } from \"@itwin/core-common\";\n\nexport interface Query {\n unions: QueryUnion[];\n}\n\nexport interface QueryUnion {\n classes: QueryClass[];\n properties: QueryProperty[];\n}\n\nexport interface QueryClass {\n // schemaName.className\n className: string;\n classJoins: ClassJoin[];\n}\n\nexport interface ClassJoin {\n classProperty: string;\n joinClassName: string;\n joinClassProperty: string;\n}\n\nexport interface QueryProperty {\n className: string;\n classProperties: ClassProperty[];\n isCategory: boolean;\n modeledElementClass?: string;\n isAspect: boolean;\n}\n\nexport interface ClassProperty {\n name: string;\n value: Primitives.Value;\n needsQuote: boolean;\n}\n\nexport interface AddedProperty {\n propertyRecord: PropertyRecord;\n propertiesField: PropertiesField;\n}\n\n/* This class is to build adaptive and dynamic query for find similar property selections */\nexport class QueryBuilder {\n private static readonly MULTI_ASPECT_PRIMARY_CLASS = \"BisCore:ElementOwnsMultiAspects\";\n private static readonly UNIQUE_ASPECT_PRIMARY_CLASS = \"BisCore:ElementOwnsUniqueAspect\";\n private static readonly DEFAULT_DOUBLE_PRECISION = 4;\n private query: Query | undefined;\n\n constructor(\n private readonly dataProvider: PresentationPropertyDataProvider,\n private readonly iModelConnection: IModelConnection,\n ) {}\n\n private isCategory(propertyField: PropertiesField): boolean {\n const classInfo = propertyField.properties[0].property.navigationPropertyInfo?.classInfo;\n return classInfo?.name === \"BisCore:GeometricElement3dIsInCategory\";\n }\n\n private async getPotentialModeledElement(propertyField: PropertiesField, propertyRecord: PropertyRecord): Promise<string | undefined> {\n const classInfo = propertyField.properties[0].property.navigationPropertyInfo?.classInfo;\n if (propertyRecord.value?.valueFormat !== PropertyValueFormat.Primitive) return;\n const navigationPropertyValue = propertyRecord.value.value as NavigationPropertyValue;\n if (classInfo?.name === \"BisCore:ModelContainsElements\") {\n // https://www.itwinjs.org/bis/guide/fundamentals/model-fundamentals/#model-identity\n // Lookup the modeled element as they share the same ECInstanceId\n const modeledElementQuery = `SELECT ec_classname(ecclassid) FROM biscore.element WHERE ecinstanceid = ? LIMIT 1`;\n const queryBinder = new QueryBinder();\n queryBinder.bindString(1, navigationPropertyValue.id);\n const modeledElement = (await this.iModelConnection.createQueryReader(modeledElementQuery, queryBinder).next()).value[0];\n return modeledElement.replace(\":\", \".\");\n }\n return;\n }\n\n private _propertyMap: Map<string, AddedProperty> = new Map();\n\n public resetQueryBuilder = () => {\n this._propertyMap = new Map();\n };\n\n private regenerateQuery = async () => {\n this.query = undefined;\n\n for (const property of this._propertyMap.values()) {\n await this.buildProperty(property.propertyRecord, property.propertiesField);\n }\n };\n\n public async addProperty(prop: PropertyRecord): Promise<boolean> {\n // TODO: only handle primitive properties now\n if (prop.value?.valueFormat !== PropertyValueFormat.Primitive) {\n toaster.warning(\"Only primitive types are supported for now.\");\n return false;\n }\n if (prop.value.value === undefined) {\n return false;\n }\n\n const propertyField = (await this.dataProvider.getFieldByPropertyRecord(prop)) as PropertiesField;\n\n if (!propertyField) {\n toaster.negative(\"Error. Failed to fetch field for this property record.\");\n return false;\n }\n\n this._propertyMap.set(JSON.stringify(propertyField.getFieldDescriptor()), { propertyRecord: prop, propertiesField: propertyField });\n return true;\n }\n\n public async removeProperty(prop: PropertyRecord) {\n const propertyField = (await this.dataProvider.getFieldByPropertyRecord(prop)) as PropertiesField;\n\n this._propertyMap.delete(JSON.stringify(propertyField.getFieldDescriptor()));\n }\n\n private async buildProperty(prop: PropertyRecord, propertiesField: PropertiesField) {\n if (prop.value?.valueFormat !== PropertyValueFormat.Primitive || prop.value.value === undefined) {\n toaster.negative(\"Error. An unexpected error has occured while building a query.\");\n return;\n }\n\n function replaceAll(str: string, match: string, replacement: string) {\n return str.split(match).join(replacement);\n }\n // if property value has single quote, escape\n if ((typeof prop.value.value === \"string\" || prop.value.value instanceof String) && String(prop.value.value).indexOf(\"'\") >= 0) {\n prop.value.value = replaceAll(prop.value.value.toString(), \"'\", \"''\");\n }\n\n const pathToPrimaryClass = propertiesField.parent?.pathToPrimaryClass;\n\n // get the special cases\n const isNavigation: boolean = prop.property.typename.toLowerCase() === \"navigation\";\n const isCategory: boolean = isNavigation && this.isCategory(propertiesField);\n const modeledElement = await this.getPotentialModeledElement(propertiesField, prop);\n\n const isAspect: boolean =\n pathToPrimaryClass?.find(\n (a) => a.relationshipInfo?.name === QueryBuilder.UNIQUE_ASPECT_PRIMARY_CLASS || a.relationshipInfo?.name === QueryBuilder.MULTI_ASPECT_PRIMARY_CLASS,\n ) !== undefined;\n\n for (let i = 0; i < propertiesField.properties.length; i++) {\n const property = propertiesField.properties[i].property;\n\n const className = property.classInfo.name.replace(\":\", \".\");\n const propertyName = isNavigation ? (isCategory || modeledElement ? `${property.name}.CodeValue` : `${property.name}.id`) : property.name;\n const propertyValue = isNavigation\n ? isCategory || modeledElement\n ? prop.value.displayValue ?? \"\"\n : (prop.value.value as InstanceKey).id\n : prop.value.value;\n\n if (!isAspect && pathToPrimaryClass && pathToPrimaryClass.length > 0) {\n this.addRelatedToQuery(i, propertiesField, propertyName, propertyValue);\n } else {\n this.addPropertyToQuery(i, className, propertyName, propertyValue, this.needsQuote(propertiesField), isCategory, modeledElement, isAspect);\n }\n }\n return true;\n }\n\n private needsQuote(propertyField: PropertiesField): boolean {\n // list of property types that need quote around property value\n const typeName = propertyField.type.typeName.toLowerCase();\n return \"string\" === typeName || \"uri\" === typeName;\n }\n\n private addRelatedToQuery(unionIndex: number, propertyField: PropertiesField, propertyName: string, propertyValue: Primitives.Value) {\n const paths = [...(propertyField.parent?.pathToPrimaryClass ?? [])];\n paths.reverse().forEach((path) => {\n const sourceClassName = path.sourceClassInfo?.name.replace(\":\", \".\");\n const targetClassName = path.targetClassInfo?.name.replace(\":\", \".\");\n const relClassName = path.relationshipInfo?.name.replace(\":\", \".\");\n\n const relClassProperty = path.isForwardRelationship ? `SourceECInstanceId` : `TargetECInstanceId`;\n\n const relPropertyValue = path.isForwardRelationship ? `TargetECInstanceId` : `SourceECInstanceId`;\n\n this.addClassToQuery(unionIndex, targetClassName, `ECInstanceId`, relClassName, relPropertyValue);\n\n this.addClassToQuery(unionIndex, relClassName, relClassProperty, sourceClassName, `ECInstanceId`);\n\n if (path.sourceClassInfo?.name === propertyField.parent?.contentClassInfo.name) {\n this.addPropertyToQuery(unionIndex, sourceClassName, propertyName, propertyValue, this.needsQuote(propertyField), false, \"\", false);\n }\n });\n }\n\n private addClassToQuery(unionIndex: number, className: string, classProperty: string, joinClassName: string, joinClassProperty: string) {\n if (this.query === undefined) {\n this.query = { unions: [] };\n }\n\n const classJoin: ClassJoin = {\n classProperty,\n joinClassName,\n joinClassProperty,\n };\n\n const queryClass: QueryClass = {\n className,\n classJoins: [classJoin],\n };\n\n if (this.query.unions.length <= unionIndex) {\n this.query.unions.push({\n classes: [queryClass],\n properties: [],\n });\n return;\n }\n\n const foundClass = this.query.unions[unionIndex].classes.find((c) => c.className === className);\n\n if (foundClass) {\n const foundJoin = foundClass.classJoins.find(\n (join) => join.classProperty === classProperty && join.joinClassName === joinClassName && join.joinClassProperty === joinClassProperty,\n );\n\n if (!foundJoin) foundClass.classJoins.push(classJoin);\n return;\n }\n\n this.query.unions[unionIndex].classes.push(queryClass);\n }\n\n private addPropertyToQuery(\n unionIndex: number,\n className: string,\n propertyName: string,\n propertyValue: Primitives.Value,\n needsQuote: boolean,\n isCategory: boolean,\n modeledElementClass: string | undefined,\n isAspect: boolean,\n ) {\n if (this.query === undefined) {\n this.query = { unions: [] };\n }\n\n const queryJoin: ClassProperty = {\n name: propertyName,\n value: propertyValue,\n needsQuote,\n };\n\n const queryProperty: QueryProperty = {\n className,\n isCategory,\n modeledElementClass,\n isAspect,\n classProperties: [queryJoin],\n };\n\n if (this.query.unions.length <= unionIndex) {\n this.query.unions.push({\n classes: [],\n properties: [queryProperty],\n });\n return;\n }\n\n const foundPropertyClass = this.query.unions[unionIndex].properties.find((p) => p.className === className);\n\n if (foundPropertyClass) {\n const foundJoin = foundPropertyClass?.classProperties.find((join) => join.name === propertyName);\n\n if (foundJoin) {\n foundJoin.value = propertyValue;\n return;\n }\n\n foundPropertyClass.classProperties.push(queryJoin);\n return;\n }\n\n this.query.unions[unionIndex].properties.push(queryProperty);\n }\n\n public async buildQueryString() {\n await this.regenerateQuery();\n if (this.query === undefined || this.query.unions.find((u) => u.classes.length === 0 && u.properties.length === 0)) {\n return \"\";\n }\n\n const unionSegments: string[] = [];\n for (const union of this.query.unions) {\n const baseClass = union.classes[0];\n const baseProperty = union.properties[0];\n const baseClassName = baseClass ? baseClass.className : baseProperty?.className;\n const baseIdName = `${baseClassName}.ECInstanceId`;\n\n const selectClause = this.selectClause(baseProperty, baseClass);\n\n let querySegments: Map<string, string[]> = new Map();\n querySegments = this.relationalJoinSegments(union.classes, querySegments);\n\n const whereSegments: string[] = [];\n for (const property of union.properties) {\n if (property.isCategory) {\n if (property.className !== baseClassName)\n querySegments.set(\"BisCore.GeometricElement3d\", [`BisCore.GeometricElement3d.ECInstanceId = ${baseIdName}`]);\n\n querySegments.set(\"BisCore.Category\", [`BisCore.Category.ECInstanceId = BisCore.GeometricElement3d.category.id`]);\n whereSegments.push(this.categoryWhereQuery(property.classProperties[0].value.toString()));\n continue;\n } else if (property.modeledElementClass) {\n querySegments.set(property.modeledElementClass, [`${property.modeledElementClass}.ECInstanceId = BisCore.Element.Model.id`]);\n whereSegments.push(\n `${property.modeledElementClass}.UserLabel = '${property.classProperties[0].value.toString()}' OR ${property.modeledElementClass}.CodeValue = '${property.classProperties[0].value.toString()}'`,\n );\n continue;\n }\n\n const joinIdName = property.isAspect ? `${property.className}.Element.id` : `${property.className}.ECInstanceId`;\n\n if (!querySegments.has(property.className) && property.className !== baseClassName)\n querySegments.set(property.className, [`${joinIdName} = ${baseIdName}`]);\n\n for (const prop of property.classProperties) {\n whereSegments.push(this.propertyQuerySegment(property.className, prop, prop.needsQuote));\n }\n }\n\n const joinClauses: string[] = [];\n for (const key of querySegments.keys()) {\n joinClauses.push(`JOIN ${key} ON ${querySegments.get(key)?.join(\" AND \")}`);\n }\n\n const whereClause = `WHERE ${whereSegments.join(\" AND \")}`;\n\n unionSegments.push([selectClause, ...joinClauses, whereClause].join(\" \"));\n }\n\n return unionSegments.join(\" UNION \");\n }\n\n private selectClause(baseProperty: QueryProperty | undefined, baseClass: QueryClass | undefined) {\n if (baseClass) {\n return `SELECT ${baseClass.className}.ECInstanceId, ${baseClass.className}.ECClassId FROM ${baseClass.className}`;\n }\n\n if (baseProperty) {\n const baseIdName = baseProperty.isAspect\n ? `${baseProperty.className}.Element.id ECInstanceId`\n : `${baseProperty.className}.ECInstanceId, ${baseProperty.className}.ECClassId`;\n\n return `SELECT ${baseIdName} FROM ${baseProperty.className}`;\n }\n\n return \"\";\n }\n\n private relationalJoinSegments = (classes: QueryClass[], querySegments: Map<string, string[]>): Map<string, string[]> => {\n for (const queryClass of classes) {\n for (const classJoin of queryClass.classJoins) {\n const querySegment = [\n ...(querySegments.get(classJoin.joinClassName) ?? []),\n `${queryClass.className}.${classJoin.classProperty} = ${classJoin.joinClassName}.${classJoin.joinClassProperty}`,\n ];\n querySegments.set(classJoin.joinClassName, querySegment);\n }\n }\n\n return querySegments;\n };\n\n private propertyQuerySegment = (className: string, property: ClassProperty, needsQuote: boolean): string => {\n if (this.isFloat(property.value))\n return (\n `ROUND(${className}.${property.name}, ` +\n `${QueryBuilder.DEFAULT_DOUBLE_PRECISION}) = ` +\n `${Number(property.value).toFixed(QueryBuilder.DEFAULT_DOUBLE_PRECISION)}`\n );\n\n const propertyValue = needsQuote ? `'${property.value}'` : property.value;\n return `${className}.${property.name} = ${propertyValue}`;\n };\n\n private categoryWhereQuery(codeValue: string): string {\n return `((BisCore.Category.CodeValue = '${codeValue}') OR (BisCore.Category.UserLabel = '${codeValue}'))`;\n }\n\n private isFloat(n: unknown): boolean {\n return Number(n) === n && n % 1 !== 0;\n }\n}\n"]}
|
|
@@ -7,8 +7,13 @@ import { PropertyValueFormat } from "@itwin/appui-abstract";
|
|
|
7
7
|
import { usePropertyGridWrapper } from "../context/PropertyGridWrapperContext";
|
|
8
8
|
import { Checkbox } from "@itwin/itwinui-react";
|
|
9
9
|
import "./PropertyAction.scss";
|
|
10
|
+
import { useGroupingMappingApiConfig } from "../context/GroupingApiConfigContext";
|
|
10
11
|
const usePropertySelection = (property, currentPropertyList, queryBuilder) => {
|
|
11
12
|
const [isCheckboxLoading, setIsCheckboxLoading] = useState(false);
|
|
13
|
+
const { iModelConnection } = useGroupingMappingApiConfig();
|
|
14
|
+
if (!iModelConnection) {
|
|
15
|
+
throw new Error("This hook requires an active iModelConnection.");
|
|
16
|
+
}
|
|
12
17
|
const checkIfPropertyIsSelected = useCallback((property) => {
|
|
13
18
|
if (property.value.valueFormat === PropertyValueFormat.Primitive) {
|
|
14
19
|
return currentPropertyList.includes(property);
|
|
@@ -50,12 +55,12 @@ export const PropertyAction = ({ property }) => {
|
|
|
50
55
|
if (isPropertySelected) {
|
|
51
56
|
await removeProperty(property);
|
|
52
57
|
setCurrentPropertyList((prevList) => prevList.filter((x) => x !== property));
|
|
53
|
-
setQuery(queryBuilder?.buildQueryString() ?? "");
|
|
58
|
+
setQuery(await queryBuilder?.buildQueryString() ?? "");
|
|
54
59
|
}
|
|
55
60
|
else {
|
|
56
61
|
if (await addProperty(property)) {
|
|
57
62
|
setCurrentPropertyList((prevList) => prevList.concat(property));
|
|
58
|
-
setQuery(queryBuilder?.buildQueryString() ?? "");
|
|
63
|
+
setQuery(await queryBuilder?.buildQueryString() ?? "");
|
|
59
64
|
}
|
|
60
65
|
}
|
|
61
66
|
}, [addProperty, isPropertySelected, property, removeProperty, queryBuilder, setCurrentPropertyList, setQuery]);
|