@itwin/grouping-mapping-widget 0.2.1 → 0.3.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.
Files changed (95) hide show
  1. package/lib/cjs/widget/components/ActionPanel.d.ts +3 -2
  2. package/lib/cjs/widget/components/ActionPanel.js +6 -4
  3. package/lib/cjs/widget/components/ActionPanel.js.map +1 -1
  4. package/lib/cjs/widget/components/CalculatedPropertyAction.js +8 -3
  5. package/lib/cjs/widget/components/CalculatedPropertyAction.js.map +1 -1
  6. package/lib/cjs/widget/components/CalculatedPropertyAction.scss +5 -5
  7. package/lib/cjs/widget/components/ConfirmMappingsImport.js +30 -12
  8. package/lib/cjs/widget/components/ConfirmMappingsImport.js.map +1 -1
  9. package/lib/cjs/widget/components/ConfirmMappingsImport.scss +0 -7
  10. package/lib/cjs/widget/components/CustomCalculationAction.js +1 -1
  11. package/lib/cjs/widget/components/CustomCalculationAction.js.map +1 -1
  12. package/lib/cjs/widget/components/DeleteModal.js +4 -2
  13. package/lib/cjs/widget/components/DeleteModal.js.map +1 -1
  14. package/lib/cjs/widget/components/DeleteModal.scss +6 -0
  15. package/lib/cjs/widget/components/GroupAction.js +97 -18
  16. package/lib/cjs/widget/components/GroupAction.js.map +1 -1
  17. package/lib/cjs/widget/components/GroupAction.scss +23 -0
  18. package/lib/cjs/widget/components/GroupPropertyAction.js +51 -20
  19. package/lib/cjs/widget/components/GroupPropertyAction.js.map +1 -1
  20. package/lib/cjs/widget/components/GroupQueryBuilderContext.d.ts +2 -0
  21. package/lib/cjs/widget/components/GroupQueryBuilderContext.js +2 -0
  22. package/lib/cjs/widget/components/GroupQueryBuilderContext.js.map +1 -1
  23. package/lib/cjs/widget/components/Grouping.js +8 -5
  24. package/lib/cjs/widget/components/Grouping.js.map +1 -1
  25. package/lib/cjs/widget/components/MappingAction.js +1 -1
  26. package/lib/cjs/widget/components/MappingAction.js.map +1 -1
  27. package/lib/cjs/widget/components/PropertyMenu.js +4 -0
  28. package/lib/cjs/widget/components/PropertyMenu.js.map +1 -1
  29. package/lib/cjs/widget/components/QueryBuilder.d.ts +1 -1
  30. package/lib/cjs/widget/components/QueryBuilder.js +12 -6
  31. package/lib/cjs/widget/components/QueryBuilder.js.map +1 -1
  32. package/lib/cjs/widget/components/property-grid/PrimitivePropertyRenderer.js +7 -3
  33. package/lib/cjs/widget/components/property-grid/PrimitivePropertyRenderer.js.map +1 -1
  34. package/lib/cjs/widget/components/property-grid/PropertyGrid.scss +3 -3
  35. package/lib/cjs/widget/components/property-grid/PropertyRender.d.ts +1 -1
  36. package/lib/cjs/widget/components/property-grid/PropertyRender.js +5 -8
  37. package/lib/cjs/widget/components/property-grid/PropertyRender.js.map +1 -1
  38. package/lib/cjs/widget/components/property-grid/PropertyView.d.ts +2 -0
  39. package/lib/cjs/widget/components/property-grid/PropertyView.js +17 -11
  40. package/lib/cjs/widget/components/property-grid/PropertyView.js.map +1 -1
  41. package/lib/cjs/widget/components/property-grid/PropertyView.scss +19 -4
  42. package/lib/cjs/widget/components/utils.d.ts +1 -0
  43. package/lib/cjs/widget/components/utils.js +25 -26
  44. package/lib/cjs/widget/components/utils.js.map +1 -1
  45. package/lib/cjs/widget/components/utils.scss +5 -0
  46. package/lib/cjs/widget/components/viewerUtils.js +1 -1
  47. package/lib/cjs/widget/components/viewerUtils.js.map +1 -1
  48. package/lib/esm/widget/components/ActionPanel.d.ts +3 -2
  49. package/lib/esm/widget/components/ActionPanel.js +7 -5
  50. package/lib/esm/widget/components/ActionPanel.js.map +1 -1
  51. package/lib/esm/widget/components/CalculatedPropertyAction.js +8 -3
  52. package/lib/esm/widget/components/CalculatedPropertyAction.js.map +1 -1
  53. package/lib/esm/widget/components/CalculatedPropertyAction.scss +5 -5
  54. package/lib/esm/widget/components/ConfirmMappingsImport.js +30 -12
  55. package/lib/esm/widget/components/ConfirmMappingsImport.js.map +1 -1
  56. package/lib/esm/widget/components/ConfirmMappingsImport.scss +0 -7
  57. package/lib/esm/widget/components/CustomCalculationAction.js +1 -1
  58. package/lib/esm/widget/components/CustomCalculationAction.js.map +1 -1
  59. package/lib/esm/widget/components/DeleteModal.js +6 -4
  60. package/lib/esm/widget/components/DeleteModal.js.map +1 -1
  61. package/lib/esm/widget/components/DeleteModal.scss +6 -0
  62. package/lib/esm/widget/components/GroupAction.js +99 -20
  63. package/lib/esm/widget/components/GroupAction.js.map +1 -1
  64. package/lib/esm/widget/components/GroupAction.scss +23 -0
  65. package/lib/esm/widget/components/GroupPropertyAction.js +51 -20
  66. package/lib/esm/widget/components/GroupPropertyAction.js.map +1 -1
  67. package/lib/esm/widget/components/GroupQueryBuilderContext.d.ts +2 -0
  68. package/lib/esm/widget/components/GroupQueryBuilderContext.js +2 -0
  69. package/lib/esm/widget/components/GroupQueryBuilderContext.js.map +1 -1
  70. package/lib/esm/widget/components/Grouping.js +8 -5
  71. package/lib/esm/widget/components/Grouping.js.map +1 -1
  72. package/lib/esm/widget/components/MappingAction.js +1 -1
  73. package/lib/esm/widget/components/MappingAction.js.map +1 -1
  74. package/lib/esm/widget/components/PropertyMenu.js +4 -0
  75. package/lib/esm/widget/components/PropertyMenu.js.map +1 -1
  76. package/lib/esm/widget/components/QueryBuilder.d.ts +1 -1
  77. package/lib/esm/widget/components/QueryBuilder.js +12 -6
  78. package/lib/esm/widget/components/QueryBuilder.js.map +1 -1
  79. package/lib/esm/widget/components/property-grid/PrimitivePropertyRenderer.js +7 -3
  80. package/lib/esm/widget/components/property-grid/PrimitivePropertyRenderer.js.map +1 -1
  81. package/lib/esm/widget/components/property-grid/PropertyGrid.scss +3 -3
  82. package/lib/esm/widget/components/property-grid/PropertyRender.d.ts +1 -1
  83. package/lib/esm/widget/components/property-grid/PropertyRender.js +5 -8
  84. package/lib/esm/widget/components/property-grid/PropertyRender.js.map +1 -1
  85. package/lib/esm/widget/components/property-grid/PropertyView.d.ts +2 -0
  86. package/lib/esm/widget/components/property-grid/PropertyView.js +17 -11
  87. package/lib/esm/widget/components/property-grid/PropertyView.js.map +1 -1
  88. package/lib/esm/widget/components/property-grid/PropertyView.scss +19 -4
  89. package/lib/esm/widget/components/utils.d.ts +1 -0
  90. package/lib/esm/widget/components/utils.js +24 -26
  91. package/lib/esm/widget/components/utils.js.map +1 -1
  92. package/lib/esm/widget/components/utils.scss +5 -0
  93. package/lib/esm/widget/components/viewerUtils.js +1 -1
  94. package/lib/esm/widget/components/viewerUtils.js.map +1 -1
  95. package/package.json +6 -4
@@ -1 +1 @@
1
- {"version":3,"file":"Grouping.js","sourceRoot":"","sources":["../../../../src/widget/components/Grouping.tsx"],"names":[],"mappings":"AAUA,OAAO,EACL,OAAO,GACR,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,EACZ,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EACL,MAAM,EACN,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,cAAc,EACd,KAAK,EACL,OAAO,GACR,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,MAAM,EACN,SAAS,EACT,OAAO,EACP,OAAO,EACP,OAAO,GACR,MAAM,4BAA4B,CAAC;AACpC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,WAAW,MAAM,eAAe,CAAC;AAIxC,IAAK,UAKJ;AALD,WAAK,UAAU;IACb,+BAAiB,CAAA;IACjB,qCAAuB,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C,CAAC,oBAAC,cAAc,IAAC,IAAI,EAAC,OAAO,EAAC,aAAa,SAAG,CAAC,CAAC,CAAC,oBAAC,MAAM,OAAG,EAE7E,SAAS,EAAC,iBAAiB,EAC3B,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,IAExB,cAAc,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,WAAW,CAC3C;oBACT,oBAAC,KAAK,IACJ,IAAI,EAAE,MAAM,EACZ,OAAO,EAAC,iBAAiB,EACzB,OAAO,EAAE,aAAa,EACtB,iBAAiB,EAAC,sBAAsB,EACxC,UAAU,QACV,YAAY,QACZ,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,GAAG,EAAE,CAAC,cAAc,EACnC,YAAY,EAAE,iBAAiB,EAC/B,kBAAkB,EAAE,eAAe,GACnC,CACE;gBACN,oBAAC,WAAW,IACV,UAAU,EAAE,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,SAAS,mCAAI,EAAE,EAC1C,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,KAAK,IAAI,EAAE;;wBACnB,MAAM,kBAAkB,CAAC,WAAW,CAClC,QAAQ,EACR,MAAA,OAAO,CAAC,EAAE,mCAAI,EAAE,EAChB,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,EAAE,mCAAI,EAAE,CACxB,CAAC;oBACJ,CAAC,EACD,OAAO,EAAE,OAAO,GAChB,CACD,CACJ,CAAC;KACL;AACH,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 {\n ActionType,\n CellProps,\n TableInstance,\n TableState,\n} from \"react-table\";\nimport {\n actions,\n} from \"react-table\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { GroupReportingAPI, MappingReportingAPI } from \"../../api/generated/api\";\nimport { reportingClientApi } from \"../../api/reportingClient\";\nimport type { CreateTypeFromInterface } from \"../utils\";\nimport {\n Button,\n DropdownMenu,\n IconButton,\n MenuItem,\n ProgressRadial,\n Table,\n toaster,\n} from \"@itwin/itwinui-react\";\nimport {\n SvgAdd,\n SvgDelete,\n SvgEdit,\n SvgList,\n SvgMore,\n} from \"@itwin/itwinui-icons-react\";\nimport DeleteModal from \"./DeleteModal\";\nimport \"./Grouping.scss\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport { PropertyMenu } from \"./PropertyMenu\";\nimport {\n clearEmphasizedElements,\n visualizeElements,\n visualizeElementsById,\n zoomToElements,\n} from \"./viewerUtils\";\nimport { fetchIdsFromQuery, handleError, WidgetHeader } from \"./utils\";\nimport GroupAction from \"./GroupAction\";\n\nexport type Group = CreateTypeFromInterface<GroupReportingAPI>;\n\nenum GroupsView {\n GROUPS = \"groups\",\n MODIFYING = \"modifying\",\n ADD = \"ADD\",\n PROPERTIES = \"properties\",\n}\n\ninterface GroupsTreeProps {\n mapping: MappingReportingAPI;\n goBack: () => Promise<void>;\n}\n\nconst fetchGroups = async (\n setGroups: React.Dispatch<React.SetStateAction<Group[]>>,\n iModelId: string,\n mappingId: string,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,\n) => {\n try {\n setIsLoading(true);\n const groups = await reportingClientApi.getGroups(iModelId, mappingId);\n setGroups(groups.groups ?? []);\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n};\n\nconst useFetchGroups = (\n iModelId: string,\n mappingId: string,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,\n): [Group[], React.Dispatch<React.SetStateAction<Group[]>>] => {\n const [groups, setGroups] = useState<GroupReportingAPI[]>([]);\n\n useEffect(() => {\n void fetchGroups(setGroups, iModelId, mappingId, setIsLoading);\n }, [iModelId, mappingId, setIsLoading]);\n\n return [groups, setGroups];\n};\n\nexport const Groupings = ({ mapping, goBack }: GroupsTreeProps) => {\n const iModelConnection = useActiveIModelConnection() as IModelConnection;\n const iModelId = useActiveIModelConnection()?.iModelId as string;\n const [showDeleteModal, setShowDeleteModal] = useState<boolean>(false);\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [groupsView, setGroupsView] = useState<GroupsView>(GroupsView.GROUPS);\n const [selectedGroup, setSelectedGroup] = useState<Group | undefined>(\n undefined,\n );\n const [groups, setGroups] = useFetchGroups(\n iModelId,\n mapping.id ?? \"\",\n setIsLoading,\n );\n const hilitedElements = useRef<Map<string, string[]>>(new Map());\n const [selectedRows, setSelectedRows] = useState<Record<string, boolean>>({});\n const [isLoadingQuery, setLoadingQuery] = useState<boolean>(false);\n\n const refresh = useCallback(async () => {\n setGroupsView(GroupsView.GROUPS);\n setSelectedGroup(undefined);\n setGroups([]);\n await fetchGroups(setGroups, iModelId, mapping.id ?? \"\", setIsLoading);\n }, [iModelId, mapping.id, setGroups]);\n\n const addGroup = () => {\n // TODO Retain selection in view without emphasizes. Goal is to make it so we can distinguish\n // hilited elements from regular elements without emphasis due to it blocking selection. For now clearing\n // selection.\n clearEmphasizedElements();\n setGroupsView(GroupsView.ADD);\n };\n\n const onModify = useCallback((value) => {\n clearEmphasizedElements();\n setSelectedGroup(value.row.original);\n setGroupsView(GroupsView.MODIFYING);\n }, []);\n\n const openProperties = useCallback((value) => {\n clearEmphasizedElements();\n setSelectedGroup(value.row.original);\n setGroupsView(GroupsView.PROPERTIES);\n }, []);\n\n const groupsColumns = useMemo(\n () => [\n {\n Header: \"Table\",\n columns: [\n {\n id: \"groupName\",\n Header: \"Group\",\n accessor: \"groupName\",\n Cell: (value: CellProps<Group>) => (\n <>\n {isLoadingQuery ? (\n value.row.original.groupName\n ) : (\n <div\n className='iui-anchor'\n onClick={(e) => {\n e.stopPropagation();\n openProperties(value);\n }}\n >\n {value.row.original.groupName}\n </div>\n )}\n </>\n ),\n },\n {\n id: \"description\",\n Header: \"Description\",\n accessor: \"description\",\n },\n {\n id: \"dropdown\",\n Header: \"\",\n width: 80,\n Cell: (value: CellProps<Group>) => {\n return (\n <div onClick={(e) => e.stopPropagation()}>\n <DropdownMenu\n disabled={isLoadingQuery}\n menuItems={(close: () => void) => [\n <MenuItem\n key={0}\n onClick={() => onModify(value)}\n icon={<SvgEdit />}\n >\n Modify\n </MenuItem>,\n <MenuItem\n key={1}\n onClick={() => openProperties(value)}\n icon={<SvgList />}\n >\n Properties\n </MenuItem>,\n <MenuItem\n key={2}\n onClick={() => {\n setSelectedGroup(value.row.original);\n setShowDeleteModal(true);\n close();\n }}\n icon={<SvgDelete />}\n >\n Remove\n </MenuItem>,\n ]}\n >\n <IconButton\n disabled={isLoadingQuery}\n styleType='borderless'\n >\n <SvgMore\n style={{\n width: \"16px\",\n height: \"16px\",\n }}\n />\n </IconButton>\n </DropdownMenu>\n </div>\n );\n },\n },\n ],\n },\n ],\n [isLoadingQuery, onModify, openProperties],\n );\n\n // Temp\n const stringToColor = function (str: string) {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n hash = str.charCodeAt(i) + ((hash << 5) - hash);\n }\n let colour = \"#\";\n for (let i = 0; i < 3; i++) {\n const value = (hash >> (i * 8)) & 0xff;\n colour += (`00${value.toString(16)}`).substr(-2);\n }\n return colour;\n };\n\n const onSelect = useCallback(\n async (selectedData: Group[] | undefined) => {\n clearEmphasizedElements();\n if (selectedData && selectedData.length > 0) {\n setLoadingQuery(true);\n let allIds: string[] = [];\n for (const row of selectedData) {\n const query = row.query ?? \"\";\n if (hilitedElements.current.has(query)) {\n const hilitedIds = hilitedElements.current.get(query) ?? [];\n visualizeElements(hilitedIds, stringToColor(row.id ?? \"\"));\n allIds = allIds.concat(hilitedIds);\n } else {\n try {\n const ids: string[] = await fetchIdsFromQuery(\n row.query ?? \"\",\n iModelConnection,\n );\n const hiliteIds = await visualizeElementsById(\n ids,\n stringToColor(row.id ?? \"\"),\n iModelConnection,\n );\n hilitedElements.current.set(row.query ?? \"\", hiliteIds);\n\n allIds = allIds.concat(ids);\n } catch {\n const index = groups.findIndex((group) => group.id === row.id);\n setSelectedRows((rowIds) => {\n const selectedRowIds = { ...rowIds };\n delete selectedRowIds[index];\n return selectedRowIds;\n });\n toaster.negative(`Could not load ${row.groupName}.`);\n\n }\n }\n }\n await zoomToElements(allIds);\n setLoadingQuery(false);\n }\n },\n [iModelConnection, groups],\n );\n\n const controlledState = useCallback(\n (state) => {\n return {\n ...state,\n selectedRowIds: { ...selectedRows },\n };\n },\n [selectedRows],\n );\n\n const propertyMenuGoBack = useCallback(async () => {\n clearEmphasizedElements();\n setGroupsView(GroupsView.GROUPS);\n await refresh();\n }, [refresh]);\n\n const tableStateReducer = (\n newState: TableState,\n action: ActionType,\n _previousState: TableState,\n instance?: TableInstance,\n ): TableState => {\n switch (action.type) {\n case actions.toggleRowSelected: {\n const newSelectedRows = {\n ...selectedRows,\n };\n if (action.value) {\n newSelectedRows[action.id] = true;\n } else {\n delete newSelectedRows[action.id];\n }\n setSelectedRows(newSelectedRows);\n newState.selectedRowIds = newSelectedRows;\n break;\n }\n case actions.toggleAllRowsSelected: {\n if (!instance?.rowsById) {\n break;\n }\n const newSelectedRows = {} as Record<string, boolean>;\n if (action.value) {\n Object.keys(instance.rowsById).forEach(\n (id) => (newSelectedRows[id] = true),\n );\n }\n setSelectedRows(newSelectedRows);\n newState.selectedRowIds = newSelectedRows;\n break;\n }\n default:\n break;\n }\n return newState;\n };\n\n switch (groupsView) {\n case GroupsView.ADD:\n return (\n <GroupAction\n iModelId={iModelId}\n mappingId={mapping.id ?? \"\"}\n goBack={async () => {\n clearEmphasizedElements();\n setGroupsView(GroupsView.GROUPS);\n await refresh();\n }}\n />\n );\n case GroupsView.MODIFYING:\n return selectedGroup ? (\n <GroupAction\n iModelId={iModelId}\n mappingId={mapping.id ?? \"\"}\n group={selectedGroup}\n goBack={async () => {\n clearEmphasizedElements();\n setGroupsView(GroupsView.GROUPS);\n await refresh();\n }}\n />\n ) : null;\n case GroupsView.PROPERTIES:\n return selectedGroup ? (\n <PropertyMenu\n iModelId={iModelId}\n mappingId={mapping.id ?? \"\"}\n group={selectedGroup}\n goBack={propertyMenuGoBack}\n />\n ) : null;\n default:\n return (\n <>\n <WidgetHeader\n title={mapping.mappingName ?? \"\"}\n disabled={isLoading || isLoadingQuery}\n returnFn={async () => {\n clearEmphasizedElements();\n await goBack();\n }}\n />\n <div className='groups-container'>\n <Button\n startIcon={\n isLoadingQuery ? <ProgressRadial size=\"small\" indeterminate /> : <SvgAdd />\n }\n styleType='high-visibility'\n disabled={isLoadingQuery}\n onClick={() => addGroup()}\n >\n {isLoadingQuery ? \"Loading Group(s)\" : \"Add Group\"}\n </Button>\n <Table<Group>\n data={groups}\n density='extra-condensed'\n columns={groupsColumns}\n emptyTableContent='No Groups available.'\n isSortable\n isSelectable\n onSelect={onSelect}\n isLoading={isLoading}\n isRowDisabled={() => isLoadingQuery}\n stateReducer={tableStateReducer}\n useControlledState={controlledState}\n />\n </div>\n <DeleteModal\n entityName={selectedGroup?.groupName ?? \"\"}\n show={showDeleteModal}\n setShow={setShowDeleteModal}\n onDelete={async () => {\n await reportingClientApi.deleteGroup(\n iModelId,\n mapping.id ?? \"\",\n selectedGroup?.id ?? \"\",\n );\n }}\n refresh={refresh}\n />\n </>\n );\n }\n};\n"]}
1
+ {"version":3,"file":"Grouping.js","sourceRoot":"","sources":["../../../../src/widget/components/Grouping.tsx"],"names":[],"mappings":"AAUA,OAAO,EACL,OAAO,GACR,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,EACZ,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,kBAAkB,EAAE,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/B,kBAAkB,EAAE,eAAe,GACnC,CACE;gBACN,oBAAC,WAAW,IACV,UAAU,EAAE,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,SAAS,mCAAI,EAAE,EAC1C,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,KAAK,IAAI,EAAE;;wBACnB,MAAM,kBAAkB,CAAC,WAAW,CAClC,QAAQ,EACR,MAAA,OAAO,CAAC,EAAE,mCAAI,EAAE,EAChB,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,EAAE,mCAAI,EAAE,CACxB,CAAC;oBACJ,CAAC,EACD,OAAO,EAAE,OAAO,GAChB,CACD,CACJ,CAAC;KACL;AACH,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 {\n ActionType,\n CellProps,\n TableInstance,\n TableState,\n} from \"react-table\";\nimport {\n actions,\n} from \"react-table\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { GroupReportingAPI, MappingReportingAPI } from \"../../api/generated/api\";\nimport { reportingClientApi } from \"../../api/reportingClient\";\nimport type { CreateTypeFromInterface } from \"../utils\";\nimport {\n Button,\n DropdownMenu,\n IconButton,\n MenuItem,\n ProgressRadial,\n Table,\n toaster,\n} from \"@itwin/itwinui-react\";\nimport {\n SvgAdd,\n SvgDelete,\n SvgEdit,\n SvgList,\n SvgMore,\n} from \"@itwin/itwinui-icons-react\";\nimport DeleteModal from \"./DeleteModal\";\nimport \"./Grouping.scss\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport { PropertyMenu } from \"./PropertyMenu\";\nimport {\n clearEmphasizedElements,\n visualizeElements,\n visualizeElementsById,\n zoomToElements,\n} from \"./viewerUtils\";\nimport { fetchIdsFromQuery, handleError, WidgetHeader } from \"./utils\";\nimport GroupAction from \"./GroupAction\";\n\nexport type Group = CreateTypeFromInterface<GroupReportingAPI>;\n\nenum GroupsView {\n GROUPS = \"groups\",\n MODIFYING = \"modifying\",\n ADD = \"ADD\",\n PROPERTIES = \"properties\",\n}\n\ninterface GroupsTreeProps {\n mapping: MappingReportingAPI;\n goBack: () => Promise<void>;\n}\n\nconst fetchGroups = async (\n setGroups: React.Dispatch<React.SetStateAction<Group[]>>,\n iModelId: string,\n mappingId: string,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,\n) => {\n try {\n setIsLoading(true);\n const groups = await reportingClientApi.getGroups(iModelId, mappingId);\n setGroups(groups.groups ?? []);\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n};\n\nconst useFetchGroups = (\n iModelId: string,\n mappingId: string,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,\n): [Group[], React.Dispatch<React.SetStateAction<Group[]>>] => {\n const [groups, setGroups] = useState<GroupReportingAPI[]>([]);\n\n useEffect(() => {\n void fetchGroups(setGroups, iModelId, mappingId, setIsLoading);\n }, [iModelId, mappingId, setIsLoading]);\n\n return [groups, setGroups];\n};\n\nexport const Groupings = ({ mapping, goBack }: GroupsTreeProps) => {\n const iModelConnection = useActiveIModelConnection() as IModelConnection;\n const iModelId = useActiveIModelConnection()?.iModelId as string;\n const [showDeleteModal, setShowDeleteModal] = useState<boolean>(false);\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [groupsView, setGroupsView] = useState<GroupsView>(GroupsView.GROUPS);\n const [selectedGroup, setSelectedGroup] = useState<Group | undefined>(\n undefined,\n );\n const [groups, setGroups] = useFetchGroups(\n iModelId,\n mapping.id ?? \"\",\n setIsLoading,\n );\n const hilitedElements = useRef<Map<string, string[]>>(new Map());\n const [selectedRows, setSelectedRows] = useState<Record<string, boolean>>({});\n const [isLoadingQuery, setLoadingQuery] = useState<boolean>(false);\n\n const refresh = useCallback(async () => {\n setGroupsView(GroupsView.GROUPS);\n setSelectedGroup(undefined);\n setGroups([]);\n await fetchGroups(setGroups, iModelId, mapping.id ?? \"\", setIsLoading);\n }, [iModelId, mapping.id, setGroups]);\n\n const addGroup = () => {\n // TODO Retain selection in view without emphasizes. Goal is to make it so we can distinguish\n // hilited elements from regular elements without emphasis due to it blocking selection. For now clearing\n // selection.\n clearEmphasizedElements();\n setGroupsView(GroupsView.ADD);\n };\n\n const onModify = useCallback((value) => {\n clearEmphasizedElements();\n setSelectedGroup(value.row.original);\n setGroupsView(GroupsView.MODIFYING);\n }, []);\n\n const openProperties = useCallback((value) => {\n clearEmphasizedElements();\n setSelectedGroup(value.row.original);\n setGroupsView(GroupsView.PROPERTIES);\n }, []);\n\n const groupsColumns = useMemo(\n () => [\n {\n Header: \"Table\",\n columns: [\n {\n id: \"groupName\",\n Header: \"Group\",\n accessor: \"groupName\",\n Cell: (value: CellProps<Group>) => (\n <>\n {isLoadingQuery ? (\n value.row.original.groupName\n ) : (\n <div\n className='iui-anchor'\n onClick={(e) => {\n e.stopPropagation();\n openProperties(value);\n }}\n >\n {value.row.original.groupName}\n </div>\n )}\n </>\n ),\n },\n {\n id: \"description\",\n Header: \"Description\",\n accessor: \"description\",\n },\n {\n id: \"dropdown\",\n Header: \"\",\n width: 80,\n Cell: (value: CellProps<Group>) => {\n return (\n <div onClick={(e) => e.stopPropagation()}>\n <DropdownMenu\n disabled={isLoadingQuery}\n menuItems={(close: () => void) => [\n <MenuItem\n key={0}\n onClick={() => onModify(value)}\n icon={<SvgEdit />}\n >\n Modify\n </MenuItem>,\n <MenuItem\n key={1}\n onClick={() => openProperties(value)}\n icon={<SvgList />}\n >\n Properties\n </MenuItem>,\n <MenuItem\n key={2}\n onClick={() => {\n setSelectedGroup(value.row.original);\n setShowDeleteModal(true);\n close();\n }}\n icon={<SvgDelete />}\n >\n Remove\n </MenuItem>,\n ]}\n >\n <IconButton\n disabled={isLoadingQuery}\n styleType='borderless'\n >\n <SvgMore\n style={{\n width: \"16px\",\n height: \"16px\",\n }}\n />\n </IconButton>\n </DropdownMenu>\n </div>\n );\n },\n },\n ],\n },\n ],\n [isLoadingQuery, onModify, openProperties],\n );\n\n // Temp\n const stringToColor = function (str: string) {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n hash = str.charCodeAt(i) + ((hash << 5) - hash);\n }\n let colour = \"#\";\n for (let i = 0; i < 3; i++) {\n const value = (hash >> (i * 8)) & 0xff;\n colour += (`00${value.toString(16)}`).substr(-2);\n }\n return colour;\n };\n\n const onSelect = useCallback(\n async (selectedData: Group[] | undefined) => {\n clearEmphasizedElements();\n if (selectedData && selectedData.length > 0) {\n setLoadingQuery(true);\n let allIds: string[] = [];\n for (const row of selectedData) {\n const query = row.query ?? \"\";\n if (hilitedElements.current.has(query)) {\n const hilitedIds = hilitedElements.current.get(query) ?? [];\n visualizeElements(hilitedIds, stringToColor(row.id ?? \"\"));\n allIds = allIds.concat(hilitedIds);\n } else {\n try {\n const ids: string[] = await fetchIdsFromQuery(\n query,\n iModelConnection,\n );\n if (ids.length === 0) {\n toaster.warning(`${row.groupName}'s query is valid but produced no results.`);\n }\n const hiliteIds = await visualizeElementsById(\n ids,\n stringToColor(row.id ?? \"\"),\n iModelConnection,\n );\n hilitedElements.current.set(query, hiliteIds);\n\n allIds = allIds.concat(ids);\n } catch {\n const index = groups.findIndex((group) => group.id === row.id);\n setSelectedRows((rowIds) => {\n const selectedRowIds = { ...rowIds };\n delete selectedRowIds[index];\n return selectedRowIds;\n });\n toaster.negative(`Could not load ${row.groupName}. Query could not be resolved.`);\n\n }\n }\n }\n await zoomToElements(allIds);\n setLoadingQuery(false);\n }\n },\n [iModelConnection, groups],\n );\n\n const controlledState = useCallback(\n (state) => {\n return {\n ...state,\n selectedRowIds: { ...selectedRows },\n };\n },\n [selectedRows],\n );\n\n const propertyMenuGoBack = useCallback(async () => {\n clearEmphasizedElements();\n setGroupsView(GroupsView.GROUPS);\n await refresh();\n }, [refresh]);\n\n const tableStateReducer = (\n newState: TableState,\n action: ActionType,\n _previousState: TableState,\n instance?: TableInstance,\n ): TableState => {\n switch (action.type) {\n case actions.toggleRowSelected: {\n const newSelectedRows = {\n ...selectedRows,\n };\n if (action.value) {\n newSelectedRows[action.id] = true;\n } else {\n delete newSelectedRows[action.id];\n }\n setSelectedRows(newSelectedRows);\n newState.selectedRowIds = newSelectedRows;\n break;\n }\n case actions.toggleAllRowsSelected: {\n if (!instance?.rowsById) {\n break;\n }\n const newSelectedRows = {} as Record<string, boolean>;\n if (action.value) {\n Object.keys(instance.rowsById).forEach(\n (id) => (newSelectedRows[id] = true),\n );\n }\n setSelectedRows(newSelectedRows);\n newState.selectedRowIds = newSelectedRows;\n break;\n }\n default:\n break;\n }\n return newState;\n };\n\n switch (groupsView) {\n case GroupsView.ADD:\n return (\n <GroupAction\n iModelId={iModelId}\n mappingId={mapping.id ?? \"\"}\n goBack={async () => {\n clearEmphasizedElements();\n setGroupsView(GroupsView.GROUPS);\n await refresh();\n }}\n />\n );\n case GroupsView.MODIFYING:\n return selectedGroup ? (\n <GroupAction\n iModelId={iModelId}\n mappingId={mapping.id ?? \"\"}\n group={selectedGroup}\n goBack={async () => {\n clearEmphasizedElements();\n setGroupsView(GroupsView.GROUPS);\n await refresh();\n }}\n />\n ) : null;\n case GroupsView.PROPERTIES:\n return selectedGroup ? (\n <PropertyMenu\n iModelId={iModelId}\n mappingId={mapping.id ?? \"\"}\n group={selectedGroup}\n goBack={propertyMenuGoBack}\n />\n ) : null;\n default:\n return (\n <>\n <WidgetHeader\n title={mapping.mappingName ?? \"\"}\n disabled={isLoading || isLoadingQuery}\n returnFn={async () => {\n clearEmphasizedElements();\n await goBack();\n }}\n />\n <div className='groups-container'>\n <Button\n startIcon={\n isLoadingQuery ? <ProgressRadial size=\"small\" indeterminate /> : <SvgAdd />\n }\n styleType='high-visibility'\n disabled={isLoadingQuery}\n onClick={() => addGroup()}\n >\n {isLoadingQuery ? \"Loading Group(s)\" : \"Add Group\"}\n </Button>\n <Table<Group>\n data={groups}\n density='extra-condensed'\n columns={groupsColumns}\n emptyTableContent='No Groups available.'\n isSortable\n isSelectable\n onSelect={onSelect}\n isLoading={isLoading}\n isRowDisabled={() => isLoadingQuery}\n stateReducer={tableStateReducer}\n useControlledState={controlledState}\n />\n </div>\n <DeleteModal\n entityName={selectedGroup?.groupName ?? \"\"}\n show={showDeleteModal}\n setShow={setShowDeleteModal}\n onDelete={async () => {\n await reportingClientApi.deleteGroup(\n iModelId,\n mapping.id ?? \"\",\n selectedGroup?.id ?? \"\",\n );\n }}\n refresh={refresh}\n />\n </>\n );\n }\n};\n"]}
@@ -69,7 +69,7 @@ const MappingAction = ({ iModelId, mapping, returnFn }) => {
69
69
  handleInputChange(event, values, setValues);
70
70
  validator.showMessageFor("description");
71
71
  } }))),
72
- React.createElement(ActionPanel, { onSave: onSave, onCancel: returnFn, disabled: !(values.name && values.description), isLoading: isLoading })));
72
+ React.createElement(ActionPanel, { onSave: onSave, onCancel: returnFn, isSavingDisabled: !(values.name && values.description), isLoading: isLoading })));
73
73
  };
74
74
  export default MappingAction;
75
75
  //# sourceMappingURL=MappingAction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MappingAction.js","sourceRoot":"","sources":["../../../../src/widget/components/MappingAction.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,YAAY,EAAE,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvE,O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EAAE,MAAM,CAAC,WAAW,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;wBAClB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;wBAC5C,SAAS,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;oBAC1C,CAAC,EACD,OAAO,EAAE,SAAS,CAAC,OAAO,CACxB,aAAa,EACb,MAAM,CAAC,WAAW,EAClB,UAAU,CACX,EACD,MAAM,EACJ,SAAS,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,WAAW,EAAE,UAAU,CAAC;wBAC9D,CAAC,CAAC,UAAU;wBACZ,CAAC,CAAC,SAAS,EAEf,MAAM,EAAE,GAAG,EAAE;wBACX,SAAS,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;oBAC1C,CAAC,EACD,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE;wBACvB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;wBAC5C,SAAS,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;oBAC1C,CAAC,GACD,CACO,CACP;QACN,oBAAC,WAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,WAAW,CAAC,EAC9C,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,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 { Fieldset, LabeledInput, Small } from \"@itwin/itwinui-react\";\nimport React, { useState } from \"react\";\nimport type { MappingReportingAPI } from \"../../api/generated/api\";\nimport { reportingClientApi } from \"../../api/reportingClient\";\nimport ActionPanel from \"./ActionPanel\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError, handleInputChange, WidgetHeader } from \"./utils\";\nimport \"./MappingAction.scss\";\n\ninterface MappingActionProps {\n iModelId: string;\n mapping?: MappingReportingAPI;\n returnFn: () => Promise<void>;\n}\n\nconst MappingAction = ({ iModelId, mapping, returnFn }: MappingActionProps) => {\n const [values, setValues] = useState({\n name: mapping?.mappingName ?? \"\",\n description: mapping?.description ?? \"\",\n });\n const [validator, showValidationMessage] = useValidator();\n const [isLoading, setIsLoading] = useState<boolean>(false);\n\n // TODO ERRORED STATE\n const onSave = async () => {\n try {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n setIsLoading(true);\n mapping\n ? await reportingClientApi.updateMapping(iModelId, mapping.id ?? \"\", {\n mappingName: values.name,\n description: values.description,\n })\n : await reportingClientApi.createMapping(iModelId, {\n mappingName: values.name,\n description: values.description,\n });\n await returnFn();\n } catch (error: any) {\n handleError(error.status);\n setIsLoading(false);\n }\n };\n\n return (\n <>\n <WidgetHeader\n title={mapping ? \"Modify Mapping\" : \"Add Mapping\"}\n returnFn={returnFn}\n />\n <div className='details-form-container'>\n <Fieldset legend='Mapping Details' className='details-form'>\n <Small className='field-legend'>\n Asterisk * indicates mandatory fields.\n </Small>\n <LabeledInput\n id='name'\n name='name'\n label='Name'\n value={values.name}\n required\n onChange={(event) => {\n handleInputChange(event, values, setValues);\n validator.showMessageFor(\"name\");\n }}\n message={validator.message(\"name\", values.name, NAME_REQUIREMENTS)}\n status={\n validator.message(\"name\", values.name, NAME_REQUIREMENTS)\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"name\");\n }}\n onBlurCapture={(event) => {\n handleInputChange(event, values, setValues);\n validator.showMessageFor(\"name\");\n }}\n />\n <LabeledInput\n id='description'\n required\n name='description'\n label='Description'\n value={values.description}\n onChange={(event) => {\n handleInputChange(event, values, setValues);\n validator.showMessageFor(\"description\");\n }}\n message={validator.message(\n \"description\",\n values.description,\n \"required\",\n )}\n status={\n validator.message(\"description\", values.description, \"required\")\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"description\");\n }}\n onBlurCapture={(event) => {\n handleInputChange(event, values, setValues);\n validator.showMessageFor(\"description\");\n }}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={returnFn}\n disabled={!(values.name && values.description)}\n isLoading={isLoading}\n />\n </>\n );\n};\n\nexport default MappingAction;\n"]}
1
+ {"version":3,"file":"MappingAction.js","sourceRoot":"","sources":["../../../../src/widget/components/MappingAction.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,YAAY,EAAE,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,sBAAsB,CAAC;AAQ9B,MAAM,aAAa,GAAG,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAsB,EAAE,EAAE;;IAC5E,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC;QACnC,IAAI,EAAE,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,mCAAI,EAAE;QAChC,WAAW,EAAE,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,mCAAI,EAAE;KACxC,CAAC,CAAC;IACH,MAAM,CAAC,SAAS,EAAE,qBAAqB,CAAC,GAAG,YAAY,EAAE,CAAC;IAC1D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC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AS,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;oBAC1C,CAAC,EACD,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE;wBACvB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;wBAC5C,SAAS,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;oBAC1C,CAAC,GACD,CACO,CACP;QACN,oBAAC,WAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,WAAW,CAAC,EACtD,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,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 { Fieldset, LabeledInput, Small } from \"@itwin/itwinui-react\";\nimport React, { useState } from \"react\";\nimport type { MappingReportingAPI } from \"../../api/generated/api\";\nimport { reportingClientApi } from \"../../api/reportingClient\";\nimport ActionPanel from \"./ActionPanel\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError, handleInputChange, WidgetHeader } from \"./utils\";\nimport \"./MappingAction.scss\";\n\ninterface MappingActionProps {\n iModelId: string;\n mapping?: MappingReportingAPI;\n returnFn: () => Promise<void>;\n}\n\nconst MappingAction = ({ iModelId, mapping, returnFn }: MappingActionProps) => {\n const [values, setValues] = useState({\n name: mapping?.mappingName ?? \"\",\n description: mapping?.description ?? \"\",\n });\n const [validator, showValidationMessage] = useValidator();\n const [isLoading, setIsLoading] = useState<boolean>(false);\n\n // TODO ERRORED STATE\n const onSave = async () => {\n try {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n setIsLoading(true);\n mapping\n ? await reportingClientApi.updateMapping(iModelId, mapping.id ?? \"\", {\n mappingName: values.name,\n description: values.description,\n })\n : await reportingClientApi.createMapping(iModelId, {\n mappingName: values.name,\n description: values.description,\n });\n await returnFn();\n } catch (error: any) {\n handleError(error.status);\n setIsLoading(false);\n }\n };\n\n return (\n <>\n <WidgetHeader\n title={mapping ? \"Modify Mapping\" : \"Add Mapping\"}\n returnFn={returnFn}\n />\n <div className='details-form-container'>\n <Fieldset legend='Mapping Details' className='details-form'>\n <Small className='field-legend'>\n Asterisk * indicates mandatory fields.\n </Small>\n <LabeledInput\n id='name'\n name='name'\n label='Name'\n value={values.name}\n required\n onChange={(event) => {\n handleInputChange(event, values, setValues);\n validator.showMessageFor(\"name\");\n }}\n message={validator.message(\"name\", values.name, NAME_REQUIREMENTS)}\n status={\n validator.message(\"name\", values.name, NAME_REQUIREMENTS)\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"name\");\n }}\n onBlurCapture={(event) => {\n handleInputChange(event, values, setValues);\n validator.showMessageFor(\"name\");\n }}\n />\n <LabeledInput\n id='description'\n required\n name='description'\n label='Description'\n value={values.description}\n onChange={(event) => {\n handleInputChange(event, values, setValues);\n validator.showMessageFor(\"description\");\n }}\n message={validator.message(\n \"description\",\n values.description,\n \"required\",\n )}\n status={\n validator.message(\"description\", values.description, \"required\")\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"description\");\n }}\n onBlurCapture={(event) => {\n handleInputChange(event, values, setValues);\n validator.showMessageFor(\"description\");\n }}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={returnFn}\n isSavingDisabled={!(values.name && values.description)}\n isLoading={isLoading}\n />\n </>\n );\n};\n\nexport default MappingAction;\n"]}
@@ -39,6 +39,10 @@ export const PropertyMenu = ({ iModelId, mappingId, group, goBack, hideGroupProp
39
39
  var _a;
40
40
  try {
41
41
  const ids = await fetchIdsFromQuery((_a = group.query) !== null && _a !== void 0 ? _a : "", iModelConnection);
42
+ if (ids.length === 0) {
43
+ toaster.warning("The query is valid but produced no results.");
44
+ await goBack();
45
+ }
42
46
  const keys = await manufactureKeys(ids, iModelConnection);
43
47
  setKeySet(keys);
44
48
  Presentation.selection.clearSelection("GroupingMappingWidget", iModelConnection);
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyMenu.js","sourceRoot":"","sources":["../../../../src/widget/components/PropertyMenu.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACvB,cAAc,GACf,MAAM,eAAe,CAAC;AAEvB,OAAO,qBAAqB,CAAC;AAC7B,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAElE,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAItD,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAChE,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,cAAc,EACd,IAAI,EACJ,OAAO,GACR,MAAM,sBAAsB,CAAC;AAK9B,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAC9D,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAY3D,MAAM,CAAN,IAAY,gBAQX;AARD,WAAY,gBAAgB;IAC1B,uCAAmB,CAAA;IACnB,6DAAyC,C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C7B,oBAAC,sBAAsB,IACrB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,MAAA,KAAK,CAAC,EAAE,mCAAI,EAAE,EACvB,yBAAyB,EAAE,yBAAyB,EACpD,4BAA4B,EAAE,4BAA4B,EAC1D,kBAAkB,EAAE,mBAAmB,EACvC,yBAAyB,EAAE,yBAAyB,GACpD,CACE,CACP,CACG;gBACN,oBAAC,gBAAgB,IACf,SAAS,EAAC,mBAAmB,EAC7B,MAAM,EAAE,sBAAsB;oBAE9B,oBAAC,sBAAsB,IACrB,OAAO,EAAE,GAAG,EAAE,CAAC,yBAAyB,CAAC,KAAK,CAAC;wBAE/C,oBAAC,IAAI,IAAC,OAAO,EAAC,YAAY,IAAE,GAAG,MAAA,KAAK,CAAC,SAAS,mCAAI,EAClD,cAAc,CAAQ,CACC;oBACzB,oBAAC,oBAAoB;wBACnB,6BAAK,SAAS,EAAC,kBAAkB;4BAC/B,oBAAC,eAAe,IACd,KAAK,EAAC,OAAO,EACb,IAAI,EAAE,EAAE,EACR,QAAQ,QACR,YAAY,EAAE,MAAA,KAAK,CAAC,KAAK,mCAAI,EAAE,GAC/B,CACE,CACe,CACN,CACK,CAC3B,CAAC;KACL;AACH,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 { IModelConnection } from \"@itwin/core-frontend\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport React, { useCallback, useEffect, useState } from \"react\";\n\nimport { fetchIdsFromQuery, WidgetHeader } from \"./utils\";\nimport {\n clearEmphasizedElements,\n manufactureKeys,\n visualizeElements,\n visualizeElementsByKeys,\n zoomToElements,\n} from \"./viewerUtils\";\nimport type { Group } from \"./Grouping\";\nimport \"./PropertyMenu.scss\";\nimport GroupPropertyAction from \"./GroupPropertyAction\";\nimport CalculatedPropertyAction from \"./CalculatedPropertyAction\";\nimport type { GroupProperty } from \"./GroupPropertyTable\";\nimport GroupPropertyTable from \"./GroupPropertyTable\";\nimport type {\n CalculatedProperty,\n} from \"./CalculatedPropertyTable\";\nimport CalculatedPropertyTable from \"./CalculatedPropertyTable\";\nimport {\n IconButton,\n InformationPanel,\n InformationPanelBody,\n InformationPanelHeader,\n InformationPanelWrapper,\n LabeledTextarea,\n ProgressRadial,\n Text,\n toaster,\n} from \"@itwin/itwinui-react\";\nimport type { CellProps } from \"react-table\";\nimport type {\n CustomCalculation,\n} from \"./CustomCalculationTable\";\nimport CustomCalculationTable from \"./CustomCalculationTable\";\nimport CustomCalculationAction from \"./CustomCalculationAction\";\nimport { KeySet } from \"@itwin/presentation-common\";\nimport { SvgProperties } from \"@itwin/itwinui-icons-react\";\n\ninterface PropertyModifyProps {\n iModelId: string;\n mappingId: string;\n group: Group;\n goBack: () => Promise<void>;\n hideGroupProps?: boolean;\n hideCalculatedProps?: boolean;\n hideCustomCalculationProps?: boolean;\n}\n\nexport enum PropertyMenuView {\n DEFAULT = \"default\",\n ADD_GROUP_PROPERTY = \"add_group_property\",\n MODIFY_GROUP_PROPERTY = \"modify_group_property\",\n ADD_CALCULATED_PROPERTY = \"add_calculated_property\",\n MODIFY_CALCULATED_PROPERTY = \"modify_calculated_property\",\n ADD_CUSTOM_CALCULATION = \"add_custom_calculation\",\n MODIFY_CUSTOM_CALCULATION = \"modify_custom_calculation\",\n}\n\nexport const PropertyMenu = ({\n iModelId,\n mappingId,\n group,\n goBack,\n hideGroupProps = false,\n hideCalculatedProps = false,\n hideCustomCalculationProps = false,\n}: PropertyModifyProps) => {\n const iModelConnection = useActiveIModelConnection() as IModelConnection;\n const [propertyMenuView, setPropertyMenuView] = useState<PropertyMenuView>(\n PropertyMenuView.DEFAULT,\n );\n const [selectedGroupProperty, setSelectedGroupProperty] = useState<\n GroupProperty | undefined\n >(undefined);\n const [selectedCalculatedProperty, setSelectedCalculatedProperty] = useState<\n CalculatedProperty | undefined\n >(undefined);\n const [selectedCustomCalculation, setSelectedCustomCalculation] = useState<\n CustomCalculation | undefined\n >(undefined);\n const [isInformationPanelOpen, setIsInformationPanelOpen] =\n useState<boolean>(false);\n const [resolvedHiliteIds, setResolvedHiliteIds] = useState<string[]>([]);\n const [keySet, setKeySet] = useState<KeySet>();\n const [isLoading, setIsLoading] = useState<boolean>(true);\n\n useEffect(() => {\n const initialize = async () => {\n try {\n const ids = await fetchIdsFromQuery(group.query ?? \"\", iModelConnection);\n const keys = await manufactureKeys(ids, iModelConnection);\n setKeySet(keys);\n Presentation.selection.clearSelection(\n \"GroupingMappingWidget\",\n iModelConnection,\n );\n clearEmphasizedElements();\n const resolvedIds = await visualizeElementsByKeys(keys, \"red\");\n await zoomToElements(resolvedIds);\n setResolvedHiliteIds(resolvedIds);\n setIsLoading(false);\n } catch {\n toaster.negative(`Could not load ${group.groupName}.`);\n await goBack();\n }\n };\n void initialize();\n }, [iModelConnection, group.query, goBack, group.groupName]);\n\n const onGroupPropertyModify = useCallback(\n (value: CellProps<GroupProperty>) => {\n setSelectedGroupProperty(value.row.original);\n setPropertyMenuView(PropertyMenuView.MODIFY_GROUP_PROPERTY);\n },\n [],\n );\n\n const onCalculatedPropertyModify = useCallback(\n (value: CellProps<CalculatedProperty>) => {\n setSelectedCalculatedProperty(value.row.original);\n setPropertyMenuView(PropertyMenuView.MODIFY_CALCULATED_PROPERTY);\n },\n [],\n );\n\n const onCustomCalculationModify = useCallback(\n (value: CellProps<CustomCalculation>) => {\n setSelectedCustomCalculation(value.row.original);\n setPropertyMenuView(PropertyMenuView.MODIFY_CUSTOM_CALCULATION);\n },\n [],\n );\n\n const calculatedPropertyReturn = useCallback(async () => {\n visualizeElements(resolvedHiliteIds, \"red\");\n await zoomToElements(resolvedHiliteIds);\n setPropertyMenuView(PropertyMenuView.DEFAULT);\n }, [resolvedHiliteIds]);\n\n if (isLoading) {\n return (\n <div className='loading-overlay'>\n <Text>Loading Group</Text>\n <ProgressRadial indeterminate />\n <Text>Please wait...</Text>\n </div>\n );\n }\n\n switch (propertyMenuView) {\n case PropertyMenuView.ADD_GROUP_PROPERTY:\n return (\n <GroupPropertyAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n keySet={keySet ?? new KeySet()}\n returnFn={async () => {\n setPropertyMenuView(PropertyMenuView.DEFAULT);\n }}\n />\n );\n case PropertyMenuView.MODIFY_GROUP_PROPERTY:\n return (\n <GroupPropertyAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n keySet={keySet ?? new KeySet()}\n groupPropertyId={selectedGroupProperty?.id ?? \"\"}\n groupPropertyName={selectedGroupProperty?.propertyName ?? \"\"}\n returnFn={async () => {\n setPropertyMenuView(PropertyMenuView.DEFAULT);\n }}\n />\n );\n case PropertyMenuView.ADD_CALCULATED_PROPERTY:\n return (\n <CalculatedPropertyAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n ids={resolvedHiliteIds}\n returnFn={calculatedPropertyReturn}\n />\n );\n case PropertyMenuView.MODIFY_CALCULATED_PROPERTY:\n return (\n <CalculatedPropertyAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n property={selectedCalculatedProperty}\n ids={resolvedHiliteIds}\n returnFn={calculatedPropertyReturn}\n />\n );\n case PropertyMenuView.ADD_CUSTOM_CALCULATION:\n return (\n <CustomCalculationAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n returnFn={async () => {\n setPropertyMenuView(PropertyMenuView.DEFAULT);\n }}\n />\n );\n case PropertyMenuView.MODIFY_CUSTOM_CALCULATION:\n return (\n <CustomCalculationAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n customCalculation={selectedCustomCalculation}\n returnFn={calculatedPropertyReturn}\n />\n );\n default:\n return (\n <InformationPanelWrapper className='property-menu-wrapper'>\n <div className='property-header'>\n <WidgetHeader\n title={`${group.groupName ?? \"\"}`}\n returnFn={goBack}\n />\n <IconButton\n styleType='borderless'\n onClick={() => setIsInformationPanelOpen(true)}\n >\n <SvgProperties />\n </IconButton>\n </div>\n <div className='property-menu-container'>\n {!hideGroupProps && (\n <div className='property-table'>\n <GroupPropertyTable\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n onGroupPropertyModify={onGroupPropertyModify}\n setSelectedGroupProperty={setSelectedGroupProperty}\n setGroupModifyView={setPropertyMenuView}\n selectedGroupProperty={selectedGroupProperty}\n />\n </div>\n )}\n\n {!hideCalculatedProps && (\n <div className='property-table'>\n <CalculatedPropertyTable\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n onCalculatedPropertyModify={onCalculatedPropertyModify}\n setSelectedCalculatedProperty={setSelectedCalculatedProperty}\n setGroupModifyView={setPropertyMenuView}\n selectedCalculatedProperty={selectedCalculatedProperty}\n />\n </div>\n )}\n {!hideCustomCalculationProps && (\n <div className='property-table'>\n <CustomCalculationTable\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n onCustomCalculationModify={onCustomCalculationModify}\n setSelectedCustomCalculation={setSelectedCustomCalculation}\n setGroupModifyView={setPropertyMenuView}\n selectedCustomCalculation={selectedCustomCalculation}\n />\n </div>\n )}\n </div>\n <InformationPanel\n className='information-panel'\n isOpen={isInformationPanelOpen}\n >\n <InformationPanelHeader\n onClose={() => setIsInformationPanelOpen(false)}\n >\n <Text variant='subheading'>{`${group.groupName ?? \"\"\n } Information`}</Text>\n </InformationPanelHeader>\n <InformationPanelBody>\n <div className='information-body'>\n <LabeledTextarea\n label='Query'\n rows={15}\n readOnly\n defaultValue={group.query ?? \"\"}\n />\n </div>\n </InformationPanelBody>\n </InformationPanel>\n </InformationPanelWrapper>\n );\n }\n};\n"]}
1
+ {"version":3,"file":"PropertyMenu.js","sourceRo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AS,EACpB,OAAO,EAAE,MAAA,KAAK,CAAC,EAAE,mCAAI,EAAE,EACvB,yBAAyB,EAAE,yBAAyB,EACpD,4BAA4B,EAAE,4BAA4B,EAC1D,kBAAkB,EAAE,mBAAmB,EACvC,yBAAyB,EAAE,yBAAyB,GACpD,CACE,CACP,CACG;gBACN,oBAAC,gBAAgB,IACf,SAAS,EAAC,mBAAmB,EAC7B,MAAM,EAAE,sBAAsB;oBAE9B,oBAAC,sBAAsB,IACrB,OAAO,EAAE,GAAG,EAAE,CAAC,yBAAyB,CAAC,KAAK,CAAC;wBAE/C,oBAAC,IAAI,IAAC,OAAO,EAAC,YAAY,IAAE,GAAG,MAAA,KAAK,CAAC,SAAS,mCAAI,EAClD,cAAc,CAAQ,CACC;oBACzB,oBAAC,oBAAoB;wBACnB,6BAAK,SAAS,EAAC,kBAAkB;4BAC/B,oBAAC,eAAe,IACd,KAAK,EAAC,OAAO,EACb,IAAI,EAAE,EAAE,EACR,QAAQ,QACR,YAAY,EAAE,MAAA,KAAK,CAAC,KAAK,mCAAI,EAAE,GAC/B,CACE,CACe,CACN,CACK,CAC3B,CAAC;KACL;AACH,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 { IModelConnection } from \"@itwin/core-frontend\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport React, { useCallback, useEffect, useState } from \"react\";\n\nimport { fetchIdsFromQuery, WidgetHeader } from \"./utils\";\nimport {\n clearEmphasizedElements,\n manufactureKeys,\n visualizeElements,\n visualizeElementsByKeys,\n zoomToElements,\n} from \"./viewerUtils\";\nimport type { Group } from \"./Grouping\";\nimport \"./PropertyMenu.scss\";\nimport GroupPropertyAction from \"./GroupPropertyAction\";\nimport CalculatedPropertyAction from \"./CalculatedPropertyAction\";\nimport type { GroupProperty } from \"./GroupPropertyTable\";\nimport GroupPropertyTable from \"./GroupPropertyTable\";\nimport type {\n CalculatedProperty,\n} from \"./CalculatedPropertyTable\";\nimport CalculatedPropertyTable from \"./CalculatedPropertyTable\";\nimport {\n IconButton,\n InformationPanel,\n InformationPanelBody,\n InformationPanelHeader,\n InformationPanelWrapper,\n LabeledTextarea,\n ProgressRadial,\n Text,\n toaster,\n} from \"@itwin/itwinui-react\";\nimport type { CellProps } from \"react-table\";\nimport type {\n CustomCalculation,\n} from \"./CustomCalculationTable\";\nimport CustomCalculationTable from \"./CustomCalculationTable\";\nimport CustomCalculationAction from \"./CustomCalculationAction\";\nimport { KeySet } from \"@itwin/presentation-common\";\nimport { SvgProperties } from \"@itwin/itwinui-icons-react\";\n\ninterface PropertyModifyProps {\n iModelId: string;\n mappingId: string;\n group: Group;\n goBack: () => Promise<void>;\n hideGroupProps?: boolean;\n hideCalculatedProps?: boolean;\n hideCustomCalculationProps?: boolean;\n}\n\nexport enum PropertyMenuView {\n DEFAULT = \"default\",\n ADD_GROUP_PROPERTY = \"add_group_property\",\n MODIFY_GROUP_PROPERTY = \"modify_group_property\",\n ADD_CALCULATED_PROPERTY = \"add_calculated_property\",\n MODIFY_CALCULATED_PROPERTY = \"modify_calculated_property\",\n ADD_CUSTOM_CALCULATION = \"add_custom_calculation\",\n MODIFY_CUSTOM_CALCULATION = \"modify_custom_calculation\",\n}\n\nexport const PropertyMenu = ({\n iModelId,\n mappingId,\n group,\n goBack,\n hideGroupProps = false,\n hideCalculatedProps = false,\n hideCustomCalculationProps = false,\n}: PropertyModifyProps) => {\n const iModelConnection = useActiveIModelConnection() as IModelConnection;\n const [propertyMenuView, setPropertyMenuView] = useState<PropertyMenuView>(\n PropertyMenuView.DEFAULT,\n );\n const [selectedGroupProperty, setSelectedGroupProperty] = useState<\n GroupProperty | undefined\n >(undefined);\n const [selectedCalculatedProperty, setSelectedCalculatedProperty] = useState<\n CalculatedProperty | undefined\n >(undefined);\n const [selectedCustomCalculation, setSelectedCustomCalculation] = useState<\n CustomCalculation | undefined\n >(undefined);\n const [isInformationPanelOpen, setIsInformationPanelOpen] =\n useState<boolean>(false);\n const [resolvedHiliteIds, setResolvedHiliteIds] = useState<string[]>([]);\n const [keySet, setKeySet] = useState<KeySet>();\n const [isLoading, setIsLoading] = useState<boolean>(true);\n\n useEffect(() => {\n const initialize = async () => {\n try {\n const ids = await fetchIdsFromQuery(group.query ?? \"\", iModelConnection);\n if (ids.length === 0) {\n toaster.warning(\"The query is valid but produced no results.\");\n await goBack();\n }\n const keys = await manufactureKeys(ids, iModelConnection);\n setKeySet(keys);\n Presentation.selection.clearSelection(\n \"GroupingMappingWidget\",\n iModelConnection,\n );\n clearEmphasizedElements();\n const resolvedIds = await visualizeElementsByKeys(keys, \"red\");\n await zoomToElements(resolvedIds);\n setResolvedHiliteIds(resolvedIds);\n setIsLoading(false);\n } catch {\n toaster.negative(`Could not load ${group.groupName}.`);\n await goBack();\n }\n };\n void initialize();\n }, [iModelConnection, group.query, goBack, group.groupName]);\n\n const onGroupPropertyModify = useCallback(\n (value: CellProps<GroupProperty>) => {\n setSelectedGroupProperty(value.row.original);\n setPropertyMenuView(PropertyMenuView.MODIFY_GROUP_PROPERTY);\n },\n [],\n );\n\n const onCalculatedPropertyModify = useCallback(\n (value: CellProps<CalculatedProperty>) => {\n setSelectedCalculatedProperty(value.row.original);\n setPropertyMenuView(PropertyMenuView.MODIFY_CALCULATED_PROPERTY);\n },\n [],\n );\n\n const onCustomCalculationModify = useCallback(\n (value: CellProps<CustomCalculation>) => {\n setSelectedCustomCalculation(value.row.original);\n setPropertyMenuView(PropertyMenuView.MODIFY_CUSTOM_CALCULATION);\n },\n [],\n );\n\n const calculatedPropertyReturn = useCallback(async () => {\n visualizeElements(resolvedHiliteIds, \"red\");\n await zoomToElements(resolvedHiliteIds);\n setPropertyMenuView(PropertyMenuView.DEFAULT);\n }, [resolvedHiliteIds]);\n\n if (isLoading) {\n return (\n <div className='loading-overlay'>\n <Text>Loading Group</Text>\n <ProgressRadial indeterminate />\n <Text>Please wait...</Text>\n </div>\n );\n }\n\n switch (propertyMenuView) {\n case PropertyMenuView.ADD_GROUP_PROPERTY:\n return (\n <GroupPropertyAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n keySet={keySet ?? new KeySet()}\n returnFn={async () => {\n setPropertyMenuView(PropertyMenuView.DEFAULT);\n }}\n />\n );\n case PropertyMenuView.MODIFY_GROUP_PROPERTY:\n return (\n <GroupPropertyAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n keySet={keySet ?? new KeySet()}\n groupPropertyId={selectedGroupProperty?.id ?? \"\"}\n groupPropertyName={selectedGroupProperty?.propertyName ?? \"\"}\n returnFn={async () => {\n setPropertyMenuView(PropertyMenuView.DEFAULT);\n }}\n />\n );\n case PropertyMenuView.ADD_CALCULATED_PROPERTY:\n return (\n <CalculatedPropertyAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n ids={resolvedHiliteIds}\n returnFn={calculatedPropertyReturn}\n />\n );\n case PropertyMenuView.MODIFY_CALCULATED_PROPERTY:\n return (\n <CalculatedPropertyAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n property={selectedCalculatedProperty}\n ids={resolvedHiliteIds}\n returnFn={calculatedPropertyReturn}\n />\n );\n case PropertyMenuView.ADD_CUSTOM_CALCULATION:\n return (\n <CustomCalculationAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n returnFn={async () => {\n setPropertyMenuView(PropertyMenuView.DEFAULT);\n }}\n />\n );\n case PropertyMenuView.MODIFY_CUSTOM_CALCULATION:\n return (\n <CustomCalculationAction\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n customCalculation={selectedCustomCalculation}\n returnFn={calculatedPropertyReturn}\n />\n );\n default:\n return (\n <InformationPanelWrapper className='property-menu-wrapper'>\n <div className='property-header'>\n <WidgetHeader\n title={`${group.groupName ?? \"\"}`}\n returnFn={goBack}\n />\n <IconButton\n styleType='borderless'\n onClick={() => setIsInformationPanelOpen(true)}\n >\n <SvgProperties />\n </IconButton>\n </div>\n <div className='property-menu-container'>\n {!hideGroupProps && (\n <div className='property-table'>\n <GroupPropertyTable\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n onGroupPropertyModify={onGroupPropertyModify}\n setSelectedGroupProperty={setSelectedGroupProperty}\n setGroupModifyView={setPropertyMenuView}\n selectedGroupProperty={selectedGroupProperty}\n />\n </div>\n )}\n\n {!hideCalculatedProps && (\n <div className='property-table'>\n <CalculatedPropertyTable\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n onCalculatedPropertyModify={onCalculatedPropertyModify}\n setSelectedCalculatedProperty={setSelectedCalculatedProperty}\n setGroupModifyView={setPropertyMenuView}\n selectedCalculatedProperty={selectedCalculatedProperty}\n />\n </div>\n )}\n {!hideCustomCalculationProps && (\n <div className='property-table'>\n <CustomCalculationTable\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={group.id ?? \"\"}\n onCustomCalculationModify={onCustomCalculationModify}\n setSelectedCustomCalculation={setSelectedCustomCalculation}\n setGroupModifyView={setPropertyMenuView}\n selectedCustomCalculation={selectedCustomCalculation}\n />\n </div>\n )}\n </div>\n <InformationPanel\n className='information-panel'\n isOpen={isInformationPanelOpen}\n >\n <InformationPanelHeader\n onClose={() => setIsInformationPanelOpen(false)}\n >\n <Text variant='subheading'>{`${group.groupName ?? \"\"\n } Information`}</Text>\n </InformationPanelHeader>\n <InformationPanelBody>\n <div className='information-body'>\n <LabeledTextarea\n label='Query'\n rows={15}\n readOnly\n defaultValue={group.query ?? \"\"}\n />\n </div>\n </InformationPanelBody>\n </InformationPanel>\n </InformationPanelWrapper>\n );\n }\n};\n"]}
@@ -26,7 +26,7 @@ export declare class QueryBuilder {
26
26
  *
27
27
  */
28
28
  constructor(provider: PresentationPropertyDataProvider | undefined);
29
- addProperty(prop: PropertyRecord): Promise<void>;
29
+ addProperty(prop: PropertyRecord): Promise<boolean>;
30
30
  private _needsQuote;
31
31
  addRelatedProperty(propertyField: PropertiesField, propertyName: string, propertyValue: Primitives.Value, isAspect: boolean): void;
32
32
  addPropertyToQuery(className: string, propertyName: string, propertyValue: Primitives.Value, isAspect: boolean, needsQuote: boolean, isRelational?: boolean): void;
@@ -1,5 +1,6 @@
1
1
  import { PropertyValueFormat, } from "@itwin/appui-abstract";
2
2
  import "core-js/features/string/virtual";
3
+ import { toaster } from "@itwin/itwinui-react";
3
4
  /* This class is to build adaptive and dynamic query for find similar property selections */
4
5
  export class QueryBuilder {
5
6
  /**
@@ -11,9 +12,12 @@ export class QueryBuilder {
11
12
  async addProperty(prop) {
12
13
  var _a, _b, _c, _d, _e;
13
14
  // TODO: only handle primitive properties now
14
- if (((_a = prop.value) === null || _a === void 0 ? void 0 : _a.valueFormat) !== PropertyValueFormat.Primitive ||
15
- prop.value.value === undefined) {
16
- return;
15
+ if (((_a = prop.value) === null || _a === void 0 ? void 0 : _a.valueFormat) !== PropertyValueFormat.Primitive) {
16
+ toaster.warning("Only primitive types are supported for now.");
17
+ return false;
18
+ }
19
+ if (prop.value.value === undefined) {
20
+ return false;
17
21
  }
18
22
  function replaceAll(str, match, replacement) {
19
23
  return str.split(match).join(replacement);
@@ -26,7 +30,8 @@ export class QueryBuilder {
26
30
  }
27
31
  const propertyField = (await ((_b = this.dataProvider) === null || _b === void 0 ? void 0 : _b.getFieldByPropertyRecord(prop)));
28
32
  if (propertyField === undefined) {
29
- return;
33
+ toaster.negative("Error. Failed to fetch field for this property record.");
34
+ return false;
30
35
  }
31
36
  // get the special cases
32
37
  const isNavigation = prop.property.typename.toLowerCase() === "navigation";
@@ -53,6 +58,7 @@ export class QueryBuilder {
53
58
  else {
54
59
  this.addPropertyToQuery(className, propertyName, propertyValue, isAspect, this._needsQuote(propertyField), false);
55
60
  }
61
+ return true;
56
62
  }
57
63
  _needsQuote(propertyField) {
58
64
  // list of property types that need quote around property value
@@ -227,9 +233,9 @@ export class QueryBuilder {
227
233
  const baseClass = this.query.classes[0];
228
234
  const baseClassName = baseClass.className;
229
235
  const baseIdName = baseClass.isAspect
230
- ? `${baseClassName}.Element.id ECInstanceId`
236
+ ? `${baseClassName}.Element.id`
231
237
  : `${baseClassName}.ECInstanceId`;
232
- let queryString = `SELECT ${baseIdName} FROM ${baseClassName}`;
238
+ let queryString = `SELECT ${baseIdName}${baseClass.isAspect ? " ECInstanceId" : ""} FROM ${baseClassName}`;
233
239
  if (this.query.classes.length > 1) {
234
240
  for (let i = 1; i < this.query.classes.length; i++) {
235
241
  const joinClass = this.query.classes[i];
@@ -1 +1 @@
1
- {"version":3,"file":"QueryBuilder.js","sourceRoot":"","sources":["../../../../src/widget/components/QueryBuilder.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,iCAAiC,CAAC;AAoBzC,4FAA4F;AAC5F,MAAM,OAAO,YAAY;IAUvB;;OAEG;IACH,YAAY,QAAsD;QAChE,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC;IAC/B,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,IAAoB;;QAC3C,6CAA6C;QAC7C,IACE,CAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,WAAW,MAAK,mBAAmB,CAAC,SAAS;YACzD,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,EAC9B;YACA,OAAO;SACR;QAED,SAAS,UAAU,CAAC,GAAW,EAAE,KAAa,EAAE,WAAmB;YACjE,OAAO,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC5C,CAAC;QACD,6CAA6C;QAC7C,IACE,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,QAAQ;YACnC,IAAI,CA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,CAAC,CAAC,KAAK,GAAG,CAAC;qBACvF;yBAAM;wBACL,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE;4BACtC,WAAW,IAAI,cAAc,aAAa,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;4BACrE,WAAW,IAAI,GAAG,YAAY,CAAC,wBAAwB,IAAI,CAAC;4BAC5D,WAAW,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,CACnD,YAAY,CAAC,wBAAwB,CACtC,EAAE,CAAC;yBACL;6BAAM;4BACL,WAAW,IAAI,QAAQ,aAAa,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;yBACrF;qBACF;iBACF;aACF;SACF;QAED,4BAA4B;QAC5B,2BAA2B;QAC3B,OAAO,WAAW,CAAC;IACrB,CAAC;IAEO,QAAQ,CAAC,CAAU;QACzB,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;;AAndsB,uCAA0B,GAC/C,iCAAiC,CAAC;AACb,wCAA2B,GAChD,iCAAiC,CAAC;AACb,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 {\n Primitives,\n PropertyRecord,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyValueFormat,\n} from \"@itwin/appui-abstract\";\nimport \"core-js/features/string/virtual\";\n\nexport interface Query {\n classes: QueryClass[];\n}\n\nexport interface QueryClass {\n // schemaName.className\n className: string;\n properties: QueryProperty[];\n isAspect: boolean;\n isRelational?: boolean;\n}\n\nexport interface QueryProperty {\n name: string;\n value: Primitives.Value;\n needsQuote: boolean;\n}\n\n/* This class is to build adaptive and dynamic query for find similar property selections */\nexport class QueryBuilder {\n public static readonly MULTI_ASPECT_PRIMARY_CLASS =\n \"BisCore:ElementOwnsMultiAspects\";\n public static readonly UNIQUE_ASPECT_PRIMARY_CLASS =\n \"BisCore:ElementOwnsUniqueAspect\";\n public static readonly DEFAULT_DOUBLE_PRECISION = 4;\n\n public dataProvider: PresentationPropertyDataProvider | undefined;\n public query: Query | undefined;\n\n /**\n *\n */\n constructor(provider: PresentationPropertyDataProvider | undefined) {\n this.dataProvider = provider;\n }\n\n public async addProperty(prop: PropertyRecord) {\n // TODO: only handle primitive properties now\n if (\n prop.value?.valueFormat !== PropertyValueFormat.Primitive ||\n prop.value.value === undefined\n ) {\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 (\n (typeof prop.value.value === \"string\" ||\n prop.value.value instanceof String) &&\n String(prop.value.value).indexOf(\"'\") >= 0\n ) {\n prop.value.value = replaceAll(prop.value.value.toString(), \"'\", \"''\");\n }\n\n const propertyField = (await this.dataProvider?.getFieldByPropertyRecord(\n prop,\n )) as PropertiesField;\n if (propertyField === undefined) {\n return;\n }\n\n // get the special cases\n const isNavigation: boolean =\n prop.property.typename.toLowerCase() === \"navigation\";\n\n const isAspect: boolean =\n propertyField.parent?.pathToPrimaryClass.find(\n (a) =>\n a.relationshipInfo?.name ===\n QueryBuilder.UNIQUE_ASPECT_PRIMARY_CLASS ||\n a.relationshipInfo?.name === QueryBuilder.MULTI_ASPECT_PRIMARY_CLASS,\n ) !== undefined;\n\n const className =\n propertyField.properties[0].property.classInfo.name.replace(\":\", \".\");\n const propertyName = isNavigation\n ? `${propertyField.properties[0].property.name}.id`\n : propertyField.properties[0].property.name;\n const propertyValue = isNavigation\n ? (prop.value.value as InstanceKey).id\n : prop.value.value;\n\n // console.log(prop);\n // console.log(propertyField);\n\n if (\n !isAspect &&\n propertyField.parent?.pathToPrimaryClass &&\n propertyField.parent?.pathToPrimaryClass.length > 0\n ) {\n this.addRelatedProperty(\n propertyField,\n propertyName,\n propertyValue,\n isAspect,\n );\n } else {\n this.addPropertyToQuery(\n className,\n propertyName,\n propertyValue,\n isAspect,\n this._needsQuote(propertyField),\n false,\n );\n }\n }\n\n private _needsQuote(propertyField: PropertiesField): boolean {\n // list of property types that need quote around property value\n if (propertyField.type.typeName.toLowerCase() === \"string\") {\n return true;\n }\n if (propertyField.type.typeName.toLowerCase() === \"uri\") {\n return true;\n }\n return false;\n }\n\n public addRelatedProperty(\n propertyField: PropertiesField,\n propertyName: string,\n propertyValue: Primitives.Value,\n isAspect: boolean,\n ) {\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 if (!path.isForwardRelationship) {\n this.addPropertyToQuery(\n targetClassName,\n `ECInstanceId`,\n `${relClassName}.SourceECInstanceId`,\n isAspect,\n false,\n true,\n );\n this.addPropertyToQuery(\n relClassName,\n `TargetECInstanceId`,\n `${sourceClassName}.ECInstanceId`,\n isAspect,\n false,\n true,\n );\n if (\n path.sourceClassInfo?.name ===\n propertyField.parent?.contentClassInfo.name\n ) {\n this.addPropertyToQuery(\n sourceClassName,\n propertyName,\n propertyValue,\n isAspect,\n this._needsQuote(propertyField),\n true,\n );\n } else {\n this.addPropertyToQuery(\n sourceClassName,\n `ECInstanceId`,\n `${relClassName}.TargetECInstanceId`,\n isAspect,\n false,\n true,\n );\n }\n } else {\n this.addPropertyToQuery(\n targetClassName,\n `ECInstanceId`,\n `${relClassName}.TargetECInstanceId`,\n isAspect,\n false,\n true,\n );\n this.addPropertyToQuery(\n relClassName,\n `SourceECInstanceId`,\n `${sourceClassName}.ECInstanceId`,\n isAspect,\n false,\n true,\n );\n if (\n path.sourceClassInfo?.name ===\n propertyField.parent?.contentClassInfo.name\n ) {\n this.addPropertyToQuery(\n sourceClassName,\n propertyName,\n propertyValue,\n isAspect,\n this._needsQuote(propertyField),\n true,\n );\n } else {\n this.addPropertyToQuery(\n sourceClassName,\n `ECInstanceId`,\n `${relClassName}.SourceECInstanceId`,\n isAspect,\n false,\n true,\n );\n }\n }\n });\n }\n\n public addPropertyToQuery(\n className: string,\n propertyName: string,\n propertyValue: Primitives.Value,\n isAspect: boolean,\n needsQuote: boolean,\n isRelational?: boolean,\n ) {\n if (this.query === undefined || this.query.classes.length === 0) {\n this.query = {\n classes: [\n {\n className,\n isAspect,\n isRelational,\n properties: [\n {\n name: propertyName,\n value: propertyValue,\n needsQuote,\n },\n ],\n },\n ],\n };\n return;\n }\n\n const foundClass = this.query.classes.find(\n (c) => c.className === className,\n );\n if (foundClass) {\n foundClass.isRelational = isRelational;\n if (!foundClass.properties.find((x) => x.name === propertyName)) {\n foundClass.properties.push({\n name: propertyName,\n value: propertyValue,\n needsQuote,\n });\n }\n } else {\n this.query.classes.push({\n className,\n isRelational,\n properties: [\n {\n name: propertyName,\n value: propertyValue,\n needsQuote,\n },\n ],\n isAspect,\n });\n }\n }\n\n public async removeProperty(prop: PropertyRecord) {\n if (this.query === undefined || this.query.classes.length === 0) {\n return;\n }\n\n const propertyField = (await this.dataProvider?.getFieldByPropertyRecord(\n prop,\n )) as PropertiesField;\n if (propertyField === undefined) {\n return;\n }\n\n const isAspect: boolean =\n propertyField.parent?.pathToPrimaryClass.find(\n (a) =>\n a.relationshipInfo?.name ===\n QueryBuilder.UNIQUE_ASPECT_PRIMARY_CLASS ||\n a.relationshipInfo?.name === QueryBuilder.MULTI_ASPECT_PRIMARY_CLASS,\n ) !== undefined;\n\n const isNavigation: boolean =\n prop.property.typename.toLowerCase() === \"navigation\";\n\n const propertyName = isNavigation\n ? `${propertyField.properties[0].property.name}.id`\n : propertyField.properties[0].property.name;\n const className =\n propertyField.properties[0].property.classInfo.name.replace(\":\", \".\");\n\n if (\n !isAspect &&\n propertyField.parent?.pathToPrimaryClass &&\n propertyField.parent?.pathToPrimaryClass.length > 0\n ) {\n this.removeRelatedProperty(propertyField, propertyName);\n } else {\n this.removePropertyFromQuery(className, propertyName);\n }\n }\n\n public removeRelatedProperty(\n propertyField: PropertiesField,\n propertyName: string,\n ) {\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 if (!path.isForwardRelationship) {\n this.removePropertyFromQuery(targetClassName, `ECInstanceId`);\n this.removePropertyFromQuery(relClassName, `TargetECInstanceId`);\n if (\n path.sourceClassInfo?.name ===\n propertyField.parent?.contentClassInfo.name\n ) {\n this.removePropertyFromQuery(sourceClassName, propertyName);\n } else {\n this.removePropertyFromQuery(sourceClassName, `ECInstanceId`);\n }\n } else {\n this.removePropertyFromQuery(targetClassName, `ECInstanceId`);\n this.removePropertyFromQuery(relClassName, `SourceECInstanceId`);\n if (\n path.sourceClassInfo?.name ===\n propertyField.parent?.contentClassInfo.name\n ) {\n this.removePropertyFromQuery(sourceClassName, propertyName);\n } else {\n this.removePropertyFromQuery(sourceClassName, `ECInstanceId`);\n }\n }\n });\n }\n\n public removePropertyFromQuery(className: string, propertyName: string) {\n const foundClass = this.query?.classes.find(\n (c) => c.className === className,\n );\n if (foundClass) {\n const foundPropertyIndex = foundClass.properties.findIndex(\n (p) => p.name === propertyName,\n );\n if (foundPropertyIndex > -1) {\n foundClass.properties.splice(foundPropertyIndex, 1);\n }\n if (foundClass.properties.length === 0) {\n // remove the entire class if all properties are removed\n const foundClassIndex =\n this.query?.classes.findIndex((c) => c.className === className) ?? -1;\n if (foundClassIndex > -1) {\n this.query?.classes.splice(foundClassIndex, 1);\n }\n }\n }\n }\n\n public buildQueryString() {\n if (this.query === undefined || this.query.classes.length === 0) {\n return \"\";\n }\n\n const baseClass = this.query.classes[0];\n const baseClassName = baseClass.className;\n const baseIdName = baseClass.isAspect\n ? `${baseClassName}.Element.id ECInstanceId`\n : `${baseClassName}.ECInstanceId`;\n\n let queryString = `SELECT ${baseIdName} FROM ${baseClassName}`;\n\n if (this.query.classes.length > 1) {\n for (let i = 1; i < this.query.classes.length; i++) {\n const joinClass = this.query.classes[i];\n const joinClassName = joinClass.className;\n const joinIdName = joinClass.isAspect\n ? `${joinClassName}.Element.id`\n : `${joinClassName}.ECInstanceId`;\n\n if (joinClass.isRelational) {\n queryString += ` JOIN ${joinClassName}`;\n if (joinClass.properties.length > 0) {\n if (joinClass.properties[0].needsQuote) {\n queryString += ` ON ${joinClassName}.${joinClass.properties[0].name}='${joinClass.properties[0].value}'`;\n } else {\n if (this._isFloat(joinClass.properties[0].value)) {\n queryString += ` ON ROUND(${joinClassName}.${joinClass.properties[0].name}, `;\n queryString += `${QueryBuilder.DEFAULT_DOUBLE_PRECISION})=`;\n queryString += `${Number(joinClass.properties[0].value).toFixed(\n QueryBuilder.DEFAULT_DOUBLE_PRECISION,\n )}`;\n } else {\n queryString += ` ON ${joinClassName}.${joinClass.properties[0].name}=${joinClass.properties[0].value}`;\n }\n }\n }\n // when base is regular property, link base to first joined relational property\n if (!baseClass.isRelational && i === 1) {\n queryString += ` AND ${joinIdName} = ${baseIdName}`;\n }\n for (const property of joinClass.properties) {\n if (property.needsQuote) {\n queryString += ` AND ${joinClassName}.${property.name}='${property.value}'`;\n } else {\n if (this._isFloat(property.value)) {\n queryString += ` AND ROUND(${joinClassName}.${property.name}, `;\n queryString += `${QueryBuilder.DEFAULT_DOUBLE_PRECISION})=`;\n queryString += `${Number(property.value).toFixed(\n QueryBuilder.DEFAULT_DOUBLE_PRECISION,\n )}`;\n } else {\n queryString += ` AND ${joinClassName}.${property.name}=${property.value}`;\n }\n }\n }\n } else {\n queryString += ` JOIN ${joinClassName} ON ${joinIdName} = ${baseIdName}`;\n for (const property of joinClass.properties) {\n if (property.needsQuote) {\n queryString += ` AND ${joinClassName}.${property.name}='${property.value}'`;\n } else {\n if (this._isFloat(property.value)) {\n queryString += ` AND ROUND(${joinClassName}.${property.name}, `;\n queryString += `${QueryBuilder.DEFAULT_DOUBLE_PRECISION})=`;\n queryString += `${Number(property.value).toFixed(\n QueryBuilder.DEFAULT_DOUBLE_PRECISION,\n )}`;\n } else {\n queryString += ` AND ${joinClassName}.${property.name}=${property.value}`;\n }\n }\n }\n }\n }\n }\n\n const properties = baseClass.properties;\n if (properties.length > 0) {\n if (properties[0].needsQuote) {\n queryString += ` WHERE ${baseClassName}.${properties[0].name}='${properties[0].value}'`;\n } else {\n if (this._isFloat(properties[0].value)) {\n queryString += ` WHERE ROUND(${baseClassName}.${properties[0].name}, `;\n queryString += `${QueryBuilder.DEFAULT_DOUBLE_PRECISION})=`;\n queryString += `${Number(properties[0].value).toFixed(\n QueryBuilder.DEFAULT_DOUBLE_PRECISION,\n )}`;\n } else {\n queryString += ` WHERE ${baseClassName}.${properties[0].name}=${properties[0].value}`;\n }\n }\n if (properties.length > 1) {\n for (let i = 1; i < properties.length; i++) {\n if (properties[i].needsQuote) {\n queryString += ` AND ${baseClassName}.${properties[i].name}='${properties[i].value}'`;\n } else {\n if (this._isFloat(properties[i].value)) {\n queryString += ` AND ROUND(${baseClassName}.${properties[i].name}, `;\n queryString += `${QueryBuilder.DEFAULT_DOUBLE_PRECISION})=`;\n queryString += `${Number(properties[i].value).toFixed(\n QueryBuilder.DEFAULT_DOUBLE_PRECISION,\n )}`;\n } else {\n queryString += ` AND ${baseClassName}.${properties[i].name}=${properties[i].value}`;\n }\n }\n }\n }\n }\n\n // console.log(queryString);\n // console.log(this.query);\n return queryString;\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/widget/components/QueryBuilder.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,iCAAiC,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAoB/C,4FAA4F;AAC5F,MAAM,OAAO,YAAY;IAUvB;;OAEG;IACH,YAAY,QAAsD;QAChE,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC;IAC/B,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,IAAoB;;QAC3C,6CAA6C;QAC7C,IACE,CAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,WAAW,MAAK,mBAAmB,CAAC,SAAS,EACzD;YACA,OAAO,CAAC,OAAO,CAAC,6CAA6C,CAAC,CAAC;YAC/D,OAAO,KAAK,CAAC;SACd;QACD,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE;YAClC,OAAO,KAAK,CAAC;SACd;QAED,SAAS,UAAU,CAAC,GAAW,EAAE,KAAa,EAAE,WAAmB;YACjE,OAAO,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC5C,CAAC;QACD,6CAA6C;QAC7C,IACE,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,QAAQ;YACnC,IAAI,CAAC,KAAK,CAAC,KAAK,YAAY,MAAM,CAAC;YACrC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAC1C;YACA,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;SACvE;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E;4BACtC,WAAW,IAAI,cAAc,aAAa,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;4BACrE,WAAW,IAAI,GAAG,YAAY,CAAC,wBAAwB,IAAI,CAAC;4BAC5D,WAAW,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,CACnD,YAAY,CAAC,wBAAwB,CACtC,EAAE,CAAC;yBACL;6BAAM;4BACL,WAAW,IAAI,QAAQ,aAAa,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;yBACrF;qBACF;iBACF;aACF;SACF;QAED,4BAA4B;QAC5B,2BAA2B;QAC3B,OAAO,WAAW,CAAC;IACrB,CAAC;IAEO,QAAQ,CAAC,CAAU;QACzB,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;;AAxdsB,uCAA0B,GAC/C,iCAAiC,CAAC;AACb,wCAA2B,GAChD,iCAAiC,CAAC;AACb,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 {\n Primitives,\n PropertyRecord,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyValueFormat,\n} from \"@itwin/appui-abstract\";\nimport \"core-js/features/string/virtual\";\nimport { toaster } from \"@itwin/itwinui-react\";\n\nexport interface Query {\n classes: QueryClass[];\n}\n\nexport interface QueryClass {\n // schemaName.className\n className: string;\n properties: QueryProperty[];\n isAspect: boolean;\n isRelational?: boolean;\n}\n\nexport interface QueryProperty {\n name: string;\n value: Primitives.Value;\n needsQuote: boolean;\n}\n\n/* This class is to build adaptive and dynamic query for find similar property selections */\nexport class QueryBuilder {\n public static readonly MULTI_ASPECT_PRIMARY_CLASS =\n \"BisCore:ElementOwnsMultiAspects\";\n public static readonly UNIQUE_ASPECT_PRIMARY_CLASS =\n \"BisCore:ElementOwnsUniqueAspect\";\n public static readonly DEFAULT_DOUBLE_PRECISION = 4;\n\n public dataProvider: PresentationPropertyDataProvider | undefined;\n public query: Query | undefined;\n\n /**\n *\n */\n constructor(provider: PresentationPropertyDataProvider | undefined) {\n this.dataProvider = provider;\n }\n\n public async addProperty(prop: PropertyRecord): Promise<boolean> {\n // TODO: only handle primitive properties now\n if (\n prop.value?.valueFormat !== PropertyValueFormat.Primitive\n ) {\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 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 (\n (typeof prop.value.value === \"string\" ||\n prop.value.value instanceof String) &&\n String(prop.value.value).indexOf(\"'\") >= 0\n ) {\n prop.value.value = replaceAll(prop.value.value.toString(), \"'\", \"''\");\n }\n\n const propertyField = (await this.dataProvider?.getFieldByPropertyRecord(\n prop,\n )) as PropertiesField;\n if (propertyField === undefined) {\n toaster.negative(\"Error. Failed to fetch field for this property record.\");\n return false;\n }\n\n // get the special cases\n const isNavigation: boolean =\n prop.property.typename.toLowerCase() === \"navigation\";\n\n const isAspect: boolean =\n propertyField.parent?.pathToPrimaryClass.find(\n (a) =>\n a.relationshipInfo?.name ===\n QueryBuilder.UNIQUE_ASPECT_PRIMARY_CLASS ||\n a.relationshipInfo?.name === QueryBuilder.MULTI_ASPECT_PRIMARY_CLASS,\n ) !== undefined;\n\n const className =\n propertyField.properties[0].property.classInfo.name.replace(\":\", \".\");\n const propertyName = isNavigation\n ? `${propertyField.properties[0].property.name}.id`\n : propertyField.properties[0].property.name;\n const propertyValue = isNavigation\n ? (prop.value.value as InstanceKey).id\n : prop.value.value;\n\n // console.log(prop);\n // console.log(propertyField);\n\n if (\n !isAspect &&\n propertyField.parent?.pathToPrimaryClass &&\n propertyField.parent?.pathToPrimaryClass.length > 0\n ) {\n this.addRelatedProperty(\n propertyField,\n propertyName,\n propertyValue,\n isAspect,\n );\n } else {\n this.addPropertyToQuery(\n className,\n propertyName,\n propertyValue,\n isAspect,\n this._needsQuote(propertyField),\n false,\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 if (propertyField.type.typeName.toLowerCase() === \"string\") {\n return true;\n }\n if (propertyField.type.typeName.toLowerCase() === \"uri\") {\n return true;\n }\n return false;\n }\n\n public addRelatedProperty(\n propertyField: PropertiesField,\n propertyName: string,\n propertyValue: Primitives.Value,\n isAspect: boolean,\n ) {\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 if (!path.isForwardRelationship) {\n this.addPropertyToQuery(\n targetClassName,\n `ECInstanceId`,\n `${relClassName}.SourceECInstanceId`,\n isAspect,\n false,\n true,\n );\n this.addPropertyToQuery(\n relClassName,\n `TargetECInstanceId`,\n `${sourceClassName}.ECInstanceId`,\n isAspect,\n false,\n true,\n );\n if (\n path.sourceClassInfo?.name ===\n propertyField.parent?.contentClassInfo.name\n ) {\n this.addPropertyToQuery(\n sourceClassName,\n propertyName,\n propertyValue,\n isAspect,\n this._needsQuote(propertyField),\n true,\n );\n } else {\n this.addPropertyToQuery(\n sourceClassName,\n `ECInstanceId`,\n `${relClassName}.TargetECInstanceId`,\n isAspect,\n false,\n true,\n );\n }\n } else {\n this.addPropertyToQuery(\n targetClassName,\n `ECInstanceId`,\n `${relClassName}.TargetECInstanceId`,\n isAspect,\n false,\n true,\n );\n this.addPropertyToQuery(\n relClassName,\n `SourceECInstanceId`,\n `${sourceClassName}.ECInstanceId`,\n isAspect,\n false,\n true,\n );\n if (\n path.sourceClassInfo?.name ===\n propertyField.parent?.contentClassInfo.name\n ) {\n this.addPropertyToQuery(\n sourceClassName,\n propertyName,\n propertyValue,\n isAspect,\n this._needsQuote(propertyField),\n true,\n );\n } else {\n this.addPropertyToQuery(\n sourceClassName,\n `ECInstanceId`,\n `${relClassName}.SourceECInstanceId`,\n isAspect,\n false,\n true,\n );\n }\n }\n });\n }\n\n public addPropertyToQuery(\n className: string,\n propertyName: string,\n propertyValue: Primitives.Value,\n isAspect: boolean,\n needsQuote: boolean,\n isRelational?: boolean,\n ) {\n if (this.query === undefined || this.query.classes.length === 0) {\n this.query = {\n classes: [\n {\n className,\n isAspect,\n isRelational,\n properties: [\n {\n name: propertyName,\n value: propertyValue,\n needsQuote,\n },\n ],\n },\n ],\n };\n return;\n }\n\n const foundClass = this.query.classes.find(\n (c) => c.className === className,\n );\n if (foundClass) {\n foundClass.isRelational = isRelational;\n if (!foundClass.properties.find((x) => x.name === propertyName)) {\n foundClass.properties.push({\n name: propertyName,\n value: propertyValue,\n needsQuote,\n });\n }\n } else {\n this.query.classes.push({\n className,\n isRelational,\n properties: [\n {\n name: propertyName,\n value: propertyValue,\n needsQuote,\n },\n ],\n isAspect,\n });\n }\n }\n\n public async removeProperty(prop: PropertyRecord) {\n if (this.query === undefined || this.query.classes.length === 0) {\n return;\n }\n\n const propertyField = (await this.dataProvider?.getFieldByPropertyRecord(\n prop,\n )) as PropertiesField;\n if (propertyField === undefined) {\n return;\n }\n\n const isAspect: boolean =\n propertyField.parent?.pathToPrimaryClass.find(\n (a) =>\n a.relationshipInfo?.name ===\n QueryBuilder.UNIQUE_ASPECT_PRIMARY_CLASS ||\n a.relationshipInfo?.name === QueryBuilder.MULTI_ASPECT_PRIMARY_CLASS,\n ) !== undefined;\n\n const isNavigation: boolean =\n prop.property.typename.toLowerCase() === \"navigation\";\n\n const propertyName = isNavigation\n ? `${propertyField.properties[0].property.name}.id`\n : propertyField.properties[0].property.name;\n const className =\n propertyField.properties[0].property.classInfo.name.replace(\":\", \".\");\n\n if (\n !isAspect &&\n propertyField.parent?.pathToPrimaryClass &&\n propertyField.parent?.pathToPrimaryClass.length > 0\n ) {\n this.removeRelatedProperty(propertyField, propertyName);\n } else {\n this.removePropertyFromQuery(className, propertyName);\n }\n }\n\n public removeRelatedProperty(\n propertyField: PropertiesField,\n propertyName: string,\n ) {\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 if (!path.isForwardRelationship) {\n this.removePropertyFromQuery(targetClassName, `ECInstanceId`);\n this.removePropertyFromQuery(relClassName, `TargetECInstanceId`);\n if (\n path.sourceClassInfo?.name ===\n propertyField.parent?.contentClassInfo.name\n ) {\n this.removePropertyFromQuery(sourceClassName, propertyName);\n } else {\n this.removePropertyFromQuery(sourceClassName, `ECInstanceId`);\n }\n } else {\n this.removePropertyFromQuery(targetClassName, `ECInstanceId`);\n this.removePropertyFromQuery(relClassName, `SourceECInstanceId`);\n if (\n path.sourceClassInfo?.name ===\n propertyField.parent?.contentClassInfo.name\n ) {\n this.removePropertyFromQuery(sourceClassName, propertyName);\n } else {\n this.removePropertyFromQuery(sourceClassName, `ECInstanceId`);\n }\n }\n });\n }\n\n public removePropertyFromQuery(className: string, propertyName: string) {\n const foundClass = this.query?.classes.find(\n (c) => c.className === className,\n );\n if (foundClass) {\n const foundPropertyIndex = foundClass.properties.findIndex(\n (p) => p.name === propertyName,\n );\n if (foundPropertyIndex > -1) {\n foundClass.properties.splice(foundPropertyIndex, 1);\n }\n if (foundClass.properties.length === 0) {\n // remove the entire class if all properties are removed\n const foundClassIndex =\n this.query?.classes.findIndex((c) => c.className === className) ?? -1;\n if (foundClassIndex > -1) {\n this.query?.classes.splice(foundClassIndex, 1);\n }\n }\n }\n }\n\n public buildQueryString() {\n if (this.query === undefined || this.query.classes.length === 0) {\n return \"\";\n }\n\n const baseClass = this.query.classes[0];\n const baseClassName = baseClass.className;\n const baseIdName = baseClass.isAspect\n ? `${baseClassName}.Element.id`\n : `${baseClassName}.ECInstanceId`;\n\n let queryString = `SELECT ${baseIdName}${baseClass.isAspect ? \" ECInstanceId\" : \"\"} FROM ${baseClassName}`;\n\n if (this.query.classes.length > 1) {\n for (let i = 1; i < this.query.classes.length; i++) {\n const joinClass = this.query.classes[i];\n const joinClassName = joinClass.className;\n const joinIdName = joinClass.isAspect\n ? `${joinClassName}.Element.id`\n : `${joinClassName}.ECInstanceId`;\n\n if (joinClass.isRelational) {\n queryString += ` JOIN ${joinClassName}`;\n if (joinClass.properties.length > 0) {\n if (joinClass.properties[0].needsQuote) {\n queryString += ` ON ${joinClassName}.${joinClass.properties[0].name}='${joinClass.properties[0].value}'`;\n } else {\n if (this._isFloat(joinClass.properties[0].value)) {\n queryString += ` ON ROUND(${joinClassName}.${joinClass.properties[0].name}, `;\n queryString += `${QueryBuilder.DEFAULT_DOUBLE_PRECISION})=`;\n queryString += `${Number(joinClass.properties[0].value).toFixed(\n QueryBuilder.DEFAULT_DOUBLE_PRECISION,\n )}`;\n } else {\n queryString += ` ON ${joinClassName}.${joinClass.properties[0].name}=${joinClass.properties[0].value}`;\n }\n }\n }\n // when base is regular property, link base to first joined relational property\n if (!baseClass.isRelational && i === 1) {\n queryString += ` AND ${joinIdName} = ${baseIdName}`;\n }\n for (const property of joinClass.properties) {\n if (property.needsQuote) {\n queryString += ` AND ${joinClassName}.${property.name}='${property.value}'`;\n } else {\n if (this._isFloat(property.value)) {\n queryString += ` AND ROUND(${joinClassName}.${property.name}, `;\n queryString += `${QueryBuilder.DEFAULT_DOUBLE_PRECISION})=`;\n queryString += `${Number(property.value).toFixed(\n QueryBuilder.DEFAULT_DOUBLE_PRECISION,\n )}`;\n } else {\n queryString += ` AND ${joinClassName}.${property.name}=${property.value}`;\n }\n }\n }\n } else {\n queryString += ` JOIN ${joinClassName} ON ${joinIdName} = ${baseIdName}`;\n for (const property of joinClass.properties) {\n if (property.needsQuote) {\n queryString += ` AND ${joinClassName}.${property.name}='${property.value}'`;\n } else {\n if (this._isFloat(property.value)) {\n queryString += ` AND ROUND(${joinClassName}.${property.name}, `;\n queryString += `${QueryBuilder.DEFAULT_DOUBLE_PRECISION})=`;\n queryString += `${Number(property.value).toFixed(\n QueryBuilder.DEFAULT_DOUBLE_PRECISION,\n )}`;\n } else {\n queryString += ` AND ${joinClassName}.${property.name}=${property.value}`;\n }\n }\n }\n }\n }\n }\n\n const properties = baseClass.properties;\n if (properties.length > 0) {\n if (properties[0].needsQuote) {\n queryString += ` WHERE ${baseClassName}.${properties[0].name}='${properties[0].value}'`;\n } else {\n if (this._isFloat(properties[0].value)) {\n queryString += ` WHERE ROUND(${baseClassName}.${properties[0].name}, `;\n queryString += `${QueryBuilder.DEFAULT_DOUBLE_PRECISION})=`;\n queryString += `${Number(properties[0].value).toFixed(\n QueryBuilder.DEFAULT_DOUBLE_PRECISION,\n )}`;\n } else {\n queryString += ` WHERE ${baseClassName}.${properties[0].name}=${properties[0].value}`;\n }\n }\n if (properties.length > 1) {\n for (let i = 1; i < properties.length; i++) {\n if (properties[i].needsQuote) {\n queryString += ` AND ${baseClassName}.${properties[i].name}='${properties[i].value}'`;\n } else {\n if (this._isFloat(properties[i].value)) {\n queryString += ` AND ROUND(${baseClassName}.${properties[i].name}, `;\n queryString += `${QueryBuilder.DEFAULT_DOUBLE_PRECISION})=`;\n queryString += `${Number(properties[i].value).toFixed(\n QueryBuilder.DEFAULT_DOUBLE_PRECISION,\n )}`;\n } else {\n queryString += ` AND ${baseClassName}.${properties[i].name}=${properties[i].value}`;\n }\n }\n }\n }\n }\n\n // console.log(queryString);\n // console.log(this.query);\n return queryString;\n }\n\n private _isFloat(n: unknown): boolean {\n return Number(n) === n && n % 1 !== 0;\n }\n}\n"]}
@@ -5,9 +5,9 @@
5
5
  import * as React from "react";
6
6
  import { Orientation } from "@itwin/core-react";
7
7
  import { PrimitivePropertyLabelRenderer } from "@itwin/components-react";
8
- import { CommonPropertyRenderer } from "@itwin/components-react/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer";
9
8
  import { HighlightedText } from "@itwin/components-react/lib/cjs/components-react/common/HighlightedText";
10
9
  import { PropertyView } from "./PropertyView";
10
+ import { CommonPropertyRenderer } from "@itwin/components-react/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer";
11
11
  /** React Component that renders primitive properties
12
12
  * @public
13
13
  */
@@ -15,7 +15,7 @@ export class PrimitivePropertyRenderer extends React.Component {
15
15
  /** @internal */
16
16
  render() {
17
17
  var _a, _b;
18
- const { indentation, highlight, ...props } = this.props;
18
+ const { highlight, indentation, ...props } = this.props;
19
19
  const displayLabel = this.props.propertyRecord.property.displayLabel;
20
20
  const offset = CommonPropertyRenderer.getLabelOffset(indentation, props.orientation, props.width, props.columnRatio, (_a = props.columnInfo) === null || _a === void 0 ? void 0 : _a.minLabelWidth);
21
21
  const activeMatchIndex = this.props.propertyRecord.property.name ===
@@ -29,7 +29,11 @@ export class PrimitivePropertyRenderer extends React.Component {
29
29
  activeMatchIndex,
30
30
  })
31
31
  : displayLabel;
32
- return (React.createElement(PropertyView, { ...props, labelElement: React.createElement(PrimitivePropertyLabelRenderer, { offset: offset, renderColon: this.props.orientation === Orientation.Horizontal, tooltip: displayLabel }, label) }));
32
+ return (React.createElement(PropertyView, { ...this.props, labelElement: React.createElement(PrimitivePropertyLabelRenderer
33
+ // Added offset to account for checkbox
34
+ , {
35
+ // Added offset to account for checkbox
36
+ offset: offset + 24, renderColon: this.props.orientation === Orientation.Horizontal, tooltip: displayLabel }, label) }));
33
37
  }
34
38
  }
35
39
  //# sourceMappingURL=PrimitivePropertyRenderer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrimitivePropertyRenderer.js","sourceRoot":"","sources":["../../../../../src/widget/components/property-grid/PrimitivePropertyRenderer.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,8FAA8F,CAAC;AACtI,OAAO,EAAE,eAAe,EAAE,MAAM,yEAAyE,CAAC;AAE1G,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAmB9C;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,KAAK,CAAC,SAAiC;IACpF,gBAAgB;IACA,MAAM;;QACpB,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACxD,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC;QACrE,MAAM,MAAM,GAAG,sBAAsB,CAAC,cAAc,CAClD,WAAW,EACX,KAAK,CAAC,WAAW,EACjB,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,WAAW,EACjB,MAAA,KAAK,CAAC,UAAU,0CAAE,aAAa,CAChC,CAAC;QAEF,MAAM,gBAAgB,GACpB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI;aACvC,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,eAAe,0CAAE,yBAAyB,CAAA;YACnD,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,cAAc;YAC1C,CAAC,CAAC,SAAS,CAAC;QAChB,MAAM,KAAK,GAAG,SAAS;YACrB,CAAC,CAAC,eAAe,CAAC;gBAChB,IAAI,EAAE,YAAY;gBAClB,UAAU,EAAE,SAAS,CAAC,eAAe;gBACrC,gBAAgB;aACjB,CAAC;YACF,CAAC,CAAC,YAAY,CAAC;QAEjB,OAAO,CACL,oBAAC,YAAY,OACP,KAAK,EACT,YAAY,EACV,oBAAC,8BAA8B,IAC7B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,KAAK,WAAW,CAAC,UAAU,EAC9D,OAAO,EAAE,YAAY,IAEpB,KAAK,CACyB,GAEnC,CACH,CAAC;IACJ,CAAC;CACF","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 * as React from \"react\";\nimport { Orientation } from \"@itwin/core-react\";\nimport { PrimitivePropertyLabelRenderer } from \"@itwin/components-react\";\nimport type { HighlightingComponentProps } from \"@itwin/components-react/lib/cjs/components-react/common/HighlightingComponentProps\";\nimport { CommonPropertyRenderer } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer\";\nimport { HighlightedText } from \"@itwin/components-react/lib/cjs/components-react/common/HighlightedText\";\n\nimport { PropertyView } from \"./PropertyView\";\nimport type { SharedRendererProps } from \"./PropertyRender\";\n\n/** Properties of [[PrimitivePropertyRenderer]] React component\n * @public\n */\nexport interface PrimitiveRendererProps extends SharedRendererProps {\n /** Property value as a React element */\n valueElement?: React.ReactNode;\n /** Render callback for property value. If specified, `valueElement` is ignored. */\n valueElementRenderer?: () => React.ReactNode;\n /** Multiplier of how much the property is indented to the right */\n indentation?: number;\n /** Properties used for highlighting\n * @beta\n */\n highlight?: HighlightingComponentProps;\n}\n\n/** React Component that renders primitive properties\n * @public\n */\nexport class PrimitivePropertyRenderer extends React.Component<PrimitiveRendererProps> {\n /** @internal */\n public override render() {\n const { indentation, highlight, ...props } = this.props;\n const displayLabel = this.props.propertyRecord.property.displayLabel;\n const offset = CommonPropertyRenderer.getLabelOffset(\n indentation,\n props.orientation,\n props.width,\n props.columnRatio,\n props.columnInfo?.minLabelWidth,\n );\n\n const activeMatchIndex =\n this.props.propertyRecord.property.name ===\n highlight?.activeHighlight?.highlightedItemIdentifier\n ? highlight.activeHighlight.highlightIndex\n : undefined;\n const label = highlight\n ? HighlightedText({\n text: displayLabel,\n searchText: highlight.highlightedText,\n activeMatchIndex,\n })\n : displayLabel;\n\n return (\n <PropertyView\n {...props}\n labelElement={\n <PrimitivePropertyLabelRenderer\n offset={offset}\n renderColon={this.props.orientation === Orientation.Horizontal}\n tooltip={displayLabel}\n >\n {label}\n </PrimitivePropertyLabelRenderer>\n }\n />\n );\n }\n}\n"]}
1
+ {"version":3,"file":"PrimitivePropertyRenderer.js","sourceRoot":"","sources":["../../../../../src/widget/components/property-grid/PrimitivePropertyRenderer.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,yEAAyE,CAAC;AAE1G,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,8FAA8F,CAAC;AAkBtI;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,KAAK,CAAC,SAAiC;IACpF,gBAAgB;IACA,MAAM;;QACpB,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACxD,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC;QACrE,MAAM,MAAM,GAAG,sBAAsB,CAAC,cAAc,CAClD,WAAW,EACX,KAAK,CAAC,WAAW,EACjB,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,WAAW,EACjB,MAAA,KAAK,CAAC,UAAU,0CAAE,aAAa,CAChC,CAAC;QAEF,MAAM,gBAAgB,GACpB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI;aACrC,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,eAAe,0CAAE,yBAAyB,CAAA;YACrD,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,cAAc;YAC1C,CAAC,CAAC,SAAS,CAAC;QAChB,MAAM,KAAK,GAAG,SAAS;YACrB,CAAC,CAAC,eAAe,CAAC;gBAChB,IAAI,EAAE,YAAY;gBAClB,UAAU,EAAE,SAAS,CAAC,eAAe;gBACrC,gBAAgB;aACjB,CAAC;YACF,CAAC,CAAC,YAAY,CAAC;QAEjB,OAAO,CACL,oBAAC,YAAY,OACP,IAAI,CAAC,KAAK,EACd,YAAY,EACV,oBAAC,8BAA8B;YAC7B,uCAAuC;;gBAAvC,uCAAuC;gBACvC,MAAM,EAAE,MAAM,GAAG,EAAE,EACnB,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,KAAK,WAAW,CAAC,UAAU,EAC9D,OAAO,EAAE,YAAY,IAEpB,KAAK,CACyB,GAEnC,CACH,CAAC;IACJ,CAAC;CACF","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 * as React from \"react\";\nimport { Orientation } from \"@itwin/core-react\";\nimport { PrimitivePropertyLabelRenderer } from \"@itwin/components-react\";\nimport type { HighlightingComponentProps } from \"@itwin/components-react/lib/cjs/components-react/common/HighlightingComponentProps\";\nimport { HighlightedText } from \"@itwin/components-react/lib/cjs/components-react/common/HighlightedText\";\n\nimport { PropertyView } from \"./PropertyView\";\nimport type { SharedRendererProps } from \"./PropertyRender\";\nimport { CommonPropertyRenderer } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer\";\n\n/** Properties of [[PrimitivePropertyRenderer]] React component\n * @public\n */\nexport interface PrimitiveRendererProps extends SharedRendererProps {\n /** Property value as a React element */\n valueElement?: React.ReactNode;\n /** Render callback for property value. If specified, `valueElement` is ignored. */\n valueElementRenderer?: () => React.ReactNode;\n /** Multiplier of how much the property is indented to the right */\n indentation?: number;\n /** Properties used for highlighting\n * @beta\n */\n highlight?: HighlightingComponentProps;\n}\n\n/** React Component that renders primitive properties\n * @public\n */\nexport class PrimitivePropertyRenderer extends React.Component<PrimitiveRendererProps> {\n /** @internal */\n public override render() {\n const { highlight, indentation, ...props } = this.props;\n const displayLabel = this.props.propertyRecord.property.displayLabel;\n const offset = CommonPropertyRenderer.getLabelOffset(\n indentation,\n props.orientation,\n props.width,\n props.columnRatio,\n props.columnInfo?.minLabelWidth,\n );\n\n const activeMatchIndex =\n this.props.propertyRecord.property.name ===\n highlight?.activeHighlight?.highlightedItemIdentifier\n ? highlight.activeHighlight.highlightIndex\n : undefined;\n const label = highlight\n ? HighlightedText({\n text: displayLabel,\n searchText: highlight.highlightedText,\n activeMatchIndex,\n })\n : displayLabel;\n\n return (\n <PropertyView\n {...this.props}\n labelElement={\n <PrimitivePropertyLabelRenderer\n // Added offset to account for checkbox\n offset={offset + 24}\n renderColon={this.props.orientation === Orientation.Horizontal}\n tooltip={displayLabel}\n >\n {label}\n </PrimitivePropertyLabelRenderer>\n }\n />\n );\n }\n}\n"]}
@@ -2,8 +2,8 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- @import "~@itwin/core-react/lib/cjs/core-react/expandable/list";
6
- @import "~@itwin/core-react/lib/cjs/core-react/scrollbar";
5
+ @import '~@itwin/core-react/lib/cjs/core-react/expandable/list';
6
+ @import '~@itwin/core-react/lib/cjs/core-react/scrollbar';
7
7
 
8
8
  .gm-components-property-grid-loader {
9
9
  display: flex;
@@ -61,7 +61,7 @@
61
61
  @include components-property-list;
62
62
 
63
63
  display: grid;
64
- grid-row-gap: 1px; // A gap of 10px is too wasteful
64
+ grid-row-gap: 0px;
65
65
  overflow: hidden;
66
66
  }
67
67
 
@@ -86,7 +86,7 @@ export declare class PropertyRenderer extends React.Component<PropertyRendererPr
86
86
  /** @internal */
87
87
  componentDidUpdate(prevProps: PropertyRendererProps): void;
88
88
  /** @internal */
89
- render(): JSX.Element | undefined;
89
+ render(): JSX.Element;
90
90
  }
91
91
  export {};
92
92
  //# sourceMappingURL=PropertyRender.d.ts.map