@itwin/grouping-mapping-widget 0.23.1 → 0.25.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/common/hooks/useIsMounted.d.ts +2 -1
- package/lib/cjs/common/hooks/useIsMounted.js +3 -3
- package/lib/cjs/common/hooks/useIsMounted.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/{GroupItem.d.ts → GroupListItem.d.ts} +4 -3
- package/lib/cjs/components/Groups/GroupListItem.js +49 -0
- package/lib/cjs/components/Groups/GroupListItem.js.map +1 -0
- package/lib/cjs/components/Groups/GroupListItem.scss +13 -0
- package/lib/cjs/components/Groups/GroupsView.js +2 -2
- package/lib/cjs/components/Groups/GroupsView.js.map +1 -1
- package/lib/cjs/components/Groups/GroupsVisualization.js +33 -11
- package/lib/cjs/components/Groups/GroupsVisualization.js.map +1 -1
- package/lib/cjs/components/Groups/groupsHelpers.d.ts +1 -1
- package/lib/cjs/components/Groups/groupsHelpers.js +1 -1
- 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/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 +13 -0
- package/lib/cjs/components/Mappings/MappingViewActionGroup.d.ts +1 -1
- package/lib/cjs/components/Mappings/MappingViewActionGroup.js +3 -3
- package/lib/cjs/components/Mappings/MappingViewActionGroup.js.map +1 -1
- 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/MappingsView.scss +0 -5
- 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 +62 -167
- 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/GroupPropertyListItem.d.ts +13 -0
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyListItem.js +21 -0
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyListItem.js.map +1 -0
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyListItem.scss +14 -0
- 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/GroupProperties/SortableHorizontalTile.d.ts +4 -4
- package/lib/cjs/components/Properties/GroupProperties/SortableHorizontalTile.js +4 -3
- package/lib/cjs/components/Properties/GroupProperties/SortableHorizontalTile.js.map +1 -1
- 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/cjs/test/GroupingMappingCustomUI.test.js +3 -3
- package/lib/cjs/test/GroupingMappingCustomUI.test.js.map +1 -1
- package/lib/esm/WidgetShell/GroupingMappingContent.js +2 -2
- package/lib/esm/WidgetShell/GroupingMappingContent.js.map +1 -1
- package/lib/esm/common/hooks/useIsMounted.d.ts +2 -1
- package/lib/esm/common/hooks/useIsMounted.js +4 -4
- package/lib/esm/common/hooks/useIsMounted.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/{GroupItem.d.ts → GroupListItem.d.ts} +4 -3
- package/lib/esm/components/Groups/GroupListItem.js +22 -0
- package/lib/esm/components/Groups/GroupListItem.js.map +1 -0
- package/lib/esm/components/Groups/GroupListItem.scss +13 -0
- package/lib/esm/components/Groups/GroupsView.js +3 -3
- package/lib/esm/components/Groups/GroupsView.js.map +1 -1
- package/lib/esm/components/Groups/GroupsVisualization.js +33 -11
- package/lib/esm/components/Groups/GroupsVisualization.js.map +1 -1
- package/lib/esm/components/Groups/groupsHelpers.d.ts +1 -1
- package/lib/esm/components/Groups/groupsHelpers.js +1 -1
- 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/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 +13 -0
- package/lib/esm/components/Mappings/MappingViewActionGroup.d.ts +1 -1
- package/lib/esm/components/Mappings/MappingViewActionGroup.js +1 -1
- package/lib/esm/components/Mappings/MappingViewActionGroup.js.map +1 -1
- package/lib/esm/components/Mappings/MappingsView.d.ts +2 -0
- package/lib/esm/components/Mappings/MappingsView.js +31 -7
- package/lib/esm/components/Mappings/MappingsView.js.map +1 -1
- package/lib/esm/components/Mappings/MappingsView.scss +0 -5
- 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 +64 -169
- 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/GroupPropertyListItem.d.ts +13 -0
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyListItem.js +14 -0
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyListItem.js.map +1 -0
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyListItem.scss +14 -0
- 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/GroupProperties/SortableHorizontalTile.d.ts +4 -4
- package/lib/esm/components/Properties/GroupProperties/SortableHorizontalTile.js +3 -4
- package/lib/esm/components/Properties/GroupProperties/SortableHorizontalTile.js.map +1 -1
- 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/lib/esm/test/GroupingMappingCustomUI.test.js +3 -3
- package/lib/esm/test/GroupingMappingCustomUI.test.js.map +1 -1
- package/package.json +3 -2
- package/lib/cjs/components/Groups/GroupItem.js +0 -23
- package/lib/cjs/components/Groups/GroupItem.js.map +0 -1
- 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/SharedComponents/HorizontalTile.d.ts +0 -19
- package/lib/cjs/components/SharedComponents/HorizontalTile.js +0 -27
- package/lib/cjs/components/SharedComponents/HorizontalTile.js.map +0 -1
- package/lib/cjs/components/SharedComponents/HorizontalTile.scss +0 -58
- package/lib/cjs/components/context/PropertiesContext.d.ts +0 -15
- package/lib/cjs/components/context/PropertiesContext.js.map +0 -1
- package/lib/esm/components/Groups/GroupItem.js +0 -16
- package/lib/esm/components/Groups/GroupItem.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/SharedComponents/HorizontalTile.d.ts +0 -19
- package/lib/esm/components/SharedComponents/HorizontalTile.js +0 -20
- package/lib/esm/components/SharedComponents/HorizontalTile.js.map +0 -1
- package/lib/esm/components/SharedComponents/HorizontalTile.scss +0 -58
- package/lib/esm/components/context/PropertiesContext.d.ts +0 -15
- package/lib/esm/components/context/PropertiesContext.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMappingsOperations.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/hooks/useMappingsOperations.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,
|
|
1
|
+
{"version":3,"file":"useMappingsOperations.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/hooks/useMappingsOperations.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,iCAAyD;AACzD,4DAAwD;AAGxD,mFAA4E;AAC5E,uDAAoE;AACpE,yDAAs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AgB,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,eAAe,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,kBAAkB,EAAE,eAAe,EAAE,kBAAkB,EAAE,eAAe,EAAE,oBAAoB,EAAC,CAAC;AAC1S,CAAC,CAAC;AA7EW,QAAA,qBAAqB,yBA6EhC","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 { useCallback, useEffect, useState } from \"react\";\nimport { ExtractorState } from \"@itwin/insights-client\";\nimport type { IMappingsClient, Mapping } from \"@itwin/insights-client\";\nimport type { GroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { useExtractionClient } from \"../../context/ExtractionClientContext\";\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { useFetchMappings } from \"./useFetchMappings\";\nimport { useFetchExtractionStatus } from \"./useFetchExtractionStatus\";\nimport { useExtractionStateJobContext } from \"../../context/ExtractionStateJobContext\";\n\nexport interface MappingsOperationsProps extends GroupingMappingApiConfig {\n mappingClient: IMappingsClient;\n}\n\nexport const useMappingsOperations = ({ iModelId, getAccessToken, mappingClient }: MappingsOperationsProps) => {\n const [showImportModal, setShowImportModal] = useState<boolean | undefined>(false);\n const [showDeleteModal, setShowDeleteModal] = useState<Mapping | undefined>(undefined);\n const extractionClient = useExtractionClient();\n const [showExtractionMessageModal, setShowExtractionMessageModal] = useState<boolean>(false);\n const queryClient = useQueryClient();\n const [initialStateExtractionFlag, setInitialExtractionStateFlag] = useState<boolean>(true);\n const { mappingIdJobInfo, setMappingIdJobInfo } = useExtractionStateJobContext();\n\n const {\n data: mappings,\n isFetched: isMappingsFetched,\n isFetching: isLoadingMappings,\n } = useFetchMappings(iModelId, getAccessToken, mappingClient);\n\n const {\n data: extractionStatus,\n isFetched: isExtractionStatusFetched,\n isFetching: isLoadingExtractionStatus,\n } = useFetchExtractionStatus({ iModelId, getAccessToken, extractionClient });\n\n const refreshExtractionStatus = useCallback(async () => {\n await queryClient.invalidateQueries({queryKey: [\"iModelExtractionStatus\"]});\n setInitialExtractionStateFlag(false);\n }, [queryClient]);\n\n useEffect(() => {\n if(initialStateExtractionFlag && isMappingsFetched && isExtractionStatusFetched && mappings && extractionStatus && !mappingIdJobInfo.size){\n const newMappingIdJobInfo = new Map<string, string>();\n const jobId = extractionStatus.latestExtractionResult.value?.jobId;\n const state = extractionStatus.latestJobStatus?.state;\n if((state === ExtractorState.Failed || state === ExtractorState.Succeeded)) return;\n !!jobId && mappings.forEach((mapping) => {\n const mappingId = mapping.id;\n const jobId = extractionStatus.latestExtractionResult.value.jobId;\n newMappingIdJobInfo.set(mappingId, jobId);\n });\n setMappingIdJobInfo(newMappingIdJobInfo);\n setInitialExtractionStateFlag(false);\n }\n }, [extractionStatus, initialStateExtractionFlag, isExtractionStatusFetched, isMappingsFetched, mappingIdJobInfo.size, mappings, setMappingIdJobInfo]);\n\n const refreshMappings = useCallback(async () => {\n await queryClient.invalidateQueries({queryKey: [\"mappings\"]});\n }, [queryClient]);\n\n const { mutateAsync: toggleExtraction, isLoading: isTogglingExtraction } = useMutation({\n mutationFn: async (mapping: Mapping) => {\n const accessToken = await getAccessToken();\n const newState = !mapping.extractionEnabled;\n await mappingClient.updateMapping(accessToken, iModelId, mapping.id, { extractionEnabled: newState });\n },\n onSuccess: async () => {\n await refreshMappings();\n },\n });\n\n const { mutateAsync: onDelete, isLoading: isDeletingMapping} = useMutation({\n mutationFn: async (mapping: Mapping) => {\n const accessToken = await getAccessToken();\n await mappingClient.deleteMapping(accessToken, iModelId, mapping.id);\n },\n onSuccess: async () => {\n await refreshMappings();\n },\n });\n\n const isLoading = isLoadingMappings || isTogglingExtraction || isDeletingMapping;\n const extractionStatusGated = (!extractionStatus || isLoadingExtractionStatus) ? {\n extractionStatusIcon: {\n iconStatus: undefined,\n iconMessage: \"Loading...\",\n },\n extractionMessageData: [],\n } : extractionStatus;\n\n return { mappings, isLoading, showExtractionMessageModal, extractionStatus: extractionStatusGated, setShowExtractionMessageModal, refreshMappings, refreshExtractionStatus, toggleExtraction, onDelete, setShowImportModal, showImportModal, setShowDeleteModal, showDeleteModal, isTogglingExtraction};\n};\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { GroupingMappingApiConfig } from "../../context/GroupingApiConfigContext";
|
|
3
|
+
import type { Mapping } from "@itwin/insights-client";
|
|
4
|
+
export interface FetchExtractionStatesProps extends GroupingMappingApiConfig {
|
|
5
|
+
jobId?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const useRunExtraction: ({ iModelId, getAccessToken, }: FetchExtractionStatesProps) => {
|
|
8
|
+
isRunExtractionLoading: boolean;
|
|
9
|
+
isRunExtractionSuccess: boolean;
|
|
10
|
+
isJobStarted: boolean;
|
|
11
|
+
setIsJobStarted: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
12
|
+
runExtraction: import("@tanstack/react-query").UseMutateAsyncFunction<import("@itwin/insights-client").ExtractionRun, unknown, Mapping[], unknown>;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=useRunExtraction.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useRunExtraction = void 0;
|
|
4
|
+
/*---------------------------------------------------------------------------------------------
|
|
5
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
+
*--------------------------------------------------------------------------------------------*/
|
|
8
|
+
const ExtractionClientContext_1 = require("../../context/ExtractionClientContext");
|
|
9
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
10
|
+
const react_1 = require("react");
|
|
11
|
+
const ExtractionStateJobContext_1 = require("../../context/ExtractionStateJobContext");
|
|
12
|
+
const useRunExtraction = ({ iModelId, getAccessToken, }) => {
|
|
13
|
+
const extractionClient = (0, ExtractionClientContext_1.useExtractionClient)();
|
|
14
|
+
const [isJobStarted, setIsJobStarted] = (0, react_1.useState)(false);
|
|
15
|
+
const { mappingIdJobInfo, setMappingIdJobInfo } = (0, ExtractionStateJobContext_1.useExtractionStateJobContext)();
|
|
16
|
+
const { mutateAsync: runExtraction, isLoading: isRunExtractionLoading, isSuccess: isRunExtractionSuccess } = (0, react_query_1.useMutation)({
|
|
17
|
+
mutationKey: ["runExtraction"],
|
|
18
|
+
mutationFn: async (mappings) => {
|
|
19
|
+
const accessToken = await getAccessToken();
|
|
20
|
+
const mappingIds = mappings.length > 0 ? mappings.map((mapping) => { return { id: mapping.id }; }) : [];
|
|
21
|
+
const extractionRequest = {
|
|
22
|
+
mappings: mappingIds,
|
|
23
|
+
};
|
|
24
|
+
const runExtractionResponse = await extractionClient.runExtraction(accessToken, iModelId, extractionRequest);
|
|
25
|
+
return runExtractionResponse;
|
|
26
|
+
},
|
|
27
|
+
onSuccess: async (runExtractionResponse, mappings) => {
|
|
28
|
+
for (const mapping of mappings) {
|
|
29
|
+
if (mappingIdJobInfo?.get(mapping.id) === undefined) {
|
|
30
|
+
setMappingIdJobInfo((prevMap) => {
|
|
31
|
+
const newMap = new Map(prevMap);
|
|
32
|
+
newMap.set(mapping.id, runExtractionResponse.id);
|
|
33
|
+
return newMap;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
return { isRunExtractionLoading, isRunExtractionSuccess, isJobStarted, setIsJobStarted, runExtraction };
|
|
40
|
+
};
|
|
41
|
+
exports.useRunExtraction = useRunExtraction;
|
|
42
|
+
//# sourceMappingURL=useRunExtraction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRunExtraction.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/hooks/useRunExtraction.ts"],"names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CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,SAAS,EAAC;oBACjD,mBAAmB,CAAC,CAAC,OAA4B,EAAE,EAAE;wBACnD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;wBAChC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,qBAAqB,CAAC,EAAE,CAAC,CAAC;wBACjD,OAAO,MAAM,CAAC;oBAChB,CAAC,CAAC,CAAC;iBACJ;aACF;QACH,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,CAAC;AAC1G,CAAC,CAAC;AAlCW,QAAA,gBAAgB,oBAkC3B","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 { useExtractionClient } from \"../../context/ExtractionClientContext\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { GroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport type { ExtractionRequestMapping, ExtractionRunRequest, Mapping } from \"@itwin/insights-client\";\nimport { useState } from \"react\";\nimport { useExtractionStateJobContext } from \"../../context/ExtractionStateJobContext\";\n\nexport interface FetchExtractionStatesProps extends GroupingMappingApiConfig {\n jobId?: string;\n}\n\nexport const useRunExtraction = ({\n iModelId,\n getAccessToken,\n}: FetchExtractionStatesProps) => {\n const extractionClient = useExtractionClient();\n const [isJobStarted, setIsJobStarted] = useState<boolean>(false);\n const { mappingIdJobInfo, setMappingIdJobInfo } = useExtractionStateJobContext();\n\n const { mutateAsync: runExtraction, isLoading: isRunExtractionLoading, isSuccess: isRunExtractionSuccess } = useMutation({\n mutationKey: [\"runExtraction\"],\n mutationFn: async (mappings: Mapping[]) => {\n const accessToken = await getAccessToken();\n const mappingIds: ExtractionRequestMapping[] = mappings.length > 0 ? mappings.map((mapping) => { return { id: mapping.id }; }) : [];\n const extractionRequest: ExtractionRunRequest = {\n mappings: mappingIds,\n };\n\n const runExtractionResponse = await extractionClient.runExtraction(accessToken, iModelId, extractionRequest);\n return runExtractionResponse;\n },\n onSuccess: async (runExtractionResponse, mappings) => {\n for (const mapping of mappings){\n if(mappingIdJobInfo?.get(mapping.id) === undefined){\n setMappingIdJobInfo((prevMap: Map<string, string>) => {\n const newMap = new Map(prevMap);\n newMap.set(mapping.id, runExtractionResponse.id);\n return newMap;\n });\n }\n }\n },\n });\n\n return { isRunExtractionLoading, isRunExtractionSuccess, isJobStarted, setIsJobStarted, runExtraction };\n};\n"]}
|
|
@@ -38,43 +38,35 @@ const useValidator_1 = __importDefault(require("../hooks/useValidator"));
|
|
|
38
38
|
require("./CalculatedPropertyAction.scss");
|
|
39
39
|
const insights_client_1 = require("@itwin/insights-client");
|
|
40
40
|
const SharedCalculatedPropertyForms_1 = require("./SharedCalculatedPropertyForms");
|
|
41
|
-
const utils_1 = require("../../../common/utils");
|
|
42
41
|
const GroupingApiConfigContext_1 = require("../../context/GroupingApiConfigContext");
|
|
43
42
|
const MappingClientContext_1 = require("../../context/MappingClientContext");
|
|
43
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
44
44
|
const CalculatedPropertyAction = ({ mappingId, group, calculatedProperty, onSaveSuccess, onClickCancel, }) => {
|
|
45
45
|
const { getAccessToken, iModelId } = (0, GroupingApiConfigContext_1.useGroupingMappingApiConfig)();
|
|
46
46
|
const mappingClient = (0, MappingClientContext_1.useMappingClient)();
|
|
47
47
|
const [propertyName, setPropertyName] = (0, react_1.useState)(calculatedProperty?.propertyName ?? "");
|
|
48
48
|
const [type, setType] = (0, react_1.useState)(calculatedProperty?.type);
|
|
49
|
-
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
50
49
|
const [validator, showValidationMessage] = (0, useValidator_1.default)();
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
? await mappingClient.updateCalculatedProperty(accessToken, iModelId, mappingId, group.id, calculatedProperty.id, {
|
|
61
|
-
propertyName,
|
|
62
|
-
type,
|
|
63
|
-
})
|
|
64
|
-
: await mappingClient.createCalculatedProperty(accessToken, iModelId, mappingId, group.id, {
|
|
65
|
-
propertyName,
|
|
66
|
-
type,
|
|
67
|
-
});
|
|
50
|
+
const queryClient = (0, react_query_1.useQueryClient)();
|
|
51
|
+
const { mutate: saveMutation, isLoading } = (0, react_query_1.useMutation)(async (type) => {
|
|
52
|
+
const accessToken = await getAccessToken();
|
|
53
|
+
return calculatedProperty
|
|
54
|
+
? mappingClient.updateCalculatedProperty(accessToken, iModelId, mappingId, group.id, calculatedProperty.id, { propertyName, type })
|
|
55
|
+
: mappingClient.createCalculatedProperty(accessToken, iModelId, mappingId, group.id, { propertyName, type });
|
|
56
|
+
}, {
|
|
57
|
+
onSuccess: async () => {
|
|
58
|
+
await queryClient.invalidateQueries({ queryKey: ["calculatedProperties", iModelId, mappingId, group.id] });
|
|
68
59
|
onSaveSuccess();
|
|
69
60
|
setPropertyName("");
|
|
70
61
|
setType(insights_client_1.CalculatedPropertyType.Undefined);
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
const onSave = () => {
|
|
65
|
+
if (!validator.allValid() || !type) {
|
|
66
|
+
showValidationMessage(true);
|
|
67
|
+
return;
|
|
71
68
|
}
|
|
72
|
-
|
|
73
|
-
(0, utils_1.handleError)(error.status);
|
|
74
|
-
}
|
|
75
|
-
finally {
|
|
76
|
-
setIsLoading(false);
|
|
77
|
-
}
|
|
69
|
+
saveMutation(type);
|
|
78
70
|
};
|
|
79
71
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
80
72
|
react_1.default.createElement("div", { className: 'gmw-calculated-properties-action-container' },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalculatedPropertyAction.js","sourceRoot":"","sources":["../../../../../src/components/Properties/CalculatedProperties/CalculatedPropertyAction.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAG8B;AAC9B,+CAAwC;AACxC,qFAA6D;AAC7D,yEAAiD;AACjD,2CAAyC;AAEzC,4DAAgE;AAChE,mFAAgF;AAChF,
|
|
1
|
+
{"version":3,"file":"CalculatedPropertyAction.js","sourceRoot":"","sources":["../../../../../src/components/Properties/CalculatedProperties/CalculatedPropertyAction.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAG8B;AAC9B,+CAAwC;AACxC,qFAA6D;AAC7D,yEAAiD;AACjD,2CAAyC;AAEzC,4DAAgE;AAChE,mFAAgF;AAChF,qFAAqF;AACrF,6EAAsE;AACtE,uDAAoE;AAU7D,MAAM,wBAAwB,GAAG,CAAC,EACvC,SAAS,EACT,KAAK,EACL,kBAAkB,EAClB,aAAa,EACb,aAAa,GACiB,EAAE,EAAE;IAClC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,IAAA,sDAA2B,GAAE,CAAC;IACnE,MAAM,aAAa,GAAG,IAAA,uCAAgB,GAAE,CAAC;IACzC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,EAC9C,kBAAkB,EAAE,YAAY,IAAI,EAAE,CACvC,CAAC;IACF,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,gBAAQ,EAAqC,kBAAkB,EAAE,IAAI,CAAC,CAAC;IAC/F,MAAM,CAAC,SAAS,EAAE,qBAAqB,CAAC,GAAG,IAAA,sBAAY,GAAE,CAAC;IAC1D,MAAM,WAAW,GAAG,IAAA,4BAAc,GAAE,CAAC;IAErC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,IAAA,yBAAW,EAAC,KAAK,EA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,6DAA6B,IAC5B,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,EAChC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,GAChB,CACO,CACP;QACN,8BAAC,qBAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,aAAa,EACvB,gBAAgB,EAAE,CAAC,CAAC,IAAI,IAAI,YAAY,CAAC,EACzC,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AA/EW,QAAA,wBAAwB,4BA+EnC","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 Fieldset,\n Text,\n} from \"@itwin/itwinui-react\";\nimport React, { useState } from \"react\";\nimport ActionPanel from \"../../SharedComponents/ActionPanel\";\nimport useValidator from \"../hooks/useValidator\";\nimport \"./CalculatedPropertyAction.scss\";\nimport type { CalculatedProperty, Group } from \"@itwin/insights-client\";\nimport { CalculatedPropertyType } from \"@itwin/insights-client\";\nimport { SharedCalculatedPropertyForms } from \"./SharedCalculatedPropertyForms\";\nimport { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { useMappingClient } from \"../../context/MappingClientContext\";\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\n\nexport interface CalculatedPropertyActionProps {\n mappingId: string;\n group: Group;\n calculatedProperty?: CalculatedProperty;\n onSaveSuccess: () => void;\n onClickCancel?: () => void;\n}\n\nexport const CalculatedPropertyAction = ({\n mappingId,\n group,\n calculatedProperty,\n onSaveSuccess,\n onClickCancel,\n}: CalculatedPropertyActionProps) => {\n const { getAccessToken, iModelId } = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n const [propertyName, setPropertyName] = useState<string>(\n calculatedProperty?.propertyName ?? \"\",\n );\n const [type, setType] = useState<CalculatedPropertyType | undefined>(calculatedProperty?.type);\n const [validator, showValidationMessage] = useValidator();\n const queryClient = useQueryClient();\n\n const { mutate: saveMutation, isLoading } = useMutation(async (type: CalculatedPropertyType) => {\n const accessToken = await getAccessToken();\n\n return calculatedProperty\n ? mappingClient.updateCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n group.id,\n calculatedProperty.id,\n { propertyName, type },\n )\n : mappingClient.createCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n group.id,\n { propertyName, type },\n );\n }, {\n onSuccess: async () => {\n await queryClient.invalidateQueries({ queryKey: [\"calculatedProperties\", iModelId, mappingId, group.id] });\n onSaveSuccess();\n setPropertyName(\"\");\n setType(CalculatedPropertyType.Undefined);\n },\n });\n\n const onSave = () => {\n if (!validator.allValid() || !type) {\n showValidationMessage(true);\n return;\n }\n\n saveMutation(type);\n };\n\n return (\n <>\n <div className='gmw-calculated-properties-action-container'>\n <Fieldset legend='Calculated Property Details' className='gmw-details-form'>\n <div className='gmw-field-legend-container'>\n <Text variant='small' as='small' className='gmw-field-legend'>\n Asterisk * indicates mandatory fields.\n </Text>\n </div>\n <SharedCalculatedPropertyForms\n validator={validator}\n propertyName={propertyName}\n setPropertyName={setPropertyName}\n type={type}\n setType={setType}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={onClickCancel}\n isSavingDisabled={!(type && propertyName)}\n isLoading={isLoading}\n />\n </>\n );\n};\n"]}
|
package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js
CHANGED
|
@@ -37,13 +37,14 @@ const react_1 = __importStar(require("react"));
|
|
|
37
37
|
const ActionPanel_1 = __importDefault(require("../../SharedComponents/ActionPanel"));
|
|
38
38
|
const BboxDimensionsDecorator_1 = require("../../../decorators/BboxDimensionsDecorator");
|
|
39
39
|
const useValidator_1 = __importDefault(require("../hooks/useValidator"));
|
|
40
|
-
const utils_1 = require("../../../common/utils");
|
|
41
40
|
const viewerUtils_1 = require("../../../common/viewerUtils");
|
|
42
41
|
require("./CalculatedPropertyActionWithVisuals.scss");
|
|
43
42
|
const MappingClientContext_1 = require("../../context/MappingClientContext");
|
|
44
43
|
const GroupingApiConfigContext_1 = require("../../context/GroupingApiConfigContext");
|
|
44
|
+
const insights_client_1 = require("@itwin/insights-client");
|
|
45
45
|
const SharedCalculatedPropertyForms_1 = require("./SharedCalculatedPropertyForms");
|
|
46
46
|
const useKeySetHiliteQueries_1 = require("../../Groups/hooks/useKeySetHiliteQueries");
|
|
47
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
47
48
|
const CalculatedPropertyActionWithVisuals = ({ mappingId, group, calculatedProperty, onSaveSuccess, onClickCancel, }) => {
|
|
48
49
|
const { getAccessToken, iModelId, iModelConnection } = (0, GroupingApiConfigContext_1.useGroupingMappingApiConfig)();
|
|
49
50
|
if (!iModelConnection) {
|
|
@@ -53,11 +54,11 @@ const CalculatedPropertyActionWithVisuals = ({ mappingId, group, calculatedPrope
|
|
|
53
54
|
const [propertyName, setPropertyName] = (0, react_1.useState)(calculatedProperty?.propertyName ?? "");
|
|
54
55
|
const [type, setType] = (0, react_1.useState)(calculatedProperty?.type);
|
|
55
56
|
const [bboxDecorator, setBboxDecorator] = (0, react_1.useState)();
|
|
56
|
-
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
57
57
|
const [inferredSpatialData, setInferredSpatialData] = (0, react_1.useState)();
|
|
58
58
|
const [validator, showValidationMessage] = (0, useValidator_1.default)();
|
|
59
59
|
const [colorProperty, setColorProperty] = (0, react_1.useState)(false);
|
|
60
60
|
const { data } = (0, useKeySetHiliteQueries_1.useGroupKeySetQuery)(group, iModelConnection, true);
|
|
61
|
+
const queryClient = (0, react_query_1.useQueryClient)();
|
|
61
62
|
const resolvedHiliteIds = (0, react_1.useMemo)(() => {
|
|
62
63
|
// Resolved ids, default to an empty array if not available
|
|
63
64
|
return data?.result?.ids ?? [];
|
|
@@ -96,33 +97,25 @@ const CalculatedPropertyActionWithVisuals = ({ mappingId, group, calculatedPrope
|
|
|
96
97
|
: bboxDecorator.clearContext();
|
|
97
98
|
}
|
|
98
99
|
}, [bboxDecorator, colorProperty, inferredSpatialData, type]);
|
|
99
|
-
const
|
|
100
|
+
const { mutate: saveMutation, isLoading } = (0, react_query_1.useMutation)(async (type) => {
|
|
101
|
+
const accessToken = await getAccessToken();
|
|
102
|
+
return calculatedProperty
|
|
103
|
+
? mappingClient.updateCalculatedProperty(accessToken, iModelId, mappingId, group.id, calculatedProperty.id, { propertyName, type })
|
|
104
|
+
: mappingClient.createCalculatedProperty(accessToken, iModelId, mappingId, group.id, { propertyName, type });
|
|
105
|
+
}, {
|
|
106
|
+
onSuccess: async () => {
|
|
107
|
+
await queryClient.invalidateQueries({ queryKey: ["calculatedProperties", iModelId, mappingId, group.id] });
|
|
108
|
+
onSaveSuccess();
|
|
109
|
+
setPropertyName("");
|
|
110
|
+
setType(insights_client_1.CalculatedPropertyType.Undefined);
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
const onSave = () => {
|
|
100
114
|
if (!validator.allValid() || !type) {
|
|
101
115
|
showValidationMessage(true);
|
|
102
116
|
return;
|
|
103
117
|
}
|
|
104
|
-
|
|
105
|
-
setIsLoading(true);
|
|
106
|
-
const accessToken = await getAccessToken();
|
|
107
|
-
calculatedProperty
|
|
108
|
-
? await mappingClient.updateCalculatedProperty(accessToken, iModelId, mappingId, group.id, calculatedProperty.id, {
|
|
109
|
-
propertyName,
|
|
110
|
-
type,
|
|
111
|
-
})
|
|
112
|
-
: await mappingClient.createCalculatedProperty(accessToken, iModelId, mappingId, group.id, {
|
|
113
|
-
propertyName,
|
|
114
|
-
type,
|
|
115
|
-
});
|
|
116
|
-
onSaveSuccess();
|
|
117
|
-
setPropertyName("");
|
|
118
|
-
setType(undefined);
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
(0, utils_1.handleError)(error.status);
|
|
122
|
-
}
|
|
123
|
-
finally {
|
|
124
|
-
setIsLoading(false);
|
|
125
|
-
}
|
|
118
|
+
saveMutation(type);
|
|
126
119
|
};
|
|
127
120
|
const getSpatialData = (value) => inferredSpatialData?.has(BboxDimensionsDecorator_1.BboxDimension[value]) && (react_1.default.createElement("div", null, `${inferredSpatialData
|
|
128
121
|
?.get(BboxDimensionsDecorator_1.BboxDimension[value])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalculatedPropertyActionWithVisuals.js","sourceRoot":"","sources":["../../../../../src/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAAiD;AAIjD,wDAK8B;AAC9B,+CAA4D;AAC5D,qFAA6D;AAC7D,yFAGqD;AACrD,yEAAiD;AACjD,iDAAoD;AACpD,6DAAgF;AAChF,sDAAoD;AACpD,6EAAsE;AACtE,qFAAqF;AAErF,mFAAgF;AAChF,sFAAgF;AAUzE,MAAM,mCAAmC,GAAG,CAAC,EAClD,SAAS,EACT,KAAK,EACL,kBAAkB,EAClB,aAAa,EACb,aAAa,GAC4B,EAAE,EAAE;IAC7C,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,gBAAgB,EAAE,GAAG,IAAA,sDAA2B,GAAE,CAAC;IACrF,IAAI,CAAC,gBAAgB,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;KACxE;IACD,MAAM,aAAa,GAAG,IAAA,uCAAgB,GAAE,CAAC;IACzC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,EAC9C,kBAAkB,EAAE,YAAY,IAAI,EAAE,CACvC,CAAC;IACF,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,gBAAQ,EAAqC,kBAAkB,EAAE,IAAI,CAAC,CAAC;IAC/F,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,IAAA,gBAAQ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,CAAC,CAAC,GAC7B,CACZ;gBACN,8BAAC,6DAA6B,IAC5B,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,EAChC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,CAC9C,8BAAC,wBAAQ;wBACP,uCAAK,SAAS,EAAC,qBAAqB;4BAClC,2CAAM,MAAM,CAAC,KAAK,CAAO;4BACxB,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CACzB,CACG,CACZ,EACD,oBAAoB,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,CACtD,uCAAK,SAAS,EAAC,iBAAiB;wBAC9B,2CAAM,MAAM,CAAC,KAAK,CAAO;wBACxB,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CACzB,CACP,GACD,CACO,CACP;QACN,8BAAC,qBAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,aAAa,EACvB,gBAAgB,EAAE,CAAC,CAAC,IAAI,IAAI,YAAY,CAAC,EACzC,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAxKW,QAAA,mCAAmC,uCAwK9C","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 { IModelApp } from \"@itwin/core-frontend\";\nimport type {\n SelectOption,\n} from \"@itwin/itwinui-react\";\nimport {\n Fieldset,\n MenuItem,\n Text,\n ToggleSwitch,\n} from \"@itwin/itwinui-react\";\nimport React, { useEffect, useMemo, useState } from \"react\";\nimport ActionPanel from \"../../SharedComponents/ActionPanel\";\nimport {\n BboxDimension,\n BboxDimensionsDecorator,\n} from \"../../../decorators/BboxDimensionsDecorator\";\nimport useValidator from \"../hooks/useValidator\";\nimport { handleError } from \"../../../common/utils\";\nimport { visualizeElements, zoomToElements } from \"../../../common/viewerUtils\";\nimport \"./CalculatedPropertyActionWithVisuals.scss\";\nimport { useMappingClient } from \"../../context/MappingClientContext\";\nimport { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport type { CalculatedProperty, CalculatedPropertyType, Group } from \"@itwin/insights-client\";\nimport { SharedCalculatedPropertyForms } from \"./SharedCalculatedPropertyForms\";\nimport { useGroupKeySetQuery } from \"../../Groups/hooks/useKeySetHiliteQueries\";\n\nexport interface CalculatedPropertyActionWithVisualsProps {\n mappingId: string;\n group: Group;\n calculatedProperty?: CalculatedProperty;\n onSaveSuccess: () => void;\n onClickCancel?: () => void;\n}\n\nexport const CalculatedPropertyActionWithVisuals = ({\n mappingId,\n group,\n calculatedProperty,\n onSaveSuccess,\n onClickCancel,\n}: CalculatedPropertyActionWithVisualsProps) => {\n const { getAccessToken, iModelId, iModelConnection } = useGroupingMappingApiConfig();\n if (!iModelConnection) {\n throw new Error(\"This component requires an active iModelConnection.\");\n }\n const mappingClient = useMappingClient();\n const [propertyName, setPropertyName] = useState<string>(\n calculatedProperty?.propertyName ?? \"\",\n );\n const [type, setType] = useState<CalculatedPropertyType | undefined>(calculatedProperty?.type);\n const [bboxDecorator, setBboxDecorator] = useState<BboxDimensionsDecorator | undefined>();\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [inferredSpatialData, setInferredSpatialData] = useState<Map<BboxDimension, number> | undefined>();\n const [validator, showValidationMessage] = useValidator();\n const [colorProperty, setColorProperty] = useState<boolean>(false);\n const { data } = useGroupKeySetQuery(group, iModelConnection, true);\n\n const resolvedHiliteIds = useMemo(() => {\n // Resolved ids, default to an empty array if not available\n return data?.result?.ids ?? [];\n }, [data?.result?.ids]);\n\n useEffect(() => {\n const decorator = new BboxDimensionsDecorator();\n IModelApp.viewManager.addDecorator(decorator);\n setBboxDecorator(decorator);\n return () => {\n IModelApp.viewManager.dropDecorator(decorator);\n };\n }, []);\n\n useEffect(() => {\n if (!colorProperty || resolvedHiliteIds.length === 0) {\n return;\n }\n visualizeElements(resolvedHiliteIds, \"red\");\n void zoomToElements(resolvedHiliteIds);\n }, [colorProperty, resolvedHiliteIds]);\n\n useEffect(() => {\n if (!colorProperty || resolvedHiliteIds.length === 0) {\n return;\n }\n const setContext = async () => {\n if (bboxDecorator) {\n await bboxDecorator.setContext(resolvedHiliteIds[0]);\n setInferredSpatialData(bboxDecorator.getInferredSpatialData());\n }\n };\n void setContext();\n }, [bboxDecorator, colorProperty, resolvedHiliteIds]);\n\n useEffect(() => {\n if (bboxDecorator && type && inferredSpatialData) {\n inferredSpatialData.has(BboxDimension[type as keyof typeof BboxDimension]) && colorProperty\n ? bboxDecorator.drawContext(\n BboxDimension[type as keyof typeof BboxDimension],\n )\n : bboxDecorator.clearContext();\n }\n }, [bboxDecorator, colorProperty, inferredSpatialData, type]);\n\n const onSave = async () => {\n if (!validator.allValid() || !type) {\n showValidationMessage(true);\n return;\n }\n try {\n setIsLoading(true);\n\n const accessToken = await getAccessToken();\n\n calculatedProperty\n ? await mappingClient.updateCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n group.id,\n calculatedProperty.id,\n {\n propertyName,\n type,\n },\n )\n : await mappingClient.createCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n group.id,\n {\n propertyName,\n type,\n },\n );\n onSaveSuccess();\n setPropertyName(\"\");\n setType(undefined);\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n };\n\n const getSpatialData = (value: string) =>\n inferredSpatialData?.has(\n BboxDimension[value as keyof typeof BboxDimension],\n ) && (\n <div>\n {`${inferredSpatialData\n ?.get(BboxDimension[value as keyof typeof BboxDimension])\n ?.toPrecision(4)}m`}\n </div>\n );\n\n return (\n <>\n <div className='gmw-calculated-properties-action-container'>\n <Fieldset legend='Calculated Property Details' className='gmw-details-form'>\n <div className='gmw-field-legend-container'>\n <Text variant='small' as='small' className='gmw-field-legend'>\n Asterisk * indicates mandatory fields.\n </Text>\n <ToggleSwitch\n label='Visualize Dimensions'\n labelPosition='left'\n disabled={isLoading}\n checked={colorProperty}\n onChange={() => setColorProperty((b) => !b)}\n ></ToggleSwitch>\n </div>\n <SharedCalculatedPropertyForms\n validator={validator}\n propertyName={propertyName}\n setPropertyName={setPropertyName}\n type={type}\n setType={setType}\n itemRenderer={(option: SelectOption<string>) => (\n <MenuItem>\n <div className='gmw-gr-cp-menu-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n </MenuItem>\n )}\n selectedItemRenderer={(option: SelectOption<string>) => (\n <div className='gmw-select-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n )}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={onClickCancel}\n isSavingDisabled={!(type && propertyName)}\n isLoading={isLoading}\n />\n </>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"CalculatedPropertyActionWithVisuals.js","sourceRoot":"","sources":["../../../../../src/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAAiD;AAIjD,wDAK8B;AAC9B,+CAA4D;AAC5D,qFAA6D;AAC7D,yFAGqD;AACrD,yEAAiD;AACjD,6DAAgF;AAChF,sDAAoD;AACpD,6EAAsE;AACtE,qFAAqF;AACrF,4DAAgE;AAEhE,mFAAgF;AAChF,sFAAgF;AAChF,uDAAoE;AAU7D,MAAM,mCAAmC,GAAG,CAAC,EAClD,SAAS,EACT,KAAK,EACL,kBAAkB,EAClB,aAAa,EACb,aAAa,GAC4B,EAAE,EAAE;IAC7C,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,gBAAgB,EAAE,GAAG,IAAA,sDAA2B,GAAE,CAAC;IACrF,IAAI,CAAC,gBAAgB,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;KACxE;I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nKW,QAAA,mCAAmC,uCAmK9C","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 { IModelApp } from \"@itwin/core-frontend\";\nimport type {\n SelectOption,\n} from \"@itwin/itwinui-react\";\nimport {\n Fieldset,\n MenuItem,\n Text,\n ToggleSwitch,\n} from \"@itwin/itwinui-react\";\nimport React, { useEffect, useMemo, useState } from \"react\";\nimport ActionPanel from \"../../SharedComponents/ActionPanel\";\nimport {\n BboxDimension,\n BboxDimensionsDecorator,\n} from \"../../../decorators/BboxDimensionsDecorator\";\nimport useValidator from \"../hooks/useValidator\";\nimport { visualizeElements, zoomToElements } from \"../../../common/viewerUtils\";\nimport \"./CalculatedPropertyActionWithVisuals.scss\";\nimport { useMappingClient } from \"../../context/MappingClientContext\";\nimport { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { CalculatedPropertyType } from \"@itwin/insights-client\";\nimport type { CalculatedProperty, Group } from \"@itwin/insights-client\";\nimport { SharedCalculatedPropertyForms } from \"./SharedCalculatedPropertyForms\";\nimport { useGroupKeySetQuery } from \"../../Groups/hooks/useKeySetHiliteQueries\";\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\n\nexport interface CalculatedPropertyActionWithVisualsProps {\n mappingId: string;\n group: Group;\n calculatedProperty?: CalculatedProperty;\n onSaveSuccess: () => void;\n onClickCancel?: () => void;\n}\n\nexport const CalculatedPropertyActionWithVisuals = ({\n mappingId,\n group,\n calculatedProperty,\n onSaveSuccess,\n onClickCancel,\n}: CalculatedPropertyActionWithVisualsProps) => {\n const { getAccessToken, iModelId, iModelConnection } = useGroupingMappingApiConfig();\n if (!iModelConnection) {\n throw new Error(\"This component requires an active iModelConnection.\");\n }\n const mappingClient = useMappingClient();\n const [propertyName, setPropertyName] = useState<string>(\n calculatedProperty?.propertyName ?? \"\",\n );\n const [type, setType] = useState<CalculatedPropertyType | undefined>(calculatedProperty?.type);\n const [bboxDecorator, setBboxDecorator] = useState<BboxDimensionsDecorator | undefined>();\n const [inferredSpatialData, setInferredSpatialData] = useState<Map<BboxDimension, number> | undefined>();\n const [validator, showValidationMessage] = useValidator();\n const [colorProperty, setColorProperty] = useState<boolean>(false);\n const { data } = useGroupKeySetQuery(group, iModelConnection, true);\n const queryClient = useQueryClient();\n\n const resolvedHiliteIds = useMemo(() => {\n // Resolved ids, default to an empty array if not available\n return data?.result?.ids ?? [];\n }, [data?.result?.ids]);\n\n useEffect(() => {\n const decorator = new BboxDimensionsDecorator();\n IModelApp.viewManager.addDecorator(decorator);\n setBboxDecorator(decorator);\n return () => {\n IModelApp.viewManager.dropDecorator(decorator);\n };\n }, []);\n\n useEffect(() => {\n if (!colorProperty || resolvedHiliteIds.length === 0) {\n return;\n }\n visualizeElements(resolvedHiliteIds, \"red\");\n void zoomToElements(resolvedHiliteIds);\n }, [colorProperty, resolvedHiliteIds]);\n\n useEffect(() => {\n if (!colorProperty || resolvedHiliteIds.length === 0) {\n return;\n }\n const setContext = async () => {\n if (bboxDecorator) {\n await bboxDecorator.setContext(resolvedHiliteIds[0]);\n setInferredSpatialData(bboxDecorator.getInferredSpatialData());\n }\n };\n void setContext();\n }, [bboxDecorator, colorProperty, resolvedHiliteIds]);\n\n useEffect(() => {\n if (bboxDecorator && type && inferredSpatialData) {\n inferredSpatialData.has(BboxDimension[type as keyof typeof BboxDimension]) && colorProperty\n ? bboxDecorator.drawContext(\n BboxDimension[type as keyof typeof BboxDimension],\n )\n : bboxDecorator.clearContext();\n }\n }, [bboxDecorator, colorProperty, inferredSpatialData, type]);\n\n const { mutate: saveMutation, isLoading } = useMutation(async (type: CalculatedPropertyType) => {\n const accessToken = await getAccessToken();\n\n return calculatedProperty\n ? mappingClient.updateCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n group.id,\n calculatedProperty.id,\n { propertyName, type },\n )\n : mappingClient.createCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n group.id,\n { propertyName, type },\n );\n }, {\n onSuccess: async () => {\n await queryClient.invalidateQueries({ queryKey: [\"calculatedProperties\", iModelId, mappingId, group.id] });\n onSaveSuccess();\n setPropertyName(\"\");\n setType(CalculatedPropertyType.Undefined);\n },\n });\n\n const onSave = () => {\n if (!validator.allValid() || !type) {\n showValidationMessage(true);\n return;\n }\n\n saveMutation(type);\n };\n\n const getSpatialData = (value: string) =>\n inferredSpatialData?.has(\n BboxDimension[value as keyof typeof BboxDimension],\n ) && (\n <div>\n {`${inferredSpatialData\n ?.get(BboxDimension[value as keyof typeof BboxDimension])\n ?.toPrecision(4)}m`}\n </div>\n );\n\n return (\n <>\n <div className='gmw-calculated-properties-action-container'>\n <Fieldset legend='Calculated Property Details' className='gmw-details-form'>\n <div className='gmw-field-legend-container'>\n <Text variant='small' as='small' className='gmw-field-legend'>\n Asterisk * indicates mandatory fields.\n </Text>\n <ToggleSwitch\n label='Visualize Dimensions'\n labelPosition='left'\n disabled={isLoading}\n checked={colorProperty}\n onChange={() => setColorProperty((b) => !b)}\n ></ToggleSwitch>\n </div>\n <SharedCalculatedPropertyForms\n validator={validator}\n propertyName={propertyName}\n setPropertyName={setPropertyName}\n type={type}\n setType={setType}\n itemRenderer={(option: SelectOption<string>) => (\n <MenuItem>\n <div className='gmw-gr-cp-menu-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n </MenuItem>\n )}\n selectedItemRenderer={(option: SelectOption<string>) => (\n <div className='gmw-select-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n )}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={onClickCancel}\n isSavingDisabled={!(type && propertyName)}\n isLoading={isLoading}\n />\n </>\n );\n};\n"]}
|
|
@@ -36,52 +36,49 @@ require("./CalculatedPropertyTable.scss");
|
|
|
36
36
|
const PropertyNameCell_1 = require("../PropertyNameCell");
|
|
37
37
|
const PropertyTable_1 = require("../PropertyTable");
|
|
38
38
|
const GroupingApiConfigContext_1 = require("../../context/GroupingApiConfigContext");
|
|
39
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
39
40
|
const CalculatedPropertyTable = ({ mappingId, groupId, onClickAdd, onClickModify, isLoading, calculatedProperties, refresh, }) => {
|
|
40
41
|
const mappingClient = (0, MappingClientContext_1.useMappingClient)();
|
|
41
42
|
const { getAccessToken, iModelId } = (0, GroupingApiConfigContext_1.useGroupingMappingApiConfig)();
|
|
43
|
+
const queryClient = (0, react_query_1.useQueryClient)();
|
|
42
44
|
const columnsFactory = (0, react_1.useCallback)((handleShowDeleteModal) => [
|
|
43
45
|
{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
? [
|
|
60
|
-
react_1.default.createElement(itwinui_react_1.MenuItem, { key: 0, onClick: () => {
|
|
61
|
-
onClickModify(value.row.original);
|
|
62
|
-
close();
|
|
63
|
-
}, icon: react_1.default.createElement(itwinui_icons_react_1.SvgEdit, null) }, "Modify"),
|
|
64
|
-
]
|
|
65
|
-
: [],
|
|
66
|
-
react_1.default.createElement(itwinui_react_1.MenuItem, { key: 1, onClick: () => {
|
|
67
|
-
handleShowDeleteModal(value.row.original);
|
|
46
|
+
id: "propertyName",
|
|
47
|
+
Header: "Calculated Property",
|
|
48
|
+
accessor: "propertyName",
|
|
49
|
+
Cell: (value) => (react_1.default.createElement(PropertyNameCell_1.PropertyNameCell, { property: value.row.original, onClickModify: onClickModify })),
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: "dropdown",
|
|
53
|
+
Header: "",
|
|
54
|
+
width: 80,
|
|
55
|
+
Cell: (value) => {
|
|
56
|
+
return (react_1.default.createElement(itwinui_react_1.DropdownMenu, { menuItems: (close) => [
|
|
57
|
+
onClickModify
|
|
58
|
+
? [
|
|
59
|
+
react_1.default.createElement(itwinui_react_1.MenuItem, { key: 0, onClick: () => {
|
|
60
|
+
onClickModify(value.row.original);
|
|
68
61
|
close();
|
|
69
|
-
}, icon: react_1.default.createElement(itwinui_icons_react_1.
|
|
70
|
-
]
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
|
|
62
|
+
}, icon: react_1.default.createElement(itwinui_icons_react_1.SvgEdit, null) }, "Modify"),
|
|
63
|
+
]
|
|
64
|
+
: [],
|
|
65
|
+
react_1.default.createElement(itwinui_react_1.MenuItem, { key: 1, onClick: () => {
|
|
66
|
+
handleShowDeleteModal(value.row.original);
|
|
67
|
+
close();
|
|
68
|
+
}, icon: react_1.default.createElement(itwinui_icons_react_1.SvgDelete, null) }, "Remove"),
|
|
69
|
+
].flatMap((p) => p) },
|
|
70
|
+
react_1.default.createElement(itwinui_react_1.IconButton, { styleType: "borderless" },
|
|
71
|
+
react_1.default.createElement(itwinui_icons_react_1.SvgMore, null))));
|
|
72
|
+
},
|
|
79
73
|
},
|
|
80
74
|
], [onClickModify]);
|
|
81
|
-
const deleteProperty = (0,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
75
|
+
const { mutateAsync: deleteProperty } = (0, react_query_1.useMutation)({
|
|
76
|
+
mutationFn: async (propertyId) => {
|
|
77
|
+
const accessToken = await getAccessToken();
|
|
78
|
+
await mappingClient.deleteCalculatedProperty(accessToken, iModelId, mappingId, groupId, propertyId);
|
|
79
|
+
},
|
|
80
|
+
onSuccess: async () => queryClient.invalidateQueries({ queryKey: ["calculatedProperties", iModelId, mappingId, groupId] }),
|
|
81
|
+
});
|
|
85
82
|
return (react_1.default.createElement(PropertyTable_1.PropertyTable, { propertyType: "Calculated", columnsFactory: columnsFactory, data: calculatedProperties, isLoading: isLoading, onClickAdd: onClickAdd, refreshProperties: refresh, deleteProperty: deleteProperty }));
|
|
86
83
|
};
|
|
87
84
|
exports.CalculatedPropertyTable = CalculatedPropertyTable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalculatedPropertyTable.js","sourceRoot":"","sources":["../../../../../src/components/Properties/CalculatedProperties/CalculatedPropertyTable.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,oEAAyE;AACzE,wDAI8B;AAC9B,+CAA2C;AAG3C,6EAAsE;AACtE,0CAAwC;AACxC,0DAAuD;AACvD,oDAAiD;AACjD,qFAAqF;
|
|
1
|
+
{"version":3,"file":"CalculatedPropertyTable.js","sourceRoot":"","sources":["../../../../../src/components/Properties/CalculatedProperties/CalculatedPropertyTable.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,oEAAyE;AACzE,wDAI8B;AAC9B,+CAA2C;AAG3C,6EAAsE;AACtE,0CAAwC;AACxC,0DAAuD;AACvD,oDAAiD;AACjD,qFAAqF;AACrF,uDAAoE;AAY7D,MAAM,uBAAuB,GAAG,CAAC,EACtC,SAAS,EACT,OAAO,EACP,UAAU,EACV,aAAa,EACb,SAAS,EACT,oBAAoB,EACpB,OAAO,GACsB,EAAE,EAAE;IACjC,MAAM,aAAa,GAAG,IAAA,uCAAgB,GAAE,CAAC;IACzC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,IAAA,sDAA2B,GAAE,CAAC;IACnE,MAAM,WAAW,GAAG,IAAA,4BAAc,GAAE,CAAC;IAErC,MAAM,cAAc,GAAG,IAAA,mBAAW,EAChC,CAAC,qBAA0D,EAAgC,EAAE,CAAC;QAC5F;YACE,EAAE,EAAE,cAAc;YAClB,MAAM,EAAE,qBAAqB;YAC7B,QAAQ,EAAE,cAAc;YACxB,IAAI,EAAE,CAAC,KAAoC,EAAE,EAAE,CAAC,CAC9C,8BAAC,mC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Q,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,sBAAsB,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC;KAC3H,CAAC,CAAC;IAEH,OAAO,CACL,8BAAC,6BAAa,IACZ,YAAY,EAAC,YAAY,EACzB,cAAc,EAAE,cAAc,EAC9B,IAAI,EAAE,oBAAoB,EAC1B,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,EACtB,iBAAiB,EAAE,OAAO,EAC1B,cAAc,EAAE,cAAc,GAC9B,CACH,CAAC;AACJ,CAAC,CAAC;AArGW,QAAA,uBAAuB,2BAqGlC","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 { SvgDelete, SvgEdit, SvgMore } 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 { CalculatedProperty } from \"@itwin/insights-client\";\nimport { useMappingClient } from \"../../context/MappingClientContext\";\nimport \"./CalculatedPropertyTable.scss\";\nimport { PropertyNameCell } from \"../PropertyNameCell\";\nimport { PropertyTable } from \"../PropertyTable\";\nimport { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\n\nexport interface CalculatedPropertyTableProps {\n mappingId: string;\n groupId: string;\n onClickAdd?: () => void;\n onClickModify?: (value: CalculatedProperty) => void;\n isLoading: boolean;\n calculatedProperties: CalculatedProperty[];\n refresh: () => Promise<void>;\n}\n\nexport const CalculatedPropertyTable = ({\n mappingId,\n groupId,\n onClickAdd,\n onClickModify,\n isLoading,\n calculatedProperties,\n refresh,\n}: CalculatedPropertyTableProps) => {\n const mappingClient = useMappingClient();\n const { getAccessToken, iModelId } = useGroupingMappingApiConfig();\n const queryClient = useQueryClient();\n\n const columnsFactory = useCallback(\n (handleShowDeleteModal: (value: CalculatedProperty) => void): Column<CalculatedProperty>[] => [\n {\n id: \"propertyName\",\n Header: \"Calculated Property\",\n accessor: \"propertyName\",\n Cell: (value: CellProps<CalculatedProperty>) => (\n <PropertyNameCell\n property={value.row.original}\n onClickModify={onClickModify}\n />\n ),\n },\n {\n id: \"dropdown\",\n Header: \"\",\n width: 80,\n Cell: (value: CellProps<CalculatedProperty>) => {\n return (\n <DropdownMenu\n menuItems={(close: () => void) =>\n [\n onClickModify\n ? [\n <MenuItem\n key={0}\n onClick={() => {\n onClickModify(\n value.row.original\n );\n close();\n }\n }\n icon={<SvgEdit />}\n >\n Modify\n </MenuItem>,\n ]\n : [],\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 >\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.deleteCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n groupId,\n propertyId,\n );\n },\n onSuccess: async () => queryClient.invalidateQueries({ queryKey: [\"calculatedProperties\", iModelId, mappingId, groupId] }),\n });\n\n return (\n <PropertyTable\n propertyType=\"Calculated\"\n columnsFactory={columnsFactory}\n data={calculatedProperties}\n isLoading={isLoading}\n onClickAdd={onClickAdd}\n refreshProperties={refresh}\n deleteProperty={deleteProperty}\n />\n );\n};\n"]}
|
|
@@ -42,7 +42,10 @@ const useFormulaValidation_1 = require("../hooks/useFormulaValidation");
|
|
|
42
42
|
const MappingClientContext_1 = require("../../context/MappingClientContext");
|
|
43
43
|
const GroupingApiConfigContext_1 = require("../../context/GroupingApiConfigContext");
|
|
44
44
|
const insights_client_1 = require("@itwin/insights-client");
|
|
45
|
-
const
|
|
45
|
+
const useCalculatedPropertiesQuery_1 = require("../hooks/useCalculatedPropertiesQuery");
|
|
46
|
+
const useCustomCalculationsQuery_1 = require("../hooks/useCustomCalculationsQuery");
|
|
47
|
+
const useGroupPropertiesQuery_1 = require("../hooks/useGroupPropertiesQuery");
|
|
48
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
46
49
|
const stringToPossibleDataType = (str) => {
|
|
47
50
|
switch (str?.toLowerCase()) {
|
|
48
51
|
case "double":
|
|
@@ -77,76 +80,34 @@ const CustomCalculationAction = ({ mappingId, groupId, customCalculation, onSave
|
|
|
77
80
|
const mappingClient = (0, MappingClientContext_1.useMappingClient)();
|
|
78
81
|
const [propertyName, setPropertyName] = (0, react_1.useState)(customCalculation?.propertyName ?? "");
|
|
79
82
|
const [formula, setFormula] = (0, react_1.useState)(customCalculation?.formula ?? "");
|
|
80
|
-
const { groupProperties, setGroupProperties, calculatedProperties, setCalculatedProperties, customCalculationProperties, setCustomCalculationProperties, } = (0, PropertiesContext_1.usePropertiesContext)();
|
|
81
83
|
const [quantityType, setQuantityType] = (0, react_1.useState)(customCalculation?.quantityType ?? insights_client_1.QuantityType.Undefined);
|
|
82
|
-
const [isLoading, setIsLoading] = (0, react_1.useState)(true);
|
|
83
84
|
const [formulaErrorMessage, setFormulaErrorMessage] = (0, react_1.useState)("");
|
|
84
85
|
const [validator, showValidationMessage] = (0, useValidator_1.default)();
|
|
85
86
|
const [properties, setProperties] = (0, react_1.useState)({});
|
|
86
87
|
const { isValid, forceValidation } = (0, useFormulaValidation_1.useFormulaValidation)(propertyName.toLowerCase(), formula, properties, setFormulaErrorMessage);
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
mappingClient.getCalculatedProperties(accessToken, iModelId, mappingId, groupId),
|
|
92
|
-
mappingClient.getCustomCalculations(accessToken, iModelId, mappingId, groupId),
|
|
93
|
-
]);
|
|
94
|
-
setGroupProperties(groupProps);
|
|
95
|
-
setCalculatedProperties(calcProps);
|
|
96
|
-
setCustomCalculationProperties(customCalcProps);
|
|
97
|
-
}, [getAccessToken, groupId, iModelId, mappingClient, mappingId, setCalculatedProperties, setCustomCalculationProperties, setGroupProperties]);
|
|
98
|
-
const fetchAllProperties = (0, react_1.useCallback)(async () => {
|
|
99
|
-
setIsLoading(true);
|
|
100
|
-
try {
|
|
101
|
-
if (!groupProperties || !calculatedProperties || !customCalculationProperties) {
|
|
102
|
-
await initialize();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
(0, utils_1.handleError)(error.status);
|
|
107
|
-
}
|
|
108
|
-
finally {
|
|
109
|
-
setIsLoading(false);
|
|
110
|
-
}
|
|
111
|
-
}, [calculatedProperties, customCalculationProperties, groupProperties, initialize]);
|
|
88
|
+
const queryClient = (0, react_query_1.useQueryClient)();
|
|
89
|
+
const { data: groupProperties, isFetching: isLoadingGroupProperties } = (0, useGroupPropertiesQuery_1.useGroupPropertiesQuery)(iModelId, mappingId, groupId, getAccessToken, mappingClient);
|
|
90
|
+
const { data: calculatedProperties, isFetching: isLoadingCalculatedProperties } = (0, useCalculatedPropertiesQuery_1.useCalculatedPropertiesQuery)(iModelId, mappingId, groupId, getAccessToken, mappingClient);
|
|
91
|
+
const { data: customCalculationProperties, isFetching: isLoadingCustomCalculations } = (0, useCustomCalculationsQuery_1.useCustomCalculationsQuery)(iModelId, mappingId, groupId, getAccessToken, mappingClient);
|
|
112
92
|
(0, react_1.useEffect)(() => {
|
|
113
93
|
const propertiesMap = convertToPropertyMap(groupProperties ?? [], calculatedProperties ?? [], customCalculationProperties ?? []);
|
|
114
94
|
setProperties(propertiesMap);
|
|
115
95
|
}, [calculatedProperties, customCalculationProperties, groupProperties]);
|
|
116
|
-
(0,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (!forceValidation()) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
try {
|
|
128
|
-
setIsLoading(true);
|
|
129
|
-
const accessToken = await getAccessToken();
|
|
130
|
-
customCalculation
|
|
131
|
-
? await mappingClient.updateCustomCalculation(accessToken, iModelId, mappingId, groupId, customCalculation.id, {
|
|
132
|
-
propertyName,
|
|
133
|
-
formula,
|
|
134
|
-
quantityType,
|
|
135
|
-
})
|
|
136
|
-
: await mappingClient.createCustomCalculation(accessToken, iModelId, mappingId, groupId, {
|
|
137
|
-
propertyName,
|
|
138
|
-
formula,
|
|
139
|
-
quantityType,
|
|
140
|
-
});
|
|
96
|
+
const { mutate: saveMutation, isLoading: isSaving } = (0, react_query_1.useMutation)(async () => {
|
|
97
|
+
const accessToken = await getAccessToken();
|
|
98
|
+
return customCalculation
|
|
99
|
+
? mappingClient.updateCustomCalculation(accessToken, iModelId, mappingId, groupId, customCalculation.id, { propertyName, formula, quantityType })
|
|
100
|
+
: mappingClient.createCustomCalculation(accessToken, iModelId, mappingId, groupId, { propertyName, formula, quantityType });
|
|
101
|
+
}, {
|
|
102
|
+
onSuccess: async () => {
|
|
103
|
+
await queryClient.invalidateQueries({ queryKey: ["customCalculations", iModelId, mappingId, groupId] });
|
|
141
104
|
onSaveSuccess();
|
|
142
105
|
setPropertyName("");
|
|
143
106
|
setFormula("");
|
|
144
107
|
setQuantityType(insights_client_1.QuantityType.Undefined);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// error instanceof Response refuses to be true when it should be.
|
|
108
|
+
},
|
|
109
|
+
onError: async (error) => {
|
|
148
110
|
if (error.status === 422) {
|
|
149
|
-
error = error;
|
|
150
111
|
const erroredResponse = await error.json();
|
|
151
112
|
if (erroredResponse.error.code === "InvalidInsightsRequest" &&
|
|
152
113
|
erroredResponse.error.target === "formula") {
|
|
@@ -156,11 +117,19 @@ const CustomCalculationAction = ({ mappingId, groupId, customCalculation, onSave
|
|
|
156
117
|
else {
|
|
157
118
|
(0, utils_1.handleError)(error.status);
|
|
158
119
|
}
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
const onSave = () => {
|
|
123
|
+
if (!validator.allValid()) {
|
|
124
|
+
showValidationMessage(true);
|
|
125
|
+
return;
|
|
159
126
|
}
|
|
160
|
-
|
|
161
|
-
|
|
127
|
+
if (!forceValidation()) {
|
|
128
|
+
return;
|
|
162
129
|
}
|
|
130
|
+
saveMutation();
|
|
163
131
|
};
|
|
132
|
+
const isLoading = isSaving || isLoadingGroupProperties || isLoadingCalculatedProperties || isLoadingCustomCalculations;
|
|
164
133
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
165
134
|
react_1.default.createElement("div", { className: 'gmw-custom-calculation-action-container' },
|
|
166
135
|
react_1.default.createElement(itwinui_react_1.Fieldset, { legend: 'Custom Calculation Details', className: 'gmw-details-form' },
|