@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.
Files changed (211) hide show
  1. package/lib/cjs/WidgetShell/GroupingMappingContent.js +2 -2
  2. package/lib/cjs/WidgetShell/GroupingMappingContent.js.map +1 -1
  3. package/lib/cjs/components/Constants.d.ts +3 -0
  4. package/lib/cjs/components/Constants.js +5 -2
  5. package/lib/cjs/components/Constants.js.map +1 -1
  6. package/lib/cjs/components/GroupingMappingContext.js +12 -14
  7. package/lib/cjs/components/GroupingMappingContext.js.map +1 -1
  8. package/lib/cjs/components/Groups/Editing/GroupAction.js +5 -1
  9. package/lib/cjs/components/Groups/Editing/GroupAction.js.map +1 -1
  10. package/lib/cjs/components/Groups/GroupsVisualization.js +44 -12
  11. package/lib/cjs/components/Groups/GroupsVisualization.js.map +1 -1
  12. package/lib/cjs/components/Groups/groupsHelpers.d.ts +2 -1
  13. package/lib/cjs/components/Groups/groupsHelpers.js +8 -5
  14. package/lib/cjs/components/Groups/groupsHelpers.js.map +1 -1
  15. package/lib/cjs/components/Groups/hooks/useKeySetHiliteQueries.d.ts +2 -2
  16. package/lib/cjs/components/Groups/hooks/useKeySetHiliteQueries.js.map +1 -1
  17. package/lib/cjs/components/Mappings/Extraction/ExtractionMessageModal.js +27 -18
  18. package/lib/cjs/components/Mappings/Extraction/ExtractionMessageModal.js.map +1 -1
  19. package/lib/cjs/components/Mappings/Extraction/ExtractionStates/QueuedExtractionState.d.ts +3 -0
  20. package/lib/cjs/components/Mappings/Extraction/ExtractionStates/QueuedExtractionState.js +17 -0
  21. package/lib/cjs/components/Mappings/Extraction/ExtractionStates/QueuedExtractionState.js.map +1 -0
  22. package/lib/cjs/components/Mappings/Extraction/ExtractionStates/RunningExtractionState.d.ts +3 -0
  23. package/lib/cjs/components/Mappings/Extraction/ExtractionStates/RunningExtractionState.js +16 -0
  24. package/lib/cjs/components/Mappings/Extraction/ExtractionStates/RunningExtractionState.js.map +1 -0
  25. package/lib/cjs/components/Mappings/Extraction/ExtractionStates/StartingExtractionState.d.ts +3 -0
  26. package/lib/cjs/components/Mappings/Extraction/ExtractionStates/StartingExtractionState.js +17 -0
  27. package/lib/cjs/components/Mappings/Extraction/ExtractionStates/StartingExtractionState.js.map +1 -0
  28. package/lib/cjs/components/Mappings/Extraction/ExtractionStates/TerminalExtractionState.d.ts +9 -0
  29. package/lib/cjs/components/Mappings/Extraction/ExtractionStates/TerminalExtractionState.js +21 -0
  30. package/lib/cjs/components/Mappings/Extraction/ExtractionStates/TerminalExtractionState.js.map +1 -0
  31. package/lib/cjs/components/Mappings/Extraction/ExtractionStatus.d.ts +17 -0
  32. package/lib/cjs/components/Mappings/Extraction/ExtractionStatus.js +79 -0
  33. package/lib/cjs/components/Mappings/Extraction/ExtractionStatus.js.map +1 -0
  34. package/lib/cjs/components/Mappings/Extraction/ExtractionStatus.scss +40 -0
  35. package/lib/cjs/components/Mappings/Import/SelectIModel.js +1 -2
  36. package/lib/cjs/components/Mappings/Import/SelectIModel.js.map +1 -1
  37. package/lib/cjs/components/Mappings/MappingListItem.d.ts +20 -0
  38. package/lib/cjs/components/Mappings/MappingListItem.js +96 -0
  39. package/lib/cjs/components/Mappings/MappingListItem.js.map +1 -0
  40. package/lib/cjs/components/Mappings/MappingListItem.scss +25 -0
  41. package/lib/cjs/components/Mappings/MappingsView.d.ts +2 -0
  42. package/lib/cjs/components/Mappings/MappingsView.js +28 -4
  43. package/lib/cjs/components/Mappings/MappingsView.js.map +1 -1
  44. package/lib/cjs/components/Mappings/hooks/useFetchExtractionStatus.d.ts +3 -1
  45. package/lib/cjs/components/Mappings/hooks/useFetchExtractionStatus.js +7 -4
  46. package/lib/cjs/components/Mappings/hooks/useFetchExtractionStatus.js.map +1 -1
  47. package/lib/cjs/components/Mappings/hooks/useFetchMappingExtractionStatus.d.ts +20 -0
  48. package/lib/cjs/components/Mappings/hooks/useFetchMappingExtractionStatus.js +55 -0
  49. package/lib/cjs/components/Mappings/hooks/useFetchMappingExtractionStatus.js.map +1 -0
  50. package/lib/cjs/components/Mappings/hooks/useMappingsOperations.d.ts +8 -0
  51. package/lib/cjs/components/Mappings/hooks/useMappingsOperations.js +29 -5
  52. package/lib/cjs/components/Mappings/hooks/useMappingsOperations.js.map +1 -1
  53. package/lib/cjs/components/Mappings/hooks/useRunExtraction.d.ts +14 -0
  54. package/lib/cjs/components/Mappings/hooks/useRunExtraction.js +42 -0
  55. package/lib/cjs/components/Mappings/hooks/useRunExtraction.js.map +1 -0
  56. package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyAction.js +17 -25
  57. package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyAction.js.map +1 -1
  58. package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js +18 -25
  59. package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js.map +1 -1
  60. package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.js +35 -38
  61. package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.js.map +1 -1
  62. package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.js +28 -59
  63. package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.js.map +1 -1
  64. package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationTable.js +37 -40
  65. package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationTable.js.map +1 -1
  66. package/lib/cjs/components/Properties/GroupColorToggle.js +30 -26
  67. package/lib/cjs/components/Properties/GroupColorToggle.js.map +1 -1
  68. package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.js +61 -166
  69. package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.js.map +1 -1
  70. package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.scss +1 -46
  71. package/lib/cjs/components/Properties/GroupProperties/GroupPropertyTable.js +34 -37
  72. package/lib/cjs/components/Properties/GroupProperties/GroupPropertyTable.js.map +1 -1
  73. package/lib/cjs/components/Properties/GroupProperties/GroupPropertyUtils.js +65 -51
  74. package/lib/cjs/components/Properties/GroupProperties/GroupPropertyUtils.js.map +1 -1
  75. package/lib/cjs/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.d.ts +12 -0
  76. package/lib/cjs/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.js +147 -0
  77. package/lib/cjs/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.js.map +1 -0
  78. package/lib/cjs/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.scss +49 -0
  79. package/lib/cjs/components/Properties/PropertyMenu.js +11 -15
  80. package/lib/cjs/components/Properties/PropertyMenu.js.map +1 -1
  81. package/lib/cjs/components/Properties/PropertyTable.js +1 -1
  82. package/lib/cjs/components/Properties/PropertyTable.js.map +1 -1
  83. package/lib/cjs/components/Properties/hooks/useCalculatedPropertiesQuery.d.ts +4 -0
  84. package/lib/cjs/components/Properties/hooks/useCalculatedPropertiesQuery.js +12 -0
  85. package/lib/cjs/components/Properties/hooks/useCalculatedPropertiesQuery.js.map +1 -0
  86. package/lib/cjs/components/Properties/hooks/useCustomCalculationsQuery.d.ts +4 -0
  87. package/lib/cjs/components/Properties/hooks/useCustomCalculationsQuery.js +12 -0
  88. package/lib/cjs/components/Properties/hooks/useCustomCalculationsQuery.js.map +1 -0
  89. package/lib/cjs/components/Properties/hooks/useGroupPropertiesQuery.d.ts +4 -0
  90. package/lib/cjs/components/Properties/hooks/useGroupPropertiesQuery.js +12 -0
  91. package/lib/cjs/components/Properties/hooks/useGroupPropertiesQuery.js.map +1 -0
  92. package/lib/cjs/components/SharedComponents/DeleteModal.d.ts +1 -2
  93. package/lib/cjs/components/SharedComponents/DeleteModal.js +1 -2
  94. package/lib/cjs/components/SharedComponents/DeleteModal.js.map +1 -1
  95. package/lib/cjs/components/context/ExtractionStateJobContext.d.ts +8 -0
  96. package/lib/cjs/components/context/ExtractionStateJobContext.js +44 -0
  97. package/lib/cjs/components/context/ExtractionStateJobContext.js.map +1 -0
  98. package/lib/cjs/components/context/PropertiesGroupColorContext.d.ts +8 -0
  99. package/lib/cjs/components/context/{PropertiesContext.js → PropertiesGroupColorContext.js} +7 -10
  100. package/lib/cjs/components/context/PropertiesGroupColorContext.js.map +1 -0
  101. package/lib/esm/WidgetShell/GroupingMappingContent.js +2 -2
  102. package/lib/esm/WidgetShell/GroupingMappingContent.js.map +1 -1
  103. package/lib/esm/components/Constants.d.ts +3 -0
  104. package/lib/esm/components/Constants.js +3 -0
  105. package/lib/esm/components/Constants.js.map +1 -1
  106. package/lib/esm/components/GroupingMappingContext.js +12 -14
  107. package/lib/esm/components/GroupingMappingContext.js.map +1 -1
  108. package/lib/esm/components/Groups/Editing/GroupAction.js +5 -1
  109. package/lib/esm/components/Groups/Editing/GroupAction.js.map +1 -1
  110. package/lib/esm/components/Groups/GroupsVisualization.js +45 -13
  111. package/lib/esm/components/Groups/GroupsVisualization.js.map +1 -1
  112. package/lib/esm/components/Groups/groupsHelpers.d.ts +2 -1
  113. package/lib/esm/components/Groups/groupsHelpers.js +6 -4
  114. package/lib/esm/components/Groups/groupsHelpers.js.map +1 -1
  115. package/lib/esm/components/Groups/hooks/useKeySetHiliteQueries.d.ts +2 -2
  116. package/lib/esm/components/Groups/hooks/useKeySetHiliteQueries.js.map +1 -1
  117. package/lib/esm/components/Mappings/Extraction/ExtractionMessageModal.js +27 -18
  118. package/lib/esm/components/Mappings/Extraction/ExtractionMessageModal.js.map +1 -1
  119. package/lib/esm/components/Mappings/Extraction/ExtractionStates/QueuedExtractionState.d.ts +3 -0
  120. package/lib/esm/components/Mappings/Extraction/ExtractionStates/QueuedExtractionState.js +10 -0
  121. package/lib/esm/components/Mappings/Extraction/ExtractionStates/QueuedExtractionState.js.map +1 -0
  122. package/lib/esm/components/Mappings/Extraction/ExtractionStates/RunningExtractionState.d.ts +3 -0
  123. package/lib/esm/components/Mappings/Extraction/ExtractionStates/RunningExtractionState.js +9 -0
  124. package/lib/esm/components/Mappings/Extraction/ExtractionStates/RunningExtractionState.js.map +1 -0
  125. package/lib/esm/components/Mappings/Extraction/ExtractionStates/StartingExtractionState.d.ts +3 -0
  126. package/lib/esm/components/Mappings/Extraction/ExtractionStates/StartingExtractionState.js +10 -0
  127. package/lib/esm/components/Mappings/Extraction/ExtractionStates/StartingExtractionState.js.map +1 -0
  128. package/lib/esm/components/Mappings/Extraction/ExtractionStates/TerminalExtractionState.d.ts +9 -0
  129. package/lib/esm/components/Mappings/Extraction/ExtractionStates/TerminalExtractionState.js +14 -0
  130. package/lib/esm/components/Mappings/Extraction/ExtractionStates/TerminalExtractionState.js.map +1 -0
  131. package/lib/esm/components/Mappings/Extraction/ExtractionStatus.d.ts +17 -0
  132. package/lib/esm/components/Mappings/Extraction/ExtractionStatus.js +52 -0
  133. package/lib/esm/components/Mappings/Extraction/ExtractionStatus.js.map +1 -0
  134. package/lib/esm/components/Mappings/Extraction/ExtractionStatus.scss +40 -0
  135. package/lib/esm/components/Mappings/Import/SelectIModel.js +1 -2
  136. package/lib/esm/components/Mappings/Import/SelectIModel.js.map +1 -1
  137. package/lib/esm/components/Mappings/MappingListItem.d.ts +20 -0
  138. package/lib/esm/components/Mappings/MappingListItem.js +69 -0
  139. package/lib/esm/components/Mappings/MappingListItem.js.map +1 -0
  140. package/lib/esm/components/Mappings/MappingListItem.scss +25 -0
  141. package/lib/esm/components/Mappings/MappingsView.d.ts +2 -0
  142. package/lib/esm/components/Mappings/MappingsView.js +30 -6
  143. package/lib/esm/components/Mappings/MappingsView.js.map +1 -1
  144. package/lib/esm/components/Mappings/hooks/useFetchExtractionStatus.d.ts +3 -1
  145. package/lib/esm/components/Mappings/hooks/useFetchExtractionStatus.js +7 -4
  146. package/lib/esm/components/Mappings/hooks/useFetchExtractionStatus.js.map +1 -1
  147. package/lib/esm/components/Mappings/hooks/useFetchMappingExtractionStatus.d.ts +20 -0
  148. package/lib/esm/components/Mappings/hooks/useFetchMappingExtractionStatus.js +49 -0
  149. package/lib/esm/components/Mappings/hooks/useFetchMappingExtractionStatus.js.map +1 -0
  150. package/lib/esm/components/Mappings/hooks/useMappingsOperations.d.ts +8 -0
  151. package/lib/esm/components/Mappings/hooks/useMappingsOperations.js +30 -6
  152. package/lib/esm/components/Mappings/hooks/useMappingsOperations.js.map +1 -1
  153. package/lib/esm/components/Mappings/hooks/useRunExtraction.d.ts +14 -0
  154. package/lib/esm/components/Mappings/hooks/useRunExtraction.js +38 -0
  155. package/lib/esm/components/Mappings/hooks/useRunExtraction.js.map +1 -0
  156. package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyAction.js +17 -25
  157. package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyAction.js.map +1 -1
  158. package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js +18 -25
  159. package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js.map +1 -1
  160. package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyTable.js +35 -38
  161. package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyTable.js.map +1 -1
  162. package/lib/esm/components/Properties/CustomCalculations/CustomCalculationAction.js +29 -60
  163. package/lib/esm/components/Properties/CustomCalculations/CustomCalculationAction.js.map +1 -1
  164. package/lib/esm/components/Properties/CustomCalculations/CustomCalculationTable.js +37 -40
  165. package/lib/esm/components/Properties/CustomCalculations/CustomCalculationTable.js.map +1 -1
  166. package/lib/esm/components/Properties/GroupColorToggle.js +32 -28
  167. package/lib/esm/components/Properties/GroupColorToggle.js.map +1 -1
  168. package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.js +63 -168
  169. package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.js.map +1 -1
  170. package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.scss +1 -46
  171. package/lib/esm/components/Properties/GroupProperties/GroupPropertyTable.js +34 -37
  172. package/lib/esm/components/Properties/GroupProperties/GroupPropertyTable.js.map +1 -1
  173. package/lib/esm/components/Properties/GroupProperties/GroupPropertyUtils.js +65 -51
  174. package/lib/esm/components/Properties/GroupProperties/GroupPropertyUtils.js.map +1 -1
  175. package/lib/esm/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.d.ts +12 -0
  176. package/lib/esm/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.js +117 -0
  177. package/lib/esm/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.js.map +1 -0
  178. package/lib/esm/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.scss +49 -0
  179. package/lib/esm/components/Properties/PropertyMenu.js +12 -16
  180. package/lib/esm/components/Properties/PropertyMenu.js.map +1 -1
  181. package/lib/esm/components/Properties/PropertyTable.js +1 -1
  182. package/lib/esm/components/Properties/PropertyTable.js.map +1 -1
  183. package/lib/esm/components/Properties/hooks/useCalculatedPropertiesQuery.d.ts +4 -0
  184. package/lib/esm/components/Properties/hooks/useCalculatedPropertiesQuery.js +8 -0
  185. package/lib/esm/components/Properties/hooks/useCalculatedPropertiesQuery.js.map +1 -0
  186. package/lib/esm/components/Properties/hooks/useCustomCalculationsQuery.d.ts +4 -0
  187. package/lib/esm/components/Properties/hooks/useCustomCalculationsQuery.js +8 -0
  188. package/lib/esm/components/Properties/hooks/useCustomCalculationsQuery.js.map +1 -0
  189. package/lib/esm/components/Properties/hooks/useGroupPropertiesQuery.d.ts +4 -0
  190. package/lib/esm/components/Properties/hooks/useGroupPropertiesQuery.js +8 -0
  191. package/lib/esm/components/Properties/hooks/useGroupPropertiesQuery.js.map +1 -0
  192. package/lib/esm/components/SharedComponents/DeleteModal.d.ts +1 -2
  193. package/lib/esm/components/SharedComponents/DeleteModal.js +1 -2
  194. package/lib/esm/components/SharedComponents/DeleteModal.js.map +1 -1
  195. package/lib/esm/components/context/ExtractionStateJobContext.d.ts +8 -0
  196. package/lib/esm/components/context/ExtractionStateJobContext.js +17 -0
  197. package/lib/esm/components/context/ExtractionStateJobContext.js.map +1 -0
  198. package/lib/esm/components/context/PropertiesGroupColorContext.d.ts +8 -0
  199. package/lib/esm/components/context/{PropertiesContext.js → PropertiesGroupColorContext.js} +5 -8
  200. package/lib/esm/components/context/PropertiesGroupColorContext.js.map +1 -0
  201. package/package.json +3 -2
  202. package/lib/cjs/components/Properties/hooks/useFetchData.d.ts +0 -7
  203. package/lib/cjs/components/Properties/hooks/useFetchData.js +0 -43
  204. package/lib/cjs/components/Properties/hooks/useFetchData.js.map +0 -1
  205. package/lib/cjs/components/context/PropertiesContext.d.ts +0 -15
  206. package/lib/cjs/components/context/PropertiesContext.js.map +0 -1
  207. package/lib/esm/components/Properties/hooks/useFetchData.d.ts +0 -7
  208. package/lib/esm/components/Properties/hooks/useFetchData.js +0 -37
  209. package/lib/esm/components/Properties/hooks/useFetchData.js.map +0 -1
  210. package/lib/esm/components/context/PropertiesContext.d.ts +0 -15
  211. 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
- Header: "Table",
18
- columns: [
19
- {
20
- id: "propertyName",
21
- Header: "Custom Calculation",
22
- accessor: "propertyName",
23
- Cell: (value) => (React.createElement(PropertyNameCell, { property: value.row.original, onClickModify: onClickModify })),
24
- },
25
- {
26
- id: "formula",
27
- Header: "Formula",
28
- accessor: "formula",
29
- },
30
- {
31
- id: "dropdown",
32
- Header: "",
33
- width: 80,
34
- Cell: (value) => {
35
- return (React.createElement(DropdownMenu, { menuItems: (close) => [onClickModify ? [
36
- React.createElement(MenuItem, { key: 0, onClick: () => {
37
- onClickModify(value.row.original);
38
- close();
39
- }, icon: React.createElement(SvgEdit, null) }, "Modify")
40
- ] : [], React.createElement(MenuItem, { key: 1, onClick: () => {
41
- handleShowDeleteModal(value.row.original);
42
- close();
43
- }, icon: React.createElement(SvgDelete, null) }, "Remove"),
44
- ].flatMap((p) => p) },
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 = useCallback(async (propertyId) => {
56
- const accessToken = await getAccessToken();
57
- await mappingClient.deleteCustomCalculation(accessToken, iModelId, mappingId, groupId, propertyId);
58
- }, [getAccessToken, groupId, iModelId, mappingClient, mappingId]);
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;AAYrF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EACrC,SAAS,EACT,OAAO,EACP,UAAU,EACV,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,OAAO,GACqB,EAAE,EAAE;IAChC,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;IACzC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,2BAA2B,EAAE,CAAC;IAEnE,MAAM,cAAc,GAAG,WAAW,CAChC,CAAC,qBAAyD,EAAE,EAAE,CAAC;QAC7D;YACE,MA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AE,MAAM;wCACb,MAAM,EAAE,MAAM;qCACf,GACD,CACS,CACA,CAChB,CAAC;oBACJ,CAAC;iBACF;aACF;SACF;KACF,EACD,CAAC,aAAa,CAAC,CAChB,CAAC;IAEF,MAAM,cAAc,GAAG,WAAW,CAAC,KAAK,EAAE,UAAkB,EAAE,EAAE;QAC9D,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAC;QAC3C,MAAM,aAAa,CAAC,uBAAuB,CACzC,WAAW,EACX,QAAQ,EACR,SAAS,EACT,OAAO,EACP,UAAU,CACX,CAAC;IACJ,CAAC,EAAE,CAAC,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC,CAAC;IAElE,OAAO,CACL,oBAAC,aAAa,IACZ,YAAY,EAAC,oBAAoB,EACjC,cAAc,EAAE,cAAc,EAC9B,IAAI,EAAE,kBAAkB,EACxB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,EACtB,iBAAiB,EAAE,OAAO,EAC1B,cAAc,EAAE,cAAc,GAC9B,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport {\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 } 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\";\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\n const columnsFactory = useCallback(\n (handleShowDeleteModal: (value: CustomCalculation) => void) => [\n {\n Header: \"Table\",\n columns: [\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 style={{\n width: \"16px\",\n height: \"16px\",\n }}\n />\n </IconButton>\n </DropdownMenu>\n );\n },\n },\n ],\n },\n ],\n [onClickModify],\n );\n\n const deleteProperty = useCallback(async (propertyId: string) => {\n const accessToken = await getAccessToken();\n await mappingClient.deleteCustomCalculation(\n accessToken,\n iModelId,\n mappingId,\n groupId,\n propertyId,\n );\n }, [getAccessToken, groupId, iModelId, mappingClient, mappingId]);\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\n"]}
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;AACrF,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAYpE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EACrC,SAAS,EACT,OAAO,EACP,UAAU,EACV,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,OAAO,GACqB,EAAE,EAAE;IAChC,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;IACzC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,2BAA2B,EAAE,CAAC;IACnE,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IAErC,MAAM,cAAc,GAAG,WAAW,CAChC,CAAC,qBAAyD,EAA+B,EAAE,CAAC;QAC1F;YACE,EAAE,EAAE,cAAc;YAClB,MAAM,EAAE,oBAAoB;YAC5B,QAAQ,EAAE,cAAc;YACxB,IAAI,EAAE,CAAC,KAAmC,EAAE,EAAE,CAAC,CAC7C,oBAAC,gBAAgB,IACf,QAAQ,EAAE,KAAK,CAAC,GAAG,CAAC,QAAQ,EAC5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X,QAAQ,EACR,SAAS,EACT,OAAO,EACP,UAAU,CACX,CAAC;QACJ,CAAC;QACD,SAAS,EAAE,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,iBAAiB,CAAC,EAAE,QAAQ,EAAE,CAAC,oBAAoB,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC;KACzH,CAAC,CAAC;IAEH,OAAO,CACL,oBAAC,aAAa,IACZ,YAAY,EAAC,oBAAoB,EACjC,cAAc,EAAE,cAAc,EAC9B,IAAI,EAAE,kBAAkB,EACxB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,EACtB,iBAAiB,EAAE,OAAO,EAC1B,cAAc,EAAE,cAAc,GAC9B,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport {\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, { useEffect, useState } from "react";
5
+ import React, { useCallback, useEffect } from "react";
6
6
  import { toaster, ToggleSwitch } from "@itwin/itwinui-react";
7
- import { clearEmphasizedOverriddenElements, clearHiddenElements, visualizeElements, zoomToElements } from "../../common/viewerUtils";
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 { usePropertiesContext } from "../context/PropertiesContext";
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 } = usePropertiesContext();
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
- const visualize = async () => {
22
- try {
23
- setIsLoading(true);
24
- clearEmphasizedOverriddenElements();
25
- clearHiddenElements();
26
- if (showGroupColor && hiliteIdsResult) {
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
- catch (error) {
33
- toaster.negative("There was an error visualizing group.");
34
- /* eslint-disable no-console */
35
- console.error(error);
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,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAE7D,OAAO,EAAE,iCAAiC,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACrI,OAAO,EAAE,YAA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+BAA+B;gBAC/B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;aACtB;oBAAS;gBACR,YAAY,CAAC,KAAK,CAAC,CAAC;aACrB;QACH,CAAC,CAAC;QACF,KAAK,SAAS,EAAE,CAAC;IACnB,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAC,CAAC;IAE/D,OAAO,CACL,oBAAC,YAAY,IACX,KAAK,EAAC,aAAa,EACnB,QAAQ,EAAE,SAAS,EACnB,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KACxC,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, { useEffect, useState } from \"react\";\nimport type { ToggleSwitchProps } from \"@itwin/itwinui-react\";\nimport { toaster, ToggleSwitch } from \"@itwin/itwinui-react\";\nimport type { Group } from \"@itwin/insights-client\";\nimport { clearEmphasizedOverriddenElements, clearHiddenElements, visualizeElements, zoomToElements } from \"../../common/viewerUtils\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { useGroupingMappingApiConfig } from \"../context/GroupingApiConfigContext\";\nimport { useGroupKeySetQuery } from \"../Groups/hooks/useKeySetHiliteQueries\";\nimport { usePropertiesContext } from \"../context/PropertiesContext\";\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 [isLoading, setIsLoading] = useState<boolean>(false);\n const { iModelConnection } = useGroupingMappingApiConfig();\n if (!iModelConnection) {\n throw new Error(\"This component requires an active iModelConnection.\");\n }\n const { showGroupColor, setShowGroupColor } = usePropertiesContext();\n const { data: hiliteIdsResult } = useGroupKeySetQuery(group, iModelConnection, showGroupColor);\n\n useEffect(() => {\n const visualize = async () => {\n try {\n setIsLoading(true);\n clearEmphasizedOverriddenElements();\n clearHiddenElements();\n if (showGroupColor && hiliteIdsResult) {\n Presentation.selection.clearSelection(\n \"GroupingMappingWidget\",\n iModelConnection,\n );\n visualizeElements(hiliteIdsResult.result.ids, color);\n await zoomToElements(hiliteIdsResult.result.ids);\n }\n } catch (error) {\n toaster.negative(\"There was an error visualizing group.\");\n /* eslint-disable no-console */\n console.error(error);\n } finally {\n setIsLoading(false);\n }\n };\n void visualize();\n }, [color, hiliteIdsResult, iModelConnection, showGroupColor]);\n\n return (\n <ToggleSwitch\n label=\"Color Group\"\n disabled={isLoading}\n checked={showGroupColor}\n onChange={() => setShowGroupColor((b) => !b)}\n {...rest}\n ></ToggleSwitch>\n );\n};\n"]}
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,CAA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AAS,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, Icon, IconButton, Label, LabeledInput, LabeledSelect, Modal, ModalButtonBar, Surface, Text, } from "@itwin/itwinui-react";
8
- import React, { useCallback, useEffect, useMemo, useState } from "react";
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 [isLoading, setIsLoading] = useState(false);
47
- const [searchInput, setSearchInput] = useState("");
48
- const [activeSearchInput, setActiveSearchInput] = useState("");
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
- const generateProperties = async () => {
82
- setIsLoading(true);
83
- if (!iModelConnection)
84
- return;
85
- const result = await manufactureKeys(group.query, iModelConnection);
86
- const descriptor = await fetchPresentationDescriptor(iModelConnection, result);
87
- // Only allow primitives and structs
88
- const propertyFields = descriptor?.fields.filter((field) => field.type.valueFormat === PropertyValueFormat.Primitive ||
89
- field.type.valueFormat === PropertyValueFormat.Struct) ?? [];
90
- const propertiesMetaData = convertPresentationFields(propertyFields);
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
- else {
124
- await onSave();
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
- ? await mappingClient.updateGroupProperty(accessToken, iModelId, mappingId, group.id, groupProperty.id, newGroupProperty)
142
- : await mappingClient.createGroupProperty(accessToken, iModelId, mappingId, group.id, newGroupProperty);
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
- catch (error) {
147
- handleError(error.status);
106
+ if (oldPropertyName !== propertyName && oldPropertyName !== "") {
107
+ setShowSaveConfirmationModal(true);
148
108
  }
149
- finally {
150
- setIsLoading(false);
109
+ else {
110
+ onSave();
151
111
  }
152
112
  };
153
- const startSearch = useCallback(() => {
154
- if (!searchInput)
155
- return;
156
- setActiveSearchInput(searchInput);
157
- setSearched(true);
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 () => setShowModal(true), disabled: isLoading }, "Select Properties")),
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: getLocalizedStringPresentation(property.categoryLabel), actionGroup: null })))))),
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(Modal, { title: "Properties Selection", isOpen: showModal, onClose: () => {
207
- setShowModal(false);
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