@itwin/grouping-mapping-widget 0.2.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/LICENSE.md +9 -0
- package/README.md +26 -0
- package/lib/cjs/api/GroupQueryBuilderApi.d.ts +15 -0
- package/lib/cjs/api/GroupQueryBuilderApi.js +27 -0
- package/lib/cjs/api/GroupQueryBuilderApi.js.map +1 -0
- package/lib/cjs/api/generated/api.d.ts +3222 -0
- package/lib/cjs/api/generated/api.js +5291 -0
- package/lib/cjs/api/generated/api.js.map +1 -0
- package/lib/cjs/api/generated/configuration.d.ts +56 -0
- package/lib/cjs/api/generated/configuration.js +30 -0
- package/lib/cjs/api/generated/configuration.js.map +1 -0
- package/lib/cjs/api/generated/index.d.ts +14 -0
- package/lib/cjs/api/generated/index.js +31 -0
- package/lib/cjs/api/generated/index.js.map +1 -0
- package/lib/cjs/api/reportingClient.d.ts +34 -0
- package/lib/cjs/api/reportingClient.js +177 -0
- package/lib/cjs/api/reportingClient.js.map +1 -0
- package/lib/cjs/decorators/BboxDimensionsDecorator.d.ts +82 -0
- package/lib/cjs/decorators/BboxDimensionsDecorator.js +418 -0
- package/lib/cjs/decorators/BboxDimensionsDecorator.js.map +1 -0
- package/lib/cjs/grouping-mapping-widget.d.ts +7 -0
- package/lib/cjs/grouping-mapping-widget.js +27 -0
- package/lib/cjs/grouping-mapping-widget.js.map +1 -0
- package/lib/cjs/widget/GroupingMappingWidget.d.ts +7 -0
- package/lib/cjs/widget/GroupingMappingWidget.js +51 -0
- package/lib/cjs/widget/GroupingMappingWidget.js.map +1 -0
- package/lib/cjs/widget/components/ActionPanel.d.ts +11 -0
- package/lib/cjs/widget/components/ActionPanel.js +37 -0
- package/lib/cjs/widget/components/ActionPanel.js.map +1 -0
- package/lib/cjs/widget/components/ActionPanel.scss +12 -0
- package/lib/cjs/widget/components/CalculatedPropertyAction.d.ts +14 -0
- package/lib/cjs/widget/components/CalculatedPropertyAction.js +160 -0
- package/lib/cjs/widget/components/CalculatedPropertyAction.js.map +1 -0
- package/lib/cjs/widget/components/CalculatedPropertyAction.scss +27 -0
- package/lib/cjs/widget/components/CalculatedPropertyTable.d.ts +18 -0
- package/lib/cjs/widget/components/CalculatedPropertyTable.js +109 -0
- package/lib/cjs/widget/components/CalculatedPropertyTable.js.map +1 -0
- package/lib/cjs/widget/components/ConfirmMappingsImport.d.ts +16 -0
- package/lib/cjs/widget/components/ConfirmMappingsImport.js +112 -0
- package/lib/cjs/widget/components/ConfirmMappingsImport.js.map +1 -0
- package/lib/cjs/widget/components/ConfirmMappingsImport.scss +84 -0
- package/lib/cjs/widget/components/CustomCalculationAction.d.ts +14 -0
- package/lib/cjs/widget/components/CustomCalculationAction.js +103 -0
- package/lib/cjs/widget/components/CustomCalculationAction.js.map +1 -0
- package/lib/cjs/widget/components/CustomCalculationAction.scss +16 -0
- package/lib/cjs/widget/components/CustomCalculationTable.d.ts +18 -0
- package/lib/cjs/widget/components/CustomCalculationTable.js +114 -0
- package/lib/cjs/widget/components/CustomCalculationTable.js.map +1 -0
- package/lib/cjs/widget/components/DeleteModal.d.ts +12 -0
- package/lib/cjs/widget/components/DeleteModal.js +64 -0
- package/lib/cjs/widget/components/DeleteModal.js.map +1 -0
- package/lib/cjs/widget/components/DeleteModal.scss +12 -0
- package/lib/cjs/widget/components/GroupAction.d.ts +12 -0
- package/lib/cjs/widget/components/GroupAction.js +166 -0
- package/lib/cjs/widget/components/GroupAction.js.map +1 -0
- package/lib/cjs/widget/components/GroupAction.scss +19 -0
- package/lib/cjs/widget/components/GroupPropertyAction.d.ts +17 -0
- package/lib/cjs/widget/components/GroupPropertyAction.js +372 -0
- package/lib/cjs/widget/components/GroupPropertyAction.js.map +1 -0
- package/lib/cjs/widget/components/GroupPropertyAction.scss +36 -0
- package/lib/cjs/widget/components/GroupPropertyTable.d.ts +18 -0
- package/lib/cjs/widget/components/GroupPropertyTable.js +109 -0
- package/lib/cjs/widget/components/GroupPropertyTable.js.map +1 -0
- package/lib/cjs/widget/components/GroupQueryBuilder.scss +24 -0
- package/lib/cjs/widget/components/GroupQueryBuilderContainer.d.ts +4 -0
- package/lib/cjs/widget/components/GroupQueryBuilderContainer.js +66 -0
- package/lib/cjs/widget/components/GroupQueryBuilderContainer.js.map +1 -0
- package/lib/cjs/widget/components/GroupQueryBuilderContext.d.ts +13 -0
- package/lib/cjs/widget/components/GroupQueryBuilderContext.js +37 -0
- package/lib/cjs/widget/components/GroupQueryBuilderContext.js.map +1 -0
- package/lib/cjs/widget/components/Grouping.d.ts +12 -0
- package/lib/cjs/widget/components/Grouping.js +214 -0
- package/lib/cjs/widget/components/Grouping.js.map +1 -0
- package/lib/cjs/widget/components/Grouping.scss +15 -0
- package/lib/cjs/widget/components/GroupingMapping.d.ts +5 -0
- package/lib/cjs/widget/components/GroupingMapping.js +34 -0
- package/lib/cjs/widget/components/GroupingMapping.js.map +1 -0
- package/lib/cjs/widget/components/GroupingMapping.scss +24 -0
- package/lib/cjs/widget/components/Mapping.d.ts +7 -0
- package/lib/cjs/widget/components/Mapping.js +162 -0
- package/lib/cjs/widget/components/Mapping.js.map +1 -0
- package/lib/cjs/widget/components/Mapping.scss +26 -0
- package/lib/cjs/widget/components/MappingAction.d.ts +11 -0
- package/lib/cjs/widget/components/MappingAction.js +98 -0
- package/lib/cjs/widget/components/MappingAction.js.map +1 -0
- package/lib/cjs/widget/components/MappingAction.scss +16 -0
- package/lib/cjs/widget/components/MappingImportWizardModal.d.ts +10 -0
- package/lib/cjs/widget/components/MappingImportWizardModal.js +102 -0
- package/lib/cjs/widget/components/MappingImportWizardModal.js.map +1 -0
- package/lib/cjs/widget/components/MappingImportWizardModal.scss +21 -0
- package/lib/cjs/widget/components/PropertyMenu.d.ts +24 -0
- package/lib/cjs/widget/components/PropertyMenu.js +141 -0
- package/lib/cjs/widget/components/PropertyMenu.js.map +1 -0
- package/lib/cjs/widget/components/PropertyMenu.scss +48 -0
- package/lib/cjs/widget/components/QueryBuilder.d.ts +39 -0
- package/lib/cjs/widget/components/QueryBuilder.js +345 -0
- package/lib/cjs/widget/components/QueryBuilder.js.map +1 -0
- package/lib/cjs/widget/components/SelectIModel.d.ts +12 -0
- package/lib/cjs/widget/components/SelectIModel.js +42 -0
- package/lib/cjs/widget/components/SelectIModel.js.map +1 -0
- package/lib/cjs/widget/components/SelectIModel.scss +20 -0
- package/lib/cjs/widget/components/SelectMapping.scss +17 -0
- package/lib/cjs/widget/components/SelectMappings.d.ts +12 -0
- package/lib/cjs/widget/components/SelectMappings.js +82 -0
- package/lib/cjs/widget/components/SelectMappings.js.map +1 -0
- package/lib/cjs/widget/components/SelectProject.d.ts +10 -0
- package/lib/cjs/widget/components/SelectProject.js +71 -0
- package/lib/cjs/widget/components/SelectProject.js.map +1 -0
- package/lib/cjs/widget/components/SelectProject.scss +38 -0
- package/lib/cjs/widget/components/property-grid/NonPrimitivePropertyRenderer.d.ts +33 -0
- package/lib/cjs/widget/components/property-grid/NonPrimitivePropertyRenderer.js +92 -0
- package/lib/cjs/widget/components/property-grid/NonPrimitivePropertyRenderer.js.map +1 -0
- package/lib/cjs/widget/components/property-grid/NonPrimitivePropertyRenderer.scss +16 -0
- package/lib/cjs/widget/components/property-grid/PrimitivePropertyRenderer.d.ts +26 -0
- package/lib/cjs/widget/components/property-grid/PrimitivePropertyRenderer.js +58 -0
- package/lib/cjs/widget/components/property-grid/PrimitivePropertyRenderer.js.map +1 -0
- package/lib/cjs/widget/components/property-grid/PropertyGrid.d.ts +67 -0
- package/lib/cjs/widget/components/property-grid/PropertyGrid.js +198 -0
- package/lib/cjs/widget/components/property-grid/PropertyGrid.js.map +1 -0
- package/lib/cjs/widget/components/property-grid/PropertyGrid.scss +71 -0
- package/lib/cjs/widget/components/property-grid/PropertyGridWrapper.d.ts +17 -0
- package/lib/cjs/widget/components/property-grid/PropertyGridWrapper.js +67 -0
- package/lib/cjs/widget/components/property-grid/PropertyGridWrapper.js.map +1 -0
- package/lib/cjs/widget/components/property-grid/PropertyList.d.ts +69 -0
- package/lib/cjs/widget/components/property-grid/PropertyList.js +87 -0
- package/lib/cjs/widget/components/property-grid/PropertyList.js.map +1 -0
- package/lib/cjs/widget/components/property-grid/PropertyRender.d.ts +92 -0
- package/lib/cjs/widget/components/property-grid/PropertyRender.js +111 -0
- package/lib/cjs/widget/components/property-grid/PropertyRender.js.map +1 -0
- package/lib/cjs/widget/components/property-grid/PropertyView.d.ts +20 -0
- package/lib/cjs/widget/components/property-grid/PropertyView.js +218 -0
- package/lib/cjs/widget/components/property-grid/PropertyView.js.map +1 -0
- package/lib/cjs/widget/components/property-grid/PropertyView.scss +111 -0
- package/lib/cjs/widget/components/utils.d.ts +14 -0
- package/lib/cjs/widget/components/utils.js +82 -0
- package/lib/cjs/widget/components/utils.js.map +1 -0
- package/lib/cjs/widget/components/utils.scss +36 -0
- package/lib/cjs/widget/components/viewerUtils.d.ts +9 -0
- package/lib/cjs/widget/components/viewerUtils.js +115 -0
- package/lib/cjs/widget/components/viewerUtils.js.map +1 -0
- package/lib/cjs/widget/hooks/useFetchAccessToken.d.ts +3 -0
- package/lib/cjs/widget/hooks/useFetchAccessToken.js +22 -0
- package/lib/cjs/widget/hooks/useFetchAccessToken.js.map +1 -0
- package/lib/cjs/widget/hooks/useValidator.d.ts +45 -0
- package/lib/cjs/widget/hooks/useValidator.js +53 -0
- package/lib/cjs/widget/hooks/useValidator.js.map +1 -0
- package/lib/cjs/widget/icons/DatabaseInfo.d.ts +5 -0
- package/lib/cjs/widget/icons/DatabaseInfo.js +19 -0
- package/lib/cjs/widget/icons/DatabaseInfo.js.map +1 -0
- package/lib/cjs/widget/icons/DatabaseInfo.scss +12 -0
- package/lib/cjs/widget/utils.d.ts +4 -0
- package/lib/cjs/widget/utils.js +3 -0
- package/lib/cjs/widget/utils.js.map +1 -0
- package/lib/esm/api/GroupQueryBuilderApi.d.ts +15 -0
- package/lib/esm/api/GroupQueryBuilderApi.js +23 -0
- package/lib/esm/api/GroupQueryBuilderApi.js.map +1 -0
- package/lib/esm/api/generated/api.d.ts +3222 -0
- package/lib/esm/api/generated/api.js +5248 -0
- package/lib/esm/api/generated/api.js.map +1 -0
- package/lib/esm/api/generated/configuration.d.ts +56 -0
- package/lib/esm/api/generated/configuration.js +26 -0
- package/lib/esm/api/generated/configuration.js.map +1 -0
- package/lib/esm/api/generated/index.d.ts +14 -0
- package/lib/esm/api/generated/index.js +19 -0
- package/lib/esm/api/generated/index.js.map +1 -0
- package/lib/esm/api/reportingClient.d.ts +34 -0
- package/lib/esm/api/reportingClient.js +173 -0
- package/lib/esm/api/reportingClient.js.map +1 -0
- package/lib/esm/decorators/BboxDimensionsDecorator.d.ts +82 -0
- package/lib/esm/decorators/BboxDimensionsDecorator.js +414 -0
- package/lib/esm/decorators/BboxDimensionsDecorator.js.map +1 -0
- package/lib/esm/grouping-mapping-widget.d.ts +7 -0
- package/lib/esm/grouping-mapping-widget.js +11 -0
- package/lib/esm/grouping-mapping-widget.js.map +1 -0
- package/lib/esm/widget/GroupingMappingWidget.d.ts +7 -0
- package/lib/esm/widget/GroupingMappingWidget.js +25 -0
- package/lib/esm/widget/GroupingMappingWidget.js.map +1 -0
- package/lib/esm/widget/components/ActionPanel.d.ts +11 -0
- package/lib/esm/widget/components/ActionPanel.js +16 -0
- package/lib/esm/widget/components/ActionPanel.js.map +1 -0
- package/lib/esm/widget/components/ActionPanel.scss +12 -0
- package/lib/esm/widget/components/CalculatedPropertyAction.d.ts +14 -0
- package/lib/esm/widget/components/CalculatedPropertyAction.js +136 -0
- package/lib/esm/widget/components/CalculatedPropertyAction.js.map +1 -0
- package/lib/esm/widget/components/CalculatedPropertyAction.scss +27 -0
- package/lib/esm/widget/components/CalculatedPropertyTable.d.ts +18 -0
- package/lib/esm/widget/components/CalculatedPropertyTable.js +85 -0
- package/lib/esm/widget/components/CalculatedPropertyTable.js.map +1 -0
- package/lib/esm/widget/components/ConfirmMappingsImport.d.ts +16 -0
- package/lib/esm/widget/components/ConfirmMappingsImport.js +91 -0
- package/lib/esm/widget/components/ConfirmMappingsImport.js.map +1 -0
- package/lib/esm/widget/components/ConfirmMappingsImport.scss +84 -0
- package/lib/esm/widget/components/CustomCalculationAction.d.ts +14 -0
- package/lib/esm/widget/components/CustomCalculationAction.js +79 -0
- package/lib/esm/widget/components/CustomCalculationAction.js.map +1 -0
- package/lib/esm/widget/components/CustomCalculationAction.scss +16 -0
- package/lib/esm/widget/components/CustomCalculationTable.d.ts +18 -0
- package/lib/esm/widget/components/CustomCalculationTable.js +90 -0
- package/lib/esm/widget/components/CustomCalculationTable.js.map +1 -0
- package/lib/esm/widget/components/DeleteModal.d.ts +12 -0
- package/lib/esm/widget/components/DeleteModal.js +41 -0
- package/lib/esm/widget/components/DeleteModal.js.map +1 -0
- package/lib/esm/widget/components/DeleteModal.scss +12 -0
- package/lib/esm/widget/components/GroupAction.d.ts +12 -0
- package/lib/esm/widget/components/GroupAction.js +142 -0
- package/lib/esm/widget/components/GroupAction.js.map +1 -0
- package/lib/esm/widget/components/GroupAction.scss +19 -0
- package/lib/esm/widget/components/GroupPropertyAction.d.ts +17 -0
- package/lib/esm/widget/components/GroupPropertyAction.js +347 -0
- package/lib/esm/widget/components/GroupPropertyAction.js.map +1 -0
- package/lib/esm/widget/components/GroupPropertyAction.scss +36 -0
- package/lib/esm/widget/components/GroupPropertyTable.d.ts +18 -0
- package/lib/esm/widget/components/GroupPropertyTable.js +85 -0
- package/lib/esm/widget/components/GroupPropertyTable.js.map +1 -0
- package/lib/esm/widget/components/GroupQueryBuilder.scss +24 -0
- package/lib/esm/widget/components/GroupQueryBuilderContainer.d.ts +4 -0
- package/lib/esm/widget/components/GroupQueryBuilderContainer.js +43 -0
- package/lib/esm/widget/components/GroupQueryBuilderContainer.js.map +1 -0
- package/lib/esm/widget/components/GroupQueryBuilderContext.d.ts +13 -0
- package/lib/esm/widget/components/GroupQueryBuilderContext.js +15 -0
- package/lib/esm/widget/components/GroupQueryBuilderContext.js.map +1 -0
- package/lib/esm/widget/components/Grouping.d.ts +12 -0
- package/lib/esm/widget/components/Grouping.js +188 -0
- package/lib/esm/widget/components/Grouping.js.map +1 -0
- package/lib/esm/widget/components/Grouping.scss +15 -0
- package/lib/esm/widget/components/GroupingMapping.d.ts +5 -0
- package/lib/esm/widget/components/GroupingMapping.js +13 -0
- package/lib/esm/widget/components/GroupingMapping.js.map +1 -0
- package/lib/esm/widget/components/GroupingMapping.scss +24 -0
- package/lib/esm/widget/components/Mapping.d.ts +7 -0
- package/lib/esm/widget/components/Mapping.js +136 -0
- package/lib/esm/widget/components/Mapping.js.map +1 -0
- package/lib/esm/widget/components/Mapping.scss +26 -0
- package/lib/esm/widget/components/MappingAction.d.ts +11 -0
- package/lib/esm/widget/components/MappingAction.js +74 -0
- package/lib/esm/widget/components/MappingAction.js.map +1 -0
- package/lib/esm/widget/components/MappingAction.scss +16 -0
- package/lib/esm/widget/components/MappingImportWizardModal.d.ts +10 -0
- package/lib/esm/widget/components/MappingImportWizardModal.js +76 -0
- package/lib/esm/widget/components/MappingImportWizardModal.js.map +1 -0
- package/lib/esm/widget/components/MappingImportWizardModal.scss +21 -0
- package/lib/esm/widget/components/PropertyMenu.d.ts +24 -0
- package/lib/esm/widget/components/PropertyMenu.js +115 -0
- package/lib/esm/widget/components/PropertyMenu.js.map +1 -0
- package/lib/esm/widget/components/PropertyMenu.scss +48 -0
- package/lib/esm/widget/components/QueryBuilder.d.ts +39 -0
- package/lib/esm/widget/components/QueryBuilder.js +341 -0
- package/lib/esm/widget/components/QueryBuilder.js.map +1 -0
- package/lib/esm/widget/components/SelectIModel.d.ts +12 -0
- package/lib/esm/widget/components/SelectIModel.js +18 -0
- package/lib/esm/widget/components/SelectIModel.js.map +1 -0
- package/lib/esm/widget/components/SelectIModel.scss +20 -0
- package/lib/esm/widget/components/SelectMapping.scss +17 -0
- package/lib/esm/widget/components/SelectMappings.d.ts +12 -0
- package/lib/esm/widget/components/SelectMappings.js +61 -0
- package/lib/esm/widget/components/SelectMappings.js.map +1 -0
- package/lib/esm/widget/components/SelectProject.d.ts +10 -0
- package/lib/esm/widget/components/SelectProject.js +47 -0
- package/lib/esm/widget/components/SelectProject.js.map +1 -0
- package/lib/esm/widget/components/SelectProject.scss +38 -0
- package/lib/esm/widget/components/property-grid/NonPrimitivePropertyRenderer.d.ts +33 -0
- package/lib/esm/widget/components/property-grid/NonPrimitivePropertyRenderer.js +69 -0
- package/lib/esm/widget/components/property-grid/NonPrimitivePropertyRenderer.js.map +1 -0
- package/lib/esm/widget/components/property-grid/NonPrimitivePropertyRenderer.scss +16 -0
- package/lib/esm/widget/components/property-grid/PrimitivePropertyRenderer.d.ts +26 -0
- package/lib/esm/widget/components/property-grid/PrimitivePropertyRenderer.js +35 -0
- package/lib/esm/widget/components/property-grid/PrimitivePropertyRenderer.js.map +1 -0
- package/lib/esm/widget/components/property-grid/PropertyGrid.d.ts +67 -0
- package/lib/esm/widget/components/property-grid/PropertyGrid.js +172 -0
- package/lib/esm/widget/components/property-grid/PropertyGrid.js.map +1 -0
- package/lib/esm/widget/components/property-grid/PropertyGrid.scss +71 -0
- package/lib/esm/widget/components/property-grid/PropertyGridWrapper.d.ts +17 -0
- package/lib/esm/widget/components/property-grid/PropertyGridWrapper.js +44 -0
- package/lib/esm/widget/components/property-grid/PropertyGridWrapper.js.map +1 -0
- package/lib/esm/widget/components/property-grid/PropertyList.d.ts +69 -0
- package/lib/esm/widget/components/property-grid/PropertyList.js +60 -0
- package/lib/esm/widget/components/property-grid/PropertyList.js.map +1 -0
- package/lib/esm/widget/components/property-grid/PropertyRender.d.ts +92 -0
- package/lib/esm/widget/components/property-grid/PropertyRender.js +88 -0
- package/lib/esm/widget/components/property-grid/PropertyRender.js.map +1 -0
- package/lib/esm/widget/components/property-grid/PropertyView.d.ts +20 -0
- package/lib/esm/widget/components/property-grid/PropertyView.js +195 -0
- package/lib/esm/widget/components/property-grid/PropertyView.js.map +1 -0
- package/lib/esm/widget/components/property-grid/PropertyView.scss +111 -0
- package/lib/esm/widget/components/utils.d.ts +14 -0
- package/lib/esm/widget/components/utils.js +72 -0
- package/lib/esm/widget/components/utils.js.map +1 -0
- package/lib/esm/widget/components/utils.scss +36 -0
- package/lib/esm/widget/components/viewerUtils.d.ts +9 -0
- package/lib/esm/widget/components/viewerUtils.js +106 -0
- package/lib/esm/widget/components/viewerUtils.js.map +1 -0
- package/lib/esm/widget/hooks/useFetchAccessToken.d.ts +3 -0
- package/lib/esm/widget/hooks/useFetchAccessToken.js +20 -0
- package/lib/esm/widget/hooks/useFetchAccessToken.js.map +1 -0
- package/lib/esm/widget/hooks/useValidator.d.ts +45 -0
- package/lib/esm/widget/hooks/useValidator.js +47 -0
- package/lib/esm/widget/hooks/useValidator.js.map +1 -0
- package/lib/esm/widget/icons/DatabaseInfo.d.ts +5 -0
- package/lib/esm/widget/icons/DatabaseInfo.js +14 -0
- package/lib/esm/widget/icons/DatabaseInfo.js.map +1 -0
- package/lib/esm/widget/icons/DatabaseInfo.scss +12 -0
- package/lib/esm/widget/utils.d.ts +4 -0
- package/lib/esm/widget/utils.js +2 -0
- package/lib/esm/widget/utils.js.map +1 -0
- package/package.json +116 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { Fieldset, LabeledInput, LabeledSelect, LabeledTextarea, Small, } from "@itwin/itwinui-react";
|
|
6
|
+
import React, { useState } from "react";
|
|
7
|
+
import { reportingClientApi } from "../../api/reportingClient";
|
|
8
|
+
import ActionPanel from "./ActionPanel";
|
|
9
|
+
import useValidator, { NAME_REQUIREMENTS } from "../hooks/useValidator";
|
|
10
|
+
import { WidgetHeader } from "./utils";
|
|
11
|
+
import "./CalculatedPropertyAction.scss";
|
|
12
|
+
import "./CustomCalculationAction.scss";
|
|
13
|
+
import { quantityTypesSelectionOptions } from "./GroupPropertyAction";
|
|
14
|
+
const CustomCalculationAction = ({ iModelId, mappingId, groupId, customCalculation, returnFn, }) => {
|
|
15
|
+
var _a, _b, _c, _d;
|
|
16
|
+
const [propertyName, setPropertyName] = useState((_a = customCalculation === null || customCalculation === void 0 ? void 0 : customCalculation.propertyName) !== null && _a !== void 0 ? _a : "");
|
|
17
|
+
const [formula, setFormula] = useState((_b = customCalculation === null || customCalculation === void 0 ? void 0 : customCalculation.formula) !== null && _b !== void 0 ? _b : "");
|
|
18
|
+
const [quantityType, setQuantityType] = useState((_c = customCalculation === null || customCalculation === void 0 ? void 0 : customCalculation.quantityType) !== null && _c !== void 0 ? _c : "Undefined");
|
|
19
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
20
|
+
const [formulaErrorMessage, setFormulaErrorMessage] = useState("");
|
|
21
|
+
const [validator, showValidationMessage] = useValidator();
|
|
22
|
+
const onSave = async () => {
|
|
23
|
+
var _a;
|
|
24
|
+
if (!validator.allValid()) {
|
|
25
|
+
showValidationMessage(true);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
setIsLoading(true);
|
|
30
|
+
const newCustomCalculation = {
|
|
31
|
+
propertyName,
|
|
32
|
+
formula,
|
|
33
|
+
quantityType,
|
|
34
|
+
};
|
|
35
|
+
customCalculation
|
|
36
|
+
? await reportingClientApi.updateCustomCalculation(iModelId, mappingId, groupId, (_a = customCalculation.id) !== null && _a !== void 0 ? _a : "", newCustomCalculation)
|
|
37
|
+
: await reportingClientApi.createCustomCalculation(iModelId, mappingId, groupId, newCustomCalculation);
|
|
38
|
+
await returnFn();
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
// error instanceof Response refuses to be true when it should be.
|
|
43
|
+
if (error.status === 422) {
|
|
44
|
+
error = error;
|
|
45
|
+
const erroredResponse = await error.json();
|
|
46
|
+
if (erroredResponse.error.code === "InvalidInsightsRequest" &&
|
|
47
|
+
erroredResponse.error.target === "formula") {
|
|
48
|
+
setFormulaErrorMessage(erroredResponse.error.message);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
setIsLoading(false);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
return (React.createElement(React.Fragment, null,
|
|
55
|
+
React.createElement(WidgetHeader, { title: customCalculation
|
|
56
|
+
? `${(_d = customCalculation === null || customCalculation === void 0 ? void 0 : customCalculation.propertyName) !== null && _d !== void 0 ? _d : ""}`
|
|
57
|
+
: "Create Custom Calculation", returnFn: returnFn }),
|
|
58
|
+
React.createElement("div", { className: 'custom-calculation-action-container' },
|
|
59
|
+
React.createElement(Fieldset, { legend: 'Custom Calculation Details', className: 'details-form' },
|
|
60
|
+
React.createElement(Small, { className: 'field-legend' }, "Asterisk * indicates mandatory fields."),
|
|
61
|
+
React.createElement(LabeledInput, { value: propertyName, required: true, name: 'name', label: 'Name', disabled: isLoading, onChange: (event) => {
|
|
62
|
+
setPropertyName(event.target.value);
|
|
63
|
+
validator.showMessageFor("name");
|
|
64
|
+
}, message: validator.message("name", propertyName, NAME_REQUIREMENTS), status: validator.message("name", propertyName, NAME_REQUIREMENTS)
|
|
65
|
+
? "negative"
|
|
66
|
+
: undefined, onBlur: () => {
|
|
67
|
+
validator.showMessageFor("name");
|
|
68
|
+
}, onBlurCapture: (event) => {
|
|
69
|
+
setPropertyName(event.target.value);
|
|
70
|
+
validator.showMessageFor("name");
|
|
71
|
+
} }),
|
|
72
|
+
React.createElement(LabeledTextarea, { value: formula, required: true, name: 'formula', label: 'Formula', disabled: isLoading, onChange: (event) => {
|
|
73
|
+
setFormula(event.target.value);
|
|
74
|
+
}, message: formulaErrorMessage, status: formulaErrorMessage ? "negative" : undefined }),
|
|
75
|
+
React.createElement(LabeledSelect, { label: 'Quantity Type', disabled: isLoading, options: quantityTypesSelectionOptions, value: quantityType, onChange: setQuantityType, onShow: () => { }, onHide: () => { } }))),
|
|
76
|
+
React.createElement(ActionPanel, { onSave: onSave, onCancel: returnFn, disabled: !(formula && propertyName), isLoading: isLoading })));
|
|
77
|
+
};
|
|
78
|
+
export default CustomCalculationAction;
|
|
79
|
+
//# sourceMappingURL=CustomCalculationAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomCalculationAction.js","sourceRoot":"","sources":["../../../../src/widget/components/CustomCalculationAction.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,eAAe,EACf,KAAK,GACN,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,YAAY,EAAE,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,iCAAiC,CAAC;AAGzC,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAUtE,MAAM,uBAAuB,GAAG,CAAC,EAC/B,QAAQ,EACR,SAAS,EACT,OAAO,EACP,iBAAiB,EACjB,QAAQ,GACsB,EAAE,EAAE;;IAClC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAC9C,MAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,YAAY,mCAAI,EAAE,CACtC,CAAC;IACF,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CACpC,MAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,OAAO,mCAAI,EAAE,CACjC,CAAC;IACF,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,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c,CAAC,MAAM,CAAC,CAAC;oBACnC,CAAC,GACD;gBACF,oBAAC,eAAe,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,GACpD;gBACF,oBAAC,aAAa,IACZ,KAAK,EAAC,eAAe,EACrB,QAAQ,EAAE,SAAS,EACnB,OAAO,EAAE,6BAA6B,EACtC,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EACjB,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,GACjB,CACO,CACP;QACN,oBAAC,WAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,CAAC,CAAC,OAAO,IAAI,YAAY,CAAC,EACpC,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,uBAAuB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport {\n Fieldset,\n LabeledInput,\n LabeledSelect,\n LabeledTextarea,\n Small,\n} from \"@itwin/itwinui-react\";\nimport React, { useState } from \"react\";\nimport { reportingClientApi } from \"../../api/reportingClient\";\nimport ActionPanel from \"./ActionPanel\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { WidgetHeader } from \"./utils\";\nimport \"./CalculatedPropertyAction.scss\";\nimport type { CustomCalculation } from \"./CustomCalculationTable\";\nimport type { CustomCalculationCreateReportingAPI } from \"../../api/generated/api\";\nimport \"./CustomCalculationAction.scss\";\nimport { quantityTypesSelectionOptions } from \"./GroupPropertyAction\";\n\ninterface CalculatedPropertyActionProps {\n iModelId: string;\n mappingId: string;\n groupId: string;\n customCalculation?: CustomCalculation;\n returnFn: () => Promise<void>;\n}\n\nconst CustomCalculationAction = ({\n iModelId,\n mappingId,\n groupId,\n customCalculation,\n returnFn,\n}: CalculatedPropertyActionProps) => {\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<string>(customCalculation?.quantityType ?? \"Undefined\");\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [formulaErrorMessage, setFormulaErrorMessage] = useState<string>(\"\");\n const [validator, showValidationMessage] = useValidator();\n\n const onSave = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n try {\n setIsLoading(true);\n\n const newCustomCalculation: CustomCalculationCreateReportingAPI = {\n propertyName,\n formula,\n quantityType,\n };\n\n customCalculation\n ? await reportingClientApi.updateCustomCalculation(\n iModelId,\n mappingId,\n groupId,\n customCalculation.id ?? \"\",\n newCustomCalculation,\n )\n : await reportingClientApi.createCustomCalculation(\n iModelId,\n mappingId,\n groupId,\n newCustomCalculation,\n );\n await returnFn();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // error instanceof Response refuses to be true when it should be.\n if (error.status === 422) {\n error = error as Response;\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 }\n setIsLoading(false);\n }\n };\n\n return (\n <>\n <WidgetHeader\n title={\n customCalculation\n ? `${customCalculation?.propertyName ?? \"\"}`\n : \"Create Custom Calculation\"\n }\n returnFn={returnFn}\n />\n <div className='custom-calculation-action-container'>\n <Fieldset legend='Custom Calculation Details' className='details-form'>\n <Small className='field-legend'>\n Asterisk * indicates mandatory fields.\n </Small>\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 <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 />\n <LabeledSelect<string>\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={returnFn}\n disabled={!(formula && propertyName)}\n isLoading={isLoading}\n />\n </>\n );\n};\n\nexport default CustomCalculationAction;\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
@import '~@itwin/itwinui-css/scss/variables';
|
|
6
|
+
|
|
7
|
+
.custom-calculation-action-container {
|
|
8
|
+
overflow-x: auto;
|
|
9
|
+
height: 100%;
|
|
10
|
+
|
|
11
|
+
.details-form {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
gap: $iui-baseline;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { CustomCalculationReportingAPI } from "../../api/generated/api";
|
|
3
|
+
import type { CreateTypeFromInterface } from "../utils";
|
|
4
|
+
import { PropertyMenuView } from "./PropertyMenu";
|
|
5
|
+
import type { CellProps } from "react-table";
|
|
6
|
+
export declare type CustomCalculation = CreateTypeFromInterface<CustomCalculationReportingAPI>;
|
|
7
|
+
interface CustomCalculationTableProps {
|
|
8
|
+
iModelId: string;
|
|
9
|
+
mappingId: string;
|
|
10
|
+
groupId: string;
|
|
11
|
+
setSelectedCustomCalculation: React.Dispatch<React.SetStateAction<CreateTypeFromInterface<CustomCalculationReportingAPI> | undefined>>;
|
|
12
|
+
setGroupModifyView: React.Dispatch<React.SetStateAction<PropertyMenuView>>;
|
|
13
|
+
onCustomCalculationModify: (value: CellProps<CustomCalculation>) => void;
|
|
14
|
+
selectedCustomCalculation?: CustomCalculation;
|
|
15
|
+
}
|
|
16
|
+
declare const CustomCalculationTable: ({ iModelId, mappingId, groupId, setSelectedCustomCalculation, setGroupModifyView, onCustomCalculationModify, selectedCustomCalculation, }: CustomCalculationTableProps) => JSX.Element;
|
|
17
|
+
export default CustomCalculationTable;
|
|
18
|
+
//# sourceMappingURL=CustomCalculationTable.d.ts.map
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { SvgAdd, SvgDelete, SvgEdit, SvgMore, } from "@itwin/itwinui-icons-react";
|
|
6
|
+
import { Button, DropdownMenu, IconButton, MenuItem, Table, } from "@itwin/itwinui-react";
|
|
7
|
+
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
8
|
+
import { reportingClientApi } from "../../api/reportingClient";
|
|
9
|
+
import { PropertyMenuView } from "./PropertyMenu";
|
|
10
|
+
import DeleteModal from "./DeleteModal";
|
|
11
|
+
const fetchCustomCalculations = async (setCustomCalculations, iModelId, mappingId, groupId, setIsLoading) => {
|
|
12
|
+
var _a;
|
|
13
|
+
try {
|
|
14
|
+
setIsLoading(true);
|
|
15
|
+
const customCalculations = await reportingClientApi.getCustomCalculations(iModelId, mappingId, groupId);
|
|
16
|
+
setCustomCalculations((_a = customCalculations.customCalculations) !== null && _a !== void 0 ? _a : []);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
// TODO Toaster
|
|
20
|
+
}
|
|
21
|
+
finally {
|
|
22
|
+
setIsLoading(false);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const useFetchCustomCalculations = (iModelId, mappingId, groupId, setIsLoading) => {
|
|
26
|
+
const [CustomCalculations, setCustomCalculations] = useState([]);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
void fetchCustomCalculations(setCustomCalculations, iModelId, mappingId, groupId, setIsLoading);
|
|
29
|
+
}, [groupId, iModelId, mappingId, setIsLoading]);
|
|
30
|
+
return [CustomCalculations, setCustomCalculations];
|
|
31
|
+
};
|
|
32
|
+
const CustomCalculationTable = ({ iModelId, mappingId, groupId, setSelectedCustomCalculation, setGroupModifyView, onCustomCalculationModify, selectedCustomCalculation, }) => {
|
|
33
|
+
var _a;
|
|
34
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
35
|
+
const [customCalculations, setCustomCalculations] = useFetchCustomCalculations(iModelId, mappingId, groupId, setIsLoading);
|
|
36
|
+
const [showCustomCalculationDeleteModal, setShowCustomCalculationDeleteModal,] = useState(false);
|
|
37
|
+
const refresh = useCallback(async () => {
|
|
38
|
+
setCustomCalculations([]);
|
|
39
|
+
await fetchCustomCalculations(setCustomCalculations, iModelId, mappingId, groupId, setIsLoading);
|
|
40
|
+
}, [groupId, iModelId, mappingId, setCustomCalculations]);
|
|
41
|
+
const CustomCalculationsColumns = useMemo(() => [
|
|
42
|
+
{
|
|
43
|
+
Header: "Table",
|
|
44
|
+
columns: [
|
|
45
|
+
{
|
|
46
|
+
id: "propertyName",
|
|
47
|
+
Header: "Calculated Property",
|
|
48
|
+
accessor: "propertyName",
|
|
49
|
+
Cell: (value) => (React.createElement("div", { className: 'iui-anchor', onClick: () => onCustomCalculationModify(value) }, value.row.original.propertyName)),
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: "formula",
|
|
53
|
+
Header: "Formula",
|
|
54
|
+
accessor: "formula",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: "dropdown",
|
|
58
|
+
Header: "",
|
|
59
|
+
width: 80,
|
|
60
|
+
Cell: (value) => {
|
|
61
|
+
return (React.createElement(DropdownMenu, { menuItems: (close) => [
|
|
62
|
+
React.createElement(MenuItem, { key: 0, onClick: () => onCustomCalculationModify(value), icon: React.createElement(SvgEdit, null) }, "Modify"),
|
|
63
|
+
React.createElement(MenuItem, { key: 1, onClick: () => {
|
|
64
|
+
setSelectedCustomCalculation(value.row.original);
|
|
65
|
+
setShowCustomCalculationDeleteModal(true);
|
|
66
|
+
close();
|
|
67
|
+
}, icon: React.createElement(SvgDelete, null) }, "Remove"),
|
|
68
|
+
] },
|
|
69
|
+
React.createElement(IconButton, { styleType: 'borderless' },
|
|
70
|
+
React.createElement(SvgMore, { style: {
|
|
71
|
+
width: "16px",
|
|
72
|
+
height: "16px",
|
|
73
|
+
} }))));
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
], [onCustomCalculationModify, setSelectedCustomCalculation]);
|
|
79
|
+
return (React.createElement(React.Fragment, null,
|
|
80
|
+
React.createElement(Button, { startIcon: React.createElement(SvgAdd, null), styleType: 'high-visibility', onClick: () => {
|
|
81
|
+
setGroupModifyView(PropertyMenuView.ADD_CUSTOM_CALCULATION);
|
|
82
|
+
} }, "Add Custom Calculation"),
|
|
83
|
+
React.createElement(Table, { data: customCalculations, density: 'extra-condensed', columns: CustomCalculationsColumns, emptyTableContent: 'No Custom Calculations', isSortable: true, isLoading: isLoading }),
|
|
84
|
+
React.createElement(DeleteModal, { entityName: (_a = selectedCustomCalculation === null || selectedCustomCalculation === void 0 ? void 0 : selectedCustomCalculation.propertyName) !== null && _a !== void 0 ? _a : "", show: showCustomCalculationDeleteModal, setShow: setShowCustomCalculationDeleteModal, onDelete: async () => {
|
|
85
|
+
var _a;
|
|
86
|
+
await reportingClientApi.deleteCustomCalculation(iModelId, mappingId, groupId, (_a = selectedCustomCalculation === null || selectedCustomCalculation === void 0 ? void 0 : selectedCustomCalculation.id) !== null && _a !== void 0 ? _a : "");
|
|
87
|
+
}, refresh: refresh })));
|
|
88
|
+
};
|
|
89
|
+
export default CustomCalculationTable;
|
|
90
|
+
//# sourceMappingURL=CustomCalculationTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomCalculationTable.js","sourceRoot":"","sources":["../../../../src/widget/components/CustomCalculationTable.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EACL,MAAM,EACN,SAAS,EACT,OAAO,EACP,OAAO,GACR,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,MAAM,EACN,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,KAAK,GACN,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,WAAW,MAAM,eAAe,CAAC;AAKxC,MAAM,uBAAuB,GAAG,KAAK,EACnC,qBAEC,EACD,QAAgB,EAChB,SAAiB,EACjB,OAAe,EACf,YAA2D,EAC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/*---------------------------------------------------------------------------------------------\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 SvgAdd,\n SvgDelete,\n SvgEdit,\n SvgMore,\n} from \"@itwin/itwinui-icons-react\";\nimport {\n Button,\n DropdownMenu,\n IconButton,\n MenuItem,\n Table,\n} from \"@itwin/itwinui-react\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport type { CustomCalculationReportingAPI } from \"../../api/generated/api\";\nimport { reportingClientApi } from \"../../api/reportingClient\";\nimport type { CreateTypeFromInterface } from \"../utils\";\nimport { PropertyMenuView } from \"./PropertyMenu\";\nimport type { CellProps } from \"react-table\";\nimport DeleteModal from \"./DeleteModal\";\n\nexport type CustomCalculation =\n CreateTypeFromInterface<CustomCalculationReportingAPI>;\n\nconst fetchCustomCalculations = async (\n setCustomCalculations: React.Dispatch<\n React.SetStateAction<CustomCalculation[]>\n >,\n iModelId: string,\n mappingId: string,\n groupId: string,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,\n) => {\n try {\n setIsLoading(true);\n const customCalculations = await reportingClientApi.getCustomCalculations(\n iModelId,\n mappingId,\n groupId,\n );\n setCustomCalculations(customCalculations.customCalculations ?? []);\n } catch {\n // TODO Toaster\n } finally {\n setIsLoading(false);\n }\n};\n\nconst useFetchCustomCalculations = (\n iModelId: string,\n mappingId: string,\n groupId: string,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,\n): [\n CustomCalculation[],\n React.Dispatch<React.SetStateAction<CustomCalculation[]>>,\n] => {\n const [CustomCalculations, setCustomCalculations] = useState<\n CustomCalculation[]\n >([]);\n\n useEffect(() => {\n void fetchCustomCalculations(\n setCustomCalculations,\n iModelId,\n mappingId,\n groupId,\n setIsLoading,\n );\n }, [groupId, iModelId, mappingId, setIsLoading]);\n\n return [CustomCalculations, setCustomCalculations];\n};\n\ninterface CustomCalculationTableProps {\n iModelId: string;\n mappingId: string;\n groupId: string;\n\n setSelectedCustomCalculation: React.Dispatch<\n React.SetStateAction<\n CreateTypeFromInterface<CustomCalculationReportingAPI> | undefined\n >\n >;\n setGroupModifyView: React.Dispatch<React.SetStateAction<PropertyMenuView>>;\n onCustomCalculationModify: (value: CellProps<CustomCalculation>) => void;\n selectedCustomCalculation?: CustomCalculation;\n}\n\nconst CustomCalculationTable = ({\n iModelId,\n mappingId,\n groupId,\n setSelectedCustomCalculation,\n setGroupModifyView,\n onCustomCalculationModify,\n selectedCustomCalculation,\n}: CustomCalculationTableProps) => {\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [customCalculations, setCustomCalculations] =\n useFetchCustomCalculations(iModelId, mappingId, groupId, setIsLoading);\n const [\n showCustomCalculationDeleteModal,\n setShowCustomCalculationDeleteModal,\n ] = useState<boolean>(false);\n\n const refresh = useCallback(async () => {\n setCustomCalculations([]);\n await fetchCustomCalculations(\n setCustomCalculations,\n iModelId,\n mappingId,\n groupId,\n setIsLoading,\n );\n }, [groupId, iModelId, mappingId, setCustomCalculations]);\n\n const CustomCalculationsColumns = useMemo(\n () => [\n {\n Header: \"Table\",\n columns: [\n {\n id: \"propertyName\",\n Header: \"Calculated Property\",\n accessor: \"propertyName\",\n Cell: (value: CellProps<CustomCalculation>) => (\n <div\n className='iui-anchor'\n onClick={() => onCustomCalculationModify(value)}\n >\n {value.row.original.propertyName}\n </div>\n ),\n },\n {\n id: \"formula\",\n Header: \"Formula\",\n accessor: \"formula\",\n },\n {\n id: \"dropdown\",\n Header: \"\",\n width: 80,\n Cell: (value: CellProps<CustomCalculation>) => {\n return (\n <DropdownMenu\n menuItems={(close: () => void) => [\n <MenuItem\n key={0}\n onClick={() => onCustomCalculationModify(value)}\n icon={<SvgEdit />}\n >\n Modify\n </MenuItem>,\n <MenuItem\n key={1}\n onClick={() => {\n setSelectedCustomCalculation(value.row.original);\n setShowCustomCalculationDeleteModal(true);\n close();\n }}\n icon={<SvgDelete />}\n >\n Remove\n </MenuItem>,\n ]}\n >\n <IconButton styleType='borderless'>\n <SvgMore\n style={{\n width: \"16px\",\n height: \"16px\",\n }}\n />\n </IconButton>\n </DropdownMenu>\n );\n },\n },\n ],\n },\n ],\n [onCustomCalculationModify, setSelectedCustomCalculation],\n );\n\n return (\n <>\n <Button\n startIcon={<SvgAdd />}\n styleType='high-visibility'\n onClick={() => {\n setGroupModifyView(PropertyMenuView.ADD_CUSTOM_CALCULATION);\n }}\n >\n Add Custom Calculation\n </Button>\n <Table<CustomCalculation>\n data={customCalculations}\n density='extra-condensed'\n columns={CustomCalculationsColumns}\n emptyTableContent='No Custom Calculations'\n isSortable\n isLoading={isLoading}\n />\n\n <DeleteModal\n entityName={selectedCustomCalculation?.propertyName ?? \"\"}\n show={showCustomCalculationDeleteModal}\n setShow={setShowCustomCalculationDeleteModal}\n onDelete={async () => {\n await reportingClientApi.deleteCustomCalculation(\n iModelId,\n mappingId,\n groupId,\n selectedCustomCalculation?.id ?? \"\",\n );\n }}\n refresh={refresh}\n />\n </>\n );\n};\n\nexport default CustomCalculationTable;\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "./DeleteModal.scss";
|
|
3
|
+
export interface DeleteModalProps {
|
|
4
|
+
entityName: string;
|
|
5
|
+
show: boolean;
|
|
6
|
+
setShow: React.Dispatch<React.SetStateAction<boolean>>;
|
|
7
|
+
onDelete: () => Promise<void>;
|
|
8
|
+
refresh: () => Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export declare const DeleteModal: ({ entityName, show, setShow, onDelete, refresh, }: DeleteModalProps) => JSX.Element;
|
|
11
|
+
export default DeleteModal;
|
|
12
|
+
//# sourceMappingURL=DeleteModal.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { Button, IconButton, Leading, MiddleTextTruncation, Modal, ModalButtonBar, ProgressRadial, } from "@itwin/itwinui-react";
|
|
6
|
+
import React, { useState } from "react";
|
|
7
|
+
import "./DeleteModal.scss";
|
|
8
|
+
export const DeleteModal = ({ entityName, show, setShow, onDelete, refresh, }) => {
|
|
9
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
10
|
+
const deleteCallback = async () => {
|
|
11
|
+
try {
|
|
12
|
+
setIsLoading(true);
|
|
13
|
+
await onDelete();
|
|
14
|
+
setShow(false);
|
|
15
|
+
await refresh();
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
// toaster.negative(`${err.response?.data ?? 'Failed to revoke key.'}`, {
|
|
19
|
+
// hasCloseButton: true,
|
|
20
|
+
// });
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
setIsLoading(false);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
return (React.createElement(React.Fragment, null,
|
|
27
|
+
React.createElement(Modal, { title: 'Confirm', modalRootId: 'grouping-mapping-widget', isOpen: show, isDismissible: !isLoading, onClose: () => {
|
|
28
|
+
setShow(false);
|
|
29
|
+
} },
|
|
30
|
+
React.createElement("div", { className: "delete-modal-body-text" },
|
|
31
|
+
React.createElement(Leading, null, "Are you sure you want to delete"),
|
|
32
|
+
React.createElement("strong", null, React.createElement(MiddleTextTruncation, { text: `${entityName}?` }))),
|
|
33
|
+
React.createElement(ModalButtonBar, null,
|
|
34
|
+
isLoading ? (React.createElement(IconButton, { styleType: 'high-visibility' },
|
|
35
|
+
React.createElement(ProgressRadial, { size: "small", indeterminate: true }))) : (React.createElement(Button, { styleType: 'high-visibility', onClick: deleteCallback }, "Delete")),
|
|
36
|
+
React.createElement(Button, { styleType: 'default', onClick: () => {
|
|
37
|
+
setShow(false);
|
|
38
|
+
}, disabled: isLoading }, "Cancel")))));
|
|
39
|
+
};
|
|
40
|
+
export default DeleteModal;
|
|
41
|
+
//# sourceMappingURL=DeleteModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeleteModal.js","sourceRoot":"","sources":["../../../../src/widget/components/DeleteModal.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EACL,MAAM,EACN,UAAU,EACV,OAAO,EACP,oBAAoB,EACpB,KAAK,EACL,cAAc,EACd,cAAc,GACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,oBAAoB,CAAC;AAU5B,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAC1B,UAAU,EACV,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,OAAO,GACU,EAAE,EAAE;IACrB,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IAE3D,MAAM,cAAc,GAAG,KAAK,IAAI,EAAE;QAChC,IAAI;YACF,YAAY,CAAC,IAAI,CAAC,CAAC;YACnB,MAAM,QAAQ,EAAE,CAAC;YACjB,OAAO,CAAC,KAAK,CAAC,CAAC;YACf,MAAM,OAAO,EAAE,CAAC;SACjB;QAAC,OAAO,GAAG,EAAE;YACZ,yEAAyE;YACzE,0BAA0B;YAC1B,MAAM;SACP;gBAAS;YACR,YAAY,CAAC,KAAK,CAAC,CAAC;SACrB;IACH,CAAC,CAAC;IAEF,OAAO,CACL;QACE,oBAAC,KAAK,IACJ,KAAK,EAAC,SAAS,EACf,WAAW,EAAC,yBAAyB,EACrC,MAAM,EAAE,IAAI,EACZ,aAAa,EAAE,CAAC,SAAS,EACzB,OAAO,EAAE,GAAG,EAAE;gBACZ,OAAO,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC;YAED,6BAAK,SAAS,EAAC,wBAAwB;gBACrC,oBAAC,OAAO,0CAEE;gBACV,oCACG,oBAAC,oBAAoB,IAAC,IAAI,EAAE,GAAG,UAAU,GAAG,GAAI,CAC1C,CACL;YACN,oBAAC,cAAc;gBACZ,SAAS,CAAC,CAAC,CAAC,CACX,oBAAC,UAAU,IAAC,SAAS,EAAC,iBAAiB;oBACrC,oBAAC,cAAc,IAAC,IAAI,EAAC,OAAO,EAAC,aAAa,SAAG,CAClC,CACd,CAAC,CAAC,CAAC,CACF,oBAAC,MAAM,IAAC,SAAS,EAAC,iBAAiB,EAAC,OAAO,EAAE,cAAc,aAElD,CACV;gBACD,oBAAC,MAAM,IACL,SAAS,EAAC,SAAS,EACnB,OAAO,EAAE,GAAG,EAAE;wBACZ,OAAO,CAAC,KAAK,CAAC,CAAC;oBACjB,CAAC,EACD,QAAQ,EAAE,SAAS,aAGZ,CACM,CACX,CACP,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport {\n Button,\n IconButton,\n Leading,\n MiddleTextTruncation,\n Modal,\n ModalButtonBar,\n ProgressRadial,\n} from \"@itwin/itwinui-react\";\nimport React, { useState } from \"react\";\nimport \"./DeleteModal.scss\";\n\nexport interface DeleteModalProps {\n entityName: string;\n show: boolean;\n setShow: React.Dispatch<React.SetStateAction<boolean>>;\n onDelete: () => Promise<void>;\n refresh: () => Promise<void>;\n}\n\nexport const DeleteModal = ({\n entityName,\n show,\n setShow,\n onDelete,\n refresh,\n}: DeleteModalProps) => {\n const [isLoading, setIsLoading] = useState<boolean>(false);\n\n const deleteCallback = async () => {\n try {\n setIsLoading(true);\n await onDelete();\n setShow(false);\n await refresh();\n } catch (err) {\n // toaster.negative(`${err.response?.data ?? 'Failed to revoke key.'}`, {\n // hasCloseButton: true,\n // });\n } finally {\n setIsLoading(false);\n }\n };\n\n return (\n <>\n <Modal\n title='Confirm'\n modalRootId='grouping-mapping-widget'\n isOpen={show}\n isDismissible={!isLoading}\n onClose={() => {\n setShow(false);\n }}\n >\n <div className=\"delete-modal-body-text\">\n <Leading>\n Are you sure you want to delete\n </Leading>\n <strong>\n {<MiddleTextTruncation text={`${entityName}?`} />}\n </strong>\n </div>\n <ModalButtonBar>\n {isLoading ? (\n <IconButton styleType='high-visibility'>\n <ProgressRadial size=\"small\" indeterminate />\n </IconButton>\n ) : (\n <Button styleType='high-visibility' onClick={deleteCallback}>\n Delete\n </Button>\n )}\n <Button\n styleType='default'\n onClick={() => {\n setShow(false);\n }}\n disabled={isLoading}\n >\n Cancel\n </Button>\n </ModalButtonBar>\n </Modal>\n </>\n );\n};\n\nexport default DeleteModal;\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
.delete-modal-body-text {
|
|
6
|
+
display: flex;
|
|
7
|
+
gap: 4px;
|
|
8
|
+
flex-wrap: wrap;
|
|
9
|
+
> strong {
|
|
10
|
+
min-width: 0px;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { Group } from "./Grouping";
|
|
3
|
+
import "./GroupAction.scss";
|
|
4
|
+
interface GroupActionProps {
|
|
5
|
+
iModelId: string;
|
|
6
|
+
mappingId: string;
|
|
7
|
+
group?: Group;
|
|
8
|
+
goBack: () => Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
declare const GroupAction: ({ iModelId, mappingId, group, goBack, }: GroupActionProps) => JSX.Element;
|
|
11
|
+
export default GroupAction;
|
|
12
|
+
//# sourceMappingURL=GroupAction.d.ts.map
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Presentation, } from "@itwin/presentation-frontend";
|
|
2
|
+
import { useActiveIModelConnection } from "@itwin/appui-react";
|
|
3
|
+
import { Fieldset, LabeledInput, Small } from "@itwin/itwinui-react";
|
|
4
|
+
import React, { useCallback, useEffect, useState } from "react";
|
|
5
|
+
import { reportingClientApi } from "../../api/reportingClient";
|
|
6
|
+
import { fetchIdsFromQuery, handleInputChange, WidgetHeader } from "./utils";
|
|
7
|
+
import "./GroupAction.scss";
|
|
8
|
+
import ActionPanel from "./ActionPanel";
|
|
9
|
+
import useValidator, { NAME_REQUIREMENTS } from "../hooks/useValidator";
|
|
10
|
+
import { GroupQueryBuilderContainer } from "./GroupQueryBuilderContainer";
|
|
11
|
+
import { GroupQueryBuilderContext } from "./GroupQueryBuilderContext";
|
|
12
|
+
import { QueryBuilder } from "./QueryBuilder";
|
|
13
|
+
import { clearEmphasizedElements, visualizeElementsById, zoomToElements, } from "./viewerUtils";
|
|
14
|
+
const GroupAction = ({ iModelId, mappingId, group, goBack, }) => {
|
|
15
|
+
var _a, _b, _c;
|
|
16
|
+
const iModelConnection = useActiveIModelConnection();
|
|
17
|
+
const [details, setDetails] = useState({
|
|
18
|
+
groupName: (_a = group === null || group === void 0 ? void 0 : group.groupName) !== null && _a !== void 0 ? _a : "",
|
|
19
|
+
description: (_b = group === null || group === void 0 ? void 0 : group.description) !== null && _b !== void 0 ? _b : "",
|
|
20
|
+
});
|
|
21
|
+
const [query, setQuery] = useState("");
|
|
22
|
+
const [simpleQuery, setSimpleQuery] = useState("");
|
|
23
|
+
const [validator, showValidationMessage] = useValidator();
|
|
24
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
25
|
+
const [currentPropertyList, setCurrentPropertyList] = React.useState([]);
|
|
26
|
+
const [queryBuilder, setQueryBuilder] = React.useState(new QueryBuilder(undefined));
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const removeListener = Presentation.selection.selectionChange.addListener(async (evt, selectionProvider) => {
|
|
29
|
+
const selection = selectionProvider.getSelection(evt.imodel, evt.level);
|
|
30
|
+
const query = `SELECT ECInstanceId FROM ${selection.instanceKeys.keys().next().value}`;
|
|
31
|
+
// Selects all instances of the class
|
|
32
|
+
// const ids = await fetchIdsFromQuery(query, iModelConnection);
|
|
33
|
+
// const keySet = await manufactureKeys(ids, iModelConnection);
|
|
34
|
+
// Presentation.selection.replaceSelection(
|
|
35
|
+
// "GroupingMappingWidget",
|
|
36
|
+
// iModelConnection,
|
|
37
|
+
// keySet
|
|
38
|
+
// );
|
|
39
|
+
// setSelectionInstanceKeys(selection.instanceKeys);
|
|
40
|
+
setSimpleQuery(query);
|
|
41
|
+
});
|
|
42
|
+
return () => {
|
|
43
|
+
removeListener();
|
|
44
|
+
};
|
|
45
|
+
}, [iModelConnection]);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
const reemphasize = async () => {
|
|
48
|
+
clearEmphasizedElements();
|
|
49
|
+
if (!query || query === "") {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const ids = await fetchIdsFromQuery(query !== null && query !== void 0 ? query : "", iModelConnection);
|
|
53
|
+
const resolvedHiliteIds = await visualizeElementsById(ids, "red", iModelConnection);
|
|
54
|
+
await zoomToElements(resolvedHiliteIds);
|
|
55
|
+
};
|
|
56
|
+
void reemphasize();
|
|
57
|
+
}, [iModelConnection, query]);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
Presentation.selection.clearSelection("GroupingMappingWidget", iModelConnection);
|
|
60
|
+
}, [iModelConnection]);
|
|
61
|
+
const save = useCallback(async () => {
|
|
62
|
+
var _a;
|
|
63
|
+
if (!validator.allValid()) {
|
|
64
|
+
showValidationMessage(true);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
setIsLoading(true);
|
|
69
|
+
const currentQuery = query || simpleQuery;
|
|
70
|
+
group
|
|
71
|
+
? await reportingClientApi.updateGroup(iModelId, mappingId, (_a = group.id) !== null && _a !== void 0 ? _a : "", { ...details, query: currentQuery })
|
|
72
|
+
: await reportingClientApi.createGroup(iModelId, mappingId, {
|
|
73
|
+
...details,
|
|
74
|
+
query: currentQuery,
|
|
75
|
+
});
|
|
76
|
+
Presentation.selection.clearSelection("GroupingMappingWidget", iModelConnection);
|
|
77
|
+
await goBack();
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
setIsLoading(false);
|
|
81
|
+
}
|
|
82
|
+
}, [
|
|
83
|
+
details,
|
|
84
|
+
goBack,
|
|
85
|
+
group,
|
|
86
|
+
iModelConnection,
|
|
87
|
+
iModelId,
|
|
88
|
+
mappingId,
|
|
89
|
+
query,
|
|
90
|
+
showValidationMessage,
|
|
91
|
+
simpleQuery,
|
|
92
|
+
validator,
|
|
93
|
+
]);
|
|
94
|
+
return (React.createElement(React.Fragment, null,
|
|
95
|
+
React.createElement(WidgetHeader, { title: group ? (_c = group.groupName) !== null && _c !== void 0 ? _c : "" : "Add Group", returnFn: async () => {
|
|
96
|
+
Presentation.selection.clearSelection("GroupingMappingWidget", iModelConnection);
|
|
97
|
+
await goBack();
|
|
98
|
+
} }),
|
|
99
|
+
React.createElement("div", { className: 'group-add-modify-container' },
|
|
100
|
+
React.createElement(Fieldset, { legend: 'Group Details', className: 'group-details' },
|
|
101
|
+
React.createElement(Small, { className: 'field-legend' }, "Asterisk * indicates mandatory fields."),
|
|
102
|
+
React.createElement(LabeledInput, { id: 'groupName', name: 'groupName', label: 'Name', value: details.groupName, required: true, onChange: (event) => {
|
|
103
|
+
handleInputChange(event, details, setDetails);
|
|
104
|
+
validator.showMessageFor("groupName");
|
|
105
|
+
}, message: validator.message("groupName", details.groupName, NAME_REQUIREMENTS), status: validator.message("groupName", details.groupName, NAME_REQUIREMENTS)
|
|
106
|
+
? "negative"
|
|
107
|
+
: undefined, onBlur: () => {
|
|
108
|
+
validator.showMessageFor("groupName");
|
|
109
|
+
}, onBlurCapture: (event) => {
|
|
110
|
+
handleInputChange(event, details, setDetails);
|
|
111
|
+
validator.showMessageFor("groupName");
|
|
112
|
+
} }),
|
|
113
|
+
React.createElement(LabeledInput, { id: 'description', required: true, name: 'description', label: 'Description', value: details.description, onChange: (event) => {
|
|
114
|
+
handleInputChange(event, details, setDetails);
|
|
115
|
+
validator.showMessageFor("description");
|
|
116
|
+
}, message: validator.message("description", details.description, "required"), status: validator.message("description", details.description, "required")
|
|
117
|
+
? "negative"
|
|
118
|
+
: undefined, onBlur: () => {
|
|
119
|
+
validator.showMessageFor("description");
|
|
120
|
+
}, onBlurCapture: (event) => {
|
|
121
|
+
handleInputChange(event, details, setDetails);
|
|
122
|
+
validator.showMessageFor("description");
|
|
123
|
+
} })),
|
|
124
|
+
React.createElement(Fieldset, { legend: 'Group By', className: 'find-similar' },
|
|
125
|
+
React.createElement(GroupQueryBuilderContext.Provider, { value: {
|
|
126
|
+
currentPropertyList,
|
|
127
|
+
setCurrentPropertyList,
|
|
128
|
+
query,
|
|
129
|
+
setQuery,
|
|
130
|
+
queryBuilder,
|
|
131
|
+
setQueryBuilder,
|
|
132
|
+
} },
|
|
133
|
+
React.createElement(GroupQueryBuilderContainer, null)))),
|
|
134
|
+
React.createElement(ActionPanel, { onSave: async () => {
|
|
135
|
+
await save();
|
|
136
|
+
}, onCancel: async () => {
|
|
137
|
+
Presentation.selection.clearSelection("GroupingMappingWidget", iModelConnection);
|
|
138
|
+
await goBack();
|
|
139
|
+
}, disabled: !(details.groupName && details.description && (query || simpleQuery)), isLoading: isLoading })));
|
|
140
|
+
};
|
|
141
|
+
export default GroupAction;
|
|
142
|
+
//# sourceMappingURL=GroupAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GroupAction.js","sourceRoot":"","sources":["../../../../src/widget/components/GroupAction.tsx"],"names":[],"mappings":"AAQA,OAAO,EACL,YAAY,GACb,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,sBAAsB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Q,EAAE,KAAK,IAAI,EAAE;gBACnB,YAAY,CAAC,SAAS,CAAC,cAAc,CACnC,uBAAuB,EACvB,gBAAgB,CACjB,CAAC;gBACF,MAAM,MAAM,EAAE,CAAC;YACjB,CAAC,EACD,QAAQ,EACN,CAAC,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,WAAW,IAAI,CAAC,KAAK,IAAI,WAAW,CAAC,CAAC,EAEvE,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type {\n ISelectionProvider,\n SelectionChangeEventArgs} from \"@itwin/presentation-frontend\";\nimport {\n Presentation,\n} from \"@itwin/presentation-frontend\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { Fieldset, LabeledInput, Small } from \"@itwin/itwinui-react\";\nimport React, { useCallback, useEffect, useState } from \"react\";\nimport { reportingClientApi } from \"../../api/reportingClient\";\nimport { fetchIdsFromQuery, handleInputChange, WidgetHeader } from \"./utils\";\nimport type { Group } from \"./Grouping\";\nimport \"./GroupAction.scss\";\nimport ActionPanel from \"./ActionPanel\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { GroupQueryBuilderContainer } from \"./GroupQueryBuilderContainer\";\nimport { GroupQueryBuilderContext } from \"./GroupQueryBuilderContext\";\nimport { QueryBuilder } from \"./QueryBuilder\";\nimport {\n clearEmphasizedElements,\n visualizeElementsById,\n zoomToElements,\n} from \"./viewerUtils\";\n\ninterface GroupActionProps {\n iModelId: string;\n mappingId: string;\n group?: Group;\n goBack: () => Promise<void>;\n}\n\nconst GroupAction = ({\n iModelId,\n mappingId,\n group,\n goBack,\n}: GroupActionProps) => {\n const iModelConnection = useActiveIModelConnection() as IModelConnection;\n const [details, setDetails] = useState({\n groupName: group?.groupName ?? \"\",\n description: group?.description ?? \"\",\n });\n const [query, setQuery] = useState<string>(\"\");\n const [simpleQuery, setSimpleQuery] = useState<string>(\"\");\n const [validator, showValidationMessage] = useValidator();\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [currentPropertyList, setCurrentPropertyList] = React.useState<\n PropertyRecord[]\n >([]);\n const [queryBuilder, setQueryBuilder] = React.useState<QueryBuilder>(\n new QueryBuilder(undefined),\n );\n\n useEffect(() => {\n const removeListener = Presentation.selection.selectionChange.addListener(\n async (\n evt: SelectionChangeEventArgs,\n selectionProvider: ISelectionProvider,\n ) => {\n const selection = selectionProvider.getSelection(evt.imodel, evt.level);\n const query = `SELECT ECInstanceId FROM ${selection.instanceKeys.keys().next().value\n }`;\n // Selects all instances of the class\n // const ids = await fetchIdsFromQuery(query, iModelConnection);\n // const keySet = await manufactureKeys(ids, iModelConnection);\n // Presentation.selection.replaceSelection(\n // \"GroupingMappingWidget\",\n // iModelConnection,\n // keySet\n // );\n // setSelectionInstanceKeys(selection.instanceKeys);\n setSimpleQuery(query);\n },\n );\n return () => {\n removeListener();\n };\n }, [iModelConnection]);\n\n useEffect(() => {\n const reemphasize = async () => {\n clearEmphasizedElements();\n if (!query || query === \"\") {\n return;\n }\n const ids = await fetchIdsFromQuery(query ?? \"\", iModelConnection);\n const resolvedHiliteIds = await visualizeElementsById(\n ids,\n \"red\",\n iModelConnection,\n );\n await zoomToElements(resolvedHiliteIds);\n };\n\n void reemphasize();\n }, [iModelConnection, query]);\n\n useEffect(() => {\n Presentation.selection.clearSelection(\n \"GroupingMappingWidget\",\n iModelConnection,\n );\n }, [iModelConnection]);\n\n const save = useCallback(async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n try {\n setIsLoading(true);\n const currentQuery = query || simpleQuery;\n\n group\n ? await reportingClientApi.updateGroup(\n iModelId,\n mappingId,\n group.id ?? \"\",\n { ...details, query: currentQuery },\n )\n : await reportingClientApi.createGroup(iModelId, mappingId, {\n ...details,\n query: currentQuery,\n });\n Presentation.selection.clearSelection(\n \"GroupingMappingWidget\",\n iModelConnection,\n );\n await goBack();\n } catch {\n setIsLoading(false);\n }\n }, [\n details,\n goBack,\n group,\n iModelConnection,\n iModelId,\n mappingId,\n query,\n showValidationMessage,\n simpleQuery,\n validator,\n ]);\n\n return (\n <>\n <WidgetHeader\n title={group ? group.groupName ?? \"\" : \"Add Group\"}\n returnFn={async () => {\n Presentation.selection.clearSelection(\n \"GroupingMappingWidget\",\n iModelConnection,\n );\n await goBack();\n }}\n />\n <div className='group-add-modify-container'>\n <Fieldset legend='Group Details' className='group-details'>\n <Small className='field-legend'>\n Asterisk * indicates mandatory fields.\n </Small>\n <LabeledInput\n id='groupName'\n name='groupName'\n label='Name'\n value={details.groupName}\n required\n onChange={(event) => {\n handleInputChange(event, details, setDetails);\n validator.showMessageFor(\"groupName\");\n }}\n message={validator.message(\n \"groupName\",\n details.groupName,\n NAME_REQUIREMENTS,\n )}\n status={\n validator.message(\n \"groupName\",\n details.groupName,\n NAME_REQUIREMENTS,\n )\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"groupName\");\n }}\n onBlurCapture={(event) => {\n handleInputChange(event, details, setDetails);\n validator.showMessageFor(\"groupName\");\n }}\n />\n <LabeledInput\n id='description'\n required\n name='description'\n label='Description'\n value={details.description}\n onChange={(event) => {\n handleInputChange(event, details, setDetails);\n validator.showMessageFor(\"description\");\n }}\n message={validator.message(\n \"description\",\n details.description,\n \"required\",\n )}\n status={\n validator.message(\"description\", details.description, \"required\")\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"description\");\n }}\n onBlurCapture={(event) => {\n handleInputChange(event, details, setDetails);\n validator.showMessageFor(\"description\");\n }}\n />\n </Fieldset>\n\n <Fieldset legend='Group By' className='find-similar'>\n <GroupQueryBuilderContext.Provider\n value={{\n currentPropertyList,\n setCurrentPropertyList,\n query,\n setQuery,\n queryBuilder,\n setQueryBuilder,\n }}\n >\n <GroupQueryBuilderContainer />\n </GroupQueryBuilderContext.Provider>\n </Fieldset>\n </div>\n <ActionPanel\n onSave={async () => {\n await save();\n }}\n onCancel={async () => {\n Presentation.selection.clearSelection(\n \"GroupingMappingWidget\",\n iModelConnection,\n );\n await goBack();\n }}\n disabled={\n !(details.groupName && details.description && (query || simpleQuery))\n }\n isLoading={isLoading}\n />\n </>\n );\n};\n\nexport default GroupAction;\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
@import '~@itwin/itwinui-css/scss/variables';
|
|
6
|
+
|
|
7
|
+
.group-add-modify-container {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
gap: $iui-baseline;
|
|
11
|
+
overflow-x: auto;
|
|
12
|
+
height: 100%;
|
|
13
|
+
|
|
14
|
+
.group-details {
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
gap: $iui-baseline;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { KeySet } from "@itwin/presentation-common";
|
|
3
|
+
import type { SelectOption } from "@itwin/itwinui-react";
|
|
4
|
+
import "./GroupPropertyAction.scss";
|
|
5
|
+
interface GroupPropertyActionProps {
|
|
6
|
+
iModelId: string;
|
|
7
|
+
mappingId: string;
|
|
8
|
+
groupId: string;
|
|
9
|
+
groupPropertyId?: string;
|
|
10
|
+
groupPropertyName?: string;
|
|
11
|
+
keySet: KeySet;
|
|
12
|
+
returnFn: () => Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export declare const quantityTypesSelectionOptions: SelectOption<string>[];
|
|
15
|
+
declare const GroupPropertyAction: ({ iModelId, mappingId, groupId, groupPropertyId, groupPropertyName, keySet, returnFn, }: GroupPropertyActionProps) => JSX.Element;
|
|
16
|
+
export default GroupPropertyAction;
|
|
17
|
+
//# sourceMappingURL=GroupPropertyAction.d.ts.map
|