@itwin/grouping-mapping-widget 0.25.2 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/WidgetShell/GroupingMapping.d.ts +5 -5
- package/lib/cjs/WidgetShell/GroupingMapping.js.map +1 -1
- package/lib/cjs/WidgetShell/GroupingMappingWidget.d.ts +4 -0
- package/lib/cjs/WidgetShell/GroupingMappingWidget.js +4 -0
- package/lib/cjs/WidgetShell/GroupingMappingWidget.js.map +1 -1
- package/lib/cjs/components/GroupingMappingContext.d.ts +19 -3
- package/lib/cjs/components/GroupingMappingContext.js +27 -9
- package/lib/cjs/components/GroupingMappingContext.js.map +1 -1
- package/lib/cjs/components/Groups/Editing/GroupAction.d.ts +10 -2
- package/lib/cjs/components/Groups/Editing/GroupAction.js +9 -5
- package/lib/cjs/components/Groups/Editing/GroupAction.js.map +1 -1
- package/lib/cjs/components/Groups/GroupColorLegend.d.ts +3 -3
- package/lib/cjs/components/Groups/GroupColorLegend.js.map +1 -1
- package/lib/cjs/components/Groups/GroupListItem.d.ts +4 -4
- package/lib/cjs/components/Groups/GroupListItem.js +6 -3
- package/lib/cjs/components/Groups/GroupListItem.js.map +1 -1
- package/lib/cjs/components/Groups/GroupListItem.scss +14 -0
- package/lib/cjs/components/Groups/GroupMenuActions.d.ts +4 -4
- package/lib/cjs/components/Groups/GroupMenuActions.js.map +1 -1
- package/lib/cjs/components/Groups/GroupMenuActions.scss +2 -0
- package/lib/cjs/components/Groups/GroupOverlapProgressBar.d.ts +2 -2
- package/lib/cjs/components/Groups/GroupOverlapProgressBar.js.map +1 -1
- package/lib/cjs/components/Groups/Groups.d.ts +12 -4
- package/lib/cjs/components/Groups/Groups.js +4 -0
- package/lib/cjs/components/Groups/Groups.js.map +1 -1
- package/lib/cjs/components/Groups/GroupsShowHideButtons.d.ts +4 -4
- package/lib/cjs/components/Groups/GroupsShowHideButtons.js.map +1 -1
- package/lib/cjs/components/Groups/GroupsView.d.ts +19 -11
- package/lib/cjs/components/Groups/GroupsView.js +4 -0
- package/lib/cjs/components/Groups/GroupsView.js.map +1 -1
- package/lib/cjs/components/Groups/GroupsVisualization.d.ts +8 -0
- package/lib/cjs/components/Groups/GroupsVisualization.js +8 -4
- package/lib/cjs/components/Groups/GroupsVisualization.js.map +1 -1
- package/lib/cjs/components/Groups/OverlappedElementsInformationPanel.d.ts +3 -3
- package/lib/cjs/components/Groups/OverlappedElementsInformationPanel.js.map +1 -1
- package/lib/cjs/components/Groups/QueryBuilder/QueryBuilderCustomUI.d.ts +2 -2
- package/lib/cjs/components/Groups/QueryBuilder/QueryBuilderCustomUI.js.map +1 -1
- package/lib/cjs/components/Groups/groupsHelpers.d.ts +2 -2
- package/lib/cjs/components/Groups/groupsHelpers.js.map +1 -1
- package/lib/cjs/components/Groups/hooks/useFetchGroups.d.ts +3 -3
- package/lib/cjs/components/Groups/hooks/useFetchGroups.js +6 -5
- package/lib/cjs/components/Groups/hooks/useFetchGroups.js.map +1 -1
- package/lib/cjs/components/Groups/hooks/useGroupsOperations.d.ts +15 -7
- package/lib/cjs/components/Groups/hooks/useGroupsOperations.js +9 -5
- package/lib/cjs/components/Groups/hooks/useGroupsOperations.js.map +1 -1
- package/lib/cjs/components/Groups/hooks/useKeySetHiliteQueries.d.ts +4 -4
- package/lib/cjs/components/Groups/hooks/useKeySetHiliteQueries.js.map +1 -1
- package/lib/cjs/components/Mappings/Editing/MappingAction.d.ts +8 -0
- package/lib/cjs/components/Mappings/Editing/MappingAction.js +7 -2
- package/lib/cjs/components/Mappings/Editing/MappingAction.js.map +1 -1
- package/lib/cjs/components/Mappings/Extraction/ExtractionMessageModal.js +3 -1
- package/lib/cjs/components/Mappings/Extraction/ExtractionMessageModal.js.map +1 -1
- package/lib/cjs/components/Mappings/Import/ConfirmMappingsImport.d.ts +1 -2
- package/lib/cjs/components/Mappings/Import/ConfirmMappingsImport.js +4 -3
- package/lib/cjs/components/Mappings/Import/ConfirmMappingsImport.js.map +1 -1
- package/lib/cjs/components/Mappings/Import/MappingImportWizardModal.js +1 -1
- package/lib/cjs/components/Mappings/Import/MappingImportWizardModal.js.map +1 -1
- package/lib/cjs/components/Mappings/Mappings.d.ts +8 -0
- package/lib/cjs/components/Mappings/Mappings.js +4 -0
- package/lib/cjs/components/Mappings/Mappings.js.map +1 -1
- package/lib/cjs/components/Mappings/MappingsView.d.ts +7 -0
- package/lib/cjs/components/Mappings/MappingsView.js +4 -0
- package/lib/cjs/components/Mappings/MappingsView.js.map +1 -1
- package/lib/cjs/components/Mappings/hooks/useFetchExtractionStatus.d.ts +1 -2
- package/lib/cjs/components/Mappings/hooks/useFetchExtractionStatus.js +9 -8
- package/lib/cjs/components/Mappings/hooks/useFetchExtractionStatus.js.map +1 -1
- package/lib/cjs/components/Mappings/hooks/useFetchMappingExtractionStatus.js +5 -4
- package/lib/cjs/components/Mappings/hooks/useFetchMappingExtractionStatus.js.map +1 -1
- package/lib/cjs/components/Mappings/hooks/useFetchMappings.js +1 -1
- package/lib/cjs/components/Mappings/hooks/useFetchMappings.js.map +1 -1
- package/lib/cjs/components/Mappings/hooks/useMappingsOperations.d.ts +9 -2
- package/lib/cjs/components/Mappings/hooks/useMappingsOperations.js +12 -8
- package/lib/cjs/components/Mappings/hooks/useMappingsOperations.js.map +1 -1
- package/lib/cjs/components/Mappings/hooks/useRunExtraction.d.ts +1 -1
- package/lib/cjs/components/Mappings/hooks/useRunExtraction.js +20 -14
- package/lib/cjs/components/Mappings/hooks/useRunExtraction.js.map +1 -1
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyAction.d.ts +10 -2
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyAction.js +20 -7
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyAction.js.map +1 -1
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.d.ts +11 -3
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js +19 -7
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js.map +1 -1
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.d.ts +3 -3
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.js +6 -4
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.js.map +1 -1
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.d.ts +10 -2
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.js +52 -34
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.js.map +1 -1
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationTable.d.ts +3 -3
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationTable.js +6 -4
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationTable.js.map +1 -1
- package/lib/cjs/components/Properties/GroupColorToggle.d.ts +2 -2
- package/lib/cjs/components/Properties/GroupColorToggle.js.map +1 -1
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.d.ts +12 -4
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.js +24 -18
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.js.map +1 -1
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyTable.d.ts +3 -3
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyTable.js +6 -4
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyTable.js.map +1 -1
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyUtils.d.ts +3 -5
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyUtils.js +0 -26
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyUtils.js.map +1 -1
- package/lib/cjs/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.js +3 -3
- package/lib/cjs/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.js.map +1 -1
- package/lib/cjs/components/Properties/PropertyMenu.d.ts +13 -5
- package/lib/cjs/components/Properties/PropertyMenu.js +12 -14
- package/lib/cjs/components/Properties/PropertyMenu.js.map +1 -1
- package/lib/cjs/components/Properties/PropertyMenuWithVisualization.d.ts +8 -0
- package/lib/cjs/components/Properties/PropertyMenuWithVisualization.js +4 -0
- package/lib/cjs/components/Properties/PropertyMenuWithVisualization.js.map +1 -1
- package/lib/cjs/components/Properties/hooks/useFormulaValidation.d.ts +2 -1
- package/lib/cjs/components/Properties/hooks/useFormulaValidation.js +8 -4
- package/lib/cjs/components/Properties/hooks/useFormulaValidation.js.map +1 -1
- package/lib/cjs/components/Properties/hooks/usePropertiesQuery.d.ts +4 -0
- package/lib/cjs/components/Properties/hooks/usePropertiesQuery.js +12 -0
- package/lib/cjs/components/Properties/hooks/usePropertiesQuery.js.map +1 -0
- package/lib/cjs/components/context/ExtractionClientContext.js +3 -3
- package/lib/cjs/components/context/ExtractionClientContext.js.map +1 -1
- package/lib/cjs/components/context/GroupingApiConfigContext.d.ts +16 -0
- package/lib/cjs/components/context/GroupingApiConfigContext.js +7 -0
- package/lib/cjs/components/context/GroupingApiConfigContext.js.map +1 -1
- package/lib/cjs/components/context/GroupsClientContext.d.ts +20 -0
- package/lib/cjs/components/context/GroupsClientContext.js +45 -0
- package/lib/cjs/components/context/GroupsClientContext.js.map +1 -0
- package/lib/cjs/components/context/MappingClientContext.d.ts +12 -0
- package/lib/cjs/components/context/MappingClientContext.js +14 -2
- package/lib/cjs/components/context/MappingClientContext.js.map +1 -1
- package/lib/cjs/components/context/PropertiesClientContext.d.ts +20 -0
- package/lib/cjs/components/context/PropertiesClientContext.js +45 -0
- package/lib/cjs/components/context/PropertiesClientContext.js.map +1 -0
- package/lib/cjs/components/customUI/GroupQueryBuilderCustomUI.d.ts +4 -0
- package/lib/cjs/components/customUI/GroupQueryBuilderCustomUI.js +4 -0
- package/lib/cjs/components/customUI/GroupQueryBuilderCustomUI.js.map +1 -1
- package/lib/cjs/components/customUI/GroupingMappingCustomUI.d.ts +15 -3
- package/lib/cjs/components/customUI/GroupingMappingCustomUI.js +3 -0
- package/lib/cjs/components/customUI/GroupingMappingCustomUI.js.map +1 -1
- package/lib/cjs/components/customUI/ManualGroupingCustomUI.d.ts +4 -0
- package/lib/cjs/components/customUI/ManualGroupingCustomUI.js +4 -0
- package/lib/cjs/components/customUI/ManualGroupingCustomUI.js.map +1 -1
- package/lib/cjs/components/customUI/SearchGroupingCustomUI.d.ts +4 -0
- package/lib/cjs/components/customUI/SearchGroupingCustomUI.js +4 -0
- package/lib/cjs/components/customUI/SearchGroupingCustomUI.js.map +1 -1
- package/lib/cjs/formula/FormulaDataTypeResolver.d.ts +1 -0
- package/lib/cjs/formula/FormulaDataTypeResolver.js +1 -0
- package/lib/cjs/formula/FormulaDataTypeResolver.js.map +1 -1
- package/lib/cjs/formula/FormulaFunctionProvider.js +41 -41
- package/lib/cjs/formula/FormulaFunctionProvider.js.map +1 -1
- package/lib/cjs/formula/FormulaOperatorsProvider.js +3 -3
- package/lib/cjs/formula/FormulaOperatorsProvider.js.map +1 -1
- package/lib/cjs/formula/FormulaTokensDataTypeResolver.js +2 -2
- package/lib/cjs/formula/FormulaTokensDataTypeResolver.js.map +1 -1
- package/lib/cjs/formula/IResult.d.ts +3 -0
- package/lib/cjs/formula/IResult.js.map +1 -1
- package/lib/cjs/formula/Types.d.ts +16 -1
- package/lib/cjs/formula/Types.js.map +1 -1
- package/lib/cjs/grouping-mapping-widget.d.ts +2 -0
- package/lib/cjs/grouping-mapping-widget.js +11 -1
- package/lib/cjs/grouping-mapping-widget.js.map +1 -1
- package/lib/cjs/test/GroupPropertyUtils.test.js +0 -39
- package/lib/cjs/test/GroupPropertyUtils.test.js.map +1 -1
- package/lib/cjs/test/GroupingMappingCustomUI.test.js +19 -8
- package/lib/cjs/test/GroupingMappingCustomUI.test.js.map +1 -1
- package/lib/esm/WidgetShell/GroupingMapping.d.ts +5 -5
- package/lib/esm/WidgetShell/GroupingMapping.js.map +1 -1
- package/lib/esm/WidgetShell/GroupingMappingWidget.d.ts +4 -0
- package/lib/esm/WidgetShell/GroupingMappingWidget.js +4 -0
- package/lib/esm/WidgetShell/GroupingMappingWidget.js.map +1 -1
- package/lib/esm/components/GroupingMappingContext.d.ts +19 -3
- package/lib/esm/components/GroupingMappingContext.js +27 -9
- package/lib/esm/components/GroupingMappingContext.js.map +1 -1
- package/lib/esm/components/Groups/Editing/GroupAction.d.ts +10 -2
- package/lib/esm/components/Groups/Editing/GroupAction.js +9 -5
- package/lib/esm/components/Groups/Editing/GroupAction.js.map +1 -1
- package/lib/esm/components/Groups/GroupColorLegend.d.ts +3 -3
- package/lib/esm/components/Groups/GroupColorLegend.js.map +1 -1
- package/lib/esm/components/Groups/GroupListItem.d.ts +4 -4
- package/lib/esm/components/Groups/GroupListItem.js +6 -3
- package/lib/esm/components/Groups/GroupListItem.js.map +1 -1
- package/lib/esm/components/Groups/GroupListItem.scss +14 -0
- package/lib/esm/components/Groups/GroupMenuActions.d.ts +4 -4
- package/lib/esm/components/Groups/GroupMenuActions.js.map +1 -1
- package/lib/esm/components/Groups/GroupMenuActions.scss +2 -0
- package/lib/esm/components/Groups/GroupOverlapProgressBar.d.ts +2 -2
- package/lib/esm/components/Groups/GroupOverlapProgressBar.js.map +1 -1
- package/lib/esm/components/Groups/Groups.d.ts +12 -4
- package/lib/esm/components/Groups/Groups.js +4 -0
- package/lib/esm/components/Groups/Groups.js.map +1 -1
- package/lib/esm/components/Groups/GroupsShowHideButtons.d.ts +4 -4
- package/lib/esm/components/Groups/GroupsShowHideButtons.js.map +1 -1
- package/lib/esm/components/Groups/GroupsView.d.ts +19 -11
- package/lib/esm/components/Groups/GroupsView.js +4 -0
- package/lib/esm/components/Groups/GroupsView.js.map +1 -1
- package/lib/esm/components/Groups/GroupsVisualization.d.ts +8 -0
- package/lib/esm/components/Groups/GroupsVisualization.js +8 -4
- package/lib/esm/components/Groups/GroupsVisualization.js.map +1 -1
- package/lib/esm/components/Groups/OverlappedElementsInformationPanel.d.ts +3 -3
- package/lib/esm/components/Groups/OverlappedElementsInformationPanel.js.map +1 -1
- package/lib/esm/components/Groups/QueryBuilder/QueryBuilderCustomUI.d.ts +2 -2
- package/lib/esm/components/Groups/QueryBuilder/QueryBuilderCustomUI.js.map +1 -1
- package/lib/esm/components/Groups/groupsHelpers.d.ts +2 -2
- package/lib/esm/components/Groups/groupsHelpers.js.map +1 -1
- package/lib/esm/components/Groups/hooks/useFetchGroups.d.ts +3 -3
- package/lib/esm/components/Groups/hooks/useFetchGroups.js +6 -5
- package/lib/esm/components/Groups/hooks/useFetchGroups.js.map +1 -1
- package/lib/esm/components/Groups/hooks/useGroupsOperations.d.ts +15 -7
- package/lib/esm/components/Groups/hooks/useGroupsOperations.js +9 -5
- package/lib/esm/components/Groups/hooks/useGroupsOperations.js.map +1 -1
- package/lib/esm/components/Groups/hooks/useKeySetHiliteQueries.d.ts +4 -4
- package/lib/esm/components/Groups/hooks/useKeySetHiliteQueries.js.map +1 -1
- package/lib/esm/components/Mappings/Editing/MappingAction.d.ts +8 -0
- package/lib/esm/components/Mappings/Editing/MappingAction.js +7 -2
- package/lib/esm/components/Mappings/Editing/MappingAction.js.map +1 -1
- package/lib/esm/components/Mappings/Extraction/ExtractionMessageModal.js +3 -1
- package/lib/esm/components/Mappings/Extraction/ExtractionMessageModal.js.map +1 -1
- package/lib/esm/components/Mappings/Import/ConfirmMappingsImport.d.ts +1 -2
- package/lib/esm/components/Mappings/Import/ConfirmMappingsImport.js +4 -3
- package/lib/esm/components/Mappings/Import/ConfirmMappingsImport.js.map +1 -1
- package/lib/esm/components/Mappings/Import/MappingImportWizardModal.js +1 -1
- package/lib/esm/components/Mappings/Import/MappingImportWizardModal.js.map +1 -1
- package/lib/esm/components/Mappings/Mappings.d.ts +8 -0
- package/lib/esm/components/Mappings/Mappings.js +4 -0
- package/lib/esm/components/Mappings/Mappings.js.map +1 -1
- package/lib/esm/components/Mappings/MappingsView.d.ts +7 -0
- package/lib/esm/components/Mappings/MappingsView.js +4 -0
- package/lib/esm/components/Mappings/MappingsView.js.map +1 -1
- package/lib/esm/components/Mappings/hooks/useFetchExtractionStatus.d.ts +1 -2
- package/lib/esm/components/Mappings/hooks/useFetchExtractionStatus.js +9 -8
- package/lib/esm/components/Mappings/hooks/useFetchExtractionStatus.js.map +1 -1
- package/lib/esm/components/Mappings/hooks/useFetchMappingExtractionStatus.js +6 -5
- package/lib/esm/components/Mappings/hooks/useFetchMappingExtractionStatus.js.map +1 -1
- package/lib/esm/components/Mappings/hooks/useFetchMappings.js +1 -1
- package/lib/esm/components/Mappings/hooks/useFetchMappings.js.map +1 -1
- package/lib/esm/components/Mappings/hooks/useMappingsOperations.d.ts +9 -2
- package/lib/esm/components/Mappings/hooks/useMappingsOperations.js +13 -9
- package/lib/esm/components/Mappings/hooks/useMappingsOperations.js.map +1 -1
- package/lib/esm/components/Mappings/hooks/useRunExtraction.d.ts +1 -1
- package/lib/esm/components/Mappings/hooks/useRunExtraction.js +20 -14
- package/lib/esm/components/Mappings/hooks/useRunExtraction.js.map +1 -1
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyAction.d.ts +10 -2
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyAction.js +21 -8
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyAction.js.map +1 -1
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.d.ts +11 -3
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js +20 -8
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js.map +1 -1
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyTable.d.ts +3 -3
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyTable.js +6 -4
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyTable.js.map +1 -1
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationAction.d.ts +10 -2
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationAction.js +53 -35
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationAction.js.map +1 -1
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationTable.d.ts +3 -3
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationTable.js +6 -4
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationTable.js.map +1 -1
- package/lib/esm/components/Properties/GroupColorToggle.d.ts +2 -2
- package/lib/esm/components/Properties/GroupColorToggle.js.map +1 -1
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.d.ts +12 -4
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.js +24 -18
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.js.map +1 -1
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyTable.d.ts +3 -3
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyTable.js +6 -4
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyTable.js.map +1 -1
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyUtils.d.ts +3 -5
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyUtils.js +0 -26
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyUtils.js.map +1 -1
- package/lib/esm/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.js +3 -3
- package/lib/esm/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.js.map +1 -1
- package/lib/esm/components/Properties/PropertyMenu.d.ts +13 -5
- package/lib/esm/components/Properties/PropertyMenu.js +12 -14
- package/lib/esm/components/Properties/PropertyMenu.js.map +1 -1
- package/lib/esm/components/Properties/PropertyMenuWithVisualization.d.ts +8 -0
- package/lib/esm/components/Properties/PropertyMenuWithVisualization.js +4 -0
- package/lib/esm/components/Properties/PropertyMenuWithVisualization.js.map +1 -1
- package/lib/esm/components/Properties/hooks/useFormulaValidation.d.ts +2 -1
- package/lib/esm/components/Properties/hooks/useFormulaValidation.js +8 -4
- package/lib/esm/components/Properties/hooks/useFormulaValidation.js.map +1 -1
- package/lib/esm/components/Properties/hooks/usePropertiesQuery.d.ts +4 -0
- package/lib/esm/components/Properties/hooks/usePropertiesQuery.js +8 -0
- package/lib/esm/components/Properties/hooks/usePropertiesQuery.js.map +1 -0
- package/lib/esm/components/context/ExtractionClientContext.js +3 -3
- package/lib/esm/components/context/ExtractionClientContext.js.map +1 -1
- package/lib/esm/components/context/GroupingApiConfigContext.d.ts +16 -0
- package/lib/esm/components/context/GroupingApiConfigContext.js +7 -0
- package/lib/esm/components/context/GroupingApiConfigContext.js.map +1 -1
- package/lib/esm/components/context/GroupsClientContext.d.ts +20 -0
- package/lib/esm/components/context/GroupsClientContext.js +39 -0
- package/lib/esm/components/context/GroupsClientContext.js.map +1 -0
- package/lib/esm/components/context/MappingClientContext.d.ts +12 -0
- package/lib/esm/components/context/MappingClientContext.js +15 -3
- package/lib/esm/components/context/MappingClientContext.js.map +1 -1
- package/lib/esm/components/context/PropertiesClientContext.d.ts +20 -0
- package/lib/esm/components/context/PropertiesClientContext.js +39 -0
- package/lib/esm/components/context/PropertiesClientContext.js.map +1 -0
- package/lib/esm/components/customUI/GroupQueryBuilderCustomUI.d.ts +4 -0
- package/lib/esm/components/customUI/GroupQueryBuilderCustomUI.js +4 -0
- package/lib/esm/components/customUI/GroupQueryBuilderCustomUI.js.map +1 -1
- package/lib/esm/components/customUI/GroupingMappingCustomUI.d.ts +15 -3
- package/lib/esm/components/customUI/GroupingMappingCustomUI.js +3 -0
- package/lib/esm/components/customUI/GroupingMappingCustomUI.js.map +1 -1
- package/lib/esm/components/customUI/ManualGroupingCustomUI.d.ts +4 -0
- package/lib/esm/components/customUI/ManualGroupingCustomUI.js +4 -0
- package/lib/esm/components/customUI/ManualGroupingCustomUI.js.map +1 -1
- package/lib/esm/components/customUI/SearchGroupingCustomUI.d.ts +4 -0
- package/lib/esm/components/customUI/SearchGroupingCustomUI.js +4 -0
- package/lib/esm/components/customUI/SearchGroupingCustomUI.js.map +1 -1
- package/lib/esm/formula/FormulaDataTypeResolver.d.ts +1 -0
- package/lib/esm/formula/FormulaDataTypeResolver.js +1 -0
- package/lib/esm/formula/FormulaDataTypeResolver.js.map +1 -1
- package/lib/esm/formula/FormulaFunctionProvider.js +41 -41
- package/lib/esm/formula/FormulaFunctionProvider.js.map +1 -1
- package/lib/esm/formula/FormulaOperatorsProvider.js +3 -3
- package/lib/esm/formula/FormulaOperatorsProvider.js.map +1 -1
- package/lib/esm/formula/FormulaTokensDataTypeResolver.js +2 -2
- package/lib/esm/formula/FormulaTokensDataTypeResolver.js.map +1 -1
- package/lib/esm/formula/IResult.d.ts +3 -0
- package/lib/esm/formula/IResult.js.map +1 -1
- package/lib/esm/formula/Types.d.ts +16 -1
- package/lib/esm/formula/Types.js.map +1 -1
- package/lib/esm/grouping-mapping-widget.d.ts +2 -0
- package/lib/esm/grouping-mapping-widget.js +2 -0
- package/lib/esm/grouping-mapping-widget.js.map +1 -1
- package/lib/esm/test/GroupPropertyUtils.test.js +0 -39
- package/lib/esm/test/GroupPropertyUtils.test.js.map +1 -1
- package/lib/esm/test/GroupingMappingCustomUI.test.js +19 -8
- package/lib/esm/test/GroupingMappingCustomUI.test.js.map +1 -1
- package/package.json +3 -2
- package/lib/cjs/components/Properties/hooks/useCalculatedPropertiesQuery.d.ts +0 -4
- package/lib/cjs/components/Properties/hooks/useCalculatedPropertiesQuery.js +0 -12
- package/lib/cjs/components/Properties/hooks/useCalculatedPropertiesQuery.js.map +0 -1
- package/lib/cjs/components/Properties/hooks/useCustomCalculationsQuery.d.ts +0 -4
- package/lib/cjs/components/Properties/hooks/useCustomCalculationsQuery.js +0 -12
- package/lib/cjs/components/Properties/hooks/useCustomCalculationsQuery.js.map +0 -1
- package/lib/cjs/components/Properties/hooks/useGroupPropertiesQuery.d.ts +0 -4
- package/lib/cjs/components/Properties/hooks/useGroupPropertiesQuery.js +0 -12
- package/lib/cjs/components/Properties/hooks/useGroupPropertiesQuery.js.map +0 -1
- package/lib/esm/components/Properties/hooks/useCalculatedPropertiesQuery.d.ts +0 -4
- package/lib/esm/components/Properties/hooks/useCalculatedPropertiesQuery.js +0 -8
- package/lib/esm/components/Properties/hooks/useCalculatedPropertiesQuery.js.map +0 -1
- package/lib/esm/components/Properties/hooks/useCustomCalculationsQuery.d.ts +0 -4
- package/lib/esm/components/Properties/hooks/useCustomCalculationsQuery.js +0 -8
- package/lib/esm/components/Properties/hooks/useCustomCalculationsQuery.js.map +0 -1
- package/lib/esm/components/Properties/hooks/useGroupPropertiesQuery.d.ts +0 -4
- package/lib/esm/components/Properties/hooks/useGroupPropertiesQuery.js +0 -8
- package/lib/esm/components/Properties/hooks/useGroupPropertiesQuery.js.map +0 -1
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import "./CalculatedPropertyAction.scss";
|
|
3
|
-
import type {
|
|
3
|
+
import type { Group, Property } from "@itwin/insights-client";
|
|
4
|
+
/**
|
|
5
|
+
* Props for the {@link CalculatedPropertyAction} component.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
4
8
|
export interface CalculatedPropertyActionProps {
|
|
5
9
|
mappingId: string;
|
|
6
10
|
group: Group;
|
|
7
|
-
calculatedProperty?:
|
|
11
|
+
calculatedProperty?: Property;
|
|
8
12
|
onSaveSuccess: () => void;
|
|
9
13
|
onClickCancel?: () => void;
|
|
10
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Component to create or update a calculated property.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
11
19
|
export declare const CalculatedPropertyAction: ({ mappingId, group, calculatedProperty, onSaveSuccess, onClickCancel, }: CalculatedPropertyActionProps) => JSX.Element;
|
|
12
20
|
//# sourceMappingURL=CalculatedPropertyAction.d.ts.map
|
|
@@ -39,26 +39,39 @@ require("./CalculatedPropertyAction.scss");
|
|
|
39
39
|
const insights_client_1 = require("@itwin/insights-client");
|
|
40
40
|
const SharedCalculatedPropertyForms_1 = require("./SharedCalculatedPropertyForms");
|
|
41
41
|
const GroupingApiConfigContext_1 = require("../../context/GroupingApiConfigContext");
|
|
42
|
-
const MappingClientContext_1 = require("../../context/MappingClientContext");
|
|
43
42
|
const react_query_1 = require("@tanstack/react-query");
|
|
43
|
+
const PropertiesClientContext_1 = require("../../context/PropertiesClientContext");
|
|
44
|
+
/**
|
|
45
|
+
* Component to create or update a calculated property.
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
44
48
|
const CalculatedPropertyAction = ({ mappingId, group, calculatedProperty, onSaveSuccess, onClickCancel, }) => {
|
|
45
49
|
const { getAccessToken, iModelId } = (0, GroupingApiConfigContext_1.useGroupingMappingApiConfig)();
|
|
46
|
-
const
|
|
50
|
+
const propertiesClient = (0, PropertiesClientContext_1.usePropertiesClient)();
|
|
47
51
|
const [propertyName, setPropertyName] = (0, react_1.useState)(calculatedProperty?.propertyName ?? "");
|
|
48
|
-
const [type, setType] = (0, react_1.useState)(calculatedProperty?.
|
|
52
|
+
const [type, setType] = (0, react_1.useState)(calculatedProperty?.calculatedPropertyType ?? undefined);
|
|
49
53
|
const [validator, showValidationMessage] = (0, useValidator_1.default)();
|
|
50
54
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
51
55
|
const { mutate: saveMutation, isLoading } = (0, react_query_1.useMutation)(async (type) => {
|
|
52
56
|
const accessToken = await getAccessToken();
|
|
53
57
|
return calculatedProperty
|
|
54
|
-
?
|
|
55
|
-
|
|
58
|
+
? propertiesClient.updateProperty(accessToken, mappingId, group.id, calculatedProperty.id, {
|
|
59
|
+
...calculatedProperty,
|
|
60
|
+
propertyName,
|
|
61
|
+
dataType: calculatedProperty.dataType,
|
|
62
|
+
calculatedPropertyType: type,
|
|
63
|
+
})
|
|
64
|
+
: propertiesClient.createProperty(accessToken, mappingId, group.id, {
|
|
65
|
+
propertyName,
|
|
66
|
+
dataType: insights_client_1.DataType.Double,
|
|
67
|
+
calculatedPropertyType: type,
|
|
68
|
+
});
|
|
56
69
|
}, {
|
|
57
70
|
onSuccess: async () => {
|
|
58
|
-
await queryClient.invalidateQueries({ queryKey: ["
|
|
71
|
+
await queryClient.invalidateQueries({ queryKey: ["properties", iModelId, mappingId, group.id] });
|
|
59
72
|
onSaveSuccess();
|
|
60
73
|
setPropertyName("");
|
|
61
|
-
setType(
|
|
74
|
+
setType(undefined);
|
|
62
75
|
},
|
|
63
76
|
});
|
|
64
77
|
const onSave = () => {
|
|
@@ -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,
|
|
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,4DAAkD;AAClD,mFAAgF;AAChF,qFAAqF;AACrF,uDAAoE;AACpE,mFAA4E;AAc5E;;;GAGG;AACI,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,gBAAgB,GAAG,IAAA,6CAAmB,GAAE,CAAC;IAC/C,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,EAC9C,kBAAkB,EAAE,YAAY,IAAI,EAAE,CACvC,CAAC;IACF,MAAM,CAAC,IAAI,EAAE,OAAO,CAA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ClC,qBAAqB,CAAC,IAAI,CAAC,CAAC;YAC5B,OAAO;SACR;QAED,YAAY,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC,CAAC;IAEF,OAAO,CACL;QACE,uCAAK,SAAS,EAAC,4CAA4C;YACzD,8BAAC,wBAAQ,IAAC,MAAM,EAAC,6BAA6B,EAAC,SAAS,EAAC,kBAAkB;gBACzE,uCAAK,SAAS,EAAC,4BAA4B;oBACzC,8BAAC,oBAAI,IAAC,OAAO,EAAC,OAAO,EAAC,EAAE,EAAC,OAAO,EAAC,SAAS,EAAC,kBAAkB,6CAEtD,CACH;gBACN,8BAAC,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;AAtFW,QAAA,wBAAwB,4BAsFnC","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 { CalculatedPropertyType, Group , Property} from \"@itwin/insights-client\";\nimport { DataType } from \"@itwin/insights-client\";\nimport { SharedCalculatedPropertyForms } from \"./SharedCalculatedPropertyForms\";\nimport { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { usePropertiesClient } from \"../../context/PropertiesClientContext\";\n\n/**\n * Props for the {@link CalculatedPropertyAction} component.\n * @public\n */\nexport interface CalculatedPropertyActionProps {\n mappingId: string;\n group: Group;\n calculatedProperty?: Property;\n onSaveSuccess: () => void;\n onClickCancel?: () => void;\n}\n\n/**\n * Component to create or update a calculated property.\n * @public\n */\nexport const CalculatedPropertyAction = ({\n mappingId,\n group,\n calculatedProperty,\n onSaveSuccess,\n onClickCancel,\n}: CalculatedPropertyActionProps) => {\n const { getAccessToken, iModelId } = useGroupingMappingApiConfig();\n const propertiesClient = usePropertiesClient();\n const [propertyName, setPropertyName] = useState<string>(\n calculatedProperty?.propertyName ?? \"\",\n );\n const [type, setType] = useState<CalculatedPropertyType | undefined>(calculatedProperty?.calculatedPropertyType ?? undefined);\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 ? propertiesClient.updateProperty(\n accessToken,\n mappingId,\n group.id,\n calculatedProperty.id,\n {\n ...calculatedProperty,\n propertyName,\n dataType: calculatedProperty.dataType,\n calculatedPropertyType: type,\n },\n )\n : propertiesClient.createProperty(\n accessToken,\n mappingId,\n group.id,\n {\n propertyName,\n dataType: DataType.Double,\n calculatedPropertyType: type,\n },\n );\n }, {\n onSuccess: async () => {\n await queryClient.invalidateQueries({ queryKey: [\"properties\", iModelId, mappingId, group.id] });\n onSaveSuccess();\n setPropertyName(\"\");\n setType(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.d.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import "./CalculatedPropertyActionWithVisuals.scss";
|
|
3
|
-
import type {
|
|
3
|
+
import type { GroupMinimal, Property } from "@itwin/insights-client";
|
|
4
|
+
/**
|
|
5
|
+
* Props for the {@link CalculatedPropertyActionWithVisuals} component.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
4
8
|
export interface CalculatedPropertyActionWithVisualsProps {
|
|
5
9
|
mappingId: string;
|
|
6
|
-
group:
|
|
7
|
-
calculatedProperty?:
|
|
10
|
+
group: GroupMinimal;
|
|
11
|
+
calculatedProperty?: Property;
|
|
8
12
|
onSaveSuccess: () => void;
|
|
9
13
|
onClickCancel?: () => void;
|
|
10
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Component to create or update a calculated property with visualizations.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
11
19
|
export declare const CalculatedPropertyActionWithVisuals: ({ mappingId, group, calculatedProperty, onSaveSuccess, onClickCancel, }: CalculatedPropertyActionWithVisualsProps) => JSX.Element;
|
|
12
20
|
//# sourceMappingURL=CalculatedPropertyActionWithVisuals.d.ts.map
|
package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js
CHANGED
|
@@ -39,20 +39,24 @@ const BboxDimensionsDecorator_1 = require("../../../decorators/BboxDimensionsDec
|
|
|
39
39
|
const useValidator_1 = __importDefault(require("../hooks/useValidator"));
|
|
40
40
|
const viewerUtils_1 = require("../../../common/viewerUtils");
|
|
41
41
|
require("./CalculatedPropertyActionWithVisuals.scss");
|
|
42
|
-
const MappingClientContext_1 = require("../../context/MappingClientContext");
|
|
43
42
|
const GroupingApiConfigContext_1 = require("../../context/GroupingApiConfigContext");
|
|
44
43
|
const insights_client_1 = require("@itwin/insights-client");
|
|
45
44
|
const SharedCalculatedPropertyForms_1 = require("./SharedCalculatedPropertyForms");
|
|
46
45
|
const useKeySetHiliteQueries_1 = require("../../Groups/hooks/useKeySetHiliteQueries");
|
|
47
46
|
const react_query_1 = require("@tanstack/react-query");
|
|
47
|
+
const PropertiesClientContext_1 = require("../../context/PropertiesClientContext");
|
|
48
|
+
/**
|
|
49
|
+
* Component to create or update a calculated property with visualizations.
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
48
52
|
const CalculatedPropertyActionWithVisuals = ({ mappingId, group, calculatedProperty, onSaveSuccess, onClickCancel, }) => {
|
|
49
53
|
const { getAccessToken, iModelId, iModelConnection } = (0, GroupingApiConfigContext_1.useGroupingMappingApiConfig)();
|
|
50
54
|
if (!iModelConnection) {
|
|
51
55
|
throw new Error("This component requires an active iModelConnection.");
|
|
52
56
|
}
|
|
53
|
-
const
|
|
57
|
+
const propertiesClient = (0, PropertiesClientContext_1.usePropertiesClient)();
|
|
54
58
|
const [propertyName, setPropertyName] = (0, react_1.useState)(calculatedProperty?.propertyName ?? "");
|
|
55
|
-
const [type, setType] = (0, react_1.useState)(calculatedProperty?.
|
|
59
|
+
const [type, setType] = (0, react_1.useState)(calculatedProperty?.calculatedPropertyType);
|
|
56
60
|
const [bboxDecorator, setBboxDecorator] = (0, react_1.useState)();
|
|
57
61
|
const [inferredSpatialData, setInferredSpatialData] = (0, react_1.useState)();
|
|
58
62
|
const [validator, showValidationMessage] = (0, useValidator_1.default)();
|
|
@@ -100,14 +104,22 @@ const CalculatedPropertyActionWithVisuals = ({ mappingId, group, calculatedPrope
|
|
|
100
104
|
const { mutate: saveMutation, isLoading } = (0, react_query_1.useMutation)(async (type) => {
|
|
101
105
|
const accessToken = await getAccessToken();
|
|
102
106
|
return calculatedProperty
|
|
103
|
-
?
|
|
104
|
-
|
|
107
|
+
? propertiesClient.updateProperty(accessToken, mappingId, group.id, calculatedProperty.id, {
|
|
108
|
+
propertyName,
|
|
109
|
+
dataType: calculatedProperty.dataType,
|
|
110
|
+
calculatedPropertyType: type,
|
|
111
|
+
})
|
|
112
|
+
: propertiesClient.createProperty(accessToken, mappingId, group.id, {
|
|
113
|
+
propertyName,
|
|
114
|
+
dataType: insights_client_1.DataType.Double,
|
|
115
|
+
calculatedPropertyType: type,
|
|
116
|
+
});
|
|
105
117
|
}, {
|
|
106
118
|
onSuccess: async () => {
|
|
107
|
-
await queryClient.invalidateQueries({ queryKey: ["
|
|
119
|
+
await queryClient.invalidateQueries({ queryKey: ["properties", iModelId, mappingId, group.id] });
|
|
108
120
|
onSaveSuccess();
|
|
109
121
|
setPropertyName("");
|
|
110
|
-
setType(
|
|
122
|
+
setType(undefined);
|
|
111
123
|
},
|
|
112
124
|
});
|
|
113
125
|
const onSave = () => {
|
|
@@ -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,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,G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AC,CAAC,IAAI,IAAI,YAAY,CAAC,EACzC,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAnKW,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"]}
|
|
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,qFAAqF;AACrF,4DAAkD;AAElD,mFAAgF;AAChF,sFAAgF;AAChF,uDAAoE;AACpE,mFAA4E;AAc5E;;;GAGG;AACI,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,gBAAgB,GAAG,IAAA,6CAAmB,GAAE,CAAC;IAC/C,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,sBAAsB,CAAC,CAAC;IACjH,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,IAAA,gBAAQ,GAAuC,CAAC;IAC1F,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GAAG,IAAA,gBAAQ,GAA0C,CAAC;IACzG,MAAM,CAAC,SAAS,EAAE,qBAAqB,CAAC,GAAG,IAAA,sBAAY,GAAE,CAAC;IAC1D,MAAM,CAAC,aAAa,EAAE,gBAAgB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AAC,CAAC,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;AAzKW,QAAA,mCAAmC,uCAyK9C","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 { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { DataType } from \"@itwin/insights-client\";\nimport type { CalculatedPropertyType, GroupMinimal, Property} from \"@itwin/insights-client\";\nimport { SharedCalculatedPropertyForms } from \"./SharedCalculatedPropertyForms\";\nimport { useGroupKeySetQuery } from \"../../Groups/hooks/useKeySetHiliteQueries\";\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { usePropertiesClient } from \"../../context/PropertiesClientContext\";\n\n/**\n * Props for the {@link CalculatedPropertyActionWithVisuals} component.\n * @public\n */\nexport interface CalculatedPropertyActionWithVisualsProps {\n mappingId: string;\n group: GroupMinimal;\n calculatedProperty?: Property;\n onSaveSuccess: () => void;\n onClickCancel?: () => void;\n}\n\n/**\n * Component to create or update a calculated property with visualizations.\n * @public\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 propertiesClient = usePropertiesClient();\n const [propertyName, setPropertyName] = useState<string>(\n calculatedProperty?.propertyName ?? \"\",\n );\n const [type, setType] = useState<CalculatedPropertyType | undefined>(calculatedProperty?.calculatedPropertyType);\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 ? propertiesClient.updateProperty(\n accessToken,\n mappingId,\n group.id,\n calculatedProperty.id,\n {\n propertyName,\n dataType: calculatedProperty.dataType,\n calculatedPropertyType: type,\n },\n )\n : propertiesClient.createProperty(\n accessToken,\n mappingId,\n group.id,\n {\n propertyName,\n dataType: DataType.Double,\n calculatedPropertyType: type,\n },\n );\n }, {\n onSuccess: async () => {\n await queryClient.invalidateQueries({ queryKey: [\"properties\", iModelId, mappingId, group.id] });\n onSaveSuccess();\n setPropertyName(\"\");\n setType(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"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
2
|
+
import type { Property } from "@itwin/insights-client";
|
|
3
3
|
import "./CalculatedPropertyTable.scss";
|
|
4
4
|
export interface CalculatedPropertyTableProps {
|
|
5
5
|
mappingId: string;
|
|
6
6
|
groupId: string;
|
|
7
7
|
onClickAdd?: () => void;
|
|
8
|
-
onClickModify?: (value:
|
|
8
|
+
onClickModify?: (value: Property) => void;
|
|
9
9
|
isLoading: boolean;
|
|
10
|
-
calculatedProperties:
|
|
10
|
+
calculatedProperties: Property[];
|
|
11
11
|
refresh: () => Promise<void>;
|
|
12
12
|
}
|
|
13
13
|
export declare const CalculatedPropertyTable: ({ mappingId, groupId, onClickAdd, onClickModify, isLoading, calculatedProperties, refresh, }: CalculatedPropertyTableProps) => JSX.Element;
|
|
@@ -31,14 +31,14 @@ exports.CalculatedPropertyTable = void 0;
|
|
|
31
31
|
const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
|
|
32
32
|
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
33
33
|
const react_1 = __importStar(require("react"));
|
|
34
|
-
const MappingClientContext_1 = require("../../context/MappingClientContext");
|
|
35
34
|
require("./CalculatedPropertyTable.scss");
|
|
36
35
|
const PropertyNameCell_1 = require("../PropertyNameCell");
|
|
37
36
|
const PropertyTable_1 = require("../PropertyTable");
|
|
38
37
|
const GroupingApiConfigContext_1 = require("../../context/GroupingApiConfigContext");
|
|
39
38
|
const react_query_1 = require("@tanstack/react-query");
|
|
39
|
+
const PropertiesClientContext_1 = require("../../context/PropertiesClientContext");
|
|
40
40
|
const CalculatedPropertyTable = ({ mappingId, groupId, onClickAdd, onClickModify, isLoading, calculatedProperties, refresh, }) => {
|
|
41
|
-
const
|
|
41
|
+
const propertiesClient = (0, PropertiesClientContext_1.usePropertiesClient)();
|
|
42
42
|
const { getAccessToken, iModelId } = (0, GroupingApiConfigContext_1.useGroupingMappingApiConfig)();
|
|
43
43
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
44
44
|
const columnsFactory = (0, react_1.useCallback)((handleShowDeleteModal) => [
|
|
@@ -75,9 +75,11 @@ const CalculatedPropertyTable = ({ mappingId, groupId, onClickAdd, onClickModify
|
|
|
75
75
|
const { mutateAsync: deleteProperty } = (0, react_query_1.useMutation)({
|
|
76
76
|
mutationFn: async (propertyId) => {
|
|
77
77
|
const accessToken = await getAccessToken();
|
|
78
|
-
await
|
|
78
|
+
await propertiesClient.deleteProperty(accessToken, mappingId, groupId, propertyId);
|
|
79
|
+
},
|
|
80
|
+
onSuccess: async () => {
|
|
81
|
+
await queryClient.invalidateQueries({ queryKey: ["properties", iModelId, mappingId, groupId] });
|
|
79
82
|
},
|
|
80
|
-
onSuccess: async () => queryClient.invalidateQueries({ queryKey: ["calculatedProperties", iModelId, mappingId, groupId] }),
|
|
81
83
|
});
|
|
82
84
|
return (react_1.default.createElement(PropertyTable_1.PropertyTable, { propertyType: "Calculated", columnsFactory: columnsFactory, data: calculatedProperties, isLoading: isLoading, onClickAdd: onClickAdd, refreshProperties: refresh, deleteProperty: deleteProperty }));
|
|
83
85
|
};
|
|
@@ -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,
|
|
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,0CAAwC;AACxC,0DAAuD;AACvD,oDAAiD;AACjD,qFAAqF;AACrF,uDAAoE;AACpE,mFAA4E;AAYrE,MAAM,uBAAuB,GAAG,CAAC,EACtC,SAAS,EACT,OAAO,EACP,UAAU,EACV,aAAa,EACb,SAAS,EACT,oBAAoB,EACpB,OAAO,GACsB,EAAE,EAAE;IACjC,MAAM,gBAAgB,GAAG,IAAA,6CAAmB,GAAE,CAAC;IAC/C,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,qBAAgD,EAAsB,EAAE,CAAC;QACxE;YACE,EAAE,EAAE,c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AAkB,EAAE,EAAE;YACvC,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAC;YAC3C,MAAM,gBAAgB,CAAC,cAAc,CACnC,WAAW,EACX,SAAS,EACT,OAAO,EACP,UAAU,CACX,CAAC;QACJ,CAAC;QACD,SAAS,EAAE,KAAK,IAAI,EAAE;YACpB,MAAM,WAAW,CAAC,iBAAiB,CAAC,EAAE,QAAQ,EAAE,CAAC,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;QAClG,CAAC;KACF,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;AAtGW,QAAA,uBAAuB,2BAsGlC","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 { Property } from \"@itwin/insights-client\";\nimport \"./CalculatedPropertyTable.scss\";\nimport { PropertyNameCell } from \"../PropertyNameCell\";\nimport { PropertyTable } from \"../PropertyTable\";\nimport { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { usePropertiesClient } from \"../../context/PropertiesClientContext\";\n\nexport interface CalculatedPropertyTableProps {\n mappingId: string;\n groupId: string;\n onClickAdd?: () => void;\n onClickModify?: (value: Property) => void;\n isLoading: boolean;\n calculatedProperties: Property[];\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 propertiesClient = usePropertiesClient();\n const { getAccessToken, iModelId } = useGroupingMappingApiConfig();\n const queryClient = useQueryClient();\n\n const columnsFactory = useCallback(\n (handleShowDeleteModal: (value: Property) => void): Column<Property>[] => [\n {\n id: \"propertyName\",\n Header: \"Calculated Property\",\n accessor: \"propertyName\",\n Cell: (value: CellProps<Property>) => (\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<Property>) => {\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 propertiesClient.deleteProperty(\n accessToken,\n mappingId,\n groupId,\n propertyId,\n );\n },\n onSuccess: async () => {\n await queryClient.invalidateQueries({ queryKey: [\"properties\", iModelId, mappingId, groupId] });\n },\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"]}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import "./CustomCalculationAction.scss";
|
|
3
|
-
import type {
|
|
3
|
+
import type { Property } from "@itwin/insights-client";
|
|
4
|
+
/**
|
|
5
|
+
* Props for the {@link CustomCalculationAction} component.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
4
8
|
export interface CustomCalculationActionProps {
|
|
5
9
|
mappingId: string;
|
|
6
10
|
groupId: string;
|
|
7
|
-
customCalculation?:
|
|
11
|
+
customCalculation?: Property;
|
|
8
12
|
onSaveSuccess: () => void;
|
|
9
13
|
onClickCancel?: () => void;
|
|
10
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Component to create or update a custom calculation property.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
11
19
|
export declare const CustomCalculationAction: ({ mappingId, groupId, customCalculation, onSaveSuccess, onClickCancel, }: CustomCalculationActionProps) => JSX.Element;
|
|
12
20
|
//# sourceMappingURL=CustomCalculationAction.d.ts.map
|
|
@@ -39,72 +39,90 @@ const utils_1 = require("../../../common/utils");
|
|
|
39
39
|
require("./CustomCalculationAction.scss");
|
|
40
40
|
const GroupPropertyAction_1 = require("../GroupProperties/GroupPropertyAction");
|
|
41
41
|
const useFormulaValidation_1 = require("../hooks/useFormulaValidation");
|
|
42
|
-
const MappingClientContext_1 = require("../../context/MappingClientContext");
|
|
43
42
|
const GroupingApiConfigContext_1 = require("../../context/GroupingApiConfigContext");
|
|
44
43
|
const insights_client_1 = require("@itwin/insights-client");
|
|
45
|
-
const
|
|
46
|
-
const useCustomCalculationsQuery_1 = require("../hooks/useCustomCalculationsQuery");
|
|
47
|
-
const useGroupPropertiesQuery_1 = require("../hooks/useGroupPropertiesQuery");
|
|
44
|
+
const usePropertiesQuery_1 = require("../hooks/usePropertiesQuery");
|
|
48
45
|
const react_query_1 = require("@tanstack/react-query");
|
|
46
|
+
const PropertiesClientContext_1 = require("../../context/PropertiesClientContext");
|
|
49
47
|
const stringToPossibleDataType = (str) => {
|
|
50
48
|
switch (str?.toLowerCase()) {
|
|
51
|
-
case "double":
|
|
52
|
-
case "
|
|
49
|
+
case "double": return "Double";
|
|
50
|
+
case "integer": return "Integer";
|
|
53
51
|
case "string": return "String";
|
|
54
52
|
case "boolean": return "Boolean";
|
|
55
53
|
default: return "Undefined";
|
|
56
54
|
}
|
|
57
55
|
};
|
|
58
|
-
const convertToPropertyMap = (
|
|
56
|
+
const convertToPropertyMap = (properties, selectedPropertyName) => {
|
|
59
57
|
const map = {};
|
|
60
58
|
const selectedLowerName = selectedPropertyName?.toLowerCase();
|
|
61
|
-
|
|
62
|
-
const lowerName = p.propertyName?.toLowerCase();
|
|
63
|
-
if (lowerName && lowerName !== selectedLowerName)
|
|
64
|
-
map[lowerName] = stringToPossibleDataType(p.dataType);
|
|
65
|
-
});
|
|
66
|
-
calculatedProperties.forEach((p) => {
|
|
67
|
-
const lowerName = p.propertyName?.toLowerCase();
|
|
68
|
-
if (lowerName)
|
|
69
|
-
map[lowerName] = "Number";
|
|
70
|
-
});
|
|
71
|
-
customCalculations.forEach((p) => {
|
|
59
|
+
properties.forEach((p) => {
|
|
72
60
|
const lowerName = p.propertyName?.toLowerCase();
|
|
73
61
|
if (lowerName && lowerName !== selectedLowerName)
|
|
74
62
|
map[lowerName] = stringToPossibleDataType(p.dataType);
|
|
75
63
|
});
|
|
76
64
|
return map;
|
|
77
65
|
};
|
|
66
|
+
const inferToPropertyDataType = (value) => {
|
|
67
|
+
switch (value) {
|
|
68
|
+
case "Double":
|
|
69
|
+
return insights_client_1.DataType.Double;
|
|
70
|
+
case "Integer":
|
|
71
|
+
return insights_client_1.DataType.Integer;
|
|
72
|
+
case "String":
|
|
73
|
+
return insights_client_1.DataType.String;
|
|
74
|
+
case "Boolean":
|
|
75
|
+
return insights_client_1.DataType.Boolean;
|
|
76
|
+
default:
|
|
77
|
+
return insights_client_1.DataType.String;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Component to create or update a custom calculation property.
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
78
84
|
const CustomCalculationAction = ({ mappingId, groupId, customCalculation, onSaveSuccess, onClickCancel, }) => {
|
|
79
85
|
const { getAccessToken, iModelId } = (0, GroupingApiConfigContext_1.useGroupingMappingApiConfig)();
|
|
80
|
-
const
|
|
86
|
+
const propertiesClient = (0, PropertiesClientContext_1.usePropertiesClient)();
|
|
81
87
|
const [propertyName, setPropertyName] = (0, react_1.useState)(customCalculation?.propertyName ?? "");
|
|
82
88
|
const [formula, setFormula] = (0, react_1.useState)(customCalculation?.formula ?? "");
|
|
83
|
-
const [quantityType, setQuantityType] = (0, react_1.useState)(customCalculation?.quantityType ??
|
|
89
|
+
const [quantityType, setQuantityType] = (0, react_1.useState)(customCalculation?.quantityType ?? undefined);
|
|
84
90
|
const [formulaErrorMessage, setFormulaErrorMessage] = (0, react_1.useState)("");
|
|
85
91
|
const [validator, showValidationMessage] = (0, useValidator_1.default)();
|
|
86
92
|
const [properties, setProperties] = (0, react_1.useState)({});
|
|
87
|
-
const { isValid, forceValidation } = (0, useFormulaValidation_1.useFormulaValidation)(propertyName.toLowerCase(), formula, properties, setFormulaErrorMessage);
|
|
93
|
+
const { isValid, forceValidation, inferredDataType } = (0, useFormulaValidation_1.useFormulaValidation)(propertyName.toLowerCase(), formula, properties, setFormulaErrorMessage);
|
|
88
94
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
89
|
-
const { data: groupProperties, isFetching: isLoadingGroupProperties } = (0,
|
|
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);
|
|
95
|
+
const { data: groupProperties, isFetching: isLoadingGroupProperties } = (0, usePropertiesQuery_1.usePropertiesQuery)(iModelId, mappingId, groupId, getAccessToken, propertiesClient);
|
|
92
96
|
(0, react_1.useEffect)(() => {
|
|
93
|
-
const propertiesMap = convertToPropertyMap(groupProperties ?? []
|
|
97
|
+
const propertiesMap = convertToPropertyMap(groupProperties?.properties ?? []);
|
|
94
98
|
setProperties(propertiesMap);
|
|
95
|
-
}, [
|
|
99
|
+
}, [groupProperties]);
|
|
96
100
|
const { mutate: saveMutation, isLoading: isSaving } = (0, react_query_1.useMutation)(async () => {
|
|
97
101
|
const accessToken = await getAccessToken();
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
102
|
+
if (customCalculation) {
|
|
103
|
+
return propertiesClient.updateProperty(accessToken, mappingId, groupId, customCalculation.id, {
|
|
104
|
+
propertyName,
|
|
105
|
+
dataType: customCalculation.dataType,
|
|
106
|
+
formula,
|
|
107
|
+
quantityType,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
if (inferredDataType) {
|
|
111
|
+
return propertiesClient.createProperty(accessToken, mappingId, groupId, {
|
|
112
|
+
propertyName,
|
|
113
|
+
dataType: inferToPropertyDataType(inferredDataType),
|
|
114
|
+
formula,
|
|
115
|
+
quantityType,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return;
|
|
101
119
|
}, {
|
|
102
120
|
onSuccess: async () => {
|
|
103
|
-
await queryClient.invalidateQueries({ queryKey: ["
|
|
121
|
+
await queryClient.invalidateQueries({ queryKey: ["properties", iModelId, mappingId, groupId] });
|
|
104
122
|
onSaveSuccess();
|
|
105
123
|
setPropertyName("");
|
|
106
124
|
setFormula("");
|
|
107
|
-
setQuantityType(
|
|
125
|
+
setQuantityType(undefined);
|
|
108
126
|
},
|
|
109
127
|
onError: async (error) => {
|
|
110
128
|
if (error.status === 422) {
|
|
@@ -129,7 +147,7 @@ const CustomCalculationAction = ({ mappingId, groupId, customCalculation, onSave
|
|
|
129
147
|
}
|
|
130
148
|
saveMutation();
|
|
131
149
|
};
|
|
132
|
-
const isLoading = isSaving || isLoadingGroupProperties
|
|
150
|
+
const isLoading = isSaving || isLoadingGroupProperties;
|
|
133
151
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
134
152
|
react_1.default.createElement("div", { className: 'gmw-custom-calculation-action-container' },
|
|
135
153
|
react_1.default.createElement(itwinui_react_1.Fieldset, { legend: 'Custom Calculation Details', className: 'gmw-details-form' },
|
|
@@ -145,13 +163,13 @@ const CustomCalculationAction = ({ mappingId, groupId, customCalculation, onSave
|
|
|
145
163
|
setPropertyName(event.target.value);
|
|
146
164
|
validator.showMessageFor("name");
|
|
147
165
|
} }),
|
|
148
|
-
react_1.default.createElement(itwinui_react_1.Alert, { type: 'informational', clickableText: 'Click here.', clickableTextProps: { href: "https://developer.bentley.com/apis/
|
|
166
|
+
react_1.default.createElement(itwinui_react_1.Alert, { type: 'informational', clickableText: 'Click here.', clickableTextProps: { href: "https://developer.bentley.com/apis/grouping-and-mapping/operations/create-property/#customcalculations", target: "_blank", rel: "noreferrer" } }, "To learn more about creating custom calculation formulas, view the documentation."),
|
|
149
167
|
react_1.default.createElement(itwinui_react_1.LabeledTextarea, { value: formula, required: true, name: 'formula', label: 'Formula', disabled: isLoading, onChange: (event) => {
|
|
150
168
|
setFormula(event.target.value);
|
|
151
169
|
}, message: formulaErrorMessage, status: formulaErrorMessage ? "negative" : undefined, onBlurCapture: () => {
|
|
152
170
|
forceValidation();
|
|
153
171
|
} }),
|
|
154
|
-
react_1.default.createElement(itwinui_react_1.LabeledSelect, { label: 'Quantity Type', disabled: isLoading, options: GroupPropertyAction_1.quantityTypesSelectionOptions, value: quantityType, onChange: setQuantityType, onShow: () => { }, onHide: () => { } }))),
|
|
172
|
+
react_1.default.createElement(itwinui_react_1.LabeledSelect, { label: 'Quantity Type', disabled: isLoading, options: GroupPropertyAction_1.quantityTypesSelectionOptions, value: quantityType, onChange: setQuantityType, onShow: () => { }, onHide: () => { }, placeholder: "No Quantity Type" }))),
|
|
155
173
|
react_1.default.createElement(ActionPanel_1.default, { onSave: onSave, onCancel: onClickCancel, isSavingDisabled: !(formula && propertyName && isValid), isLoading: isLoading })));
|
|
156
174
|
};
|
|
157
175
|
exports.CustomCalculationAction = CustomCalculationAction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomCalculationAction.js","sourceRoot":"","sources":["../../../../../src/components/Properties/CustomCalculations/CustomCalculationAction.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAO8B;AAC9B,+CAAmD;AACnD,qFAA6D;AAC7D,sEAAwE;AACxE,iDAAoD;AACpD,0CAAwC;AACxC,gFAAuF;AACvF,wEAAqE;AAErE,6EAAsE;AACtE,qFAAqF;AAErF,4DAAsD;AACtD,wFAAqF;AACrF,oFAAiF;AACjF,8EAA2E;AAC3E,uDAAoE;AAUpE,MAAM,wBAAwB,GAAG,CAAC,GAAY,EAAoB,EAAE;IAClE,QAAQ,GAAG,EAAE,WAAW,EAAE,EAAE;QAC1B,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC,CAAC,OAAO,QAAQ,CAAC;QAC/B,KAAK,QAAQ,CAAC,CAAC,OAAO,QAAQ,CAAC;QAC/B,KAAK,SAAS,CAAC,CAAC,OAAO,SAAS,CAAC;QACjC,OAAO,CAAC,CAAC,OAAO,WAAW,CAAC;KAC7B;AACH,CAAC,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAC3B,eAAgC,EAChC,oBAA0C,EAC1C,kBAAuC,EACvC,oBAA6B,EAChB,EAAE;IACf,MAAM,GAAG,GAAgB,EAAE,CAAC;IAC5B,MAAM,iBAAiB,GAAG,oBAAoB,EAAE,WAAW,EAAE,CAAC;IAE9D,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QAC5B,MAAM,SAAS,GAAG,CAAC,CAAC,YAA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uBAAuB,2BA+JlC","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 Alert,\n Fieldset,\n LabeledInput,\n LabeledSelect,\n LabeledTextarea,\n Text,\n} from \"@itwin/itwinui-react\";\nimport React, { useEffect, useState } from \"react\";\nimport ActionPanel from \"../../SharedComponents/ActionPanel\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError } from \"../../../common/utils\";\nimport \"./CustomCalculationAction.scss\";\nimport { quantityTypesSelectionOptions } from \"../GroupProperties/GroupPropertyAction\";\nimport { useFormulaValidation } from \"../hooks/useFormulaValidation\";\nimport type { PossibleDataType, PropertyMap } from \"../../../formula/Types\";\nimport { useMappingClient } from \"../../context/MappingClientContext\";\nimport { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport type { CalculatedProperty, CustomCalculation, GroupProperty } from \"@itwin/insights-client\";\nimport { QuantityType } from \"@itwin/insights-client\";\nimport { useCalculatedPropertiesQuery } from \"../hooks/useCalculatedPropertiesQuery\";\nimport { useCustomCalculationsQuery } from \"../hooks/useCustomCalculationsQuery\";\nimport { useGroupPropertiesQuery } from \"../hooks/useGroupPropertiesQuery\";\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\n\nexport interface CustomCalculationActionProps {\n mappingId: string;\n groupId: string;\n customCalculation?: CustomCalculation;\n onSaveSuccess: () => void;\n onClickCancel?: () => void;\n}\n\nconst stringToPossibleDataType = (str?: string): PossibleDataType => {\n switch (str?.toLowerCase()) {\n case \"double\":\n case \"number\": return \"Number\";\n case \"string\": return \"String\";\n case \"boolean\": return \"Boolean\";\n default: return \"Undefined\";\n }\n};\n\nconst convertToPropertyMap = (\n groupProperties: GroupProperty[],\n calculatedProperties: CalculatedProperty[],\n customCalculations: CustomCalculation[],\n selectedPropertyName?: string\n): PropertyMap => {\n const map: PropertyMap = {};\n const selectedLowerName = selectedPropertyName?.toLowerCase();\n\n groupProperties.forEach((p) => {\n const lowerName = p.propertyName?.toLowerCase();\n if (lowerName && lowerName !== selectedLowerName)\n map[lowerName] = stringToPossibleDataType(p.dataType);\n });\n\n calculatedProperties.forEach((p) => {\n const lowerName = p.propertyName?.toLowerCase();\n if (lowerName)\n map[lowerName] = \"Number\";\n });\n\n customCalculations.forEach((p) => {\n const lowerName = p.propertyName?.toLowerCase();\n if (lowerName && lowerName !== selectedLowerName)\n map[lowerName] = stringToPossibleDataType(p.dataType);\n });\n\n return map;\n};\n\nexport const CustomCalculationAction = ({\n mappingId,\n groupId,\n customCalculation,\n onSaveSuccess,\n onClickCancel,\n}: CustomCalculationActionProps) => {\n const { getAccessToken, iModelId } = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n const [propertyName, setPropertyName] = useState<string>(\n customCalculation?.propertyName ?? \"\",\n );\n const [formula, setFormula] = useState<string>(\n customCalculation?.formula ?? \"\",\n );\n const [quantityType, setQuantityType] = useState<QuantityType>(customCalculation?.quantityType ?? QuantityType.Undefined);\n const [formulaErrorMessage, setFormulaErrorMessage] = useState<string>(\"\");\n const [validator, showValidationMessage] = useValidator();\n const [properties, setProperties] = useState<PropertyMap>({});\n const { isValid, forceValidation } = useFormulaValidation(propertyName.toLowerCase(), formula, properties, setFormulaErrorMessage);\n const queryClient = useQueryClient();\n\n const { data: groupProperties, isFetching: isLoadingGroupProperties } = useGroupPropertiesQuery(iModelId, mappingId, groupId, getAccessToken, mappingClient);\n const { data: calculatedProperties, isFetching: isLoadingCalculatedProperties } = useCalculatedPropertiesQuery(iModelId, mappingId, groupId, getAccessToken, mappingClient);\n const { data: customCalculationProperties, isFetching: isLoadingCustomCalculations } = useCustomCalculationsQuery(iModelId, mappingId, groupId, getAccessToken, mappingClient);\n\n useEffect(() => {\n const propertiesMap = convertToPropertyMap(groupProperties ?? [], calculatedProperties ?? [], customCalculationProperties ?? []);\n setProperties(propertiesMap);\n }, [calculatedProperties, customCalculationProperties, groupProperties]);\n\n const { mutate: saveMutation, isLoading: isSaving } = useMutation(async () => {\n\n const accessToken = await getAccessToken();\n\n return customCalculation\n ? mappingClient.updateCustomCalculation(\n accessToken,\n iModelId,\n mappingId,\n groupId,\n customCalculation.id,\n { propertyName, formula, quantityType }\n )\n : mappingClient.createCustomCalculation(\n accessToken,\n iModelId,\n mappingId,\n groupId,\n { propertyName, formula, quantityType }\n );\n }, {\n onSuccess: async () => {\n await queryClient.invalidateQueries({ queryKey: [\"customCalculations\", iModelId, mappingId, groupId] });\n onSaveSuccess();\n setPropertyName(\"\");\n setFormula(\"\");\n setQuantityType(QuantityType.Undefined);\n },\n onError: async (error: any) => {\n if (error.status === 422) {\n const erroredResponse = await error.json();\n if (\n erroredResponse.error.code === \"InvalidInsightsRequest\" &&\n erroredResponse.error.target === \"formula\"\n ) {\n setFormulaErrorMessage(erroredResponse.error.message);\n }\n } else {\n handleError(error.status);\n }\n },\n });\n\n const onSave = () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n if (!forceValidation()) {\n return;\n }\n saveMutation();\n };\n\n const isLoading = isSaving || isLoadingGroupProperties || isLoadingCalculatedProperties || isLoadingCustomCalculations;\n\n return (\n <>\n <div className='gmw-custom-calculation-action-container'>\n <Fieldset legend='Custom Calculation Details' className='gmw-details-form'>\n <Text variant='small' as='small' className='gmw-field-legend'>\n Asterisk * indicates mandatory fields.\n </Text>\n <LabeledInput\n value={propertyName}\n required\n name='name'\n label='Name'\n disabled={isLoading}\n onChange={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n message={validator.message(\"name\", propertyName, NAME_REQUIREMENTS)}\n status={\n validator.message(\"name\", propertyName, NAME_REQUIREMENTS)\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"name\");\n }}\n onBlurCapture={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n />\n <Alert\n type='informational'\n clickableText='Click here.'\n clickableTextProps={{ href: \"https://developer.bentley.com/apis/insights/operations/create-customcalculation/\", target: \"_blank\", rel: \"noreferrer\" }}\n >\n To learn more about creating custom calculation formulas, view the documentation.\n </Alert>\n <LabeledTextarea\n value={formula}\n required\n name='formula'\n label='Formula'\n disabled={isLoading}\n onChange={(event) => {\n setFormula(event.target.value);\n }}\n message={formulaErrorMessage}\n status={formulaErrorMessage ? \"negative\" : undefined}\n onBlurCapture={() => {\n forceValidation();\n }}\n />\n <LabeledSelect<QuantityType>\n label='Quantity Type'\n disabled={isLoading}\n options={quantityTypesSelectionOptions}\n value={quantityType}\n onChange={setQuantityType}\n onShow={() => { }}\n onHide={() => { }}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={onClickCancel}\n isSavingDisabled={!(formula && propertyName && isValid)}\n isLoading={isLoading}\n />\n </>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"CustomCalculationAction.js","sourceRoot":"","sources":["../../../../../src/components/Properties/CustomCalculations/CustomCalculationAction.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAO8B;AAC9B,+CAAmD;AACnD,qFAA6D;AAC7D,sEAAwE;AACxE,iDAAoD;AACpD,0CAAwC;AACxC,gFAAuF;AACvF,wEAAqE;AAErE,qFAAqF;AAErF,4DAAkD;AAElD,oEAAiE;AACjE,uDAAoE;AACpE,mFAA4E;AAc5E,MAAM,wBAAwB,GAAG,CAAC,GAAY,EAAoB,EAAE;IAClE,QAAQ,GAAG,EAAE,WAAW,EAAE,EAAE;QAC1B,KAAK,QAAQ,CAAC,CAAC,OAAO,QAAQ,CAAC;QAC/B,KAAK,SAAS,CAAC,CAAC,OAAO,SAAS,CAAC;QACjC,KAAK,QAAQ,CAAC,CAAC,OAAO,QAAQ,CAAC;QAC/B,KAAK,SAAS,CAAC,CAAC,OAAO,SAAS,CAAC;QACjC,OA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SAAS,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;oBACnC,CAAC,GACD;gBACF,8BAAC,qBAAK,IACJ,IAAI,EAAC,eAAe,EACpB,aAAa,EAAC,aAAa,EAC3B,kBAAkB,EAAE,EAAE,IAAI,EAAE,wGAAwG,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,YAAY,EAAE,wFAGrK;gBACR,8BAAC,+BAAe,IACd,KAAK,EAAE,OAAO,EACd,QAAQ,QACR,IAAI,EAAC,SAAS,EACd,KAAK,EAAC,SAAS,EACf,QAAQ,EAAE,SAAS,EACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;wBAClB,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;oBACjC,CAAC,EACD,OAAO,EAAE,mBAAmB,EAC5B,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,EACpD,aAAa,EAAE,GAAG,EAAE;wBAClB,eAAe,EAAE,CAAC;oBACpB,CAAC,GACD;gBACF,8BAAC,6BAAa,IACZ,KAAK,EAAC,eAAe,EACrB,QAAQ,EAAE,SAAS,EACnB,OAAO,EAAE,mDAA6B,EACtC,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EACjB,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EACjB,WAAW,EAAG,kBAAkB,GAChC,CACO,CACP;QACN,8BAAC,qBAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,aAAa,EACvB,gBAAgB,EAAE,CAAC,CAAC,OAAO,IAAI,YAAY,IAAI,OAAO,CAAC,EACvD,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AA3KW,QAAA,uBAAuB,2BA2KlC","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 Alert,\n Fieldset,\n LabeledInput,\n LabeledSelect,\n LabeledTextarea,\n Text,\n} from \"@itwin/itwinui-react\";\nimport React, { useEffect, useState } from \"react\";\nimport ActionPanel from \"../../SharedComponents/ActionPanel\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError } from \"../../../common/utils\";\nimport \"./CustomCalculationAction.scss\";\nimport { quantityTypesSelectionOptions } from \"../GroupProperties/GroupPropertyAction\";\nimport { useFormulaValidation } from \"../hooks/useFormulaValidation\";\nimport type { PossibleDataType, PropertyMap } from \"../../../formula/Types\";\nimport { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport type { Property , QuantityType } from \"@itwin/insights-client\";\nimport { DataType } from \"@itwin/insights-client\";\nimport type { DataType as FormulaDataType } from \"../../../formula/Types\";\nimport { usePropertiesQuery } from \"../hooks/usePropertiesQuery\";\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { usePropertiesClient } from \"../../context/PropertiesClientContext\";\n\n/**\n * Props for the {@link CustomCalculationAction} component.\n * @public\n */\nexport interface CustomCalculationActionProps {\n mappingId: string;\n groupId: string;\n customCalculation?: Property;\n onSaveSuccess: () => void;\n onClickCancel?: () => void;\n}\n\nconst stringToPossibleDataType = (str?: string): PossibleDataType => {\n switch (str?.toLowerCase()) {\n case \"double\": return \"Double\";\n case \"integer\": return \"Integer\";\n case \"string\": return \"String\";\n case \"boolean\": return \"Boolean\";\n default: return \"Undefined\";\n }\n};\n\nconst convertToPropertyMap = (\n properties: Property[],\n selectedPropertyName?: string\n): PropertyMap => {\n const map: PropertyMap = {};\n const selectedLowerName = selectedPropertyName?.toLowerCase();\n\n properties.forEach((p) => {\n const lowerName = p.propertyName?.toLowerCase();\n if (lowerName && lowerName !== selectedLowerName)\n map[lowerName] = stringToPossibleDataType(p.dataType);\n });\n\n return map;\n};\n\nconst inferToPropertyDataType = (value: FormulaDataType): DataType => {\n switch(value){\n case \"Double\":\n return DataType.Double;\n case \"Integer\":\n return DataType.Integer;\n case \"String\":\n return DataType.String;\n case \"Boolean\":\n return DataType.Boolean;\n default:\n return DataType.String;\n }\n};\n\n/**\n * Component to create or update a custom calculation property.\n * @public\n */\nexport const CustomCalculationAction = ({\n mappingId,\n groupId,\n customCalculation,\n onSaveSuccess,\n onClickCancel,\n}: CustomCalculationActionProps) => {\n const { getAccessToken, iModelId } = useGroupingMappingApiConfig();\n const propertiesClient = usePropertiesClient();\n const [propertyName, setPropertyName] = useState<string>(\n customCalculation?.propertyName ?? \"\",\n );\n const [formula, setFormula] = useState<string>(\n customCalculation?.formula ?? \"\",\n );\n const [quantityType, setQuantityType] = useState<QuantityType | undefined>(customCalculation?.quantityType ?? undefined);\n const [formulaErrorMessage, setFormulaErrorMessage] = useState<string>(\"\");\n const [validator, showValidationMessage] = useValidator();\n const [properties, setProperties] = useState<PropertyMap>({});\n const { isValid, forceValidation, inferredDataType } = useFormulaValidation(propertyName.toLowerCase(), formula, properties, setFormulaErrorMessage);\n const queryClient = useQueryClient();\n\n const { data: groupProperties, isFetching: isLoadingGroupProperties } = usePropertiesQuery(iModelId, mappingId, groupId, getAccessToken, propertiesClient);\n\n useEffect(() => {\n const propertiesMap = convertToPropertyMap(groupProperties?.properties ?? []);\n setProperties(propertiesMap);\n }, [groupProperties]);\n\n const { mutate: saveMutation, isLoading: isSaving } = useMutation(async () => {\n\n const accessToken = await getAccessToken();\n\n if(customCalculation){\n return propertiesClient.updateProperty(\n accessToken,\n mappingId,\n groupId,\n customCalculation.id,\n {\n propertyName,\n dataType: customCalculation.dataType,\n formula,\n quantityType,\n }\n );\n }\n\n if(inferredDataType){\n return propertiesClient.createProperty(\n accessToken,\n mappingId,\n groupId,\n {\n propertyName,\n dataType: inferToPropertyDataType(inferredDataType),\n formula,\n quantityType,\n }\n );\n }\n return;\n }, {\n onSuccess: async () => {\n await queryClient.invalidateQueries({ queryKey: [\"properties\", iModelId, mappingId, groupId] });\n onSaveSuccess();\n setPropertyName(\"\");\n setFormula(\"\");\n setQuantityType(undefined);\n },\n onError: async (error: any) => {\n if (error.status === 422) {\n const erroredResponse = await error.json();\n if (\n erroredResponse.error.code === \"InvalidInsightsRequest\" &&\n erroredResponse.error.target === \"formula\"\n ) {\n setFormulaErrorMessage(erroredResponse.error.message);\n }\n } else {\n handleError(error.status);\n }\n },\n });\n\n const onSave = () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n if (!forceValidation()) {\n return;\n }\n saveMutation();\n };\n\n const isLoading = isSaving || isLoadingGroupProperties;\n\n return (\n <>\n <div className='gmw-custom-calculation-action-container'>\n <Fieldset legend='Custom Calculation Details' className='gmw-details-form'>\n <Text variant='small' as='small' className='gmw-field-legend'>\n Asterisk * indicates mandatory fields.\n </Text>\n <LabeledInput\n value={propertyName}\n required\n name='name'\n label='Name'\n disabled={isLoading}\n onChange={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n message={validator.message(\"name\", propertyName, NAME_REQUIREMENTS)}\n status={\n validator.message(\"name\", propertyName, NAME_REQUIREMENTS)\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"name\");\n }}\n onBlurCapture={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n />\n <Alert\n type='informational'\n clickableText='Click here.'\n clickableTextProps={{ href: \"https://developer.bentley.com/apis/grouping-and-mapping/operations/create-property/#customcalculations\", target: \"_blank\", rel: \"noreferrer\" }}\n >\n To learn more about creating custom calculation formulas, view the documentation.\n </Alert>\n <LabeledTextarea\n value={formula}\n required\n name='formula'\n label='Formula'\n disabled={isLoading}\n onChange={(event) => {\n setFormula(event.target.value);\n }}\n message={formulaErrorMessage}\n status={formulaErrorMessage ? \"negative\" : undefined}\n onBlurCapture={() => {\n forceValidation();\n }}\n />\n <LabeledSelect<QuantityType | undefined>\n label='Quantity Type'\n disabled={isLoading}\n options={quantityTypesSelectionOptions}\n value={quantityType}\n onChange={setQuantityType}\n onShow={() => { }}\n onHide={() => { }}\n placeholder = \"No Quantity Type\"\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={onClickCancel}\n isSavingDisabled={!(formula && propertyName && isValid)}\n isLoading={isLoading}\n />\n </>\n );\n};\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
2
|
+
import type { Property } from "@itwin/insights-client";
|
|
3
3
|
export interface CustomCalculationTableProps {
|
|
4
4
|
mappingId: string;
|
|
5
5
|
groupId: string;
|
|
6
6
|
onClickAdd?: () => void;
|
|
7
|
-
onClickModify?: (value:
|
|
7
|
+
onClickModify?: (value: Property) => void;
|
|
8
8
|
isLoading: boolean;
|
|
9
|
-
customCalculations:
|
|
9
|
+
customCalculations: Property[];
|
|
10
10
|
refresh: () => Promise<void>;
|
|
11
11
|
}
|
|
12
12
|
export declare const CustomCalculationTable: ({ mappingId, groupId, onClickAdd, onClickModify, isLoading, customCalculations, refresh, }: CustomCalculationTableProps) => JSX.Element;
|