@itwin/grouping-mapping-widget 0.26.1 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/lib/cjs/WidgetShell/Router/GroupingMappingRouter.js +1 -15
  2. package/lib/cjs/WidgetShell/Router/GroupingMappingRouter.js.map +1 -1
  3. package/lib/cjs/components/Groups/hooks/useKeySetHiliteQueries.d.ts +1 -1
  4. package/lib/cjs/components/Mappings/MappingViewActionGroup.d.ts +1 -1
  5. package/lib/cjs/components/Mappings/MappingViewActionGroup.js +1 -2
  6. package/lib/cjs/components/Mappings/MappingViewActionGroup.js.map +1 -1
  7. package/lib/cjs/components/Mappings/MappingsView.js +1 -1
  8. package/lib/cjs/components/Mappings/MappingsView.js.map +1 -1
  9. package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyAction.d.ts +2 -0
  10. package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyAction.js +2 -1
  11. package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyAction.js.map +1 -1
  12. package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.d.ts +7 -8
  13. package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js +21 -61
  14. package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js.map +1 -1
  15. package/lib/cjs/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.d.ts +5 -9
  16. package/lib/cjs/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.js +3 -12
  17. package/lib/cjs/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.js.map +1 -1
  18. package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.d.ts +8 -9
  19. package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.js +17 -164
  20. package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.js.map +1 -1
  21. package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.scss +4 -3
  22. package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.js +76 -19
  23. package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.js.map +1 -1
  24. package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.scss +3 -2
  25. package/lib/cjs/components/Properties/GroupProperties/GroupPropertyTable.js +10 -2
  26. package/lib/cjs/components/Properties/GroupProperties/GroupPropertyTable.js.map +1 -1
  27. package/lib/cjs/components/Properties/PropertyMenu.d.ts +1 -1
  28. package/lib/cjs/components/Properties/PropertyMenu.js +2 -7
  29. package/lib/cjs/components/Properties/PropertyMenu.js.map +1 -1
  30. package/lib/cjs/components/Properties/ScrollableExpandableBlock.d.ts +11 -0
  31. package/lib/cjs/components/Properties/ScrollableExpandableBlock.js +55 -0
  32. package/lib/cjs/components/Properties/ScrollableExpandableBlock.js.map +1 -0
  33. package/lib/cjs/components/Properties/hooks/useFormulaValidation.d.ts +6 -3
  34. package/lib/cjs/components/Properties/hooks/useFormulaValidation.js +59 -13
  35. package/lib/cjs/components/Properties/hooks/useFormulaValidation.js.map +1 -1
  36. package/lib/cjs/components/Properties/hooks/useForwardRef.d.ts +3 -0
  37. package/lib/cjs/components/Properties/hooks/useForwardRef.js +20 -0
  38. package/lib/cjs/components/Properties/hooks/useForwardRef.js.map +1 -0
  39. package/lib/cjs/components/SharedComponents/ActionPanel.d.ts +3 -1
  40. package/lib/cjs/components/SharedComponents/ActionPanel.js +3 -3
  41. package/lib/cjs/components/SharedComponents/ActionPanel.js.map +1 -1
  42. package/lib/cjs/formula/FormulaDataTypeResolver.d.ts +3 -2
  43. package/lib/cjs/formula/FormulaDataTypeResolver.js +10 -6
  44. package/lib/cjs/formula/FormulaDataTypeResolver.js.map +1 -1
  45. package/lib/cjs/grouping-mapping-widget.d.ts +0 -2
  46. package/lib/cjs/grouping-mapping-widget.js +1 -5
  47. package/lib/cjs/grouping-mapping-widget.js.map +1 -1
  48. package/lib/esm/WidgetShell/Router/GroupingMappingRouter.js +1 -15
  49. package/lib/esm/WidgetShell/Router/GroupingMappingRouter.js.map +1 -1
  50. package/lib/esm/components/Groups/hooks/useKeySetHiliteQueries.d.ts +1 -1
  51. package/lib/esm/components/Mappings/MappingViewActionGroup.d.ts +1 -1
  52. package/lib/esm/components/Mappings/MappingViewActionGroup.js +1 -2
  53. package/lib/esm/components/Mappings/MappingViewActionGroup.js.map +1 -1
  54. package/lib/esm/components/Mappings/MappingsView.js +1 -1
  55. package/lib/esm/components/Mappings/MappingsView.js.map +1 -1
  56. package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyAction.d.ts +2 -0
  57. package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyAction.js +2 -1
  58. package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyAction.js.map +1 -1
  59. package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.d.ts +7 -8
  60. package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js +23 -60
  61. package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js.map +1 -1
  62. package/lib/esm/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.d.ts +5 -9
  63. package/lib/esm/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.js +4 -13
  64. package/lib/esm/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.js.map +1 -1
  65. package/lib/esm/components/Properties/CustomCalculations/CustomCalculationAction.d.ts +8 -9
  66. package/lib/esm/components/Properties/CustomCalculations/CustomCalculationAction.js +18 -142
  67. package/lib/esm/components/Properties/CustomCalculations/CustomCalculationAction.js.map +1 -1
  68. package/lib/esm/components/Properties/CustomCalculations/CustomCalculationAction.scss +4 -3
  69. package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.js +79 -22
  70. package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.js.map +1 -1
  71. package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.scss +3 -2
  72. package/lib/esm/components/Properties/GroupProperties/GroupPropertyTable.js +12 -4
  73. package/lib/esm/components/Properties/GroupProperties/GroupPropertyTable.js.map +1 -1
  74. package/lib/esm/components/Properties/PropertyMenu.d.ts +1 -1
  75. package/lib/esm/components/Properties/PropertyMenu.js +2 -7
  76. package/lib/esm/components/Properties/PropertyMenu.js.map +1 -1
  77. package/lib/esm/components/Properties/ScrollableExpandableBlock.d.ts +11 -0
  78. package/lib/esm/components/Properties/ScrollableExpandableBlock.js +29 -0
  79. package/lib/esm/components/Properties/ScrollableExpandableBlock.js.map +1 -0
  80. package/lib/esm/components/Properties/hooks/useFormulaValidation.d.ts +6 -3
  81. package/lib/esm/components/Properties/hooks/useFormulaValidation.js +57 -12
  82. package/lib/esm/components/Properties/hooks/useFormulaValidation.js.map +1 -1
  83. package/lib/esm/components/Properties/hooks/useForwardRef.d.ts +3 -0
  84. package/lib/esm/components/Properties/hooks/useForwardRef.js +16 -0
  85. package/lib/esm/components/Properties/hooks/useForwardRef.js.map +1 -0
  86. package/lib/esm/components/SharedComponents/ActionPanel.d.ts +3 -1
  87. package/lib/esm/components/SharedComponents/ActionPanel.js +3 -3
  88. package/lib/esm/components/SharedComponents/ActionPanel.js.map +1 -1
  89. package/lib/esm/formula/FormulaDataTypeResolver.d.ts +3 -2
  90. package/lib/esm/formula/FormulaDataTypeResolver.js +10 -6
  91. package/lib/esm/formula/FormulaDataTypeResolver.js.map +1 -1
  92. package/lib/esm/grouping-mapping-widget.d.ts +0 -2
  93. package/lib/esm/grouping-mapping-widget.js +0 -2
  94. package/lib/esm/grouping-mapping-widget.js.map +1 -1
  95. package/package.json +1 -1
  96. package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.d.ts +0 -14
  97. package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.js +0 -87
  98. package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.js.map +0 -1
  99. package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.scss +0 -9
  100. package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationTable.d.ts +0 -13
  101. package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationTable.js +0 -91
  102. package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationTable.js.map +0 -1
  103. package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyTable.d.ts +0 -14
  104. package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyTable.js +0 -60
  105. package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyTable.js.map +0 -1
  106. package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyTable.scss +0 -9
  107. package/lib/esm/components/Properties/CustomCalculations/CustomCalculationTable.d.ts +0 -13
  108. package/lib/esm/components/Properties/CustomCalculations/CustomCalculationTable.js +0 -64
  109. package/lib/esm/components/Properties/CustomCalculations/CustomCalculationTable.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"SharedCalculatedPropertyForms.js","sourceRoot":"","sources":["../../../../../src/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAanE,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,EAC5C,YAAY,EACZ,eAAe,EACf,IAAI,EACJ,OAAO,EACP,SAAS,EACT,YAAY,EACZ,oBAAoB,GACe,EAAE,EAAE;IACvC,MAAM,yCAAyC,GAAG,WAAW,CAAC,GAAG,EAAE;QACjE,MAAM,OAAO,GAA2C,EAAE,CAAC;QAE3D,MAAM,aAAa,GAAG,sBAA8D,CAAC;QAErF,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,CAAC;YACnC,CAAC,GACD;QACF,oBAAC,aAAa,IACZ,KAAK,EAAC,eAAe,EACrB,QAAQ,QACR,OAAO,EAAE,yCAAyC,EAAE,EACpD,KAAK,EAAE,IAAI,EACX,QAAQ,EAAE,OAAO,EACjB,YAAY,EAAE,YAAY,EAC1B,oBAAoB,EAAE,oBAAoB,EAC1C,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC,EAChB,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC,GAChB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nimport { CalculatedPropertyType } from \"@itwin/insights-client\";\nimport React, { useCallback } from \"react\";\nimport { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { LabeledInput, LabeledSelect } from \"@itwin/itwinui-react\";\nimport type SimpleReactValidator from \"simple-react-validator\";\n\ninterface SharedCalculatedPropertyFormsProps {\n propertyName: string;\n setPropertyName: (value: string) => void;\n type: CalculatedPropertyType | undefined;\n setType: (value: CalculatedPropertyType | undefined) => void;\n validator: SimpleReactValidator;\n itemRenderer?: (option: SelectOption<string>) => JSX.Element;\n selectedItemRenderer?: (option: SelectOption<string>) => JSX.Element;\n}\n\nexport const SharedCalculatedPropertyForms = ({\n propertyName,\n setPropertyName,\n type,\n setType,\n validator,\n itemRenderer,\n selectedItemRenderer,\n}: SharedCalculatedPropertyFormsProps) => {\n const generateOptionsFromCalculatedPropertyType = useCallback(() => {\n const options: SelectOption<CalculatedPropertyType>[] = [];\n\n const indexableEnum = CalculatedPropertyType as unknown as { [key: string]: string };\n\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 <LabeledInput\n value={propertyName}\n required\n name=\"name\"\n label=\"Name\"\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 <LabeledSelect<CalculatedPropertyType>\n label=\"Quantity Type\"\n required\n options={generateOptionsFromCalculatedPropertyType()}\n value={type}\n onChange={setType}\n itemRenderer={itemRenderer}\n selectedItemRenderer={selectedItemRenderer}\n onShow={() => {}}\n onHide={() => {}}\n />\n </>\n );\n};\n"]}
1
+ {"version":3,"file":"SharedCalculatedPropertyForms.js","sourceRoot":"","sources":["../../../../../src/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AASrD,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,EAC5C,sBAAsB,EACtB,yBAAyB,EACzB,YAAY,EACZ,oBAAoB,GACe,EAAE,EAAE;IACvC,MAAM,yCAAyC,GAAG,WAAW,CAAC,GAAG,EAAE;QACjE,MAAM,OAAO,GAAuD,EAAE,CAAC;QACvE,MAAM,aAAa,GAAG,sBAA8D,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,oBAAC,aAAa,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","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
- * @public
5
+ * @internal
7
6
  */
8
7
  export interface CustomCalculationActionProps {
9
- mappingId: string;
10
- groupId: string;
11
- customCalculation?: Property;
12
- onSaveSuccess: () => void;
13
- onClickCancel?: () => void;
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
- * @public
16
+ * @internal
18
17
  */
19
- export declare const CustomCalculationAction: ({ mappingId, groupId, customCalculation, onSaveSuccess, onClickCancel }: CustomCalculationActionProps) => JSX.Element;
18
+ export declare const CustomCalculationAction: ({ formula, setFormula, formulaErrorMessage, forceValidation, disabled }: CustomCalculationActionProps) => JSX.Element;
20
19
  //# sourceMappingURL=CustomCalculationAction.d.ts.map
@@ -2,151 +2,27 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- import { Alert, Fieldset, LabeledInput, LabeledSelect, LabeledTextarea, Text } from "@itwin/itwinui-react";
6
- import React, { useEffect, useState } from "react";
7
- import ActionPanel from "../../SharedComponents/ActionPanel";
8
- import useValidator, { NAME_REQUIREMENTS } from "../hooks/useValidator";
9
- import { handleError } from "../../../common/utils";
5
+ import { Alert, InputGroup, LabeledTextarea } from "@itwin/itwinui-react";
6
+ import React from "react";
10
7
  import "./CustomCalculationAction.scss";
11
- import { quantityTypesSelectionOptions } from "../GroupProperties/GroupPropertyAction";
12
- import { useFormulaValidation } from "../hooks/useFormulaValidation";
13
- import { useGroupingMappingApiConfig } from "../../context/GroupingApiConfigContext";
14
- import { DataType } from "@itwin/insights-client";
15
- import { usePropertiesQuery } from "../hooks/usePropertiesQuery";
16
- import { useMutation, useQueryClient } from "@tanstack/react-query";
17
- import { usePropertiesClient } from "../../context/PropertiesClientContext";
18
- const stringToPossibleDataType = (str) => {
19
- switch (str?.toLowerCase()) {
20
- case "double":
21
- return "Double";
22
- case "integer":
23
- return "Integer";
24
- case "string":
25
- return "String";
26
- case "boolean":
27
- return "Boolean";
28
- default:
29
- return "Undefined";
30
- }
31
- };
32
- const convertToPropertyMap = (properties, selectedPropertyName) => {
33
- const map = {};
34
- const selectedLowerName = selectedPropertyName?.toLowerCase();
35
- properties.forEach((p) => {
36
- const lowerName = p.propertyName?.toLowerCase();
37
- if (lowerName && lowerName !== selectedLowerName)
38
- map[lowerName] = stringToPossibleDataType(p.dataType);
39
- });
40
- return map;
41
- };
42
- const inferToPropertyDataType = (value) => {
43
- switch (value) {
44
- case "Double":
45
- return DataType.Double;
46
- case "Integer":
47
- return DataType.Integer;
48
- case "String":
49
- return DataType.String;
50
- case "Boolean":
51
- return DataType.Boolean;
52
- default:
53
- return DataType.String;
54
- }
55
- };
56
8
  /**
57
9
  * Component to create or update a custom calculation property.
58
- * @public
10
+ * @internal
59
11
  */
60
- export const CustomCalculationAction = ({ mappingId, groupId, customCalculation, onSaveSuccess, onClickCancel }) => {
61
- const { getAccessToken, iModelId } = useGroupingMappingApiConfig();
62
- const propertiesClient = usePropertiesClient();
63
- const [propertyName, setPropertyName] = useState(customCalculation?.propertyName ?? "");
64
- const [formula, setFormula] = useState(customCalculation?.formula ?? "");
65
- const [quantityType, setQuantityType] = useState(customCalculation?.quantityType ?? undefined);
66
- const [formulaErrorMessage, setFormulaErrorMessage] = useState("");
67
- const [validator, showValidationMessage] = useValidator();
68
- const [properties, setProperties] = useState({});
69
- const { isValid, forceValidation, inferredDataType } = useFormulaValidation(propertyName.toLowerCase(), formula, properties, setFormulaErrorMessage);
70
- const queryClient = useQueryClient();
71
- const { data: groupProperties, isFetching: isLoadingGroupProperties } = usePropertiesQuery(iModelId, mappingId, groupId, getAccessToken, propertiesClient);
72
- useEffect(() => {
73
- const propertiesMap = convertToPropertyMap(groupProperties?.properties ?? []);
74
- setProperties(propertiesMap);
75
- }, [groupProperties]);
76
- const { mutate: saveMutation, isLoading: isSaving } = useMutation(async () => {
77
- const accessToken = await getAccessToken();
78
- if (customCalculation) {
79
- return propertiesClient.updateProperty(accessToken, mappingId, groupId, customCalculation.id, {
80
- propertyName,
81
- dataType: customCalculation.dataType,
82
- formula,
83
- quantityType,
84
- });
85
- }
86
- if (inferredDataType) {
87
- return propertiesClient.createProperty(accessToken, mappingId, groupId, {
88
- propertyName,
89
- dataType: inferToPropertyDataType(inferredDataType),
90
- formula,
91
- quantityType,
92
- });
93
- }
94
- return;
95
- }, {
96
- onSuccess: async () => {
97
- await queryClient.invalidateQueries({ queryKey: ["properties", iModelId, mappingId, groupId] });
98
- onSaveSuccess();
99
- setPropertyName("");
100
- setFormula("");
101
- setQuantityType(undefined);
102
- },
103
- onError: async (error) => {
104
- if (error.status === 422) {
105
- const erroredResponse = await error.json();
106
- if (erroredResponse.error.code === "InvalidInsightsRequest" && erroredResponse.error.target === "formula") {
107
- setFormulaErrorMessage(erroredResponse.error.message);
108
- }
109
- }
110
- else {
111
- handleError(error.status);
112
- }
113
- },
114
- });
115
- const onSave = () => {
116
- if (!validator.allValid()) {
117
- showValidationMessage(true);
118
- return;
119
- }
120
- if (!forceValidation()) {
121
- return;
122
- }
123
- saveMutation();
124
- };
125
- const isLoading = isSaving || isLoadingGroupProperties;
126
- return (React.createElement(React.Fragment, null,
127
- React.createElement("div", { className: "gmw-custom-calculation-action-container" },
128
- React.createElement(Fieldset, { legend: "Custom Calculation Details", className: "gmw-details-form" },
129
- React.createElement(Text, { variant: "small", as: "small", className: "gmw-field-legend" }, "Asterisk * indicates mandatory fields."),
130
- React.createElement(LabeledInput, { value: propertyName, required: true, name: "name", label: "Name", disabled: isLoading, onChange: (event) => {
131
- setPropertyName(event.target.value);
132
- validator.showMessageFor("name");
133
- }, message: validator.message("name", propertyName, NAME_REQUIREMENTS), status: validator.message("name", propertyName, NAME_REQUIREMENTS) ? "negative" : undefined, onBlur: () => {
134
- validator.showMessageFor("name");
135
- }, onBlurCapture: (event) => {
136
- setPropertyName(event.target.value);
137
- validator.showMessageFor("name");
138
- } }),
139
- React.createElement(Alert, { type: "informational", clickableText: "Click here.", clickableTextProps: {
140
- href: "https://developer.bentley.com/apis/grouping-and-mapping/operations/create-property/#customcalculations",
141
- target: "_blank",
142
- rel: "noreferrer",
143
- } }, "To learn more about creating custom calculation formulas, view the documentation."),
144
- React.createElement(LabeledTextarea, { value: formula, required: true, name: "formula", label: "Formula", disabled: isLoading, onChange: (event) => {
145
- setFormula(event.target.value);
146
- }, message: formulaErrorMessage, status: formulaErrorMessage ? "negative" : undefined, onBlurCapture: () => {
147
- forceValidation();
148
- } }),
149
- React.createElement(LabeledSelect, { label: "Quantity Type", disabled: isLoading, options: quantityTypesSelectionOptions, value: quantityType, onChange: setQuantityType, onShow: () => { }, onHide: () => { }, placeholder: "No Quantity Type" }))),
150
- React.createElement(ActionPanel, { onSave: onSave, onCancel: onClickCancel, isSavingDisabled: !(formula && propertyName && isValid), isLoading: isLoading })));
12
+ export const CustomCalculationAction = ({ formula, setFormula, formulaErrorMessage, forceValidation, disabled }) => {
13
+ return (React.createElement(InputGroup, { className: "gmw-custom-calculation-action-container" },
14
+ React.createElement(Alert, { type: "informational", clickableText: "Click here.", clickableTextProps: {
15
+ href: "https://developer.bentley.com/apis/grouping-and-mapping/operations/create-property/#customcalculations",
16
+ target: "_blank",
17
+ rel: "noreferrer",
18
+ } }, "To learn more about creating custom calculation formulas, view the documentation."),
19
+ React.createElement(LabeledTextarea, { className: "gmw-details-form", value: formula, name: "formula", label: "Formula", disabled: disabled, onChange: (event) => {
20
+ setFormula(event.target.value);
21
+ }, message: formulaErrorMessage, status: formulaErrorMessage ? "negative" : undefined, onBlur: (event) => {
22
+ if (event.target.textLength === 0)
23
+ setFormula(undefined);
24
+ }, onBlurCapture: () => {
25
+ forceValidation();
26
+ } })));
151
27
  };
152
28
  //# 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,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC3G,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,WAA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E,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,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,GAAE,CAAC,EAChB,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC,EAChB,WAAW,EAAC,kBAAkB,GAC9B,CACO,CACP;QACN,oBAAC,WAAW,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","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,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,gCAAgC,CAAC;AAcxC;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,eAAe,EAAE,QAAQ,EAAgC,EAAE,EAAE;IAC/I,OAAO,CACL,oBAAC,UAAU,IAAC,SAAS,EAAC,yCAAyC;QAC7D,oBAAC,KAAK,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,oBAAC,eAAe,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","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
- display: flex;
12
- flex-direction: column;
13
- gap: var(--iui-size-s);
14
+ padding-top: var(--iui-size-s);
14
15
  }
15
16
  }
@@ -3,20 +3,27 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { PropertyValueFormat } from "@itwin/presentation-common";
6
- import { Alert, Button, Fieldset, LabeledInput, LabeledSelect, Text } from "@itwin/itwinui-react";
7
- import React, { useCallback, useEffect, useState } from "react";
6
+ import { Alert, Button, Fieldset, Icon, LabeledInput, LabeledSelect, Text } from "@itwin/itwinui-react";
7
+ import React, { useCallback, useEffect, useRef, useState } from "react";
8
8
  import ActionPanel from "../../SharedComponents/ActionPanel";
9
9
  import useValidator, { NAME_REQUIREMENTS } from "../hooks/useValidator";
10
10
  import { useGroupingMappingApiConfig } from "../../context/GroupingApiConfigContext";
11
11
  import { DataType, QuantityType } from "@itwin/insights-client";
12
12
  import "./GroupPropertyAction.scss";
13
13
  import { convertPresentationFields, convertToECProperties, fetchPresentationDescriptor, findProperties } from "./GroupPropertyUtils";
14
- import { manufactureKeys } from "../../../common/viewerUtils";
14
+ import { clearAll, manufactureKeys } from "../../../common/viewerUtils";
15
15
  import { SaveModal } from "./SaveModal";
16
16
  import { GroupsPropertiesSelectionModal } from "./GroupsPropertiesSelectionModal";
17
17
  import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
18
18
  import { GroupPropertyListItem } from "./GroupPropertyListItem";
19
19
  import { usePropertiesClient } from "../../context/PropertiesClientContext";
20
+ import { SvgFunction, SvgLabel, SvgMeasure } from "@itwin/itwinui-icons-react";
21
+ import { CalculatedPropertyActionWithVisuals } from "../CalculatedProperties/CalculatedPropertyActionWithVisuals";
22
+ import { handleError } from "../../../common/utils";
23
+ import { CustomCalculationAction } from "../CustomCalculations/CustomCalculationAction";
24
+ import { usePropertiesQuery } from "../hooks/usePropertiesQuery";
25
+ import { useFormulaValidation } from "../hooks/useFormulaValidation";
26
+ import { ScrollableExpandableBlock } from "../ScrollableExpandableBlock";
20
27
  export const quantityTypesSelectionOptions = [
21
28
  { value: QuantityType.Area, label: "Area" },
22
29
  { value: QuantityType.Distance, label: "Distance" },
@@ -32,23 +39,35 @@ export const quantityTypesSelectionOptions = [
32
39
  * @public
33
40
  */
34
41
  export const GroupPropertyAction = ({ mappingId, group, groupProperty, onSaveSuccess, onClickCancel }) => {
35
- const { getAccessToken, iModelId, iModelConnection } = useGroupingMappingApiConfig();
42
+ const actionContainerRef = useRef(null);
43
+ const calculatedPropertyActionRef = useRef(null);
44
+ const customCalculationActionRef = useRef(null);
36
45
  const propertiesClient = usePropertiesClient();
46
+ const queryClient = useQueryClient();
37
47
  const [propertyName, setPropertyName] = useState("");
38
48
  const [oldPropertyName, setOldPropertyName] = useState("");
39
- const [dataType, setDataType] = useState(DataType.String);
40
- const [quantityType, setQuantityType] = useState();
49
+ const [dataType, setDataType] = useState(groupProperty?.dataType ?? DataType.String);
50
+ const [quantityType, setQuantityType] = useState(groupProperty?.quantityType ?? undefined);
41
51
  const [selectedProperties, setSelectedProperties] = useState([]);
42
52
  const [propertiesMetaData, setPropertiesMetaData] = useState([]);
43
53
  const [propertiesNotFoundAlert, setPropertiesNotFoundAlert] = useState(false);
44
54
  const [validator, showValidationMessage] = useValidator();
45
55
  const [showPropertiesSelectionModal, setShowPropertiesSelectionModal] = useState(false);
46
56
  const [showSaveConfirmationModal, setShowSaveConfirmationModal] = useState(false);
47
- const queryClient = useQueryClient();
57
+ const [calculatedPropertyType, setCalculatedPropertyType] = useState(groupProperty?.calculatedPropertyType ?? undefined);
58
+ const [isCalculatedBlockExpanded, setIsCalculatedBlockExpanded] = useState(!!calculatedPropertyType);
59
+ const [formula, setFormula] = useState(groupProperty?.formula ?? undefined);
60
+ const [formulaErrorMessage, setFormulaErrorMessage] = useState(undefined);
61
+ const { getAccessToken, iModelId, iModelConnection } = useGroupingMappingApiConfig();
62
+ const { data: groupProperties, isFetching: isLoadingGroupProperties } = usePropertiesQuery(iModelId, mappingId, group.id, getAccessToken, propertiesClient);
63
+ const { forceValidation } = useFormulaValidation(propertyName.toLowerCase(), formula, groupProperties?.properties ?? [], setFormulaErrorMessage, dataType);
48
64
  const reset = useCallback(() => {
49
65
  setPropertyName("");
50
66
  setDataType(DataType.String);
67
+ setQuantityType(undefined);
51
68
  setSelectedProperties([]);
69
+ setCalculatedPropertyType(undefined);
70
+ setFormula(undefined);
52
71
  }, []);
53
72
  const fetchPropertiesMetadata = useCallback(async () => {
54
73
  if (!iModelConnection)
@@ -66,6 +85,16 @@ export const GroupPropertyAction = ({ mappingId, group, groupProperty, onSaveSuc
66
85
  }
67
86
  return { propertiesMetaData, groupPropertyDetails };
68
87
  }, [getAccessToken, group.id, group.query, groupProperty, iModelConnection, mappingId, propertiesClient]);
88
+ const scrollToFormulaErrorMessage = useCallback(() => {
89
+ setTimeout(() => {
90
+ if (actionContainerRef.current && customCalculationActionRef.current) {
91
+ actionContainerRef.current.scrollTo({
92
+ top: customCalculationActionRef.current.offsetTop,
93
+ behavior: "smooth",
94
+ });
95
+ }
96
+ }, 500);
97
+ }, [actionContainerRef]);
69
98
  const { data, isFetching: isLoadingProperties, isSuccess: isLoadingPropertiesSuccessful, } = useQuery(["properties", iModelId, mappingId, group.id, groupProperty?.id, "metadata"], fetchPropertiesMetadata);
70
99
  useEffect(() => {
71
100
  if (isLoadingPropertiesSuccessful && data?.propertiesMetaData) {
@@ -76,14 +105,29 @@ export const GroupPropertyAction = ({ mappingId, group, groupProperty, onSaveSuc
76
105
  setDataType(data.groupPropertyDetails.dataType);
77
106
  if (data.groupPropertyDetails.quantityType)
78
107
  setQuantityType(data.groupPropertyDetails.quantityType);
79
- const properties = findProperties(data.groupPropertyDetails.ecProperties ?? [], data.propertiesMetaData);
80
- if (properties.length === 0) {
81
- setPropertiesNotFoundAlert(true);
108
+ if (data.groupPropertyDetails.ecProperties) {
109
+ const properties = findProperties(data.groupPropertyDetails.ecProperties, data.propertiesMetaData);
110
+ if (properties.length === 0) {
111
+ setPropertiesNotFoundAlert(true);
112
+ }
113
+ setSelectedProperties(properties);
82
114
  }
83
- setSelectedProperties(properties);
84
115
  }
85
116
  }
86
117
  }, [data, isLoadingPropertiesSuccessful]);
118
+ useEffect(() => {
119
+ if (calculatedPropertyType) {
120
+ setDataType(DataType.Double);
121
+ }
122
+ if (isCalculatedBlockExpanded === false || !calculatedPropertyType) {
123
+ clearAll();
124
+ }
125
+ }, [calculatedPropertyType, isCalculatedBlockExpanded]);
126
+ useEffect(() => {
127
+ if (formulaErrorMessage) {
128
+ scrollToFormulaErrorMessage();
129
+ }
130
+ }, [formulaErrorMessage, scrollToFormulaErrorMessage]);
87
131
  const { mutate: onSave, isLoading: isSaving } = useMutation({
88
132
  mutationFn: async () => {
89
133
  const accessToken = await getAccessToken();
@@ -92,6 +136,8 @@ export const GroupPropertyAction = ({ mappingId, group, groupProperty, onSaveSuc
92
136
  dataType,
93
137
  quantityType,
94
138
  ecProperties: selectedProperties.map((p) => convertToECProperties(p)).flat(),
139
+ calculatedPropertyType,
140
+ formula,
95
141
  };
96
142
  return groupProperty
97
143
  ? propertiesClient.updateProperty(accessToken, mappingId, group.id, groupProperty.id, newGroupProperty)
@@ -102,6 +148,9 @@ export const GroupPropertyAction = ({ mappingId, group, groupProperty, onSaveSuc
102
148
  reset();
103
149
  await queryClient.invalidateQueries(["properties", iModelId, mappingId, group.id]);
104
150
  },
151
+ onError(error) {
152
+ handleError(error.status);
153
+ },
105
154
  });
106
155
  const handleSaveClick = async () => {
107
156
  if (!validator.allValid()) {
@@ -118,9 +167,9 @@ export const GroupPropertyAction = ({ mappingId, group, groupProperty, onSaveSuc
118
167
  const handleCloseSaveModal = () => {
119
168
  setShowSaveConfirmationModal(false);
120
169
  };
121
- const isLoading = isLoadingProperties || isSaving;
170
+ const isLoading = isLoadingProperties || isSaving || isLoadingGroupProperties;
122
171
  return (React.createElement(React.Fragment, null,
123
- React.createElement("div", { className: "gmw-group-property-action-container" },
172
+ React.createElement("div", { className: "gmw-group-property-action-container", ref: actionContainerRef },
124
173
  React.createElement(Fieldset, { disabled: isLoading, className: "gmw-property-options", legend: "Property Details" },
125
174
  React.createElement(Text, { variant: "small", as: "small", className: "gmw-field-legend" }, "Asterisk * indicates mandatory fields."),
126
175
  React.createElement(LabeledInput, { id: "propertyName", label: "Property Name", value: propertyName, required: true, onChange: (event) => {
@@ -134,21 +183,29 @@ export const GroupPropertyAction = ({ mappingId, group, groupProperty, onSaveSuc
134
183
  { value: DataType.Integer, label: "Integer" },
135
184
  { value: DataType.Double, label: "Double" },
136
185
  { value: DataType.String, label: "String" },
137
- ], required: true, value: dataType, onChange: (value) => {
186
+ ], required: true, value: calculatedPropertyType ? DataType.Double : dataType, onChange: (value) => {
138
187
  validator.showMessageFor("dataType");
139
188
  setDataType(value);
140
189
  }, message: validator.message("dataType", propertyName, "required"), status: validator.message("dataType", propertyName, "required") ? "negative" : undefined, onBlur: () => {
141
190
  validator.showMessageFor("dataType");
142
- }, onShow: () => { }, onHide: () => { } }),
191
+ }, disabled: calculatedPropertyType ? true : false, onShow: () => { }, onHide: () => { } }),
143
192
  React.createElement(LabeledSelect, { label: "Quantity Type", options: quantityTypesSelectionOptions, value: quantityType, onChange: setQuantityType, onShow: () => { }, onHide: () => { }, placeholder: "No Quantity Type" })),
144
193
  propertiesNotFoundAlert && (React.createElement(Alert, { type: "warning" }, "Warning: Could not match saved properties from the current generated list. It does not confirm or deny validity. Overwriting will occur if a new selection is made and saved.")),
145
- React.createElement(Fieldset, { className: "gmw-property-view-container", legend: "Mapped Properties" },
146
- React.createElement("div", { className: "gmw-property-view-button" },
147
- React.createElement(Button, { onClick: async () => setShowPropertiesSelectionModal(true), disabled: isLoading }, "Select Properties")),
148
- React.createElement("div", { className: "gmw-properties-list" }, selectedProperties.length === 0 && !isLoading ? (React.createElement("div", { className: "gmw-empty-selection" },
149
- React.createElement(Text, null, "No properties selected."),
150
- React.createElement(Text, null, "Press the \"Select Properties\" button for options."))) : (selectedProperties.map((property) => (React.createElement(GroupPropertyListItem, { key: property.key, content: `${property.displayLabel}`, title: `${property.actualECClassName}`, description: property.categoryLabel }))))))),
151
- React.createElement(ActionPanel, { onSave: handleSaveClick, onCancel: onClickCancel, isLoading: isLoading, isSavingDisabled: selectedProperties.length === 0 || !propertyName || dataType === undefined }),
194
+ React.createElement(ScrollableExpandableBlock, { title: "Mapped Properties", endIcon: React.createElement(Icon, { fill: selectedProperties.length > 0 ? "informational" : "default" },
195
+ React.createElement(SvgLabel, null)), isExpanded: selectedProperties.length > 0, setIsExpanded: () => { } },
196
+ React.createElement("div", { className: "gmw-property-view-container" },
197
+ React.createElement("div", { className: "gmw-property-view-button" },
198
+ React.createElement(Button, { onClick: async () => setShowPropertiesSelectionModal(true), disabled: isLoading }, "Select Properties")),
199
+ React.createElement("div", { className: "gmw-properties-list" }, selectedProperties.length === 0 && !isLoading ? (React.createElement("div", { className: "gmw-empty-selection" },
200
+ React.createElement(Text, null, "No properties selected."),
201
+ React.createElement(Text, null, "Press the \"Select Properties\" button for options."))) : (selectedProperties.map((property) => (React.createElement(GroupPropertyListItem, { key: property.key, content: `${property.displayLabel}`, title: `${property.actualECClassName}`, description: property.categoryLabel }))))))),
202
+ React.createElement(ScrollableExpandableBlock, { parentRef: actionContainerRef, ref: calculatedPropertyActionRef, title: "Calculated Property", endIcon: React.createElement(Icon, { fill: calculatedPropertyType ? "informational" : "default" },
203
+ React.createElement(SvgMeasure, null)), isExpanded: !!calculatedPropertyType, setIsExpanded: setIsCalculatedBlockExpanded },
204
+ React.createElement(CalculatedPropertyActionWithVisuals, { group: group, calculatedPropertyType: calculatedPropertyType, setCalculatedPropertyType: setCalculatedPropertyType })),
205
+ React.createElement(ScrollableExpandableBlock, { parentRef: actionContainerRef, ref: customCalculationActionRef, title: "Custom Calculation", endIcon: React.createElement(Icon, { fill: formula ? "informational" : "default" },
206
+ React.createElement(SvgFunction, null)), isExpanded: formula !== undefined, setIsExpanded: () => { } },
207
+ React.createElement(CustomCalculationAction, { formula: formula, setFormula: setFormula, formulaErrorMessage: formulaErrorMessage, forceValidation: forceValidation, disabled: isLoading }))),
208
+ React.createElement(ActionPanel, { onSave: handleSaveClick, onCancel: onClickCancel, onSaveCapture: clearAll, onCancelCapture: clearAll, isLoading: isLoading, isSavingDisabled: !propertyName || dataType === undefined || formulaErrorMessage !== undefined }),
152
209
  React.createElement(GroupsPropertiesSelectionModal, { showModal: showPropertiesSelectionModal, setShowModal: setShowPropertiesSelectionModal, selectedProperties: selectedProperties, setSelectedProperties: setSelectedProperties, propertiesMetaData: propertiesMetaData }),
153
210
  React.createElement(SaveModal, { onSave: onSave, onClose: handleCloseSaveModal, showSaveModal: showSaveConfirmationModal })));
154
211
  };
@@ -1 +1 @@
1
- {"version":3,"file":"GroupPropertyAction.js","sourceRoot":"","sources":["../../../../../src/components/Properties/GroupProperties/GroupPropertyAction.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,WAAW,MAAM,oCAAoC,CAAC;AAC7D,OAAO,YAAY,EAAE,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,4BAA4B,CAAC;AAEpC,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACrI,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAc5E,MAAM,CAAC,MAAM,6BAA6B,GAA6C;IACrF,EAAE,KAAK,EAAE,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAA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AC,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 { PropertyValueFormat } from \"@itwin/presentation-common\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { Alert, Button, Fieldset, LabeledInput, LabeledSelect, Text } from \"@itwin/itwinui-react\";\nimport React, { useCallback, useEffect, useState } from \"react\";\nimport ActionPanel from \"../../SharedComponents/ActionPanel\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { DataType, QuantityType } from \"@itwin/insights-client\";\nimport type { GroupMinimal, Property, PropertyModify } from \"@itwin/insights-client\";\nimport \"./GroupPropertyAction.scss\";\nimport type { PropertyMetaData } from \"./GroupPropertyUtils\";\nimport { convertPresentationFields, convertToECProperties, fetchPresentationDescriptor, findProperties } from \"./GroupPropertyUtils\";\nimport { manufactureKeys } from \"../../../common/viewerUtils\";\nimport { SaveModal } from \"./SaveModal\";\nimport { GroupsPropertiesSelectionModal } from \"./GroupsPropertiesSelectionModal\";\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { GroupPropertyListItem } from \"./GroupPropertyListItem\";\nimport { usePropertiesClient } from \"../../context/PropertiesClientContext\";\n\n/**\n * Props for the {@link GroupPropertyAction} component.\n * @public\n */\nexport interface GroupPropertyActionProps {\n mappingId: string;\n group: GroupMinimal;\n groupProperty?: Property;\n onSaveSuccess: () => void;\n onClickCancel?: () => void;\n}\n\nexport const quantityTypesSelectionOptions: SelectOption<QuantityType | undefined>[] = [\n { value: QuantityType.Area, label: \"Area\" },\n { value: QuantityType.Distance, label: \"Distance\" },\n { value: QuantityType.Force, label: \"Force\" },\n { value: QuantityType.Mass, label: \"Mass\" },\n { value: QuantityType.Monetary, label: \"Monetary\" },\n { value: QuantityType.Time, label: \"Time\" },\n { value: QuantityType.Volume, label: \"Volume\" },\n { value: undefined, label: \"No Quantity Type\" },\n];\n\n/**\n * Component to create or update a group.\n * @public\n */\nexport const GroupPropertyAction = ({ mappingId, group, groupProperty, onSaveSuccess, onClickCancel }: GroupPropertyActionProps) => {\n const { getAccessToken, iModelId, iModelConnection } = useGroupingMappingApiConfig();\n const propertiesClient = usePropertiesClient();\n const [propertyName, setPropertyName] = useState<string>(\"\");\n const [oldPropertyName, setOldPropertyName] = useState<string>(\"\");\n const [dataType, setDataType] = useState<DataType>(DataType.String);\n const [quantityType, setQuantityType] = useState<QuantityType>();\n const [selectedProperties, setSelectedProperties] = useState<PropertyMetaData[]>([]);\n const [propertiesMetaData, setPropertiesMetaData] = useState<PropertyMetaData[]>([]);\n const [propertiesNotFoundAlert, setPropertiesNotFoundAlert] = useState<boolean>(false);\n const [validator, showValidationMessage] = useValidator();\n const [showPropertiesSelectionModal, setShowPropertiesSelectionModal] = useState<boolean>(false);\n const [showSaveConfirmationModal, setShowSaveConfirmationModal] = useState<boolean>(false);\n const queryClient = useQueryClient();\n\n const reset = useCallback(() => {\n setPropertyName(\"\");\n setDataType(DataType.String);\n setSelectedProperties([]);\n }, []);\n\n const fetchPropertiesMetadata = useCallback(async () => {\n if (!iModelConnection) return;\n\n const result = await manufactureKeys(group.query, iModelConnection);\n const descriptor = await fetchPresentationDescriptor(iModelConnection, result);\n\n // Only allow primitives and structs\n const propertyFields =\n descriptor?.fields.filter((field) => field.type.valueFormat === PropertyValueFormat.Primitive || field.type.valueFormat === PropertyValueFormat.Struct) ??\n [];\n\n const propertiesMetaData = convertPresentationFields(propertyFields);\n\n let groupPropertyDetails = null;\n if (groupProperty) {\n const accessToken = await getAccessToken();\n groupPropertyDetails = await propertiesClient.getProperty(accessToken, mappingId, group.id, groupProperty.id);\n }\n\n return { propertiesMetaData, groupPropertyDetails };\n }, [getAccessToken, group.id, group.query, groupProperty, iModelConnection, mappingId, propertiesClient]);\n\n const {\n data,\n isFetching: isLoadingProperties,\n isSuccess: isLoadingPropertiesSuccessful,\n } = useQuery([\"properties\", iModelId, mappingId, group.id, groupProperty?.id, \"metadata\"], fetchPropertiesMetadata);\n\n useEffect(() => {\n if (isLoadingPropertiesSuccessful && data?.propertiesMetaData) {\n setPropertiesMetaData(data.propertiesMetaData);\n\n if (data.groupPropertyDetails) {\n setPropertyName(data.groupPropertyDetails.propertyName);\n setOldPropertyName(data.groupPropertyDetails.propertyName);\n setDataType(data.groupPropertyDetails.dataType);\n if (data.groupPropertyDetails.quantityType) setQuantityType(data.groupPropertyDetails.quantityType);\n\n const properties = findProperties(data.groupPropertyDetails.ecProperties ?? [], data.propertiesMetaData);\n if (properties.length === 0) {\n setPropertiesNotFoundAlert(true);\n }\n\n setSelectedProperties(properties);\n }\n }\n }, [data, isLoadingPropertiesSuccessful]);\n\n const { mutate: onSave, isLoading: isSaving } = useMutation({\n mutationFn: async () => {\n const accessToken = await getAccessToken();\n const newGroupProperty: PropertyModify = {\n propertyName,\n dataType,\n quantityType,\n ecProperties: selectedProperties.map((p) => convertToECProperties(p)).flat(),\n };\n\n return groupProperty\n ? propertiesClient.updateProperty(accessToken, mappingId, group.id, groupProperty.id, newGroupProperty)\n : propertiesClient.createProperty(accessToken, mappingId, group.id, newGroupProperty);\n },\n onSuccess: async () => {\n onSaveSuccess();\n reset();\n await queryClient.invalidateQueries([\"properties\", iModelId, mappingId, group.id]);\n },\n });\n\n const handleSaveClick = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n if (oldPropertyName !== propertyName && oldPropertyName !== \"\") {\n setShowSaveConfirmationModal(true);\n } else {\n onSave();\n }\n };\n\n const handleCloseSaveModal = () => {\n setShowSaveConfirmationModal(false);\n };\n\n const isLoading = isLoadingProperties || isSaving;\n\n return (\n <>\n <div className=\"gmw-group-property-action-container\">\n <Fieldset disabled={isLoading} className=\"gmw-property-options\" legend=\"Property Details\">\n <Text variant=\"small\" as=\"small\" className=\"gmw-field-legend\">\n Asterisk * indicates mandatory fields.\n </Text>\n <LabeledInput\n id=\"propertyName\"\n label=\"Property Name\"\n value={propertyName}\n required\n onChange={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"propertyName\");\n }}\n message={validator.message(\"propertyName\", propertyName, NAME_REQUIREMENTS)}\n status={validator.message(\"propertyName\", propertyName, NAME_REQUIREMENTS) ? \"negative\" : undefined}\n onBlur={() => {\n validator.showMessageFor(\"propertyName\");\n }}\n />\n <LabeledSelect<DataType>\n label={\"Data Type\"}\n id=\"dataType\"\n options={[\n { value: DataType.Boolean, label: \"Boolean\" },\n { value: DataType.Integer, label: \"Integer\" },\n { value: DataType.Double, label: \"Double\" },\n { value: DataType.String, label: \"String\" },\n ]}\n required\n value={dataType}\n onChange={(value) => {\n validator.showMessageFor(\"dataType\");\n setDataType(value);\n }}\n message={validator.message(\"dataType\", propertyName, \"required\")}\n status={validator.message(\"dataType\", propertyName, \"required\") ? \"negative\" : undefined}\n onBlur={() => {\n validator.showMessageFor(\"dataType\");\n }}\n onShow={() => {}}\n onHide={() => {}}\n />\n <LabeledSelect<QuantityType | undefined>\n label=\"Quantity Type\"\n options={quantityTypesSelectionOptions}\n value={quantityType}\n onChange={setQuantityType}\n onShow={() => {}}\n onHide={() => {}}\n placeholder=\"No Quantity Type\"\n />\n </Fieldset>\n {propertiesNotFoundAlert && (\n <Alert type=\"warning\">\n Warning: Could not match saved properties from the current generated list. It does not confirm or deny validity. Overwriting will occur if a new\n selection is made and saved.\n </Alert>\n )}\n <Fieldset className=\"gmw-property-view-container\" legend=\"Mapped Properties\">\n <div className=\"gmw-property-view-button\">\n <Button onClick={async () => setShowPropertiesSelectionModal(true)} disabled={isLoading}>\n Select Properties\n </Button>\n </div>\n <div className=\"gmw-properties-list\">\n {selectedProperties.length === 0 && !isLoading ? (\n <div className=\"gmw-empty-selection\">\n <Text>No properties selected.</Text>\n <Text>Press the &quot;Select Properties&quot; button for options.</Text>\n </div>\n ) : (\n selectedProperties.map((property) => (\n <GroupPropertyListItem\n key={property.key}\n content={`${property.displayLabel}`}\n title={`${property.actualECClassName}`}\n description={property.categoryLabel}\n />\n ))\n )}\n </div>\n </Fieldset>\n </div>\n <ActionPanel\n onSave={handleSaveClick}\n onCancel={onClickCancel}\n isLoading={isLoading}\n isSavingDisabled={selectedProperties.length === 0 || !propertyName || dataType === undefined}\n />\n <GroupsPropertiesSelectionModal\n showModal={showPropertiesSelectionModal}\n setShowModal={setShowPropertiesSelectionModal}\n selectedProperties={selectedProperties}\n setSelectedProperties={setSelectedProperties}\n propertiesMetaData={propertiesMetaData}\n />\n <SaveModal onSave={onSave} onClose={handleCloseSaveModal} showSaveModal={showSaveConfirmationModal} />\n </>\n );\n};\n"]}
1
+ {"version":3,"file":"GroupPropertyAction.js","sourceRoot":"","sources":["../../../../../src/components/Properties/GroupProperties/GroupPropertyAction.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACxG,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxE,OAAO,WAAW,MAAM,oCAAoC,CAAC;AAC7D,OAAO,YAAY,EAAE,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,4BAA4B,CAAC;AAEpC,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACrI,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,M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EAAE,SAAS,GACnB,CACwB,CACxB;QACN,oBAAC,WAAW,IACV,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,aAAa,EACvB,aAAa,EAAE,QAAQ,EACvB,eAAe,EAAE,QAAQ,EACzB,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,CAAC,YAAY,IAAI,QAAQ,KAAK,SAAS,IAAI,mBAAmB,KAAK,SAAS,GAC9F;QACF,oBAAC,8BAA8B,IAC7B,SAAS,EAAE,4BAA4B,EACvC,YAAY,EAAE,+BAA+B,EAC7C,kBAAkB,EAAE,kBAAkB,EACtC,qBAAqB,EAAE,qBAAqB,EAC5C,kBAAkB,EAAE,kBAAkB,GACtC;QACF,oBAAC,SAAS,IAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,yBAAyB,GAAI,CACrG,CACJ,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nimport { PropertyValueFormat } from \"@itwin/presentation-common\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { Alert, Button, Fieldset, Icon, LabeledInput, LabeledSelect, Text } from \"@itwin/itwinui-react\";\nimport React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport ActionPanel from \"../../SharedComponents/ActionPanel\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { DataType, QuantityType } from \"@itwin/insights-client\";\nimport type { CalculatedPropertyType, GroupMinimal, Property, PropertyModify } from \"@itwin/insights-client\";\nimport \"./GroupPropertyAction.scss\";\nimport type { PropertyMetaData } from \"./GroupPropertyUtils\";\nimport { convertPresentationFields, convertToECProperties, fetchPresentationDescriptor, findProperties } from \"./GroupPropertyUtils\";\nimport { clearAll, manufactureKeys } from \"../../../common/viewerUtils\";\nimport { SaveModal } from \"./SaveModal\";\nimport { GroupsPropertiesSelectionModal } from \"./GroupsPropertiesSelectionModal\";\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { GroupPropertyListItem } from \"./GroupPropertyListItem\";\nimport { usePropertiesClient } from \"../../context/PropertiesClientContext\";\nimport { SvgFunction, SvgLabel, SvgMeasure } from \"@itwin/itwinui-icons-react\";\nimport { CalculatedPropertyActionWithVisuals } from \"../CalculatedProperties/CalculatedPropertyActionWithVisuals\";\nimport { handleError } from \"../../../common/utils\";\nimport { CustomCalculationAction } from \"../CustomCalculations/CustomCalculationAction\";\nimport { usePropertiesQuery } from \"../hooks/usePropertiesQuery\";\nimport { useFormulaValidation } from \"../hooks/useFormulaValidation\";\nimport { ScrollableExpandableBlock } from \"../ScrollableExpandableBlock\";\n\n/**\n * Props for the {@link GroupPropertyAction} component.\n * @public\n */\nexport interface GroupPropertyActionProps {\n mappingId: string;\n group: GroupMinimal;\n groupProperty?: Property;\n onSaveSuccess: () => void;\n onClickCancel?: () => void;\n}\n\nexport const quantityTypesSelectionOptions: SelectOption<QuantityType | undefined>[] = [\n { value: QuantityType.Area, label: \"Area\" },\n { value: QuantityType.Distance, label: \"Distance\" },\n { value: QuantityType.Force, label: \"Force\" },\n { value: QuantityType.Mass, label: \"Mass\" },\n { value: QuantityType.Monetary, label: \"Monetary\" },\n { value: QuantityType.Time, label: \"Time\" },\n { value: QuantityType.Volume, label: \"Volume\" },\n { value: undefined, label: \"No Quantity Type\" },\n];\n\n/**\n * Component to create or update a group.\n * @public\n */\nexport const GroupPropertyAction = ({ mappingId, group, groupProperty, onSaveSuccess, onClickCancel }: GroupPropertyActionProps) => {\n const actionContainerRef = useRef<HTMLDivElement>(null);\n const calculatedPropertyActionRef = useRef<HTMLDivElement>(null);\n const customCalculationActionRef = useRef<HTMLDivElement>(null);\n const propertiesClient = usePropertiesClient();\n const queryClient = useQueryClient();\n\n const [propertyName, setPropertyName] = useState<string>(\"\");\n const [oldPropertyName, setOldPropertyName] = useState<string>(\"\");\n const [dataType, setDataType] = useState<DataType>(groupProperty?.dataType ?? DataType.String);\n const [quantityType, setQuantityType] = useState<QuantityType | undefined>(groupProperty?.quantityType ?? undefined);\n const [selectedProperties, setSelectedProperties] = useState<PropertyMetaData[]>([]);\n const [propertiesMetaData, setPropertiesMetaData] = useState<PropertyMetaData[]>([]);\n const [propertiesNotFoundAlert, setPropertiesNotFoundAlert] = useState<boolean>(false);\n const [validator, showValidationMessage] = useValidator();\n const [showPropertiesSelectionModal, setShowPropertiesSelectionModal] = useState<boolean>(false);\n const [showSaveConfirmationModal, setShowSaveConfirmationModal] = useState<boolean>(false);\n const [calculatedPropertyType, setCalculatedPropertyType] = useState<CalculatedPropertyType | undefined>(groupProperty?.calculatedPropertyType ?? undefined);\n const [isCalculatedBlockExpanded, setIsCalculatedBlockExpanded] = useState<boolean>(!!calculatedPropertyType);\n const [formula, setFormula] = useState<string | undefined>(groupProperty?.formula ?? undefined);\n const [formulaErrorMessage, setFormulaErrorMessage] = useState<string | undefined>(undefined);\n\n const { getAccessToken, iModelId, iModelConnection } = useGroupingMappingApiConfig();\n const { data: groupProperties, isFetching: isLoadingGroupProperties } = usePropertiesQuery(iModelId, mappingId, group.id, getAccessToken, propertiesClient);\n const { forceValidation } = useFormulaValidation(propertyName.toLowerCase(), formula, groupProperties?.properties ?? [], setFormulaErrorMessage, dataType);\n\n const reset = useCallback(() => {\n setPropertyName(\"\");\n setDataType(DataType.String);\n setQuantityType(undefined);\n setSelectedProperties([]);\n setCalculatedPropertyType(undefined);\n setFormula(undefined);\n }, []);\n\n const fetchPropertiesMetadata = useCallback(async () => {\n if (!iModelConnection) return;\n\n const result = await manufactureKeys(group.query, iModelConnection);\n const descriptor = await fetchPresentationDescriptor(iModelConnection, result);\n\n // Only allow primitives and structs\n const propertyFields =\n descriptor?.fields.filter((field) => field.type.valueFormat === PropertyValueFormat.Primitive || field.type.valueFormat === PropertyValueFormat.Struct) ??\n [];\n\n const propertiesMetaData = convertPresentationFields(propertyFields);\n\n let groupPropertyDetails = null;\n if (groupProperty) {\n const accessToken = await getAccessToken();\n groupPropertyDetails = await propertiesClient.getProperty(accessToken, mappingId, group.id, groupProperty.id);\n }\n\n return { propertiesMetaData, groupPropertyDetails };\n }, [getAccessToken, group.id, group.query, groupProperty, iModelConnection, mappingId, propertiesClient]);\n\n const scrollToFormulaErrorMessage = useCallback(() => {\n setTimeout(() => {\n if (actionContainerRef.current && customCalculationActionRef.current) {\n actionContainerRef.current.scrollTo({\n top: customCalculationActionRef.current.offsetTop,\n behavior: \"smooth\",\n });\n }\n }, 500);\n }, [actionContainerRef]);\n\n const {\n data,\n isFetching: isLoadingProperties,\n isSuccess: isLoadingPropertiesSuccessful,\n } = useQuery([\"properties\", iModelId, mappingId, group.id, groupProperty?.id, \"metadata\"], fetchPropertiesMetadata);\n\n useEffect(() => {\n if (isLoadingPropertiesSuccessful && data?.propertiesMetaData) {\n setPropertiesMetaData(data.propertiesMetaData);\n\n if (data.groupPropertyDetails) {\n setPropertyName(data.groupPropertyDetails.propertyName);\n setOldPropertyName(data.groupPropertyDetails.propertyName);\n setDataType(data.groupPropertyDetails.dataType);\n if (data.groupPropertyDetails.quantityType) setQuantityType(data.groupPropertyDetails.quantityType);\n\n if (data.groupPropertyDetails.ecProperties) {\n const properties = findProperties(data.groupPropertyDetails.ecProperties, data.propertiesMetaData);\n if (properties.length === 0) {\n setPropertiesNotFoundAlert(true);\n }\n setSelectedProperties(properties);\n }\n }\n }\n }, [data, isLoadingPropertiesSuccessful]);\n\n useEffect(() => {\n if (calculatedPropertyType) {\n setDataType(DataType.Double);\n }\n\n if (isCalculatedBlockExpanded === false || !calculatedPropertyType) {\n clearAll();\n }\n }, [calculatedPropertyType, isCalculatedBlockExpanded]);\n\n useEffect(() => {\n if (formulaErrorMessage) {\n scrollToFormulaErrorMessage();\n }\n }, [formulaErrorMessage, scrollToFormulaErrorMessage]);\n\n const { mutate: onSave, isLoading: isSaving } = useMutation({\n mutationFn: async () => {\n const accessToken = await getAccessToken();\n const newGroupProperty: PropertyModify = {\n propertyName,\n dataType,\n quantityType,\n ecProperties: selectedProperties.map((p) => convertToECProperties(p)).flat(),\n calculatedPropertyType,\n formula,\n };\n\n return groupProperty\n ? propertiesClient.updateProperty(accessToken, mappingId, group.id, groupProperty.id, newGroupProperty)\n : propertiesClient.createProperty(accessToken, mappingId, group.id, newGroupProperty);\n },\n onSuccess: async () => {\n onSaveSuccess();\n reset();\n await queryClient.invalidateQueries([\"properties\", iModelId, mappingId, group.id]);\n },\n onError(error: any) {\n handleError(error.status);\n },\n });\n\n const handleSaveClick = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n if (oldPropertyName !== propertyName && oldPropertyName !== \"\") {\n setShowSaveConfirmationModal(true);\n } else {\n onSave();\n }\n };\n\n const handleCloseSaveModal = () => {\n setShowSaveConfirmationModal(false);\n };\n\n const isLoading = isLoadingProperties || isSaving || isLoadingGroupProperties;\n\n return (\n <>\n <div className=\"gmw-group-property-action-container\" ref={actionContainerRef}>\n <Fieldset disabled={isLoading} className=\"gmw-property-options\" legend=\"Property Details\">\n <Text variant=\"small\" as=\"small\" className=\"gmw-field-legend\">\n Asterisk * indicates mandatory fields.\n </Text>\n <LabeledInput\n id=\"propertyName\"\n label=\"Property Name\"\n value={propertyName}\n required\n onChange={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"propertyName\");\n }}\n message={validator.message(\"propertyName\", propertyName, NAME_REQUIREMENTS)}\n status={validator.message(\"propertyName\", propertyName, NAME_REQUIREMENTS) ? \"negative\" : undefined}\n onBlur={() => {\n validator.showMessageFor(\"propertyName\");\n }}\n />\n <LabeledSelect<DataType>\n label={\"Data Type\"}\n id=\"dataType\"\n options={[\n { value: DataType.Boolean, label: \"Boolean\" },\n { value: DataType.Integer, label: \"Integer\" },\n { value: DataType.Double, label: \"Double\" },\n { value: DataType.String, label: \"String\" },\n ]}\n required\n value={calculatedPropertyType ? DataType.Double : dataType}\n onChange={(value) => {\n validator.showMessageFor(\"dataType\");\n setDataType(value);\n }}\n message={validator.message(\"dataType\", propertyName, \"required\")}\n status={validator.message(\"dataType\", propertyName, \"required\") ? \"negative\" : undefined}\n onBlur={() => {\n validator.showMessageFor(\"dataType\");\n }}\n disabled={calculatedPropertyType ? true : false}\n onShow={() => {}}\n onHide={() => {}}\n />\n <LabeledSelect<QuantityType | undefined>\n label=\"Quantity Type\"\n options={quantityTypesSelectionOptions}\n value={quantityType}\n onChange={setQuantityType}\n onShow={() => {}}\n onHide={() => {}}\n placeholder=\"No Quantity Type\"\n />\n </Fieldset>\n {propertiesNotFoundAlert && (\n <Alert type=\"warning\">\n Warning: Could not match saved properties from the current generated list. It does not confirm or deny validity. Overwriting will occur if a new\n selection is made and saved.\n </Alert>\n )}\n <ScrollableExpandableBlock\n title={\"Mapped Properties\"}\n endIcon={\n <Icon fill={selectedProperties.length > 0 ? \"informational\" : \"default\"}>\n <SvgLabel />\n </Icon>\n }\n isExpanded={selectedProperties.length > 0}\n setIsExpanded={() => {}}\n >\n <div className=\"gmw-property-view-container\">\n <div className=\"gmw-property-view-button\">\n <Button onClick={async () => setShowPropertiesSelectionModal(true)} disabled={isLoading}>\n Select Properties\n </Button>\n </div>\n <div className=\"gmw-properties-list\">\n {selectedProperties.length === 0 && !isLoading ? (\n <div className=\"gmw-empty-selection\">\n <Text>No properties selected.</Text>\n <Text>Press the &quot;Select Properties&quot; button for options.</Text>\n </div>\n ) : (\n selectedProperties.map((property) => (\n <GroupPropertyListItem\n key={property.key}\n content={`${property.displayLabel}`}\n title={`${property.actualECClassName}`}\n description={property.categoryLabel}\n />\n ))\n )}\n </div>\n </div>\n </ScrollableExpandableBlock>\n <ScrollableExpandableBlock\n parentRef={actionContainerRef}\n ref={calculatedPropertyActionRef}\n title={\"Calculated Property\"}\n endIcon={\n <Icon fill={calculatedPropertyType ? \"informational\" : \"default\"}>\n <SvgMeasure />\n </Icon>\n }\n isExpanded={!!calculatedPropertyType}\n setIsExpanded={setIsCalculatedBlockExpanded}\n >\n <CalculatedPropertyActionWithVisuals\n group={group}\n calculatedPropertyType={calculatedPropertyType}\n setCalculatedPropertyType={setCalculatedPropertyType}\n />\n </ScrollableExpandableBlock>\n <ScrollableExpandableBlock\n parentRef={actionContainerRef}\n ref={customCalculationActionRef}\n title={\"Custom Calculation\"}\n endIcon={\n <Icon fill={formula ? \"informational\" : \"default\"}>\n <SvgFunction />\n </Icon>\n }\n isExpanded={formula !== undefined}\n setIsExpanded={() => {}}\n >\n <CustomCalculationAction\n formula={formula}\n setFormula={setFormula}\n formulaErrorMessage={formulaErrorMessage}\n forceValidation={forceValidation}\n disabled={isLoading}\n />\n </ScrollableExpandableBlock>\n </div>\n <ActionPanel\n onSave={handleSaveClick}\n onCancel={onClickCancel}\n onSaveCapture={clearAll}\n onCancelCapture={clearAll}\n isLoading={isLoading}\n isSavingDisabled={!propertyName || dataType === undefined || formulaErrorMessage !== undefined}\n />\n <GroupsPropertiesSelectionModal\n showModal={showPropertiesSelectionModal}\n setShowModal={setShowPropertiesSelectionModal}\n selectedProperties={selectedProperties}\n setSelectedProperties={setSelectedProperties}\n propertiesMetaData={propertiesMetaData}\n />\n <SaveModal onSave={onSave} onClose={handleCloseSaveModal} showSaveModal={showSaveConfirmationModal} />\n </>\n );\n};\n"]}