@itwin/grouping-mapping-widget 0.26.1 → 0.28.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 +3 -1
- package/lib/cjs/WidgetShell/GroupingMapping.js +1 -1
- package/lib/cjs/WidgetShell/GroupingMapping.js.map +1 -1
- package/lib/cjs/WidgetShell/GroupingMappingContent.d.ts +2 -1
- package/lib/cjs/WidgetShell/GroupingMappingContent.js +2 -2
- package/lib/cjs/WidgetShell/GroupingMappingContent.js.map +1 -1
- package/lib/cjs/WidgetShell/Router/GroupingMappingRouter.d.ts +2 -1
- package/lib/cjs/WidgetShell/Router/GroupingMappingRouter.js +5 -19
- package/lib/cjs/WidgetShell/Router/GroupingMappingRouter.js.map +1 -1
- package/lib/cjs/components/Groups/Groups.d.ts +2 -1
- package/lib/cjs/components/Groups/Groups.js +2 -2
- package/lib/cjs/components/Groups/Groups.js.map +1 -1
- package/lib/cjs/components/Groups/GroupsView.d.ts +2 -1
- package/lib/cjs/components/Groups/GroupsView.js +5 -5
- package/lib/cjs/components/Groups/GroupsView.js.map +1 -1
- package/lib/cjs/components/Groups/GroupsVisualization.d.ts +3 -1
- package/lib/cjs/components/Groups/GroupsVisualization.js +8 -3
- package/lib/cjs/components/Groups/GroupsVisualization.js.map +1 -1
- package/lib/cjs/components/Groups/GroupsVisualizationActions.d.ts +2 -1
- package/lib/cjs/components/Groups/GroupsVisualizationActions.js +36 -9
- package/lib/cjs/components/Groups/GroupsVisualizationActions.js.map +1 -1
- package/lib/cjs/components/Groups/hooks/useKeySetHiliteQueries.d.ts +1 -1
- package/lib/cjs/components/Mappings/MappingViewActionGroup.d.ts +1 -1
- package/lib/cjs/components/Mappings/MappingViewActionGroup.js +1 -2
- package/lib/cjs/components/Mappings/MappingViewActionGroup.js.map +1 -1
- package/lib/cjs/components/Mappings/Mappings.d.ts +1 -0
- package/lib/cjs/components/Mappings/Mappings.js.map +1 -1
- package/lib/cjs/components/Mappings/MappingsView.d.ts +2 -1
- package/lib/cjs/components/Mappings/MappingsView.js +4 -4
- package/lib/cjs/components/Mappings/MappingsView.js.map +1 -1
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyAction.d.ts +2 -0
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyAction.js +2 -1
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyAction.js.map +1 -1
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.d.ts +7 -8
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js +21 -61
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js.map +1 -1
- package/lib/cjs/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.d.ts +5 -9
- package/lib/cjs/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.js +3 -12
- package/lib/cjs/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.js.map +1 -1
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.d.ts +8 -9
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.js +17 -164
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.js.map +1 -1
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.scss +4 -3
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.js +76 -19
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.js.map +1 -1
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.scss +3 -2
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyTable.d.ts +2 -1
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyTable.js +12 -4
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyTable.js.map +1 -1
- package/lib/cjs/components/Properties/PropertyMenu.d.ts +2 -1
- package/lib/cjs/components/Properties/PropertyMenu.js +2 -7
- package/lib/cjs/components/Properties/PropertyMenu.js.map +1 -1
- package/lib/cjs/components/Properties/PropertyMenuWithVisualization.d.ts +1 -1
- package/lib/cjs/components/Properties/PropertyMenuWithVisualization.js +2 -2
- package/lib/cjs/components/Properties/PropertyMenuWithVisualization.js.map +1 -1
- package/lib/cjs/components/Properties/PropertyTable.d.ts +2 -1
- package/lib/cjs/components/Properties/PropertyTable.js +2 -2
- package/lib/cjs/components/Properties/PropertyTable.js.map +1 -1
- package/lib/cjs/components/Properties/PropertyTableToolbar.d.ts +2 -1
- package/lib/cjs/components/Properties/PropertyTableToolbar.js +3 -3
- package/lib/cjs/components/Properties/PropertyTableToolbar.js.map +1 -1
- package/lib/cjs/components/Properties/ScrollableExpandableBlock.d.ts +11 -0
- package/lib/cjs/components/Properties/ScrollableExpandableBlock.js +55 -0
- package/lib/cjs/components/Properties/ScrollableExpandableBlock.js.map +1 -0
- package/lib/cjs/components/Properties/hooks/useFormulaValidation.d.ts +6 -3
- package/lib/cjs/components/Properties/hooks/useFormulaValidation.js +59 -13
- package/lib/cjs/components/Properties/hooks/useFormulaValidation.js.map +1 -1
- package/lib/cjs/components/Properties/hooks/useForwardRef.d.ts +3 -0
- package/lib/cjs/components/Properties/hooks/useForwardRef.js +20 -0
- package/lib/cjs/components/Properties/hooks/useForwardRef.js.map +1 -0
- package/lib/cjs/components/SharedComponents/ActionPanel.d.ts +3 -1
- package/lib/cjs/components/SharedComponents/ActionPanel.js +3 -3
- package/lib/cjs/components/SharedComponents/ActionPanel.js.map +1 -1
- package/lib/cjs/formula/FormulaDataTypeResolver.d.ts +3 -2
- package/lib/cjs/formula/FormulaDataTypeResolver.js +10 -6
- package/lib/cjs/formula/FormulaDataTypeResolver.js.map +1 -1
- package/lib/cjs/grouping-mapping-widget.d.ts +0 -2
- package/lib/cjs/grouping-mapping-widget.js +1 -5
- package/lib/cjs/grouping-mapping-widget.js.map +1 -1
- package/lib/esm/WidgetShell/GroupingMapping.d.ts +3 -1
- package/lib/esm/WidgetShell/GroupingMapping.js +1 -1
- package/lib/esm/WidgetShell/GroupingMapping.js.map +1 -1
- package/lib/esm/WidgetShell/GroupingMappingContent.d.ts +2 -1
- package/lib/esm/WidgetShell/GroupingMappingContent.js +2 -2
- package/lib/esm/WidgetShell/GroupingMappingContent.js.map +1 -1
- package/lib/esm/WidgetShell/Router/GroupingMappingRouter.d.ts +2 -1
- package/lib/esm/WidgetShell/Router/GroupingMappingRouter.js +5 -19
- package/lib/esm/WidgetShell/Router/GroupingMappingRouter.js.map +1 -1
- package/lib/esm/components/Groups/Groups.d.ts +2 -1
- package/lib/esm/components/Groups/Groups.js +2 -2
- package/lib/esm/components/Groups/Groups.js.map +1 -1
- package/lib/esm/components/Groups/GroupsView.d.ts +2 -1
- package/lib/esm/components/Groups/GroupsView.js +5 -5
- package/lib/esm/components/Groups/GroupsView.js.map +1 -1
- package/lib/esm/components/Groups/GroupsVisualization.d.ts +3 -1
- package/lib/esm/components/Groups/GroupsVisualization.js +8 -3
- package/lib/esm/components/Groups/GroupsVisualization.js.map +1 -1
- package/lib/esm/components/Groups/GroupsVisualizationActions.d.ts +2 -1
- package/lib/esm/components/Groups/GroupsVisualizationActions.js +14 -7
- package/lib/esm/components/Groups/GroupsVisualizationActions.js.map +1 -1
- package/lib/esm/components/Groups/hooks/useKeySetHiliteQueries.d.ts +1 -1
- package/lib/esm/components/Mappings/MappingViewActionGroup.d.ts +1 -1
- package/lib/esm/components/Mappings/MappingViewActionGroup.js +1 -2
- package/lib/esm/components/Mappings/MappingViewActionGroup.js.map +1 -1
- package/lib/esm/components/Mappings/Mappings.d.ts +1 -0
- package/lib/esm/components/Mappings/Mappings.js.map +1 -1
- package/lib/esm/components/Mappings/MappingsView.d.ts +2 -1
- package/lib/esm/components/Mappings/MappingsView.js +4 -4
- package/lib/esm/components/Mappings/MappingsView.js.map +1 -1
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyAction.d.ts +2 -0
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyAction.js +2 -1
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyAction.js.map +1 -1
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.d.ts +7 -8
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js +23 -60
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js.map +1 -1
- package/lib/esm/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.d.ts +5 -9
- package/lib/esm/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.js +4 -13
- package/lib/esm/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.js.map +1 -1
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationAction.d.ts +8 -9
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationAction.js +18 -142
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationAction.js.map +1 -1
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationAction.scss +4 -3
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.js +79 -22
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.js.map +1 -1
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.scss +3 -2
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyTable.d.ts +2 -1
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyTable.js +14 -6
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyTable.js.map +1 -1
- package/lib/esm/components/Properties/PropertyMenu.d.ts +2 -1
- package/lib/esm/components/Properties/PropertyMenu.js +2 -7
- package/lib/esm/components/Properties/PropertyMenu.js.map +1 -1
- package/lib/esm/components/Properties/PropertyMenuWithVisualization.d.ts +1 -1
- package/lib/esm/components/Properties/PropertyMenuWithVisualization.js +2 -2
- package/lib/esm/components/Properties/PropertyMenuWithVisualization.js.map +1 -1
- package/lib/esm/components/Properties/PropertyTable.d.ts +2 -1
- package/lib/esm/components/Properties/PropertyTable.js +2 -2
- package/lib/esm/components/Properties/PropertyTable.js.map +1 -1
- package/lib/esm/components/Properties/PropertyTableToolbar.d.ts +2 -1
- package/lib/esm/components/Properties/PropertyTableToolbar.js +3 -3
- package/lib/esm/components/Properties/PropertyTableToolbar.js.map +1 -1
- package/lib/esm/components/Properties/ScrollableExpandableBlock.d.ts +11 -0
- package/lib/esm/components/Properties/ScrollableExpandableBlock.js +29 -0
- package/lib/esm/components/Properties/ScrollableExpandableBlock.js.map +1 -0
- package/lib/esm/components/Properties/hooks/useFormulaValidation.d.ts +6 -3
- package/lib/esm/components/Properties/hooks/useFormulaValidation.js +57 -12
- package/lib/esm/components/Properties/hooks/useFormulaValidation.js.map +1 -1
- package/lib/esm/components/Properties/hooks/useForwardRef.d.ts +3 -0
- package/lib/esm/components/Properties/hooks/useForwardRef.js +16 -0
- package/lib/esm/components/Properties/hooks/useForwardRef.js.map +1 -0
- package/lib/esm/components/SharedComponents/ActionPanel.d.ts +3 -1
- package/lib/esm/components/SharedComponents/ActionPanel.js +3 -3
- package/lib/esm/components/SharedComponents/ActionPanel.js.map +1 -1
- package/lib/esm/formula/FormulaDataTypeResolver.d.ts +3 -2
- package/lib/esm/formula/FormulaDataTypeResolver.js +10 -6
- package/lib/esm/formula/FormulaDataTypeResolver.js.map +1 -1
- package/lib/esm/grouping-mapping-widget.d.ts +0 -2
- package/lib/esm/grouping-mapping-widget.js +0 -2
- package/lib/esm/grouping-mapping-widget.js.map +1 -1
- package/package.json +1 -1
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.d.ts +0 -14
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.js +0 -87
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.js.map +0 -1
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.scss +0 -9
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationTable.d.ts +0 -13
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationTable.js +0 -91
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationTable.js.map +0 -1
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyTable.d.ts +0 -14
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyTable.js +0 -60
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyTable.js.map +0 -1
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyTable.scss +0 -9
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationTable.d.ts +0 -13
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationTable.js +0 -64
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationTable.js.map +0 -1
package/lib/cjs/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.d.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CalculatedPropertyType } from "@itwin/insights-client";
|
|
3
3
|
import type { SelectOption } from "@itwin/itwinui-react";
|
|
4
|
-
import type SimpleReactValidator from "simple-react-validator";
|
|
5
4
|
interface SharedCalculatedPropertyFormsProps {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
validator: SimpleReactValidator;
|
|
11
|
-
itemRenderer?: (option: SelectOption<string>) => JSX.Element;
|
|
12
|
-
selectedItemRenderer?: (option: SelectOption<string>) => JSX.Element;
|
|
5
|
+
calculatedPropertyType: CalculatedPropertyType | undefined;
|
|
6
|
+
setCalculatedPropertyType: (value: CalculatedPropertyType | undefined) => void;
|
|
7
|
+
itemRenderer?: (option: SelectOption<string | undefined>) => JSX.Element;
|
|
8
|
+
selectedItemRenderer?: (option: SelectOption<string | undefined>) => JSX.Element;
|
|
13
9
|
}
|
|
14
|
-
export declare const SharedCalculatedPropertyForms: ({
|
|
10
|
+
export declare const SharedCalculatedPropertyForms: ({ calculatedPropertyType, setCalculatedPropertyType, itemRenderer, selectedItemRenderer, }: SharedCalculatedPropertyFormsProps) => JSX.Element;
|
|
15
11
|
export {};
|
|
16
12
|
//# sourceMappingURL=SharedCalculatedPropertyForms.d.ts.map
|
|
@@ -30,12 +30,12 @@ exports.SharedCalculatedPropertyForms = void 0;
|
|
|
30
30
|
*--------------------------------------------------------------------------------------------*/
|
|
31
31
|
const insights_client_1 = require("@itwin/insights-client");
|
|
32
32
|
const react_1 = __importStar(require("react"));
|
|
33
|
-
const useValidator_1 = require("../hooks/useValidator");
|
|
34
33
|
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
35
|
-
const SharedCalculatedPropertyForms = ({
|
|
34
|
+
const SharedCalculatedPropertyForms = ({ calculatedPropertyType, setCalculatedPropertyType, itemRenderer, selectedItemRenderer, }) => {
|
|
36
35
|
const generateOptionsFromCalculatedPropertyType = (0, react_1.useCallback)(() => {
|
|
37
36
|
const options = [];
|
|
38
37
|
const indexableEnum = insights_client_1.CalculatedPropertyType;
|
|
38
|
+
options.push({ value: undefined, label: "No Calculated Property Type" });
|
|
39
39
|
for (const key in indexableEnum) {
|
|
40
40
|
if (typeof indexableEnum[key] === "string" && key !== "Undefined") {
|
|
41
41
|
// Generate labels by adding space between capitals
|
|
@@ -49,16 +49,7 @@ const SharedCalculatedPropertyForms = ({ propertyName, setPropertyName, type, se
|
|
|
49
49
|
return options;
|
|
50
50
|
}, []);
|
|
51
51
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
52
|
-
react_1.default.createElement(itwinui_react_1.
|
|
53
|
-
setPropertyName(event.target.value);
|
|
54
|
-
validator.showMessageFor("name");
|
|
55
|
-
}, message: validator.message("name", propertyName, useValidator_1.NAME_REQUIREMENTS), status: validator.message("name", propertyName, useValidator_1.NAME_REQUIREMENTS) ? "negative" : undefined, onBlur: () => {
|
|
56
|
-
validator.showMessageFor("name");
|
|
57
|
-
}, onBlurCapture: (event) => {
|
|
58
|
-
setPropertyName(event.target.value);
|
|
59
|
-
validator.showMessageFor("name");
|
|
60
|
-
} }),
|
|
61
|
-
react_1.default.createElement(itwinui_react_1.LabeledSelect, { label: "Quantity Type", required: true, options: generateOptionsFromCalculatedPropertyType(), value: type, onChange: setType, itemRenderer: itemRenderer, selectedItemRenderer: selectedItemRenderer, onShow: () => { }, onHide: () => { } })));
|
|
52
|
+
react_1.default.createElement(itwinui_react_1.LabeledSelect, { label: "Calculated Property Type", options: generateOptionsFromCalculatedPropertyType(), value: calculatedPropertyType, onChange: setCalculatedPropertyType, itemRenderer: itemRenderer, selectedItemRenderer: selectedItemRenderer, placeholder: 'No Calculated Property Type', onShow: () => { }, onHide: () => { } })));
|
|
62
53
|
};
|
|
63
54
|
exports.SharedCalculatedPropertyForms = SharedCalculatedPropertyForms;
|
|
64
55
|
//# sourceMappingURL=SharedCalculatedPropertyForms.js.map
|
package/lib/cjs/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharedCalculatedPropertyForms.js","sourceRoot":"","sources":["../../../../../src/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,4DAAgE;AAChE,+CAA2C;
|
|
1
|
+
{"version":3,"file":"SharedCalculatedPropertyForms.js","sourceRoot":"","sources":["../../../../../src/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,4DAAgE;AAChE,+CAA2C;AAE3C,wDAAqD;AAS9C,MAAM,6BAA6B,GAAG,CAAC,EAC5C,sBAAsB,EACtB,yBAAyB,EACzB,YAAY,EACZ,oBAAoB,GACe,EAAE,EAAE;IACvC,MAAM,yCAAyC,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QACjE,MAAM,OAAO,GAAuD,EAAE,CAAC;QACvE,MAAM,aAAa,GAAG,wCAA8D,CAAC;QAErF,OAAO,CAAC,IAAI,CAAC,EAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,6BAA6B,EAAC,CAAC,CAAC;QACvE,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE;YAC/B,IAAI,OAAO,aAAa,CAAC,GAAG,CAAC,KAAK,QAAQ,IAAI,GAAG,KAAK,WAAW,EAAE;gBACjE,mDAAmD;gBACnD,MAAM,KAAK,GAAG,GAAG;qBACd,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC;qBAC1B,IAAI,EAAE;qBACN,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;gBAC1C,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,GAAG,CAA2B,EAAE,KAAK,EAAE,CAAC,CAAC;aAC9E;SACF;QACD,OAAO,OAAO,CAAC;IACjB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL;QACE,8BAAC,6BAAa,IACZ,KAAK,EAAC,0BAA0B,EAChC,OAAO,EAAE,yCAAyC,EAAE,EACpD,KAAK,EAAE,sBAAsB,EAC7B,QAAQ,EAAE,yBAAyB,EACnC,YAAY,EAAE,YAAY,EAC1B,oBAAoB,EAAE,oBAAoB,EAC1C,WAAW,EAAG,6BAA6B,EAC3C,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EACjB,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,GACjB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAvCW,QAAA,6BAA6B,iCAuCxC","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 { CalculatedPropertyType } from \"@itwin/insights-client\";\nimport React, { useCallback } from \"react\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { LabeledSelect } from \"@itwin/itwinui-react\";\n\ninterface SharedCalculatedPropertyFormsProps {\n calculatedPropertyType: CalculatedPropertyType | undefined;\n setCalculatedPropertyType: (value: CalculatedPropertyType | undefined) => void;\n itemRenderer?: (option: SelectOption<string | undefined>) => JSX.Element;\n selectedItemRenderer?: (option: SelectOption<string | undefined>) => JSX.Element;\n}\n\nexport const SharedCalculatedPropertyForms = ({\n calculatedPropertyType,\n setCalculatedPropertyType,\n itemRenderer,\n selectedItemRenderer,\n}: SharedCalculatedPropertyFormsProps) => {\n const generateOptionsFromCalculatedPropertyType = useCallback(() => {\n const options: SelectOption<CalculatedPropertyType | undefined>[] = [];\n const indexableEnum = CalculatedPropertyType as unknown as { [key: string]: string };\n \n options.push({value: undefined, label: \"No Calculated Property Type\"});\n for (const key in indexableEnum) {\n if (typeof indexableEnum[key] === \"string\" && key !== \"Undefined\") {\n // Generate labels by adding space between capitals\n const label = key\n .replace(/([A-Z])/g, \" $1\")\n .trim()\n .replace(/^\\w/, (c) => c.toUpperCase());\n options.push({ value: indexableEnum[key] as CalculatedPropertyType, label });\n }\n }\n return options;\n }, []);\n\n return (\n <>\n <LabeledSelect<CalculatedPropertyType | undefined>\n label=\"Calculated Property Type\"\n options={generateOptionsFromCalculatedPropertyType()}\n value={calculatedPropertyType}\n onChange={setCalculatedPropertyType}\n itemRenderer={itemRenderer}\n selectedItemRenderer={selectedItemRenderer}\n placeholder = 'No Calculated Property Type'\n onShow={() => { }}\n onHide={() => { }}\n />\n </>\n );\n};\n"]}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import "./CustomCalculationAction.scss";
|
|
3
|
-
import type { Property } from "@itwin/insights-client";
|
|
4
3
|
/**
|
|
5
4
|
* Props for the {@link CustomCalculationAction} component.
|
|
6
|
-
* @
|
|
5
|
+
* @internal
|
|
7
6
|
*/
|
|
8
7
|
export interface CustomCalculationActionProps {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
formula?: string;
|
|
9
|
+
setFormula: (formula: string | undefined) => void;
|
|
10
|
+
formulaErrorMessage?: string;
|
|
11
|
+
forceValidation: () => void;
|
|
12
|
+
disabled?: boolean;
|
|
14
13
|
}
|
|
15
14
|
/**
|
|
16
15
|
* Component to create or update a custom calculation property.
|
|
17
|
-
* @
|
|
16
|
+
* @internal
|
|
18
17
|
*/
|
|
19
|
-
export declare const CustomCalculationAction: ({
|
|
18
|
+
export declare const CustomCalculationAction: ({ formula, setFormula, formulaErrorMessage, forceValidation, disabled }: CustomCalculationActionProps) => JSX.Element;
|
|
20
19
|
//# sourceMappingURL=CustomCalculationAction.d.ts.map
|
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
@@ -32,151 +9,27 @@ exports.CustomCalculationAction = void 0;
|
|
|
32
9
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
33
10
|
*--------------------------------------------------------------------------------------------*/
|
|
34
11
|
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
35
|
-
const react_1 =
|
|
36
|
-
const ActionPanel_1 = __importDefault(require("../../SharedComponents/ActionPanel"));
|
|
37
|
-
const useValidator_1 = __importStar(require("../hooks/useValidator"));
|
|
38
|
-
const utils_1 = require("../../../common/utils");
|
|
12
|
+
const react_1 = __importDefault(require("react"));
|
|
39
13
|
require("./CustomCalculationAction.scss");
|
|
40
|
-
const GroupPropertyAction_1 = require("../GroupProperties/GroupPropertyAction");
|
|
41
|
-
const useFormulaValidation_1 = require("../hooks/useFormulaValidation");
|
|
42
|
-
const GroupingApiConfigContext_1 = require("../../context/GroupingApiConfigContext");
|
|
43
|
-
const insights_client_1 = require("@itwin/insights-client");
|
|
44
|
-
const usePropertiesQuery_1 = require("../hooks/usePropertiesQuery");
|
|
45
|
-
const react_query_1 = require("@tanstack/react-query");
|
|
46
|
-
const PropertiesClientContext_1 = require("../../context/PropertiesClientContext");
|
|
47
|
-
const stringToPossibleDataType = (str) => {
|
|
48
|
-
switch (str?.toLowerCase()) {
|
|
49
|
-
case "double":
|
|
50
|
-
return "Double";
|
|
51
|
-
case "integer":
|
|
52
|
-
return "Integer";
|
|
53
|
-
case "string":
|
|
54
|
-
return "String";
|
|
55
|
-
case "boolean":
|
|
56
|
-
return "Boolean";
|
|
57
|
-
default:
|
|
58
|
-
return "Undefined";
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
const convertToPropertyMap = (properties, selectedPropertyName) => {
|
|
62
|
-
const map = {};
|
|
63
|
-
const selectedLowerName = selectedPropertyName?.toLowerCase();
|
|
64
|
-
properties.forEach((p) => {
|
|
65
|
-
const lowerName = p.propertyName?.toLowerCase();
|
|
66
|
-
if (lowerName && lowerName !== selectedLowerName)
|
|
67
|
-
map[lowerName] = stringToPossibleDataType(p.dataType);
|
|
68
|
-
});
|
|
69
|
-
return map;
|
|
70
|
-
};
|
|
71
|
-
const inferToPropertyDataType = (value) => {
|
|
72
|
-
switch (value) {
|
|
73
|
-
case "Double":
|
|
74
|
-
return insights_client_1.DataType.Double;
|
|
75
|
-
case "Integer":
|
|
76
|
-
return insights_client_1.DataType.Integer;
|
|
77
|
-
case "String":
|
|
78
|
-
return insights_client_1.DataType.String;
|
|
79
|
-
case "Boolean":
|
|
80
|
-
return insights_client_1.DataType.Boolean;
|
|
81
|
-
default:
|
|
82
|
-
return insights_client_1.DataType.String;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
14
|
/**
|
|
86
15
|
* Component to create or update a custom calculation property.
|
|
87
|
-
* @
|
|
16
|
+
* @internal
|
|
88
17
|
*/
|
|
89
|
-
const CustomCalculationAction = ({
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}, [groupProperties]);
|
|
105
|
-
const { mutate: saveMutation, isLoading: isSaving } = (0, react_query_1.useMutation)(async () => {
|
|
106
|
-
const accessToken = await getAccessToken();
|
|
107
|
-
if (customCalculation) {
|
|
108
|
-
return propertiesClient.updateProperty(accessToken, mappingId, groupId, customCalculation.id, {
|
|
109
|
-
propertyName,
|
|
110
|
-
dataType: customCalculation.dataType,
|
|
111
|
-
formula,
|
|
112
|
-
quantityType,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
if (inferredDataType) {
|
|
116
|
-
return propertiesClient.createProperty(accessToken, mappingId, groupId, {
|
|
117
|
-
propertyName,
|
|
118
|
-
dataType: inferToPropertyDataType(inferredDataType),
|
|
119
|
-
formula,
|
|
120
|
-
quantityType,
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
return;
|
|
124
|
-
}, {
|
|
125
|
-
onSuccess: async () => {
|
|
126
|
-
await queryClient.invalidateQueries({ queryKey: ["properties", iModelId, mappingId, groupId] });
|
|
127
|
-
onSaveSuccess();
|
|
128
|
-
setPropertyName("");
|
|
129
|
-
setFormula("");
|
|
130
|
-
setQuantityType(undefined);
|
|
131
|
-
},
|
|
132
|
-
onError: async (error) => {
|
|
133
|
-
if (error.status === 422) {
|
|
134
|
-
const erroredResponse = await error.json();
|
|
135
|
-
if (erroredResponse.error.code === "InvalidInsightsRequest" && erroredResponse.error.target === "formula") {
|
|
136
|
-
setFormulaErrorMessage(erroredResponse.error.message);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
(0, utils_1.handleError)(error.status);
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
});
|
|
144
|
-
const onSave = () => {
|
|
145
|
-
if (!validator.allValid()) {
|
|
146
|
-
showValidationMessage(true);
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
if (!forceValidation()) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
saveMutation();
|
|
153
|
-
};
|
|
154
|
-
const isLoading = isSaving || isLoadingGroupProperties;
|
|
155
|
-
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
156
|
-
react_1.default.createElement("div", { className: "gmw-custom-calculation-action-container" },
|
|
157
|
-
react_1.default.createElement(itwinui_react_1.Fieldset, { legend: "Custom Calculation Details", className: "gmw-details-form" },
|
|
158
|
-
react_1.default.createElement(itwinui_react_1.Text, { variant: "small", as: "small", className: "gmw-field-legend" }, "Asterisk * indicates mandatory fields."),
|
|
159
|
-
react_1.default.createElement(itwinui_react_1.LabeledInput, { value: propertyName, required: true, name: "name", label: "Name", disabled: isLoading, onChange: (event) => {
|
|
160
|
-
setPropertyName(event.target.value);
|
|
161
|
-
validator.showMessageFor("name");
|
|
162
|
-
}, message: validator.message("name", propertyName, useValidator_1.NAME_REQUIREMENTS), status: validator.message("name", propertyName, useValidator_1.NAME_REQUIREMENTS) ? "negative" : undefined, onBlur: () => {
|
|
163
|
-
validator.showMessageFor("name");
|
|
164
|
-
}, onBlurCapture: (event) => {
|
|
165
|
-
setPropertyName(event.target.value);
|
|
166
|
-
validator.showMessageFor("name");
|
|
167
|
-
} }),
|
|
168
|
-
react_1.default.createElement(itwinui_react_1.Alert, { type: "informational", clickableText: "Click here.", clickableTextProps: {
|
|
169
|
-
href: "https://developer.bentley.com/apis/grouping-and-mapping/operations/create-property/#customcalculations",
|
|
170
|
-
target: "_blank",
|
|
171
|
-
rel: "noreferrer",
|
|
172
|
-
} }, "To learn more about creating custom calculation formulas, view the documentation."),
|
|
173
|
-
react_1.default.createElement(itwinui_react_1.LabeledTextarea, { value: formula, required: true, name: "formula", label: "Formula", disabled: isLoading, onChange: (event) => {
|
|
174
|
-
setFormula(event.target.value);
|
|
175
|
-
}, message: formulaErrorMessage, status: formulaErrorMessage ? "negative" : undefined, onBlurCapture: () => {
|
|
176
|
-
forceValidation();
|
|
177
|
-
} }),
|
|
178
|
-
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" }))),
|
|
179
|
-
react_1.default.createElement(ActionPanel_1.default, { onSave: onSave, onCancel: onClickCancel, isSavingDisabled: !(formula && propertyName && isValid), isLoading: isLoading })));
|
|
18
|
+
const CustomCalculationAction = ({ formula, setFormula, formulaErrorMessage, forceValidation, disabled }) => {
|
|
19
|
+
return (react_1.default.createElement(itwinui_react_1.InputGroup, { className: "gmw-custom-calculation-action-container" },
|
|
20
|
+
react_1.default.createElement(itwinui_react_1.Alert, { type: "informational", clickableText: "Click here.", clickableTextProps: {
|
|
21
|
+
href: "https://developer.bentley.com/apis/grouping-and-mapping/operations/create-property/#customcalculations",
|
|
22
|
+
target: "_blank",
|
|
23
|
+
rel: "noreferrer",
|
|
24
|
+
} }, "To learn more about creating custom calculation formulas, view the documentation."),
|
|
25
|
+
react_1.default.createElement(itwinui_react_1.LabeledTextarea, { className: "gmw-details-form", value: formula, name: "formula", label: "Formula", disabled: disabled, onChange: (event) => {
|
|
26
|
+
setFormula(event.target.value);
|
|
27
|
+
}, message: formulaErrorMessage, status: formulaErrorMessage ? "negative" : undefined, onBlur: (event) => {
|
|
28
|
+
if (event.target.textLength === 0)
|
|
29
|
+
setFormula(undefined);
|
|
30
|
+
}, onBlurCapture: () => {
|
|
31
|
+
forceValidation();
|
|
32
|
+
} })));
|
|
180
33
|
};
|
|
181
34
|
exports.CustomCalculationAction = CustomCalculationAction;
|
|
182
35
|
//# sourceMappingURL=CustomCalculationAction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomCalculationAction.js","sourceRoot":"","sources":["../../../../../src/components/Properties/CustomCalculations/CustomCalculationAction.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,wDAA2G;AAC3G,+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;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,SAAS;YACZ,O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AC,KAAK,CAAC,CAAC;wBACpC,SAAS,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;oBACnC,CAAC,GACD;gBACF,8BAAC,qBAAK,IACJ,IAAI,EAAC,eAAe,EACpB,aAAa,EAAC,aAAa,EAC3B,kBAAkB,EAAE;wBAClB,IAAI,EAAE,wGAAwG;wBAC9G,MAAM,EAAE,QAAQ;wBAChB,GAAG,EAAE,YAAY;qBAClB,wFAGK;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,GAAE,CAAC,EAChB,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC,EAChB,WAAW,EAAC,kBAAkB,GAC9B,CACO,CACP;QACN,8BAAC,qBAAW,IAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,gBAAgB,EAAE,CAAC,CAAC,OAAO,IAAI,YAAY,IAAI,OAAO,CAAC,EAAE,SAAS,EAAE,SAAS,GAAI,CACtI,CACJ,CAAC;AACJ,CAAC,CAAC;AAhJW,QAAA,uBAAuB,2BAgJlC","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 { Alert, Fieldset, LabeledInput, LabeledSelect, LabeledTextarea, Text } 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\":\n return \"Double\";\n case \"integer\":\n return \"Integer\";\n case \"string\":\n return \"String\";\n case \"boolean\":\n return \"Boolean\";\n default:\n return \"Undefined\";\n }\n};\n\nconst convertToPropertyMap = (properties: Property[], selectedPropertyName?: string): 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) 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 = ({ mappingId, groupId, customCalculation, onSaveSuccess, onClickCancel }: CustomCalculationActionProps) => {\n const { getAccessToken, iModelId } = useGroupingMappingApiConfig();\n const propertiesClient = usePropertiesClient();\n const [propertyName, setPropertyName] = useState<string>(customCalculation?.propertyName ?? \"\");\n const [formula, setFormula] = useState<string>(customCalculation?.formula ?? \"\");\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(\n async () => {\n const accessToken = await getAccessToken();\n\n if (customCalculation) {\n return propertiesClient.updateProperty(accessToken, mappingId, groupId, customCalculation.id, {\n propertyName,\n dataType: customCalculation.dataType,\n formula,\n quantityType,\n });\n }\n\n if (inferredDataType) {\n return propertiesClient.createProperty(accessToken, mappingId, groupId, {\n propertyName,\n dataType: inferToPropertyDataType(inferredDataType),\n formula,\n quantityType,\n });\n }\n return;\n },\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 (erroredResponse.error.code === \"InvalidInsightsRequest\" && erroredResponse.error.target === \"formula\") {\n setFormulaErrorMessage(erroredResponse.error.message);\n }\n } else {\n handleError(error.status);\n }\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={validator.message(\"name\", propertyName, NAME_REQUIREMENTS) ? \"negative\" : undefined}\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={{\n href: \"https://developer.bentley.com/apis/grouping-and-mapping/operations/create-property/#customcalculations\",\n target: \"_blank\",\n rel: \"noreferrer\",\n }}\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 onSave={onSave} onCancel={onClickCancel} isSavingDisabled={!(formula && propertyName && isValid)} isLoading={isLoading} />\n </>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"CustomCalculationAction.js","sourceRoot":"","sources":["../../../../../src/components/Properties/CustomCalculations/CustomCalculationAction.tsx"],"names":[],"mappings":";;;;;;AAAA;;;gGAGgG;AAChG,wDAA0E;AAC1E,kDAA0B;AAC1B,0CAAwC;AAcxC;;;GAGG;AACI,MAAM,uBAAuB,GAAG,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,eAAe,EAAE,QAAQ,EAAgC,EAAE,EAAE;IAC/I,OAAO,CACL,8BAAC,0BAAU,IAAC,SAAS,EAAC,yCAAyC;QAC7D,8BAAC,qBAAK,IACJ,IAAI,EAAC,eAAe,EACpB,aAAa,EAAC,aAAa,EAC3B,kBAAkB,EAAE;gBAClB,IAAI,EAAE,wGAAwG;gBAC9G,MAAM,EAAE,QAAQ;gBAChB,GAAG,EAAE,YAAY;aAClB,wFAGK;QACR,8BAAC,+BAAe,IACd,SAAS,EAAC,kBAAkB,EAC5B,KAAK,EAAE,OAAO,EACd,IAAI,EAAC,SAAS,EACd,KAAK,EAAC,SAAS,EACf,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;gBAClB,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACjC,CAAC,EACD,OAAO,EAAE,mBAAmB,EAC5B,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,EACpD,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;gBAChB,IAAI,KAAK,CAAC,MAAM,CAAC,UAAU,KAAK,CAAC;oBAAE,UAAU,CAAC,SAAS,CAAC,CAAC;YAC3D,CAAC,EACD,aAAa,EAAE,GAAG,EAAE;gBAClB,eAAe,EAAE,CAAC;YACpB,CAAC,GACD,CACS,CACd,CAAC;AACJ,CAAC,CAAC;AAlCW,QAAA,uBAAuB,2BAkClC","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 { Alert, InputGroup, LabeledTextarea } from \"@itwin/itwinui-react\";\nimport React from \"react\";\nimport \"./CustomCalculationAction.scss\";\n\n/**\n * Props for the {@link CustomCalculationAction} component.\n * @internal\n */\nexport interface CustomCalculationActionProps {\n formula?: string;\n setFormula: (formula: string | undefined) => void;\n formulaErrorMessage?: string;\n forceValidation: () => void;\n disabled?: boolean;\n}\n\n/**\n * Component to create or update a custom calculation property.\n * @internal\n */\nexport const CustomCalculationAction = ({ formula, setFormula, formulaErrorMessage, forceValidation, disabled }: CustomCalculationActionProps) => {\n return (\n <InputGroup className=\"gmw-custom-calculation-action-container\">\n <Alert\n type=\"informational\"\n clickableText=\"Click here.\"\n clickableTextProps={{\n href: \"https://developer.bentley.com/apis/grouping-and-mapping/operations/create-property/#customcalculations\",\n target: \"_blank\",\n rel: \"noreferrer\",\n }}\n >\n To learn more about creating custom calculation formulas, view the documentation.\n </Alert>\n <LabeledTextarea\n className=\"gmw-details-form\"\n value={formula}\n name=\"formula\"\n label=\"Formula\"\n disabled={disabled}\n onChange={(event) => {\n setFormula(event.target.value);\n }}\n message={formulaErrorMessage}\n status={formulaErrorMessage ? \"negative\" : undefined}\n onBlur={(event) => {\n if (event.target.textLength === 0) setFormula(undefined);\n }}\n onBlurCapture={() => {\n forceValidation();\n }}\n />\n </InputGroup>\n );\n};\n"]}
|
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
|
|
6
6
|
.gmw-custom-calculation-action-container {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
7
9
|
overflow-x: auto;
|
|
8
10
|
height: 100%;
|
|
11
|
+
gap: var(--iui-size-s);
|
|
9
12
|
|
|
10
13
|
.gmw-details-form {
|
|
11
|
-
|
|
12
|
-
flex-direction: column;
|
|
13
|
-
gap: var(--iui-size-s);
|
|
14
|
+
padding-top: var(--iui-size-s);
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -46,6 +46,13 @@ const GroupsPropertiesSelectionModal_1 = require("./GroupsPropertiesSelectionMod
|
|
|
46
46
|
const react_query_1 = require("@tanstack/react-query");
|
|
47
47
|
const GroupPropertyListItem_1 = require("./GroupPropertyListItem");
|
|
48
48
|
const PropertiesClientContext_1 = require("../../context/PropertiesClientContext");
|
|
49
|
+
const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
|
|
50
|
+
const CalculatedPropertyActionWithVisuals_1 = require("../CalculatedProperties/CalculatedPropertyActionWithVisuals");
|
|
51
|
+
const utils_1 = require("../../../common/utils");
|
|
52
|
+
const CustomCalculationAction_1 = require("../CustomCalculations/CustomCalculationAction");
|
|
53
|
+
const usePropertiesQuery_1 = require("../hooks/usePropertiesQuery");
|
|
54
|
+
const useFormulaValidation_1 = require("../hooks/useFormulaValidation");
|
|
55
|
+
const ScrollableExpandableBlock_1 = require("../ScrollableExpandableBlock");
|
|
49
56
|
exports.quantityTypesSelectionOptions = [
|
|
50
57
|
{ value: insights_client_1.QuantityType.Area, label: "Area" },
|
|
51
58
|
{ value: insights_client_1.QuantityType.Distance, label: "Distance" },
|
|
@@ -61,23 +68,35 @@ exports.quantityTypesSelectionOptions = [
|
|
|
61
68
|
* @public
|
|
62
69
|
*/
|
|
63
70
|
const GroupPropertyAction = ({ mappingId, group, groupProperty, onSaveSuccess, onClickCancel }) => {
|
|
64
|
-
const
|
|
71
|
+
const actionContainerRef = (0, react_1.useRef)(null);
|
|
72
|
+
const calculatedPropertyActionRef = (0, react_1.useRef)(null);
|
|
73
|
+
const customCalculationActionRef = (0, react_1.useRef)(null);
|
|
65
74
|
const propertiesClient = (0, PropertiesClientContext_1.usePropertiesClient)();
|
|
75
|
+
const queryClient = (0, react_query_1.useQueryClient)();
|
|
66
76
|
const [propertyName, setPropertyName] = (0, react_1.useState)("");
|
|
67
77
|
const [oldPropertyName, setOldPropertyName] = (0, react_1.useState)("");
|
|
68
|
-
const [dataType, setDataType] = (0, react_1.useState)(insights_client_1.DataType.String);
|
|
69
|
-
const [quantityType, setQuantityType] = (0, react_1.useState)();
|
|
78
|
+
const [dataType, setDataType] = (0, react_1.useState)(groupProperty?.dataType ?? insights_client_1.DataType.String);
|
|
79
|
+
const [quantityType, setQuantityType] = (0, react_1.useState)(groupProperty?.quantityType ?? undefined);
|
|
70
80
|
const [selectedProperties, setSelectedProperties] = (0, react_1.useState)([]);
|
|
71
81
|
const [propertiesMetaData, setPropertiesMetaData] = (0, react_1.useState)([]);
|
|
72
82
|
const [propertiesNotFoundAlert, setPropertiesNotFoundAlert] = (0, react_1.useState)(false);
|
|
73
83
|
const [validator, showValidationMessage] = (0, useValidator_1.default)();
|
|
74
84
|
const [showPropertiesSelectionModal, setShowPropertiesSelectionModal] = (0, react_1.useState)(false);
|
|
75
85
|
const [showSaveConfirmationModal, setShowSaveConfirmationModal] = (0, react_1.useState)(false);
|
|
76
|
-
const
|
|
86
|
+
const [calculatedPropertyType, setCalculatedPropertyType] = (0, react_1.useState)(groupProperty?.calculatedPropertyType ?? undefined);
|
|
87
|
+
const [isCalculatedBlockExpanded, setIsCalculatedBlockExpanded] = (0, react_1.useState)(!!calculatedPropertyType);
|
|
88
|
+
const [formula, setFormula] = (0, react_1.useState)(groupProperty?.formula ?? undefined);
|
|
89
|
+
const [formulaErrorMessage, setFormulaErrorMessage] = (0, react_1.useState)(undefined);
|
|
90
|
+
const { getAccessToken, iModelId, iModelConnection } = (0, GroupingApiConfigContext_1.useGroupingMappingApiConfig)();
|
|
91
|
+
const { data: groupProperties, isFetching: isLoadingGroupProperties } = (0, usePropertiesQuery_1.usePropertiesQuery)(iModelId, mappingId, group.id, getAccessToken, propertiesClient);
|
|
92
|
+
const { forceValidation } = (0, useFormulaValidation_1.useFormulaValidation)(propertyName.toLowerCase(), formula, groupProperties?.properties ?? [], setFormulaErrorMessage, dataType);
|
|
77
93
|
const reset = (0, react_1.useCallback)(() => {
|
|
78
94
|
setPropertyName("");
|
|
79
95
|
setDataType(insights_client_1.DataType.String);
|
|
96
|
+
setQuantityType(undefined);
|
|
80
97
|
setSelectedProperties([]);
|
|
98
|
+
setCalculatedPropertyType(undefined);
|
|
99
|
+
setFormula(undefined);
|
|
81
100
|
}, []);
|
|
82
101
|
const fetchPropertiesMetadata = (0, react_1.useCallback)(async () => {
|
|
83
102
|
if (!iModelConnection)
|
|
@@ -95,6 +114,16 @@ const GroupPropertyAction = ({ mappingId, group, groupProperty, onSaveSuccess, o
|
|
|
95
114
|
}
|
|
96
115
|
return { propertiesMetaData, groupPropertyDetails };
|
|
97
116
|
}, [getAccessToken, group.id, group.query, groupProperty, iModelConnection, mappingId, propertiesClient]);
|
|
117
|
+
const scrollToFormulaErrorMessage = (0, react_1.useCallback)(() => {
|
|
118
|
+
setTimeout(() => {
|
|
119
|
+
if (actionContainerRef.current && customCalculationActionRef.current) {
|
|
120
|
+
actionContainerRef.current.scrollTo({
|
|
121
|
+
top: customCalculationActionRef.current.offsetTop,
|
|
122
|
+
behavior: "smooth",
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}, 500);
|
|
126
|
+
}, [actionContainerRef]);
|
|
98
127
|
const { data, isFetching: isLoadingProperties, isSuccess: isLoadingPropertiesSuccessful, } = (0, react_query_1.useQuery)(["properties", iModelId, mappingId, group.id, groupProperty?.id, "metadata"], fetchPropertiesMetadata);
|
|
99
128
|
(0, react_1.useEffect)(() => {
|
|
100
129
|
if (isLoadingPropertiesSuccessful && data?.propertiesMetaData) {
|
|
@@ -105,14 +134,29 @@ const GroupPropertyAction = ({ mappingId, group, groupProperty, onSaveSuccess, o
|
|
|
105
134
|
setDataType(data.groupPropertyDetails.dataType);
|
|
106
135
|
if (data.groupPropertyDetails.quantityType)
|
|
107
136
|
setQuantityType(data.groupPropertyDetails.quantityType);
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
137
|
+
if (data.groupPropertyDetails.ecProperties) {
|
|
138
|
+
const properties = (0, GroupPropertyUtils_1.findProperties)(data.groupPropertyDetails.ecProperties, data.propertiesMetaData);
|
|
139
|
+
if (properties.length === 0) {
|
|
140
|
+
setPropertiesNotFoundAlert(true);
|
|
141
|
+
}
|
|
142
|
+
setSelectedProperties(properties);
|
|
111
143
|
}
|
|
112
|
-
setSelectedProperties(properties);
|
|
113
144
|
}
|
|
114
145
|
}
|
|
115
146
|
}, [data, isLoadingPropertiesSuccessful]);
|
|
147
|
+
(0, react_1.useEffect)(() => {
|
|
148
|
+
if (calculatedPropertyType) {
|
|
149
|
+
setDataType(insights_client_1.DataType.Double);
|
|
150
|
+
}
|
|
151
|
+
if (isCalculatedBlockExpanded === false || !calculatedPropertyType) {
|
|
152
|
+
(0, viewerUtils_1.clearAll)();
|
|
153
|
+
}
|
|
154
|
+
}, [calculatedPropertyType, isCalculatedBlockExpanded]);
|
|
155
|
+
(0, react_1.useEffect)(() => {
|
|
156
|
+
if (formulaErrorMessage) {
|
|
157
|
+
scrollToFormulaErrorMessage();
|
|
158
|
+
}
|
|
159
|
+
}, [formulaErrorMessage, scrollToFormulaErrorMessage]);
|
|
116
160
|
const { mutate: onSave, isLoading: isSaving } = (0, react_query_1.useMutation)({
|
|
117
161
|
mutationFn: async () => {
|
|
118
162
|
const accessToken = await getAccessToken();
|
|
@@ -121,6 +165,8 @@ const GroupPropertyAction = ({ mappingId, group, groupProperty, onSaveSuccess, o
|
|
|
121
165
|
dataType,
|
|
122
166
|
quantityType,
|
|
123
167
|
ecProperties: selectedProperties.map((p) => (0, GroupPropertyUtils_1.convertToECProperties)(p)).flat(),
|
|
168
|
+
calculatedPropertyType,
|
|
169
|
+
formula,
|
|
124
170
|
};
|
|
125
171
|
return groupProperty
|
|
126
172
|
? propertiesClient.updateProperty(accessToken, mappingId, group.id, groupProperty.id, newGroupProperty)
|
|
@@ -131,6 +177,9 @@ const GroupPropertyAction = ({ mappingId, group, groupProperty, onSaveSuccess, o
|
|
|
131
177
|
reset();
|
|
132
178
|
await queryClient.invalidateQueries(["properties", iModelId, mappingId, group.id]);
|
|
133
179
|
},
|
|
180
|
+
onError(error) {
|
|
181
|
+
(0, utils_1.handleError)(error.status);
|
|
182
|
+
},
|
|
134
183
|
});
|
|
135
184
|
const handleSaveClick = async () => {
|
|
136
185
|
if (!validator.allValid()) {
|
|
@@ -147,9 +196,9 @@ const GroupPropertyAction = ({ mappingId, group, groupProperty, onSaveSuccess, o
|
|
|
147
196
|
const handleCloseSaveModal = () => {
|
|
148
197
|
setShowSaveConfirmationModal(false);
|
|
149
198
|
};
|
|
150
|
-
const isLoading = isLoadingProperties || isSaving;
|
|
199
|
+
const isLoading = isLoadingProperties || isSaving || isLoadingGroupProperties;
|
|
151
200
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
152
|
-
react_1.default.createElement("div", { className: "gmw-group-property-action-container" },
|
|
201
|
+
react_1.default.createElement("div", { className: "gmw-group-property-action-container", ref: actionContainerRef },
|
|
153
202
|
react_1.default.createElement(itwinui_react_1.Fieldset, { disabled: isLoading, className: "gmw-property-options", legend: "Property Details" },
|
|
154
203
|
react_1.default.createElement(itwinui_react_1.Text, { variant: "small", as: "small", className: "gmw-field-legend" }, "Asterisk * indicates mandatory fields."),
|
|
155
204
|
react_1.default.createElement(itwinui_react_1.LabeledInput, { id: "propertyName", label: "Property Name", value: propertyName, required: true, onChange: (event) => {
|
|
@@ -163,21 +212,29 @@ const GroupPropertyAction = ({ mappingId, group, groupProperty, onSaveSuccess, o
|
|
|
163
212
|
{ value: insights_client_1.DataType.Integer, label: "Integer" },
|
|
164
213
|
{ value: insights_client_1.DataType.Double, label: "Double" },
|
|
165
214
|
{ value: insights_client_1.DataType.String, label: "String" },
|
|
166
|
-
], required: true, value: dataType, onChange: (value) => {
|
|
215
|
+
], required: true, value: calculatedPropertyType ? insights_client_1.DataType.Double : dataType, onChange: (value) => {
|
|
167
216
|
validator.showMessageFor("dataType");
|
|
168
217
|
setDataType(value);
|
|
169
218
|
}, message: validator.message("dataType", propertyName, "required"), status: validator.message("dataType", propertyName, "required") ? "negative" : undefined, onBlur: () => {
|
|
170
219
|
validator.showMessageFor("dataType");
|
|
171
|
-
}, onShow: () => { }, onHide: () => { } }),
|
|
220
|
+
}, disabled: calculatedPropertyType ? true : false, onShow: () => { }, onHide: () => { } }),
|
|
172
221
|
react_1.default.createElement(itwinui_react_1.LabeledSelect, { label: "Quantity Type", options: exports.quantityTypesSelectionOptions, value: quantityType, onChange: setQuantityType, onShow: () => { }, onHide: () => { }, placeholder: "No Quantity Type" })),
|
|
173
222
|
propertiesNotFoundAlert && (react_1.default.createElement(itwinui_react_1.Alert, { type: "warning" }, "Warning: Could not match saved properties from the current generated list. It does not confirm or deny validity. Overwriting will occur if a new selection is made and saved.")),
|
|
174
|
-
react_1.default.createElement(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
react_1.default.createElement(
|
|
180
|
-
|
|
223
|
+
react_1.default.createElement(ScrollableExpandableBlock_1.ScrollableExpandableBlock, { title: "Mapped Properties", endIcon: react_1.default.createElement(itwinui_react_1.Icon, { fill: selectedProperties.length > 0 ? "informational" : "default" },
|
|
224
|
+
react_1.default.createElement(itwinui_icons_react_1.SvgLabel, null)), isExpanded: selectedProperties.length > 0, setIsExpanded: () => { } },
|
|
225
|
+
react_1.default.createElement("div", { className: "gmw-property-view-container" },
|
|
226
|
+
react_1.default.createElement("div", { className: "gmw-property-view-button" },
|
|
227
|
+
react_1.default.createElement(itwinui_react_1.Button, { onClick: async () => setShowPropertiesSelectionModal(true), disabled: isLoading }, "Select Properties")),
|
|
228
|
+
react_1.default.createElement("div", { className: "gmw-properties-list" }, selectedProperties.length === 0 && !isLoading ? (react_1.default.createElement("div", { className: "gmw-empty-selection" },
|
|
229
|
+
react_1.default.createElement(itwinui_react_1.Text, null, "No properties selected."),
|
|
230
|
+
react_1.default.createElement(itwinui_react_1.Text, null, "Press the \"Select Properties\" button for options."))) : (selectedProperties.map((property) => (react_1.default.createElement(GroupPropertyListItem_1.GroupPropertyListItem, { key: property.key, content: `${property.displayLabel}`, title: `${property.actualECClassName}`, description: property.categoryLabel }))))))),
|
|
231
|
+
react_1.default.createElement(ScrollableExpandableBlock_1.ScrollableExpandableBlock, { parentRef: actionContainerRef, ref: calculatedPropertyActionRef, title: "Calculated Property", endIcon: react_1.default.createElement(itwinui_react_1.Icon, { fill: calculatedPropertyType ? "informational" : "default" },
|
|
232
|
+
react_1.default.createElement(itwinui_icons_react_1.SvgMeasure, null)), isExpanded: !!calculatedPropertyType, setIsExpanded: setIsCalculatedBlockExpanded },
|
|
233
|
+
react_1.default.createElement(CalculatedPropertyActionWithVisuals_1.CalculatedPropertyActionWithVisuals, { group: group, calculatedPropertyType: calculatedPropertyType, setCalculatedPropertyType: setCalculatedPropertyType })),
|
|
234
|
+
react_1.default.createElement(ScrollableExpandableBlock_1.ScrollableExpandableBlock, { parentRef: actionContainerRef, ref: customCalculationActionRef, title: "Custom Calculation", endIcon: react_1.default.createElement(itwinui_react_1.Icon, { fill: formula ? "informational" : "default" },
|
|
235
|
+
react_1.default.createElement(itwinui_icons_react_1.SvgFunction, null)), isExpanded: formula !== undefined, setIsExpanded: () => { } },
|
|
236
|
+
react_1.default.createElement(CustomCalculationAction_1.CustomCalculationAction, { formula: formula, setFormula: setFormula, formulaErrorMessage: formulaErrorMessage, forceValidation: forceValidation, disabled: isLoading }))),
|
|
237
|
+
react_1.default.createElement(ActionPanel_1.default, { onSave: handleSaveClick, onCancel: onClickCancel, onSaveCapture: viewerUtils_1.clearAll, onCancelCapture: viewerUtils_1.clearAll, isLoading: isLoading, isSavingDisabled: !propertyName || dataType === undefined || formulaErrorMessage !== undefined }),
|
|
181
238
|
react_1.default.createElement(GroupsPropertiesSelectionModal_1.GroupsPropertiesSelectionModal, { showModal: showPropertiesSelectionModal, setShowModal: setShowPropertiesSelectionModal, selectedProperties: selectedProperties, setSelectedProperties: setSelectedProperties, propertiesMetaData: propertiesMetaData }),
|
|
182
239
|
react_1.default.createElement(SaveModal_1.SaveModal, { onSave: onSave, onClose: handleCloseSaveModal, showSaveModal: showSaveConfirmationModal })));
|
|
183
240
|
};
|