@itwin/grouping-mapping-widget 0.23.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/WidgetShell/GroupingMappingContent.js +2 -2
- package/lib/cjs/WidgetShell/GroupingMappingContent.js.map +1 -1
- package/lib/cjs/components/Constants.d.ts +3 -0
- package/lib/cjs/components/Constants.js +5 -2
- package/lib/cjs/components/Constants.js.map +1 -1
- package/lib/cjs/components/GroupingMappingContext.js +12 -14
- package/lib/cjs/components/GroupingMappingContext.js.map +1 -1
- package/lib/cjs/components/Groups/Editing/GroupAction.js +5 -1
- package/lib/cjs/components/Groups/Editing/GroupAction.js.map +1 -1
- package/lib/cjs/components/Groups/GroupsVisualization.js +44 -12
- package/lib/cjs/components/Groups/GroupsVisualization.js.map +1 -1
- package/lib/cjs/components/Groups/groupsHelpers.d.ts +2 -1
- package/lib/cjs/components/Groups/groupsHelpers.js +8 -5
- package/lib/cjs/components/Groups/groupsHelpers.js.map +1 -1
- package/lib/cjs/components/Groups/hooks/useKeySetHiliteQueries.d.ts +2 -2
- package/lib/cjs/components/Groups/hooks/useKeySetHiliteQueries.js.map +1 -1
- package/lib/cjs/components/Mappings/Extraction/ExtractionMessageModal.js +27 -18
- package/lib/cjs/components/Mappings/Extraction/ExtractionMessageModal.js.map +1 -1
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/QueuedExtractionState.d.ts +3 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/QueuedExtractionState.js +17 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/QueuedExtractionState.js.map +1 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/RunningExtractionState.d.ts +3 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/RunningExtractionState.js +16 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/RunningExtractionState.js.map +1 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/StartingExtractionState.d.ts +3 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/StartingExtractionState.js +17 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/StartingExtractionState.js.map +1 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/TerminalExtractionState.d.ts +9 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/TerminalExtractionState.js +21 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/TerminalExtractionState.js.map +1 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStatus.d.ts +17 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStatus.js +79 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStatus.js.map +1 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStatus.scss +40 -0
- package/lib/cjs/components/Mappings/Import/SelectIModel.js +1 -2
- package/lib/cjs/components/Mappings/Import/SelectIModel.js.map +1 -1
- package/lib/cjs/components/Mappings/MappingListItem.d.ts +20 -0
- package/lib/cjs/components/Mappings/MappingListItem.js +96 -0
- package/lib/cjs/components/Mappings/MappingListItem.js.map +1 -0
- package/lib/cjs/components/Mappings/MappingListItem.scss +25 -0
- package/lib/cjs/components/Mappings/MappingsView.d.ts +2 -0
- package/lib/cjs/components/Mappings/MappingsView.js +28 -4
- package/lib/cjs/components/Mappings/MappingsView.js.map +1 -1
- package/lib/cjs/components/Mappings/hooks/useFetchExtractionStatus.d.ts +3 -1
- package/lib/cjs/components/Mappings/hooks/useFetchExtractionStatus.js +7 -4
- package/lib/cjs/components/Mappings/hooks/useFetchExtractionStatus.js.map +1 -1
- package/lib/cjs/components/Mappings/hooks/useFetchMappingExtractionStatus.d.ts +20 -0
- package/lib/cjs/components/Mappings/hooks/useFetchMappingExtractionStatus.js +55 -0
- package/lib/cjs/components/Mappings/hooks/useFetchMappingExtractionStatus.js.map +1 -0
- package/lib/cjs/components/Mappings/hooks/useMappingsOperations.d.ts +8 -0
- package/lib/cjs/components/Mappings/hooks/useMappingsOperations.js +29 -5
- package/lib/cjs/components/Mappings/hooks/useMappingsOperations.js.map +1 -1
- package/lib/cjs/components/Mappings/hooks/useRunExtraction.d.ts +14 -0
- package/lib/cjs/components/Mappings/hooks/useRunExtraction.js +42 -0
- package/lib/cjs/components/Mappings/hooks/useRunExtraction.js.map +1 -0
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyAction.js +17 -25
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyAction.js.map +1 -1
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js +18 -25
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js.map +1 -1
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.js +35 -38
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.js.map +1 -1
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.js +28 -59
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.js.map +1 -1
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationTable.js +37 -40
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationTable.js.map +1 -1
- package/lib/cjs/components/Properties/GroupColorToggle.js +30 -26
- package/lib/cjs/components/Properties/GroupColorToggle.js.map +1 -1
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.js +61 -166
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.js.map +1 -1
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.scss +1 -46
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyTable.js +34 -37
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyTable.js.map +1 -1
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyUtils.js +65 -51
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyUtils.js.map +1 -1
- package/lib/cjs/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.d.ts +12 -0
- package/lib/cjs/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.js +147 -0
- package/lib/cjs/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.js.map +1 -0
- package/lib/cjs/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.scss +49 -0
- package/lib/cjs/components/Properties/PropertyMenu.js +11 -15
- package/lib/cjs/components/Properties/PropertyMenu.js.map +1 -1
- package/lib/cjs/components/Properties/PropertyTable.js +1 -1
- package/lib/cjs/components/Properties/PropertyTable.js.map +1 -1
- package/lib/cjs/components/Properties/hooks/useCalculatedPropertiesQuery.d.ts +4 -0
- package/lib/cjs/components/Properties/hooks/useCalculatedPropertiesQuery.js +12 -0
- package/lib/cjs/components/Properties/hooks/useCalculatedPropertiesQuery.js.map +1 -0
- package/lib/cjs/components/Properties/hooks/useCustomCalculationsQuery.d.ts +4 -0
- package/lib/cjs/components/Properties/hooks/useCustomCalculationsQuery.js +12 -0
- package/lib/cjs/components/Properties/hooks/useCustomCalculationsQuery.js.map +1 -0
- package/lib/cjs/components/Properties/hooks/useGroupPropertiesQuery.d.ts +4 -0
- package/lib/cjs/components/Properties/hooks/useGroupPropertiesQuery.js +12 -0
- package/lib/cjs/components/Properties/hooks/useGroupPropertiesQuery.js.map +1 -0
- package/lib/cjs/components/SharedComponents/DeleteModal.d.ts +1 -2
- package/lib/cjs/components/SharedComponents/DeleteModal.js +1 -2
- package/lib/cjs/components/SharedComponents/DeleteModal.js.map +1 -1
- package/lib/cjs/components/context/ExtractionStateJobContext.d.ts +8 -0
- package/lib/cjs/components/context/ExtractionStateJobContext.js +44 -0
- package/lib/cjs/components/context/ExtractionStateJobContext.js.map +1 -0
- package/lib/cjs/components/context/PropertiesGroupColorContext.d.ts +8 -0
- package/lib/cjs/components/context/{PropertiesContext.js → PropertiesGroupColorContext.js} +7 -10
- package/lib/cjs/components/context/PropertiesGroupColorContext.js.map +1 -0
- package/lib/esm/WidgetShell/GroupingMappingContent.js +2 -2
- package/lib/esm/WidgetShell/GroupingMappingContent.js.map +1 -1
- package/lib/esm/components/Constants.d.ts +3 -0
- package/lib/esm/components/Constants.js +3 -0
- package/lib/esm/components/Constants.js.map +1 -1
- package/lib/esm/components/GroupingMappingContext.js +12 -14
- package/lib/esm/components/GroupingMappingContext.js.map +1 -1
- package/lib/esm/components/Groups/Editing/GroupAction.js +5 -1
- package/lib/esm/components/Groups/Editing/GroupAction.js.map +1 -1
- package/lib/esm/components/Groups/GroupsVisualization.js +45 -13
- package/lib/esm/components/Groups/GroupsVisualization.js.map +1 -1
- package/lib/esm/components/Groups/groupsHelpers.d.ts +2 -1
- package/lib/esm/components/Groups/groupsHelpers.js +6 -4
- package/lib/esm/components/Groups/groupsHelpers.js.map +1 -1
- package/lib/esm/components/Groups/hooks/useKeySetHiliteQueries.d.ts +2 -2
- package/lib/esm/components/Groups/hooks/useKeySetHiliteQueries.js.map +1 -1
- package/lib/esm/components/Mappings/Extraction/ExtractionMessageModal.js +27 -18
- package/lib/esm/components/Mappings/Extraction/ExtractionMessageModal.js.map +1 -1
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/QueuedExtractionState.d.ts +3 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/QueuedExtractionState.js +10 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/QueuedExtractionState.js.map +1 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/RunningExtractionState.d.ts +3 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/RunningExtractionState.js +9 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/RunningExtractionState.js.map +1 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/StartingExtractionState.d.ts +3 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/StartingExtractionState.js +10 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/StartingExtractionState.js.map +1 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/TerminalExtractionState.d.ts +9 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/TerminalExtractionState.js +14 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/TerminalExtractionState.js.map +1 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStatus.d.ts +17 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStatus.js +52 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStatus.js.map +1 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStatus.scss +40 -0
- package/lib/esm/components/Mappings/Import/SelectIModel.js +1 -2
- package/lib/esm/components/Mappings/Import/SelectIModel.js.map +1 -1
- package/lib/esm/components/Mappings/MappingListItem.d.ts +20 -0
- package/lib/esm/components/Mappings/MappingListItem.js +69 -0
- package/lib/esm/components/Mappings/MappingListItem.js.map +1 -0
- package/lib/esm/components/Mappings/MappingListItem.scss +25 -0
- package/lib/esm/components/Mappings/MappingsView.d.ts +2 -0
- package/lib/esm/components/Mappings/MappingsView.js +30 -6
- package/lib/esm/components/Mappings/MappingsView.js.map +1 -1
- package/lib/esm/components/Mappings/hooks/useFetchExtractionStatus.d.ts +3 -1
- package/lib/esm/components/Mappings/hooks/useFetchExtractionStatus.js +7 -4
- package/lib/esm/components/Mappings/hooks/useFetchExtractionStatus.js.map +1 -1
- package/lib/esm/components/Mappings/hooks/useFetchMappingExtractionStatus.d.ts +20 -0
- package/lib/esm/components/Mappings/hooks/useFetchMappingExtractionStatus.js +49 -0
- package/lib/esm/components/Mappings/hooks/useFetchMappingExtractionStatus.js.map +1 -0
- package/lib/esm/components/Mappings/hooks/useMappingsOperations.d.ts +8 -0
- package/lib/esm/components/Mappings/hooks/useMappingsOperations.js +30 -6
- package/lib/esm/components/Mappings/hooks/useMappingsOperations.js.map +1 -1
- package/lib/esm/components/Mappings/hooks/useRunExtraction.d.ts +14 -0
- package/lib/esm/components/Mappings/hooks/useRunExtraction.js +38 -0
- package/lib/esm/components/Mappings/hooks/useRunExtraction.js.map +1 -0
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyAction.js +17 -25
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyAction.js.map +1 -1
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js +18 -25
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js.map +1 -1
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyTable.js +35 -38
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyTable.js.map +1 -1
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationAction.js +29 -60
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationAction.js.map +1 -1
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationTable.js +37 -40
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationTable.js.map +1 -1
- package/lib/esm/components/Properties/GroupColorToggle.js +32 -28
- package/lib/esm/components/Properties/GroupColorToggle.js.map +1 -1
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.js +63 -168
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.js.map +1 -1
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.scss +1 -46
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyTable.js +34 -37
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyTable.js.map +1 -1
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyUtils.js +65 -51
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyUtils.js.map +1 -1
- package/lib/esm/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.d.ts +12 -0
- package/lib/esm/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.js +117 -0
- package/lib/esm/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.js.map +1 -0
- package/lib/esm/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.scss +49 -0
- package/lib/esm/components/Properties/PropertyMenu.js +12 -16
- package/lib/esm/components/Properties/PropertyMenu.js.map +1 -1
- package/lib/esm/components/Properties/PropertyTable.js +1 -1
- package/lib/esm/components/Properties/PropertyTable.js.map +1 -1
- package/lib/esm/components/Properties/hooks/useCalculatedPropertiesQuery.d.ts +4 -0
- package/lib/esm/components/Properties/hooks/useCalculatedPropertiesQuery.js +8 -0
- package/lib/esm/components/Properties/hooks/useCalculatedPropertiesQuery.js.map +1 -0
- package/lib/esm/components/Properties/hooks/useCustomCalculationsQuery.d.ts +4 -0
- package/lib/esm/components/Properties/hooks/useCustomCalculationsQuery.js +8 -0
- package/lib/esm/components/Properties/hooks/useCustomCalculationsQuery.js.map +1 -0
- package/lib/esm/components/Properties/hooks/useGroupPropertiesQuery.d.ts +4 -0
- package/lib/esm/components/Properties/hooks/useGroupPropertiesQuery.js +8 -0
- package/lib/esm/components/Properties/hooks/useGroupPropertiesQuery.js.map +1 -0
- package/lib/esm/components/SharedComponents/DeleteModal.d.ts +1 -2
- package/lib/esm/components/SharedComponents/DeleteModal.js +1 -2
- package/lib/esm/components/SharedComponents/DeleteModal.js.map +1 -1
- package/lib/esm/components/context/ExtractionStateJobContext.d.ts +8 -0
- package/lib/esm/components/context/ExtractionStateJobContext.js +17 -0
- package/lib/esm/components/context/ExtractionStateJobContext.js.map +1 -0
- package/lib/esm/components/context/PropertiesGroupColorContext.d.ts +8 -0
- package/lib/esm/components/context/{PropertiesContext.js → PropertiesGroupColorContext.js} +5 -8
- package/lib/esm/components/context/PropertiesGroupColorContext.js.map +1 -0
- package/package.json +3 -2
- package/lib/cjs/components/Properties/hooks/useFetchData.d.ts +0 -7
- package/lib/cjs/components/Properties/hooks/useFetchData.js +0 -43
- package/lib/cjs/components/Properties/hooks/useFetchData.js.map +0 -1
- package/lib/cjs/components/context/PropertiesContext.d.ts +0 -15
- package/lib/cjs/components/context/PropertiesContext.js.map +0 -1
- package/lib/esm/components/Properties/hooks/useFetchData.d.ts +0 -7
- package/lib/esm/components/Properties/hooks/useFetchData.js +0 -37
- package/lib/esm/components/Properties/hooks/useFetchData.js.map +0 -1
- package/lib/esm/components/context/PropertiesContext.d.ts +0 -15
- package/lib/esm/components/context/PropertiesContext.js.map +0 -1
|
@@ -9,53 +9,50 @@ import { useMappingClient } from "../../context/MappingClientContext";
|
|
|
9
9
|
import { PropertyNameCell } from "../PropertyNameCell";
|
|
10
10
|
import { PropertyTable } from "../PropertyTable";
|
|
11
11
|
import { useGroupingMappingApiConfig } from "../../context/GroupingApiConfigContext";
|
|
12
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
12
13
|
export const CustomCalculationTable = ({ mappingId, groupId, onClickAdd, onClickModify, isLoading, customCalculations, refresh, }) => {
|
|
13
14
|
const mappingClient = useMappingClient();
|
|
14
15
|
const { getAccessToken, iModelId } = useGroupingMappingApiConfig();
|
|
16
|
+
const queryClient = useQueryClient();
|
|
15
17
|
const columnsFactory = useCallback((handleShowDeleteModal) => [
|
|
16
18
|
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
React.createElement(IconButton, { styleType: 'borderless' },
|
|
46
|
-
React.createElement(SvgMore, { style: {
|
|
47
|
-
width: "16px",
|
|
48
|
-
height: "16px",
|
|
49
|
-
} }))));
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
],
|
|
19
|
+
id: "propertyName",
|
|
20
|
+
Header: "Custom Calculation",
|
|
21
|
+
accessor: "propertyName",
|
|
22
|
+
Cell: (value) => (React.createElement(PropertyNameCell, { property: value.row.original, onClickModify: onClickModify })),
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: "formula",
|
|
26
|
+
Header: "Formula",
|
|
27
|
+
accessor: "formula",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "dropdown",
|
|
31
|
+
Header: "",
|
|
32
|
+
width: 80,
|
|
33
|
+
Cell: (value) => {
|
|
34
|
+
return (React.createElement(DropdownMenu, { menuItems: (close) => [onClickModify ? [
|
|
35
|
+
React.createElement(MenuItem, { key: 0, onClick: () => {
|
|
36
|
+
onClickModify(value.row.original);
|
|
37
|
+
close();
|
|
38
|
+
}, icon: React.createElement(SvgEdit, null) }, "Modify")
|
|
39
|
+
] : [], React.createElement(MenuItem, { key: 1, onClick: () => {
|
|
40
|
+
handleShowDeleteModal(value.row.original);
|
|
41
|
+
close();
|
|
42
|
+
}, icon: React.createElement(SvgDelete, null) }, "Remove"),
|
|
43
|
+
].flatMap((p) => p) },
|
|
44
|
+
React.createElement(IconButton, { styleType: 'borderless' },
|
|
45
|
+
React.createElement(SvgMore, null))));
|
|
46
|
+
},
|
|
53
47
|
},
|
|
54
48
|
], [onClickModify]);
|
|
55
|
-
const deleteProperty =
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
49
|
+
const { mutateAsync: deleteProperty } = useMutation({
|
|
50
|
+
mutationFn: async (propertyId) => {
|
|
51
|
+
const accessToken = await getAccessToken();
|
|
52
|
+
await mappingClient.deleteCustomCalculation(accessToken, iModelId, mappingId, groupId, propertyId);
|
|
53
|
+
},
|
|
54
|
+
onSuccess: async () => queryClient.invalidateQueries({ queryKey: ["customCalculations", iModelId, mappingId, groupId] }),
|
|
55
|
+
});
|
|
59
56
|
return (React.createElement(PropertyTable, { propertyType: "Custom Calculation", columnsFactory: columnsFactory, data: customCalculations, isLoading: isLoading, onClickAdd: onClickAdd, refreshProperties: refresh, deleteProperty: deleteProperty }));
|
|
60
57
|
};
|
|
61
58
|
//# sourceMappingURL=CustomCalculationTable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomCalculationTable.js","sourceRoot":"","sources":["../../../../../src/components/Properties/CustomCalculations/CustomCalculationTable.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EACL,SAAS,EACT,OAAO,EACP,OAAO,GACR,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,YAAY,EACZ,UAAU,EACV,QAAQ,GACT,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAG3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"CustomCalculationTable.js","sourceRoot":"","sources":["../../../../../src/components/Properties/CustomCalculations/CustomCalculationTable.tsx"],"names":[],"mappings":"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","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 {\n SvgDelete,\n SvgEdit,\n SvgMore,\n} from \"@itwin/itwinui-icons-react\";\nimport {\n DropdownMenu,\n IconButton,\n MenuItem,\n} from \"@itwin/itwinui-react\";\nimport React, { useCallback } from \"react\";\nimport type { CellProps, Column } from \"react-table\";\nimport type { CustomCalculation } from \"@itwin/insights-client\";\nimport { useMappingClient } from \"../../context/MappingClientContext\";\nimport { PropertyNameCell } from \"../PropertyNameCell\";\nimport { PropertyTable } from \"../PropertyTable\";\nimport { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\n\nexport interface CustomCalculationTableProps {\n mappingId: string;\n groupId: string;\n onClickAdd?: () => void;\n onClickModify?: (value: CustomCalculation) => void;\n isLoading: boolean;\n customCalculations: CustomCalculation[];\n refresh: () => Promise<void>;\n}\n\nexport const CustomCalculationTable = ({\n mappingId,\n groupId,\n onClickAdd,\n onClickModify,\n isLoading,\n customCalculations,\n refresh,\n}: CustomCalculationTableProps) => {\n const mappingClient = useMappingClient();\n const { getAccessToken, iModelId } = useGroupingMappingApiConfig();\n const queryClient = useQueryClient();\n\n const columnsFactory = useCallback(\n (handleShowDeleteModal: (value: CustomCalculation) => void): Column<CustomCalculation>[] => [\n {\n id: \"propertyName\",\n Header: \"Custom Calculation\",\n accessor: \"propertyName\",\n Cell: (value: CellProps<CustomCalculation>) => (\n <PropertyNameCell\n property={value.row.original}\n onClickModify={onClickModify}\n />\n ),\n },\n {\n id: \"formula\",\n Header: \"Formula\",\n accessor: \"formula\",\n },\n {\n id: \"dropdown\",\n Header: \"\",\n width: 80,\n Cell: (value: CellProps<CustomCalculation>) => {\n return (\n <DropdownMenu\n menuItems={(close: () => void) => [onClickModify ? [\n <MenuItem\n key={0}\n onClick={() => {\n onClickModify(value.row.original);\n close();\n }}\n icon={<SvgEdit />}\n >\n Modify\n </MenuItem>] : [],\n <MenuItem\n key={1}\n onClick={() => {\n handleShowDeleteModal(value.row.original);\n close();\n }}\n icon={<SvgDelete />}\n >\n Remove\n </MenuItem>,\n ].flatMap((p) => p)}\n >\n <IconButton styleType='borderless'>\n <SvgMore />\n </IconButton>\n </DropdownMenu>\n );\n },\n },\n ],\n [onClickModify],\n );\n\n const { mutateAsync: deleteProperty } = useMutation({\n mutationFn: async (propertyId: string) => {\n const accessToken = await getAccessToken();\n await mappingClient.deleteCustomCalculation(\n accessToken,\n iModelId,\n mappingId,\n groupId,\n propertyId,\n );\n },\n onSuccess: async () => queryClient.invalidateQueries({ queryKey: [\"customCalculations\", iModelId, mappingId, groupId] }),\n });\n\n return (\n <PropertyTable\n propertyType=\"Custom Calculation\"\n columnsFactory={columnsFactory}\n data={customCalculations}\n isLoading={isLoading}\n onClickAdd={onClickAdd}\n refreshProperties={refresh}\n deleteProperty={deleteProperty}\n />\n );\n};\n"]}
|
|
@@ -2,44 +2,48 @@
|
|
|
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 React, {
|
|
5
|
+
import React, { useCallback, useEffect } from "react";
|
|
6
6
|
import { toaster, ToggleSwitch } from "@itwin/itwinui-react";
|
|
7
|
-
import {
|
|
7
|
+
import { clearAll, visualizeElements, zoomToElements } from "../../common/viewerUtils";
|
|
8
8
|
import { Presentation } from "@itwin/presentation-frontend";
|
|
9
9
|
import { useGroupingMappingApiConfig } from "../context/GroupingApiConfigContext";
|
|
10
10
|
import { useGroupKeySetQuery } from "../Groups/hooks/useKeySetHiliteQueries";
|
|
11
|
-
import {
|
|
11
|
+
import { usePropertiesGroupColorContext } from "../context/PropertiesGroupColorContext";
|
|
12
|
+
import { useMutation } from "@tanstack/react-query";
|
|
13
|
+
import { useIsMounted } from "../../common/hooks/useIsMounted";
|
|
12
14
|
export const GroupColorToggle = ({ color, group, ...rest }) => {
|
|
13
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
14
15
|
const { iModelConnection } = useGroupingMappingApiConfig();
|
|
15
16
|
if (!iModelConnection) {
|
|
16
17
|
throw new Error("This component requires an active iModelConnection.");
|
|
17
18
|
}
|
|
18
|
-
const { showGroupColor, setShowGroupColor } =
|
|
19
|
-
const { data: hiliteIdsResult } = useGroupKeySetQuery(group, iModelConnection, showGroupColor);
|
|
19
|
+
const { showGroupColor, setShowGroupColor } = usePropertiesGroupColorContext();
|
|
20
|
+
const { data: hiliteIdsResult, isFetched, isFetching } = useGroupKeySetQuery(group, iModelConnection, showGroupColor);
|
|
21
|
+
const isMounted = useIsMounted();
|
|
22
|
+
const { mutate: mutateVisualization, isLoading: isVisualizing } = useMutation({
|
|
23
|
+
mutationFn: async (hiliteIds) => {
|
|
24
|
+
clearAll();
|
|
25
|
+
Presentation.selection.clearSelection("GroupingMappingWidget", iModelConnection);
|
|
26
|
+
visualizeElements(hiliteIds.result.ids, color);
|
|
27
|
+
await zoomToElements(hiliteIds.result.ids);
|
|
28
|
+
},
|
|
29
|
+
onError: (error) => {
|
|
30
|
+
toaster.negative("There was an error visualizing group.");
|
|
31
|
+
// eslint-disable-next-line no-console
|
|
32
|
+
console.error(error);
|
|
33
|
+
},
|
|
34
|
+
});
|
|
20
35
|
useEffect(() => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
Presentation.selection.clearSelection("GroupingMappingWidget", iModelConnection);
|
|
28
|
-
visualizeElements(hiliteIdsResult.result.ids, color);
|
|
29
|
-
await zoomToElements(hiliteIdsResult.result.ids);
|
|
30
|
-
}
|
|
36
|
+
isFetched && showGroupColor && hiliteIdsResult && isMounted() && mutateVisualization(hiliteIdsResult);
|
|
37
|
+
}, [hiliteIdsResult, isFetched, isMounted, showGroupColor, mutateVisualization]);
|
|
38
|
+
const handleToggleChange = useCallback(() => {
|
|
39
|
+
setShowGroupColor((b) => {
|
|
40
|
+
if (b) {
|
|
41
|
+
clearAll();
|
|
31
42
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
finally {
|
|
38
|
-
setIsLoading(false);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
void visualize();
|
|
42
|
-
}, [color, hiliteIdsResult, iModelConnection, showGroupColor]);
|
|
43
|
-
return (React.createElement(ToggleSwitch, { label: "Color Group", disabled: isLoading, checked: showGroupColor, onChange: () => setShowGroupColor((b) => !b), ...rest }));
|
|
43
|
+
return !b;
|
|
44
|
+
});
|
|
45
|
+
}, [setShowGroupColor]);
|
|
46
|
+
const isLoading = isFetching || isVisualizing;
|
|
47
|
+
return (React.createElement(ToggleSwitch, { label: "Color Group", disabled: isLoading, checked: showGroupColor, onChange: handleToggleChange, ...rest }));
|
|
44
48
|
};
|
|
45
49
|
//# sourceMappingURL=GroupColorToggle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupColorToggle.js","sourceRoot":"","sources":["../../../../src/components/Properties/GroupColorToggle.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"GroupColorToggle.js","sourceRoot":"","sources":["../../../../src/components/Properties/GroupColorToggle.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAElF,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAO/D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAC/B,KAAK,EACL,KAAK,EACL,GAAG,IAAI,EACe,EAAE,EAAE;IAC1B,MAAM,EAAE,gBAAgB,EAAE,GAAG,2BAA2B,EAAE,CAAC;IAC3D,IAAI,CAAC,gBAAgB,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;KACxE;IACD,MAAM,EAAE,cAAc,EAAE,iBAAiB,EAAE,GAAG,8BAA8B,EAAE,CAAC;IAC/E,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAC;IACtH,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IAEjC,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,WAAW,CAAC;QAC5E,UAAU,EAAE,KAAK,EAAE,SAAuB,EAAE,EAAE;YAC5C,QAAQ,EAAE,CAAC;YACX,YAAY,CAAC,SAAS,CAAC,cAAc,CACnC,uBAAuB,EACvB,gBAAgB,CACjB,CAAC;YACF,iBAAiB,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YAC/C,MAAM,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACjB,OAAO,CAAC,QAAQ,CAAC,uCAAuC,CAAC,CAAC;YAC1D,sCAAsC;YACtC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;KACF,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,SAAS,IAAI,cAAc,IAAI,eAAe,IAAI,SAAS,EAAE,IAAI,mBAAmB,CAAC,eAAe,CAAC,CAAC;IACxG,CAAC,EAAE,CAAC,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAEjF,MAAM,kBAAkB,GAAG,WAAW,CAAC,GAAG,EAAE;QAC1C,iBAAiB,CAAC,CAAC,CAAC,EAAE,EAAE;YACtB,IAAI,CAAC,EAAE;gBACL,QAAQ,EAAE,CAAC;aACZ;YACD,OAAO,CAAC,CAAC,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAExB,MAAM,SAAS,GAAG,UAAU,IAAI,aAAa,CAAC;IAE9C,OAAO,CACL,oBAAC,YAAY,IACX,KAAK,EAAC,aAAa,EACnB,QAAQ,EAAE,SAAS,EACnB,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,kBAAkB,KACxB,IAAI,GACM,CACjB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport React, { useCallback, useEffect } from \"react\";\nimport type { ToggleSwitchProps } from \"@itwin/itwinui-react\";\nimport { toaster, ToggleSwitch } from \"@itwin/itwinui-react\";\nimport type { Group } from \"@itwin/insights-client\";\nimport { clearAll, visualizeElements, zoomToElements } from \"../../common/viewerUtils\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { useGroupingMappingApiConfig } from \"../context/GroupingApiConfigContext\";\nimport type { QueryResults } from \"../Groups/hooks/useKeySetHiliteQueries\";\nimport { useGroupKeySetQuery } from \"../Groups/hooks/useKeySetHiliteQueries\";\nimport { usePropertiesGroupColorContext } from \"../context/PropertiesGroupColorContext\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useIsMounted } from \"../../common/hooks/useIsMounted\";\n\nexport type GroupColorToggleProps = Partial<ToggleSwitchProps> & {\n color: string;\n group: Group;\n};\n\nexport const GroupColorToggle = ({\n color,\n group,\n ...rest\n}: GroupColorToggleProps) => {\n const { iModelConnection } = useGroupingMappingApiConfig();\n if (!iModelConnection) {\n throw new Error(\"This component requires an active iModelConnection.\");\n }\n const { showGroupColor, setShowGroupColor } = usePropertiesGroupColorContext();\n const { data: hiliteIdsResult, isFetched, isFetching } = useGroupKeySetQuery(group, iModelConnection, showGroupColor);\n const isMounted = useIsMounted();\n\n const { mutate: mutateVisualization, isLoading: isVisualizing } = useMutation({\n mutationFn: async (hiliteIds: QueryResults) => {\n clearAll();\n Presentation.selection.clearSelection(\n \"GroupingMappingWidget\",\n iModelConnection,\n );\n visualizeElements(hiliteIds.result.ids, color);\n await zoomToElements(hiliteIds.result.ids);\n },\n onError: (error) => {\n toaster.negative(\"There was an error visualizing group.\");\n // eslint-disable-next-line no-console\n console.error(error);\n },\n });\n\n useEffect(() => {\n isFetched && showGroupColor && hiliteIdsResult && isMounted() && mutateVisualization(hiliteIdsResult);\n }, [hiliteIdsResult, isFetched, isMounted, showGroupColor, mutateVisualization]);\n\n const handleToggleChange = useCallback(() => {\n setShowGroupColor((b) => {\n if (b) {\n clearAll();\n }\n return !b;\n });\n }, [setShowGroupColor]);\n\n const isLoading = isFetching || isVisualizing;\n\n return (\n <ToggleSwitch\n label=\"Color Group\"\n disabled={isLoading}\n checked={showGroupColor}\n onChange={handleToggleChange}\n {...rest}\n ></ToggleSwitch>\n );\n};\n"]}
|
|
@@ -2,26 +2,21 @@
|
|
|
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 { renderToStaticMarkup } from "react-dom/server";
|
|
6
5
|
import { PropertyValueFormat } from "@itwin/presentation-common";
|
|
7
|
-
import { Alert, Button, Fieldset,
|
|
8
|
-
import React, { useCallback, useEffect,
|
|
6
|
+
import { Alert, Button, Fieldset, LabeledInput, LabeledSelect, Text, } from "@itwin/itwinui-react";
|
|
7
|
+
import React, { useCallback, useEffect, useState } from "react";
|
|
9
8
|
import ActionPanel from "../../SharedComponents/ActionPanel";
|
|
10
9
|
import useValidator, { NAME_REQUIREMENTS } from "../hooks/useValidator";
|
|
11
|
-
import { getLocalizedStringPresentation, handleError } from "../../../common/utils";
|
|
12
10
|
import { useMappingClient } from "../../context/MappingClientContext";
|
|
13
11
|
import { useGroupingMappingApiConfig } from "../../context/GroupingApiConfigContext";
|
|
14
12
|
import { HorizontalTile } from "../../SharedComponents/HorizontalTile";
|
|
15
13
|
import { DataType, QuantityType } from "@itwin/insights-client";
|
|
16
|
-
import { SvgClose, SvgDragHandleVertical, SvgMoreVerticalSmall, SvgRemove, SvgSearch, } from "@itwin/itwinui-icons-react";
|
|
17
|
-
import { closestCenter, DndContext, DragOverlay, KeyboardSensor, PointerSensor, useSensor, useSensors, } from "@dnd-kit/core";
|
|
18
|
-
import { arrayMove, SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy, } from "@dnd-kit/sortable";
|
|
19
|
-
import SortableHorizontalTile from "./SortableHorizontalTile";
|
|
20
|
-
import Split from "react-split";
|
|
21
14
|
import "./GroupPropertyAction.scss";
|
|
22
15
|
import { convertPresentationFields, convertToECProperties, fetchPresentationDescriptor, findProperties, } from "./GroupPropertyUtils";
|
|
23
16
|
import { manufactureKeys } from "../../../common/viewerUtils";
|
|
24
17
|
import { SaveModal } from "./SaveModal";
|
|
18
|
+
import { GroupsPropertiesSelectionModal } from "./GroupsPropertiesSelectionModal";
|
|
19
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
25
20
|
export const quantityTypesSelectionOptions = [
|
|
26
21
|
{ value: QuantityType.Area, label: "Area" },
|
|
27
22
|
{ value: QuantityType.Distance, label: "Distance" },
|
|
@@ -43,93 +38,49 @@ export const GroupPropertyAction = ({ mappingId, group, groupProperty, onSaveSuc
|
|
|
43
38
|
const [propertiesMetaData, setPropertiesMetaData] = useState([]);
|
|
44
39
|
const [propertiesNotFoundAlert, setPropertiesNotFoundAlert] = useState(false);
|
|
45
40
|
const [validator, showValidationMessage] = useValidator();
|
|
46
|
-
const [
|
|
47
|
-
const [
|
|
48
|
-
const
|
|
49
|
-
const [searched, setSearched] = useState(false);
|
|
50
|
-
const [activeDragProperty, setActiveDragProperty] = useState();
|
|
51
|
-
const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, {
|
|
52
|
-
coordinateGetter: sortableKeyboardCoordinates,
|
|
53
|
-
}));
|
|
54
|
-
const [showModal, setShowModal] = useState(false);
|
|
55
|
-
const [showSaveModal, setShowSaveModal] = useState(false);
|
|
56
|
-
const handleDragStart = useCallback((event) => {
|
|
57
|
-
const { active } = event;
|
|
58
|
-
const activeProperty = selectedProperties.find((p) => active.id === p.key);
|
|
59
|
-
setActiveDragProperty(activeProperty);
|
|
60
|
-
}, [selectedProperties]);
|
|
61
|
-
const handleDragEnd = useCallback((event) => {
|
|
62
|
-
const { active, over } = event;
|
|
63
|
-
if (over && (active.id !== over.id)) {
|
|
64
|
-
setSelectedProperties((items) => {
|
|
65
|
-
const oldIndex = selectedProperties.findIndex((p) => active.id === p.key);
|
|
66
|
-
const newIndex = selectedProperties.findIndex((p) => over.id === p.key);
|
|
67
|
-
return arrayMove(items, oldIndex, newIndex);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
setActiveDragProperty(undefined);
|
|
71
|
-
}, [selectedProperties]);
|
|
72
|
-
const filteredProperties = useMemo(() => propertiesMetaData.filter((p) => [p.displayLabel, p.categoryLabel, p.actualECClassName]
|
|
73
|
-
.map((l) => l.toLowerCase())
|
|
74
|
-
.some((l) => l.includes(activeSearchInput.toLowerCase()))), [activeSearchInput, propertiesMetaData]);
|
|
41
|
+
const [showPropertiesSelectionModal, setShowPropertiesSelectionModal] = useState(false);
|
|
42
|
+
const [showSaveConfirmationModal, setShowSaveConfirmationModal] = useState(false);
|
|
43
|
+
const queryClient = useQueryClient();
|
|
75
44
|
const reset = useCallback(() => {
|
|
76
45
|
setPropertyName("");
|
|
77
46
|
setDataType(DataType.Undefined);
|
|
78
47
|
setSelectedProperties([]);
|
|
79
48
|
}, []);
|
|
49
|
+
const fetchPropertiesMetadata = useCallback(async () => {
|
|
50
|
+
if (!iModelConnection)
|
|
51
|
+
return;
|
|
52
|
+
const result = await manufactureKeys(group.query, iModelConnection);
|
|
53
|
+
const descriptor = await fetchPresentationDescriptor(iModelConnection, result);
|
|
54
|
+
// Only allow primitives and structs
|
|
55
|
+
const propertyFields = descriptor?.fields.filter((field) => field.type.valueFormat === PropertyValueFormat.Primitive ||
|
|
56
|
+
field.type.valueFormat === PropertyValueFormat.Struct) ?? [];
|
|
57
|
+
const propertiesMetaData = convertPresentationFields(propertyFields);
|
|
58
|
+
let groupPropertyDetails = null;
|
|
59
|
+
if (groupProperty) {
|
|
60
|
+
const accessToken = await getAccessToken();
|
|
61
|
+
groupPropertyDetails = await mappingClient.getGroupProperty(accessToken, iModelId, mappingId, group.id, groupProperty.id);
|
|
62
|
+
}
|
|
63
|
+
return { propertiesMetaData, groupPropertyDetails };
|
|
64
|
+
}, [getAccessToken, group.id, group.query, groupProperty, iModelConnection, iModelId, mappingClient, mappingId]);
|
|
65
|
+
const { data, isFetching: isLoadingProperties, isSuccess: isLoadingPropertiesSuccessful } = useQuery(["groupProperties", iModelId, mappingId, group.id, groupProperty?.id, "metadata"], fetchPropertiesMetadata);
|
|
80
66
|
useEffect(() => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
setPropertiesMetaData(propertiesMetaData);
|
|
92
|
-
if (groupProperty) {
|
|
93
|
-
const accessToken = await getAccessToken();
|
|
94
|
-
let response;
|
|
95
|
-
try {
|
|
96
|
-
response = await mappingClient.getGroupProperty(accessToken, iModelId, mappingId, group.id, groupProperty.id);
|
|
97
|
-
setPropertyName(response.propertyName);
|
|
98
|
-
setOldPropertyName(response.propertyName);
|
|
99
|
-
setDataType(response.dataType);
|
|
100
|
-
setQuantityType(response.quantityType);
|
|
101
|
-
const properties = findProperties(response.ecProperties, propertiesMetaData);
|
|
102
|
-
if (properties.length === 0) {
|
|
103
|
-
setPropertiesNotFoundAlert(true);
|
|
104
|
-
}
|
|
105
|
-
setSelectedProperties(properties);
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
handleError(error.status);
|
|
67
|
+
if (isLoadingPropertiesSuccessful && data?.propertiesMetaData) {
|
|
68
|
+
setPropertiesMetaData(data.propertiesMetaData);
|
|
69
|
+
if (data.groupPropertyDetails) {
|
|
70
|
+
setPropertyName(data.groupPropertyDetails.propertyName);
|
|
71
|
+
setOldPropertyName(data.groupPropertyDetails.propertyName);
|
|
72
|
+
setDataType(data.groupPropertyDetails.dataType);
|
|
73
|
+
setQuantityType(data.groupPropertyDetails.quantityType);
|
|
74
|
+
const properties = findProperties(data.groupPropertyDetails.ecProperties, data.propertiesMetaData);
|
|
75
|
+
if (properties.length === 0) {
|
|
76
|
+
setPropertiesNotFoundAlert(true);
|
|
109
77
|
}
|
|
78
|
+
setSelectedProperties(properties);
|
|
110
79
|
}
|
|
111
|
-
setIsLoading(false);
|
|
112
|
-
};
|
|
113
|
-
void generateProperties();
|
|
114
|
-
}, [getAccessToken, mappingClient, iModelConnection, iModelId, groupProperty, mappingId, group]);
|
|
115
|
-
const handleSaveClick = async () => {
|
|
116
|
-
if (!validator.allValid()) {
|
|
117
|
-
showValidationMessage(true);
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
if (oldPropertyName !== propertyName && oldPropertyName !== "") {
|
|
121
|
-
setShowSaveModal(true);
|
|
122
80
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
};
|
|
127
|
-
const handleCloseSaveModal = () => {
|
|
128
|
-
setShowSaveModal(false);
|
|
129
|
-
};
|
|
130
|
-
const onSave = async () => {
|
|
131
|
-
try {
|
|
132
|
-
setIsLoading(true);
|
|
81
|
+
}, [data, isLoadingPropertiesSuccessful]);
|
|
82
|
+
const { mutate: onSave, isLoading: isSaving } = useMutation({
|
|
83
|
+
mutationFn: async () => {
|
|
133
84
|
const accessToken = await getAccessToken();
|
|
134
85
|
const newGroupProperty = {
|
|
135
86
|
propertyName,
|
|
@@ -137,37 +88,33 @@ export const GroupPropertyAction = ({ mappingId, group, groupProperty, onSaveSuc
|
|
|
137
88
|
quantityType,
|
|
138
89
|
ecProperties: selectedProperties.map((p) => convertToECProperties(p)).flat(),
|
|
139
90
|
};
|
|
140
|
-
groupProperty
|
|
141
|
-
?
|
|
142
|
-
:
|
|
91
|
+
return groupProperty
|
|
92
|
+
? mappingClient.updateGroupProperty(accessToken, iModelId, mappingId, group.id, groupProperty.id, newGroupProperty)
|
|
93
|
+
: mappingClient.createGroupProperty(accessToken, iModelId, mappingId, group.id, newGroupProperty);
|
|
94
|
+
},
|
|
95
|
+
onSuccess: async () => {
|
|
143
96
|
onSaveSuccess();
|
|
144
97
|
reset();
|
|
98
|
+
await queryClient.invalidateQueries(["groupProperties", iModelId, mappingId, group.id]);
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
const handleSaveClick = async () => {
|
|
102
|
+
if (!validator.allValid()) {
|
|
103
|
+
showValidationMessage(true);
|
|
104
|
+
return;
|
|
145
105
|
}
|
|
146
|
-
|
|
147
|
-
|
|
106
|
+
if (oldPropertyName !== propertyName && oldPropertyName !== "") {
|
|
107
|
+
setShowSaveConfirmationModal(true);
|
|
148
108
|
}
|
|
149
|
-
|
|
150
|
-
|
|
109
|
+
else {
|
|
110
|
+
onSave();
|
|
151
111
|
}
|
|
152
112
|
};
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}, [searchInput]);
|
|
159
|
-
const clearSearch = useCallback(() => {
|
|
160
|
-
setSearchInput("");
|
|
161
|
-
setActiveSearchInput("");
|
|
162
|
-
setSearched(false);
|
|
163
|
-
}, []);
|
|
164
|
-
useEffect(() => {
|
|
165
|
-
if (searchInput.length === 0) {
|
|
166
|
-
setSearched(false);
|
|
167
|
-
clearSearch();
|
|
168
|
-
}
|
|
169
|
-
}, [searchInput, setSearched, clearSearch]);
|
|
170
|
-
return (React.createElement(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragStart: handleDragStart, onDragEnd: handleDragEnd },
|
|
113
|
+
const handleCloseSaveModal = () => {
|
|
114
|
+
setShowSaveConfirmationModal(false);
|
|
115
|
+
};
|
|
116
|
+
const isLoading = isLoadingProperties || isSaving;
|
|
117
|
+
return (React.createElement(React.Fragment, null,
|
|
171
118
|
React.createElement("div", { className: 'gmw-group-property-action-container' },
|
|
172
119
|
React.createElement(Fieldset, { disabled: isLoading, className: 'gmw-property-options', legend: 'Property Details' },
|
|
173
120
|
React.createElement(Text, { variant: 'small', as: 'small', className: 'gmw-field-legend' }, "Asterisk * indicates mandatory fields."),
|
|
@@ -196,66 +143,14 @@ export const GroupPropertyAction = ({ mappingId, group, groupProperty, onSaveSuc
|
|
|
196
143
|
React.createElement(Alert, { type: "warning" }, "Warning: Could not match saved properties from the current generated list. It does not confirm or deny validity. Overwriting will occur if a new selection is made and saved."),
|
|
197
144
|
React.createElement(Fieldset, { className: 'gmw-property-view-container', legend: "Mapped Properties" },
|
|
198
145
|
React.createElement("div", { className: "gmw-property-view-button" },
|
|
199
|
-
React.createElement(Button, { onClick: async () =>
|
|
146
|
+
React.createElement(Button, { onClick: async () => setShowPropertiesSelectionModal(true), disabled: isLoading }, "Select Properties")),
|
|
200
147
|
React.createElement("div", { className: "gmw-properties-list" }, selectedProperties.length === 0 && !isLoading ?
|
|
201
148
|
React.createElement("div", { className: "gmw-empty-selection" },
|
|
202
149
|
React.createElement(Text, null, "No properties selected."),
|
|
203
150
|
React.createElement(Text, null, "Press the \"Select Properties\" button for options.")) :
|
|
204
|
-
selectedProperties.map((property) => (React.createElement(HorizontalTile, { key: property.key, title: `${property.displayLabel} (${property.propertyType})`, titleTooltip: `${property.actualECClassName}`, subText:
|
|
151
|
+
selectedProperties.map((property) => (React.createElement(HorizontalTile, { key: property.key, title: `${property.displayLabel} (${property.propertyType})`, titleTooltip: `${property.actualECClassName}`, subText: property.categoryLabel, actionGroup: null })))))),
|
|
205
152
|
React.createElement(ActionPanel, { onSave: handleSaveClick, onCancel: onClickCancel, isLoading: isLoading, isSavingDisabled: selectedProperties.length === 0 || !propertyName || dataType === DataType.Undefined }),
|
|
206
|
-
React.createElement(
|
|
207
|
-
|
|
208
|
-
clearSearch();
|
|
209
|
-
}, closeOnExternalClick: false },
|
|
210
|
-
React.createElement(Split, { expandToMin: false, className: "gmw-property-selection-container", gutterAlign: "center", gutterSize: 2, gutter: () => {
|
|
211
|
-
// Expects HTMLElement
|
|
212
|
-
const dragHangle = renderToStaticMarkup(React.createElement(Icon, { className: "gmw-gutter-drag-icon", size: "large" },
|
|
213
|
-
React.createElement(SvgMoreVerticalSmall, null)));
|
|
214
|
-
const gutter = document.createElement("div");
|
|
215
|
-
gutter.className = `gmw-gutter`;
|
|
216
|
-
gutter.innerHTML = dragHangle;
|
|
217
|
-
return gutter;
|
|
218
|
-
}, direction: "horizontal" },
|
|
219
|
-
React.createElement(Surface, { className: "gmw-available-properties", elevation: 1 },
|
|
220
|
-
React.createElement("div", { className: "gmw-available-properties-header" },
|
|
221
|
-
React.createElement(Label, { as: "span" }, "Available Properties"),
|
|
222
|
-
React.createElement(LabeledInput, { displayStyle: "inline", iconDisplayStyle: "inline", className: "gmw-available-prop-search", value: searchInput, size: "small", placeholder: "Search....", onChange: (event) => {
|
|
223
|
-
const { target: { value }, } = event;
|
|
224
|
-
setSearchInput(value);
|
|
225
|
-
}, onKeyDown: (event) => {
|
|
226
|
-
if (event.key === "Enter") {
|
|
227
|
-
startSearch();
|
|
228
|
-
}
|
|
229
|
-
}, svgIcon: searched ? (React.createElement(IconButton, { onClick: clearSearch, styleType: "borderless", title: 'Clear Search' },
|
|
230
|
-
React.createElement(SvgClose, null))) : (React.createElement(IconButton, { onClick: startSearch, styleType: "borderless", title: 'Search' },
|
|
231
|
-
React.createElement(SvgSearch, null))) })),
|
|
232
|
-
filteredProperties.length === 0 ?
|
|
233
|
-
React.createElement("div", { className: "gmw-empty-selection" },
|
|
234
|
-
React.createElement(Text, null, "No properties available. ")) :
|
|
235
|
-
React.createElement("div", { className: "gmw-properties-list" }, filteredProperties.map((property) => (React.createElement(HorizontalTile, { key: property.key, title: `${property.displayLabel} (${property.propertyType})`, titleTooltip: `${property.actualECClassName}`, subText: getLocalizedStringPresentation(property.categoryLabel), actionGroup: null, selected: selectedProperties.some((p) => property.key === p.key), onClick: () => setSelectedProperties((sp) => sp.some((p) => property.key === p.key)
|
|
236
|
-
? sp.filter((p) => property.key !== p.key)
|
|
237
|
-
: [...sp, property]) }))))),
|
|
238
|
-
React.createElement(Surface, { className: "gmw-selected-properties", elevation: 1 },
|
|
239
|
-
React.createElement(Label, { as: "span" }, "Selected Properties"),
|
|
240
|
-
selectedProperties.length === 0 ?
|
|
241
|
-
React.createElement("div", { className: "gmw-empty-selection" },
|
|
242
|
-
React.createElement(Text, null, "No properties selected."),
|
|
243
|
-
React.createElement(Text, null, "Add some by clicking on the properties shown left.")) :
|
|
244
|
-
React.createElement("div", { className: "gmw-properties-list" },
|
|
245
|
-
React.createElement(SortableContext, { items: selectedProperties.map((p) => p.key), strategy: verticalListSortingStrategy }, selectedProperties.map((property) => React.createElement(SortableHorizontalTile, { key: property.key, id: property.key, title: `${property.displayLabel} (${property.propertyType})`, titleTooltip: `${property.actualECClassName}`, subText: property.categoryLabel, actionGroup: React.createElement("div", null,
|
|
246
|
-
React.createElement(IconButton, { styleType: "borderless", title: "Remove", onClick: () => {
|
|
247
|
-
setSelectedProperties((sp) => sp.filter((p) => property.key !== p.key));
|
|
248
|
-
} },
|
|
249
|
-
React.createElement(SvgRemove, null))) })))))),
|
|
250
|
-
React.createElement(ModalButtonBar, null,
|
|
251
|
-
React.createElement(Button, { onClick: () => {
|
|
252
|
-
setShowModal(false);
|
|
253
|
-
clearSearch();
|
|
254
|
-
}, styleType: "high-visibility" }, "Close"))),
|
|
255
|
-
React.createElement(SaveModal, { onSave: onSave, onClose: handleCloseSaveModal, showSaveModal: showSaveModal }),
|
|
256
|
-
React.createElement(DragOverlay, { zIndex: 9999 }, activeDragProperty ?
|
|
257
|
-
React.createElement(HorizontalTile, { title: `${activeDragProperty.displayLabel} (${activeDragProperty.propertyType})`, titleTooltip: `${activeDragProperty.actualECClassName}`, subText: activeDragProperty.categoryLabel, actionGroup: React.createElement(IconButton, { styleType: "borderless" },
|
|
258
|
-
React.createElement(SvgRemove, null)), dragHandle: React.createElement(Icon, { className: "gmw-drag-icon", size: "large" },
|
|
259
|
-
React.createElement(SvgDragHandleVertical, null)) }) : null)));
|
|
153
|
+
React.createElement(GroupsPropertiesSelectionModal, { showModal: showPropertiesSelectionModal, setShowModal: setShowPropertiesSelectionModal, selectedProperties: selectedProperties, setSelectedProperties: setSelectedProperties, propertiesMetaData: propertiesMetaData }),
|
|
154
|
+
React.createElement(SaveModal, { onSave: onSave, onClose: handleCloseSaveModal, showSaveModal: showSaveConfirmationModal })));
|
|
260
155
|
};
|
|
261
156
|
//# sourceMappingURL=GroupPropertyAction.js.map
|