@itwin/grouping-mapping-widget 0.3.2 → 0.3.5

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 (199) hide show
  1. package/lib/cjs/formula/FormulaFunctionProvider.d.ts +18 -0
  2. package/lib/cjs/formula/FormulaFunctionProvider.js +136 -0
  3. package/lib/cjs/formula/FormulaFunctionProvider.js.map +1 -0
  4. package/lib/cjs/formula/FormulaOperatorsProvider.d.ts +34 -0
  5. package/lib/cjs/formula/FormulaOperatorsProvider.js +185 -0
  6. package/lib/cjs/formula/FormulaOperatorsProvider.js.map +1 -0
  7. package/lib/cjs/formula/FormulaSplitter.d.ts +2 -0
  8. package/lib/cjs/formula/FormulaSplitter.js +140 -0
  9. package/lib/cjs/formula/FormulaSplitter.js.map +1 -0
  10. package/lib/cjs/formula/FormulaTokensValidator.d.ts +5 -0
  11. package/lib/cjs/formula/FormulaTokensValidator.js +137 -0
  12. package/lib/cjs/formula/FormulaTokensValidator.js.map +1 -0
  13. package/lib/cjs/formula/FormulaValidator.d.ts +3 -0
  14. package/lib/cjs/formula/FormulaValidator.js +35 -0
  15. package/lib/cjs/formula/FormulaValidator.js.map +1 -0
  16. package/lib/cjs/formula/IResult.d.ts +5 -0
  17. package/lib/cjs/formula/IResult.js +3 -0
  18. package/lib/cjs/formula/IResult.js.map +1 -0
  19. package/lib/cjs/formula/InfixToPostfixConverter.d.ts +18 -0
  20. package/lib/cjs/formula/InfixToPostfixConverter.js +299 -0
  21. package/lib/cjs/formula/InfixToPostfixConverter.js.map +1 -0
  22. package/lib/cjs/formula/InputStream.d.ts +12 -0
  23. package/lib/cjs/formula/InputStream.js +36 -0
  24. package/lib/cjs/formula/InputStream.js.map +1 -0
  25. package/lib/cjs/formula/ParenthesisValidator.d.ts +7 -0
  26. package/lib/cjs/formula/ParenthesisValidator.js +34 -0
  27. package/lib/cjs/formula/ParenthesisValidator.js.map +1 -0
  28. package/lib/cjs/formula/Queue.d.ts +11 -0
  29. package/lib/cjs/formula/Queue.js +42 -0
  30. package/lib/cjs/formula/Queue.js.map +1 -0
  31. package/lib/cjs/formula/Stack.d.ts +14 -0
  32. package/lib/cjs/formula/Stack.js +71 -0
  33. package/lib/cjs/formula/Stack.js.map +1 -0
  34. package/lib/cjs/formula/StringBuilder.d.ts +9 -0
  35. package/lib/cjs/formula/StringBuilder.js +26 -0
  36. package/lib/cjs/formula/StringBuilder.js.map +1 -0
  37. package/lib/cjs/formula/Types.d.ts +8 -0
  38. package/lib/cjs/formula/Types.js +3 -0
  39. package/lib/cjs/formula/Types.js.map +1 -0
  40. package/lib/cjs/formula/Utils.d.ts +7 -0
  41. package/lib/cjs/formula/Utils.js +39 -0
  42. package/lib/cjs/formula/Utils.js.map +1 -0
  43. package/lib/cjs/widget/components/BlockingOverlay.d.ts +7 -0
  44. package/lib/cjs/widget/components/BlockingOverlay.js +21 -0
  45. package/lib/cjs/widget/components/BlockingOverlay.js.map +1 -0
  46. package/lib/cjs/widget/components/BlockingOverlay.scss +26 -0
  47. package/lib/cjs/widget/components/CalculatedPropertyAction.d.ts +1 -1
  48. package/lib/cjs/widget/components/CalculatedPropertyAction.js +4 -5
  49. package/lib/cjs/widget/components/CalculatedPropertyAction.js.map +1 -1
  50. package/lib/cjs/widget/components/CalculatedPropertyTable.d.ts +5 -2
  51. package/lib/cjs/widget/components/CalculatedPropertyTable.js +5 -29
  52. package/lib/cjs/widget/components/CalculatedPropertyTable.js.map +1 -1
  53. package/lib/cjs/widget/components/ConfirmMappingsImport.js +1 -2
  54. package/lib/cjs/widget/components/ConfirmMappingsImport.js.map +1 -1
  55. package/lib/cjs/widget/components/ConfirmMappingsImport.scss +4 -2
  56. package/lib/cjs/widget/components/CustomCalculationAction.d.ts +4 -2
  57. package/lib/cjs/widget/components/CustomCalculationAction.js +10 -6
  58. package/lib/cjs/widget/components/CustomCalculationAction.js.map +1 -1
  59. package/lib/cjs/widget/components/CustomCalculationTable.d.ts +5 -2
  60. package/lib/cjs/widget/components/CustomCalculationTable.js +5 -29
  61. package/lib/cjs/widget/components/CustomCalculationTable.js.map +1 -1
  62. package/lib/cjs/widget/components/GroupAction.js +3 -12
  63. package/lib/cjs/widget/components/GroupAction.js.map +1 -1
  64. package/lib/cjs/widget/components/GroupPropertyAction.d.ts +1 -1
  65. package/lib/cjs/widget/components/GroupPropertyAction.js +5 -6
  66. package/lib/cjs/widget/components/GroupPropertyAction.js.map +1 -1
  67. package/lib/cjs/widget/components/GroupPropertyTable.d.ts +5 -2
  68. package/lib/cjs/widget/components/GroupPropertyTable.js +5 -29
  69. package/lib/cjs/widget/components/GroupPropertyTable.js.map +1 -1
  70. package/lib/cjs/widget/components/Grouping.js +2 -3
  71. package/lib/cjs/widget/components/Grouping.js.map +1 -1
  72. package/lib/cjs/widget/components/Mapping.js +26 -5
  73. package/lib/cjs/widget/components/Mapping.js.map +1 -1
  74. package/lib/cjs/widget/components/MappingAction.js +10 -13
  75. package/lib/cjs/widget/components/MappingAction.js.map +1 -1
  76. package/lib/cjs/widget/components/MappingImportWizardModal.js +2 -2
  77. package/lib/cjs/widget/components/MappingImportWizardModal.js.map +1 -1
  78. package/lib/cjs/widget/components/MappingImportWizardModal.scss +6 -2
  79. package/lib/cjs/widget/components/PropertyMenu.js +77 -21
  80. package/lib/cjs/widget/components/PropertyMenu.js.map +1 -1
  81. package/lib/cjs/widget/components/SelectIModel.scss +2 -1
  82. package/lib/cjs/widget/components/SelectMapping.scss +2 -1
  83. package/lib/cjs/widget/components/SelectMappings.js +1 -2
  84. package/lib/cjs/widget/components/SelectMappings.js.map +1 -1
  85. package/lib/cjs/widget/components/SelectProject.js +9 -9
  86. package/lib/cjs/widget/components/SelectProject.js.map +1 -1
  87. package/lib/cjs/widget/components/SelectProject.scss +3 -8
  88. package/lib/cjs/widget/components/utils.d.ts +2 -0
  89. package/lib/cjs/widget/components/utils.js +13 -1
  90. package/lib/cjs/widget/components/utils.js.map +1 -1
  91. package/lib/cjs/widget/hooks/useFetchData.d.ts +9 -0
  92. package/lib/cjs/widget/hooks/useFetchData.js +41 -0
  93. package/lib/cjs/widget/hooks/useFetchData.js.map +1 -0
  94. package/lib/cjs/widget/hooks/useFormulaValidation.d.ts +6 -0
  95. package/lib/cjs/widget/hooks/useFormulaValidation.js +29 -0
  96. package/lib/cjs/widget/hooks/useFormulaValidation.js.map +1 -0
  97. package/lib/cjs/widget/utils.d.ts +1 -0
  98. package/lib/cjs/widget/utils.js +9 -0
  99. package/lib/cjs/widget/utils.js.map +1 -1
  100. package/lib/esm/formula/FormulaFunctionProvider.d.ts +18 -0
  101. package/lib/esm/formula/FormulaFunctionProvider.js +130 -0
  102. package/lib/esm/formula/FormulaFunctionProvider.js.map +1 -0
  103. package/lib/esm/formula/FormulaOperatorsProvider.d.ts +34 -0
  104. package/lib/esm/formula/FormulaOperatorsProvider.js +174 -0
  105. package/lib/esm/formula/FormulaOperatorsProvider.js.map +1 -0
  106. package/lib/esm/formula/FormulaSplitter.d.ts +2 -0
  107. package/lib/esm/formula/FormulaSplitter.js +136 -0
  108. package/lib/esm/formula/FormulaSplitter.js.map +1 -0
  109. package/lib/esm/formula/FormulaTokensValidator.d.ts +5 -0
  110. package/lib/esm/formula/FormulaTokensValidator.js +133 -0
  111. package/lib/esm/formula/FormulaTokensValidator.js.map +1 -0
  112. package/lib/esm/formula/FormulaValidator.d.ts +3 -0
  113. package/lib/esm/formula/FormulaValidator.js +31 -0
  114. package/lib/esm/formula/FormulaValidator.js.map +1 -0
  115. package/lib/esm/formula/IResult.d.ts +5 -0
  116. package/lib/esm/formula/IResult.js +2 -0
  117. package/lib/esm/formula/IResult.js.map +1 -0
  118. package/lib/esm/formula/InfixToPostfixConverter.d.ts +18 -0
  119. package/lib/esm/formula/InfixToPostfixConverter.js +295 -0
  120. package/lib/esm/formula/InfixToPostfixConverter.js.map +1 -0
  121. package/lib/esm/formula/InputStream.d.ts +12 -0
  122. package/lib/esm/formula/InputStream.js +32 -0
  123. package/lib/esm/formula/InputStream.js.map +1 -0
  124. package/lib/esm/formula/ParenthesisValidator.d.ts +7 -0
  125. package/lib/esm/formula/ParenthesisValidator.js +30 -0
  126. package/lib/esm/formula/ParenthesisValidator.js.map +1 -0
  127. package/lib/esm/formula/Queue.d.ts +11 -0
  128. package/lib/esm/formula/Queue.js +38 -0
  129. package/lib/esm/formula/Queue.js.map +1 -0
  130. package/lib/esm/formula/Stack.d.ts +14 -0
  131. package/lib/esm/formula/Stack.js +67 -0
  132. package/lib/esm/formula/Stack.js.map +1 -0
  133. package/lib/esm/formula/StringBuilder.d.ts +9 -0
  134. package/lib/esm/formula/StringBuilder.js +22 -0
  135. package/lib/esm/formula/StringBuilder.js.map +1 -0
  136. package/lib/esm/formula/Types.d.ts +8 -0
  137. package/lib/esm/formula/Types.js +2 -0
  138. package/lib/esm/formula/Types.js.map +1 -0
  139. package/lib/esm/formula/Utils.d.ts +7 -0
  140. package/lib/esm/formula/Utils.js +30 -0
  141. package/lib/esm/formula/Utils.js.map +1 -0
  142. package/lib/esm/widget/components/BlockingOverlay.d.ts +7 -0
  143. package/lib/esm/widget/components/BlockingOverlay.js +14 -0
  144. package/lib/esm/widget/components/BlockingOverlay.js.map +1 -0
  145. package/lib/esm/widget/components/BlockingOverlay.scss +26 -0
  146. package/lib/esm/widget/components/CalculatedPropertyAction.d.ts +1 -1
  147. package/lib/esm/widget/components/CalculatedPropertyAction.js +5 -6
  148. package/lib/esm/widget/components/CalculatedPropertyAction.js.map +1 -1
  149. package/lib/esm/widget/components/CalculatedPropertyTable.d.ts +5 -2
  150. package/lib/esm/widget/components/CalculatedPropertyTable.js +6 -30
  151. package/lib/esm/widget/components/CalculatedPropertyTable.js.map +1 -1
  152. package/lib/esm/widget/components/ConfirmMappingsImport.js +2 -3
  153. package/lib/esm/widget/components/ConfirmMappingsImport.js.map +1 -1
  154. package/lib/esm/widget/components/ConfirmMappingsImport.scss +4 -2
  155. package/lib/esm/widget/components/CustomCalculationAction.d.ts +4 -2
  156. package/lib/esm/widget/components/CustomCalculationAction.js +11 -7
  157. package/lib/esm/widget/components/CustomCalculationAction.js.map +1 -1
  158. package/lib/esm/widget/components/CustomCalculationTable.d.ts +5 -2
  159. package/lib/esm/widget/components/CustomCalculationTable.js +6 -30
  160. package/lib/esm/widget/components/CustomCalculationTable.js.map +1 -1
  161. package/lib/esm/widget/components/GroupAction.js +4 -13
  162. package/lib/esm/widget/components/GroupAction.js.map +1 -1
  163. package/lib/esm/widget/components/GroupPropertyAction.d.ts +1 -1
  164. package/lib/esm/widget/components/GroupPropertyAction.js +6 -7
  165. package/lib/esm/widget/components/GroupPropertyAction.js.map +1 -1
  166. package/lib/esm/widget/components/GroupPropertyTable.d.ts +5 -2
  167. package/lib/esm/widget/components/GroupPropertyTable.js +6 -30
  168. package/lib/esm/widget/components/GroupPropertyTable.js.map +1 -1
  169. package/lib/esm/widget/components/Grouping.js +3 -4
  170. package/lib/esm/widget/components/Grouping.js.map +1 -1
  171. package/lib/esm/widget/components/Mapping.js +28 -7
  172. package/lib/esm/widget/components/Mapping.js.map +1 -1
  173. package/lib/esm/widget/components/MappingAction.js +12 -15
  174. package/lib/esm/widget/components/MappingAction.js.map +1 -1
  175. package/lib/esm/widget/components/MappingImportWizardModal.js +2 -2
  176. package/lib/esm/widget/components/MappingImportWizardModal.js.map +1 -1
  177. package/lib/esm/widget/components/MappingImportWizardModal.scss +6 -2
  178. package/lib/esm/widget/components/PropertyMenu.js +79 -23
  179. package/lib/esm/widget/components/PropertyMenu.js.map +1 -1
  180. package/lib/esm/widget/components/SelectIModel.scss +2 -1
  181. package/lib/esm/widget/components/SelectMapping.scss +2 -1
  182. package/lib/esm/widget/components/SelectMappings.js +2 -3
  183. package/lib/esm/widget/components/SelectMappings.js.map +1 -1
  184. package/lib/esm/widget/components/SelectProject.js +9 -9
  185. package/lib/esm/widget/components/SelectProject.js.map +1 -1
  186. package/lib/esm/widget/components/SelectProject.scss +3 -8
  187. package/lib/esm/widget/components/utils.d.ts +2 -0
  188. package/lib/esm/widget/components/utils.js +11 -0
  189. package/lib/esm/widget/components/utils.js.map +1 -1
  190. package/lib/esm/widget/hooks/useFetchData.d.ts +9 -0
  191. package/lib/esm/widget/hooks/useFetchData.js +35 -0
  192. package/lib/esm/widget/hooks/useFetchData.js.map +1 -0
  193. package/lib/esm/widget/hooks/useFormulaValidation.d.ts +6 -0
  194. package/lib/esm/widget/hooks/useFormulaValidation.js +25 -0
  195. package/lib/esm/widget/hooks/useFormulaValidation.js.map +1 -0
  196. package/lib/esm/widget/utils.d.ts +1 -0
  197. package/lib/esm/widget/utils.js +7 -1
  198. package/lib/esm/widget/utils.js.map +1 -1
  199. package/package.json +3 -3
@@ -31,36 +31,12 @@ const itwinui_react_1 = require("@itwin/itwinui-react");
31
31
  const react_1 = __importStar(require("react"));
32
32
  const PropertyMenu_1 = require("./PropertyMenu");
33
33
  const DeleteModal_1 = __importDefault(require("./DeleteModal"));
34
- const utils_1 = require("./utils");
35
- const insights_client_1 = require("@itwin/insights-client");
36
34
  const GroupingMapping_1 = require("./GroupingMapping");
37
- const fetchCalculatedProperties = async (setCalculatedProperties, iModelId, mappingId, groupId, setIsLoading, apiContext) => {
38
- try {
39
- setIsLoading(true);
40
- const reportingClientApi = new insights_client_1.ReportingClient(apiContext.prefix);
41
- const calculatedProperties = await reportingClientApi.getCalculatedProperties(apiContext.accessToken, iModelId, mappingId, groupId);
42
- setCalculatedProperties(calculatedProperties);
43
- }
44
- catch (error) {
45
- utils_1.handleError(error.status);
46
- }
47
- finally {
48
- setIsLoading(false);
49
- }
50
- };
51
- const CalculatedPropertyTable = ({ iModelId, mappingId, groupId, setSelectedCalculatedProperty, setGroupModifyView, onCalculatedPropertyModify, selectedCalculatedProperty, }) => {
35
+ const utils_1 = require("./utils");
36
+ const CalculatedPropertyTable = ({ iModelId, mappingId, groupId, setSelectedCalculatedProperty, setGroupModifyView, onCalculatedPropertyModify, isLoadingCalculatedProperties: isLoadingGroupProperties, calculatedProperties, refreshCalculatedProperties, selectedCalculatedProperty, }) => {
52
37
  var _a;
53
38
  const apiContext = react_1.useContext(GroupingMapping_1.ApiContext);
54
- const [isLoading, setIsLoading] = react_1.useState(true);
55
39
  const [showCalculatedPropertyDeleteModal, setShowCalculatedPropertyDeleteModal,] = react_1.useState(false);
56
- const [calculatedProperties, setCalculatedProperties] = react_1.useState([]);
57
- react_1.useEffect(() => {
58
- void fetchCalculatedProperties(setCalculatedProperties, iModelId, mappingId, groupId, setIsLoading, apiContext);
59
- }, [apiContext, groupId, iModelId, mappingId, setIsLoading]);
60
- const refresh = react_1.useCallback(async () => {
61
- setCalculatedProperties([]);
62
- await fetchCalculatedProperties(setCalculatedProperties, iModelId, mappingId, groupId, setIsLoading, apiContext);
63
- }, [apiContext, groupId, iModelId, mappingId, setCalculatedProperties]);
64
40
  const calculatedPropertiesColumns = react_1.useMemo(() => [
65
41
  {
66
42
  Header: "Table",
@@ -98,12 +74,12 @@ const CalculatedPropertyTable = ({ iModelId, mappingId, groupId, setSelectedCalc
98
74
  react_1.default.createElement(itwinui_react_1.Button, { startIcon: react_1.default.createElement(itwinui_icons_react_1.SvgAdd, null), styleType: 'high-visibility', onClick: () => {
99
75
  setGroupModifyView(PropertyMenu_1.PropertyMenuView.ADD_CALCULATED_PROPERTY);
100
76
  } }, "Add Calculated Property"),
101
- react_1.default.createElement(itwinui_react_1.Table, { data: calculatedProperties, density: 'extra-condensed', columns: calculatedPropertiesColumns, emptyTableContent: 'No Calculated Properties', isSortable: true, isLoading: isLoading }),
77
+ react_1.default.createElement(itwinui_react_1.Table, { data: calculatedProperties, density: 'extra-condensed', columns: calculatedPropertiesColumns, emptyTableContent: 'No Calculated Properties', isSortable: true, isLoading: isLoadingGroupProperties }),
102
78
  react_1.default.createElement(DeleteModal_1.default, { entityName: (_a = selectedCalculatedProperty === null || selectedCalculatedProperty === void 0 ? void 0 : selectedCalculatedProperty.propertyName) !== null && _a !== void 0 ? _a : "", show: showCalculatedPropertyDeleteModal, setShow: setShowCalculatedPropertyDeleteModal, onDelete: async () => {
103
79
  var _a;
104
- const reportingClientApi = new insights_client_1.ReportingClient(apiContext.prefix);
80
+ const reportingClientApi = utils_1.getReportingClient(apiContext.prefix);
105
81
  await reportingClientApi.deleteCalculatedProperty(apiContext.accessToken, iModelId, mappingId, groupId, (_a = selectedCalculatedProperty === null || selectedCalculatedProperty === void 0 ? void 0 : selectedCalculatedProperty.id) !== null && _a !== void 0 ? _a : "");
106
- }, refresh: refresh })));
82
+ }, refresh: refreshCalculatedProperties })));
107
83
  };
108
84
  exports.default = CalculatedPropertyTable;
109
85
  //# sourceMappingURL=CalculatedPropertyTable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CalculatedPropertyTable.js","sourceRoot":"","sources":["../../../../src/widget/components/CalculatedPropertyTable.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,oEAKoC;AACpC,wDAM8B;AAC9B,+CAAqF;AAErF,iDAAkD;AAElD,gEAAwC;AACxC,mCAAsC;AAEtC,4DAAyD;AAEzD,uDAA+C;AAK/C,MAAM,yBAAyB,GAAG,KAAK,EACrC,uBAEC,EACD,QAAgB,EAChB,SAAiB,EACjB,OAAe,EACf,YAA2D,EAC3D,UAAe,EACf,EAAE;IACF,IAAI;QACF,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,MAAM,kBAAkB,GAAG,IAAI,iCAAe,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAClE,MAAM,oBAAoB,GACxB,MAAM,kBAAkB,CAAC,uBAAuB,CAC9C,UAAU,CAAC,WAAW,EACtB,QAAQ,EACR,SAAS,EACT,OAAO,CACR,CAAC;QACJ,uBAAuB,CAAC,oBAAoB,CAAC,CAAC;KAC/C;IAAC,OAAO,KAAU,EAAE;QACnB,mBAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;KAC3B;YAAS;QACR,YAAY,CAAC,KAAK,CAAC,CAAC;KACrB;AACH,CAAC,CAAC;AAiBF,M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ACT,8BAAC,qBAAK,IACJ,IAAI,EAAE,oBAAoB,EAC1B,OAAO,EAAC,iBAAiB,EACzB,OAAO,EAAE,2BAA2B,EACpC,iBAAiB,EAAC,0BAA0B,EAC5C,UAAU,QACV,SAAS,EAAE,SAAS,GACpB;QAEF,8BAAC,qBAAW,IACV,UAAU,EAAE,MAAA,0BAA0B,aAA1B,0BAA0B,uBAA1B,0BAA0B,CAAE,YAAY,mCAAI,EAAE,EAC1D,IAAI,EAAE,iCAAiC,EACvC,OAAO,EAAE,oCAAoC,EAC7C,QAAQ,EAAE,KAAK,IAAI,EAAE;;gBACnB,MAAM,kBAAkB,GAAG,IAAI,iCAAe,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBAClE,MAAM,kBAAkB,CAAC,wBAAwB,CAC/C,UAAU,CAAC,WAAW,EACtB,QAAQ,EACR,SAAS,EACT,OAAO,EACP,MAAA,0BAA0B,aAA1B,0BAA0B,uBAA1B,0BAA0B,CAAE,EAAE,mCAAI,EAAE,CACrC,CAAC;YACJ,CAAC,EACD,OAAO,EAAE,OAAO,GAChB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,uBAAuB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport {\n SvgAdd,\n SvgDelete,\n SvgEdit,\n SvgMore,\n} from \"@itwin/itwinui-icons-react\";\nimport {\n Button,\n DropdownMenu,\n IconButton,\n MenuItem,\n Table,\n} from \"@itwin/itwinui-react\";\nimport React, { useCallback, useContext, useEffect, useMemo, useState } from \"react\";\nimport type { CreateTypeFromInterface } from \"../utils\";\nimport { PropertyMenuView } from \"./PropertyMenu\";\nimport type { CellProps } from \"react-table\";\nimport DeleteModal from \"./DeleteModal\";\nimport { handleError } from \"./utils\";\nimport type { CalculatedProperty } from \"@itwin/insights-client\";\nimport { ReportingClient } from \"@itwin/insights-client\";\nimport type { Api } from \"./GroupingMapping\";\nimport { ApiContext } from \"./GroupingMapping\";\n\nexport type CalculatedPropertyType =\n CreateTypeFromInterface<CalculatedProperty>;\n\nconst fetchCalculatedProperties = async (\n setCalculatedProperties: React.Dispatch<\n React.SetStateAction<CalculatedPropertyType[]>\n >,\n iModelId: string,\n mappingId: string,\n groupId: string,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,\n apiContext: Api\n) => {\n try {\n setIsLoading(true);\n const reportingClientApi = new ReportingClient(apiContext.prefix);\n const calculatedProperties =\n await reportingClientApi.getCalculatedProperties(\n apiContext.accessToken,\n iModelId,\n mappingId,\n groupId,\n );\n setCalculatedProperties(calculatedProperties);\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n};\n\ninterface CalculatedPropertyTableProps {\n iModelId: string;\n mappingId: string;\n groupId: string;\n\n setSelectedCalculatedProperty: React.Dispatch<\n React.SetStateAction<\n CreateTypeFromInterface<CalculatedProperty> | undefined\n >\n >;\n setGroupModifyView: React.Dispatch<React.SetStateAction<PropertyMenuView>>;\n onCalculatedPropertyModify: (value: CellProps<CalculatedPropertyType>) => void;\n selectedCalculatedProperty?: CalculatedPropertyType;\n}\n\nconst CalculatedPropertyTable = ({\n iModelId,\n mappingId,\n groupId,\n setSelectedCalculatedProperty,\n setGroupModifyView,\n onCalculatedPropertyModify,\n selectedCalculatedProperty,\n}: CalculatedPropertyTableProps) => {\n const apiContext = useContext(ApiContext);\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [\n showCalculatedPropertyDeleteModal,\n setShowCalculatedPropertyDeleteModal,\n ] = useState<boolean>(false);\n const [calculatedProperties, setCalculatedProperties] = useState<\n CalculatedPropertyType[]\n >([]);\n\n useEffect(() => {\n void fetchCalculatedProperties(\n setCalculatedProperties,\n iModelId,\n mappingId,\n groupId,\n setIsLoading,\n apiContext\n );\n }, [apiContext, groupId, iModelId, mappingId, setIsLoading]);\n\n const refresh = useCallback(async () => {\n setCalculatedProperties([]);\n await fetchCalculatedProperties(\n setCalculatedProperties,\n iModelId,\n mappingId,\n groupId,\n setIsLoading,\n apiContext\n );\n }, [apiContext, groupId, iModelId, mappingId, setCalculatedProperties]);\n\n const calculatedPropertiesColumns = useMemo(\n () => [\n {\n Header: \"Table\",\n columns: [\n {\n id: \"propertyName\",\n Header: \"Calculated Property\",\n accessor: \"propertyName\",\n Cell: (value: CellProps<CalculatedPropertyType>) => (\n <div\n className='iui-anchor'\n onClick={() => onCalculatedPropertyModify(value)}\n >\n {value.row.original.propertyName}\n </div>\n ),\n },\n {\n id: \"dropdown\",\n Header: \"\",\n width: 80,\n Cell: (value: CellProps<CalculatedPropertyType>) => {\n return (\n <DropdownMenu\n menuItems={(close: () => void) => [\n <MenuItem\n key={0}\n onClick={() => onCalculatedPropertyModify(value)}\n icon={<SvgEdit />}\n >\n Modify\n </MenuItem>,\n <MenuItem\n key={1}\n onClick={() => {\n setSelectedCalculatedProperty(value.row.original);\n setShowCalculatedPropertyDeleteModal(true);\n close();\n }}\n icon={<SvgDelete />}\n >\n Remove\n </MenuItem>,\n ]}\n >\n <IconButton styleType='borderless'>\n <SvgMore\n style={{\n width: \"16px\",\n height: \"16px\",\n }}\n />\n </IconButton>\n </DropdownMenu>\n );\n },\n },\n ],\n },\n ],\n [onCalculatedPropertyModify, setSelectedCalculatedProperty],\n );\n\n return (\n <>\n <Button\n startIcon={<SvgAdd />}\n styleType='high-visibility'\n onClick={() => {\n setGroupModifyView(PropertyMenuView.ADD_CALCULATED_PROPERTY);\n }}\n >\n Add Calculated Property\n </Button>\n <Table<CalculatedPropertyType>\n data={calculatedProperties}\n density='extra-condensed'\n columns={calculatedPropertiesColumns}\n emptyTableContent='No Calculated Properties'\n isSortable\n isLoading={isLoading}\n />\n\n <DeleteModal\n entityName={selectedCalculatedProperty?.propertyName ?? \"\"}\n show={showCalculatedPropertyDeleteModal}\n setShow={setShowCalculatedPropertyDeleteModal}\n onDelete={async () => {\n const reportingClientApi = new ReportingClient(apiContext.prefix);\n await reportingClientApi.deleteCalculatedProperty(\n apiContext.accessToken,\n iModelId,\n mappingId,\n groupId,\n selectedCalculatedProperty?.id ?? \"\",\n );\n }}\n refresh={refresh}\n />\n </>\n );\n};\n\nexport default CalculatedPropertyTable;\n"]}
1
+ {"version":3,"file":"CalculatedPropertyTable.js","sourceRoot":"","sources":["../../../../src/widget/components/CalculatedPropertyTable.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,oEAKoC;AACpC,wDAM8B;AAC9B,+CAA6D;AAE7D,iDAAkD;AAElD,gEAAwC;AAExC,uDAA+C;AAC/C,mCAA6C;AAsB7C,MAAM,uBAAuB,GAAG,CAAC,EAC/B,QAAQ,EACR,SAAS,EACT,OAAO,EACP,6BAA6B,EAC7B,kBAAkB,EAClB,0BAA0B,EAC1B,6BAA6B,EAAE,wBAAwB,EACvD,oBAAoB,EACpB,2BAA2B,EAC3B,0BAA0B,GACG,EAAE,EAAE;;IACjC,MAAM,UAAU,GAAG,kBAAU,CAAC,4BAAU,CAAC,CAAC;IAC1C,MAAM,CACJ,iCAAiC,EACjC,oCAAoC,EACrC,GAAG,gBAAQ,CAAU,KAAK,CAAC,CAAC;IAE7B,MAAM,2BAA2B,GAAG,eAAO,CACzC,GAAG,EAAE,CAAC;QACJ;YACE,MAAM,EAAE,OAAO;YACf,OAAO,EAAE;gBACP;oBACE,EAAE,EAAE,cAAc;oBAClB,MAAM,EAAE,qBAAqB;oBAC7B,QAAQ,EAAE,cAAc;oBACxB,IAAI,EAAE,CAAC,KAAwC,EAAE,EAAE,CAAC,CAClD,uCACE,SAAS,EAAC,YAAY,EACtB,OAAO,EAAE,GAAG,EAAE,CAAC,0BAA0B,CAAC,KAAK,CAAC,IAE/C,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,YAAY,CAC5B,CACP;iBACF;gBACD;oBACE,EAAE,EAAE,UAAU;oBACd,M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AW,IACV,UAAU,EAAE,MAAA,0BAA0B,aAA1B,0BAA0B,uBAA1B,0BAA0B,CAAE,YAAY,mCAAI,EAAE,EAC1D,IAAI,EAAE,iCAAiC,EACvC,OAAO,EAAE,oCAAoC,EAC7C,QAAQ,EAAE,KAAK,IAAI,EAAE;;gBACnB,MAAM,kBAAkB,GAAG,0BAAkB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBACjE,MAAM,kBAAkB,CAAC,wBAAwB,CAC/C,UAAU,CAAC,WAAW,EACtB,QAAQ,EACR,SAAS,EACT,OAAO,EACP,MAAA,0BAA0B,aAA1B,0BAA0B,uBAA1B,0BAA0B,CAAE,EAAE,mCAAI,EAAE,CACrC,CAAC;YACJ,CAAC,EACD,OAAO,EAAE,2BAA2B,GACpC,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,uBAAuB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport {\n SvgAdd,\n SvgDelete,\n SvgEdit,\n SvgMore,\n} from \"@itwin/itwinui-icons-react\";\nimport {\n Button,\n DropdownMenu,\n IconButton,\n MenuItem,\n Table,\n} from \"@itwin/itwinui-react\";\nimport React, { useContext, useMemo, useState } from \"react\";\nimport type { CreateTypeFromInterface } from \"../utils\";\nimport { PropertyMenuView } from \"./PropertyMenu\";\nimport type { CellProps } from \"react-table\";\nimport DeleteModal from \"./DeleteModal\";\nimport type { CalculatedProperty } from \"@itwin/insights-client\";\nimport { ApiContext } from \"./GroupingMapping\";\nimport { getReportingClient } from \"./utils\";\n\nexport type CalculatedPropertyType =\n CreateTypeFromInterface<CalculatedProperty>;\n\ninterface CalculatedPropertyTableProps {\n iModelId: string;\n mappingId: string;\n groupId: string;\n setSelectedCalculatedProperty: React.Dispatch<\n React.SetStateAction<\n CreateTypeFromInterface<CalculatedPropertyType> | undefined\n >\n >;\n setGroupModifyView: React.Dispatch<React.SetStateAction<PropertyMenuView>>;\n onCalculatedPropertyModify: (value: CellProps<CalculatedPropertyType>) => void;\n isLoadingCalculatedProperties: boolean;\n calculatedProperties: CalculatedPropertyType[];\n refreshCalculatedProperties: () => Promise<void>;\n selectedCalculatedProperty?: CalculatedPropertyType;\n}\n\nconst CalculatedPropertyTable = ({\n iModelId,\n mappingId,\n groupId,\n setSelectedCalculatedProperty,\n setGroupModifyView,\n onCalculatedPropertyModify,\n isLoadingCalculatedProperties: isLoadingGroupProperties,\n calculatedProperties,\n refreshCalculatedProperties,\n selectedCalculatedProperty,\n}: CalculatedPropertyTableProps) => {\n const apiContext = useContext(ApiContext);\n const [\n showCalculatedPropertyDeleteModal,\n setShowCalculatedPropertyDeleteModal,\n ] = useState<boolean>(false);\n\n const calculatedPropertiesColumns = useMemo(\n () => [\n {\n Header: \"Table\",\n columns: [\n {\n id: \"propertyName\",\n Header: \"Calculated Property\",\n accessor: \"propertyName\",\n Cell: (value: CellProps<CalculatedPropertyType>) => (\n <div\n className='iui-anchor'\n onClick={() => onCalculatedPropertyModify(value)}\n >\n {value.row.original.propertyName}\n </div>\n ),\n },\n {\n id: \"dropdown\",\n Header: \"\",\n width: 80,\n Cell: (value: CellProps<CalculatedPropertyType>) => {\n return (\n <DropdownMenu\n menuItems={(close: () => void) => [\n <MenuItem\n key={0}\n onClick={() => onCalculatedPropertyModify(value)}\n icon={<SvgEdit />}\n >\n Modify\n </MenuItem>,\n <MenuItem\n key={1}\n onClick={() => {\n setSelectedCalculatedProperty(value.row.original);\n setShowCalculatedPropertyDeleteModal(true);\n close();\n }}\n icon={<SvgDelete />}\n >\n Remove\n </MenuItem>,\n ]}\n >\n <IconButton styleType='borderless'>\n <SvgMore\n style={{\n width: \"16px\",\n height: \"16px\",\n }}\n />\n </IconButton>\n </DropdownMenu>\n );\n },\n },\n ],\n },\n ],\n [onCalculatedPropertyModify, setSelectedCalculatedProperty],\n );\n\n return (\n <>\n <Button\n startIcon={<SvgAdd />}\n styleType='high-visibility'\n onClick={() => {\n setGroupModifyView(PropertyMenuView.ADD_CALCULATED_PROPERTY);\n }}\n >\n Add Calculated Property\n </Button>\n <Table<CalculatedPropertyType>\n data={calculatedProperties}\n density='extra-condensed'\n columns={calculatedPropertiesColumns}\n emptyTableContent='No Calculated Properties'\n isSortable\n isLoading={isLoadingGroupProperties}\n />\n\n <DeleteModal\n entityName={selectedCalculatedProperty?.propertyName ?? \"\"}\n show={showCalculatedPropertyDeleteModal}\n setShow={setShowCalculatedPropertyDeleteModal}\n onDelete={async () => {\n const reportingClientApi = getReportingClient(apiContext.prefix);\n await reportingClientApi.deleteCalculatedProperty(\n apiContext.accessToken,\n iModelId,\n mappingId,\n groupId,\n selectedCalculatedProperty?.id ?? \"\",\n );\n }}\n refresh={refreshCalculatedProperties}\n />\n </>\n );\n};\n\nexport default CalculatedPropertyTable;\n"]}
@@ -30,7 +30,6 @@ const appui_react_1 = require("@itwin/appui-react");
30
30
  const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
31
31
  const useValidator_1 = __importStar(require("../hooks/useValidator"));
32
32
  const utils_1 = require("./utils");
33
- const insights_client_1 = require("@itwin/insights-client");
34
33
  const GroupingMapping_1 = require("./GroupingMapping");
35
34
  const ConfirmMappingImport = ({ sourceiModelId, selectedMappings, importing, setImporting, setSelectedMappings, backFn, onCancel, onFinish, }) => {
36
35
  var _a;
@@ -62,7 +61,7 @@ const ConfirmMappingImport = ({ sourceiModelId, selectedMappings, importing, set
62
61
  }
63
62
  setImporting(true);
64
63
  try {
65
- const reportingClientApi = new insights_client_1.ReportingClient(apiContext.prefix);
64
+ const reportingClientApi = utils_1.getReportingClient(apiContext.prefix);
66
65
  for (const selectedMapping of selectedMappings) {
67
66
  setCurrentlyImporting((_a = selectedMapping.mappingName) !== null && _a !== void 0 ? _a : "");
68
67
  await reportingClientApi.copyMapping(apiContext.accessToken, sourceiModelId, (_b = selectedMapping.id) !== null && _b !== void 0 ? _b : "", {
@@ -1 +1 @@
1
- {"version":3,"file":"ConfirmMappingsImport.js","sourceRoot":"","sources":["../../../../src/widget/components/ConfirmMappingsImport.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAM8B;AAC9B,+CAA+D;AAE/D,wCAAsC;AACtC,oDAA+D;AAC/D,oEAAoE;AACpE,sEAAwE;AACxE,mCAAsC;AACtC,4DAAyD;AACzD,uDAA+C;AAa/C,MAAM,oBAAoB,GAAG,CAAC,EAC5B,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACR,QAAQ,GACkB,EAAE,EAAE;;IAC9B,MAAM,QAAQ,GAAG,MAAA,uCAAyB,EAAE,0CAAE,QAAQ,CAAC;IACvD,MAAM,UAAU,GAAG,kBAAU,CAAC,4BAAU,CAAC,CAAC;IAE1C,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,gBAAQ,CAAS,CAAC,CAAC,CAAC;IAC1D,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,gBAAQ,CAAS,EAAE,CAAC,CAAC;IACzE,MAAM,CAAC,SAAS,EAAE,qBAAqB,CAAC,GAAG,sBAAY,EAAE,CAAC;IAC1D,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,gBAAQ,CAAU,KAAK,CAAC,CAAC;IAEvD,iBAAS,CAAC,GAAG,EAAE;QACb,mBAAmB,CAAC,CAAC,gBAAgB,EAAE,EAAE,CACvC,gBAAgB,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACjC,GAAG,OAAO;YACV,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,OAAO;SAC3C,CAAC,CAAC,CACJ,CAAC;IACJ,CAAC,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC;IAE1B,MAAM,YAAY,GAAG,CACnB,CAAsC,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AC,OAAO,CACf,WAAW,OAAO,CAAC,EAAE,EAAE,EACvB,OAAO,CAAC,WAAW,EACnB,gCAAiB,CAClB;4BACC,CAAC,CAAC,UAAU;4BACZ,CAAC,CAAC,SAAS,EAEf,MAAM,EAAE,GAAG,EAAE;4BACX,SAAS,CAAC,cAAc,CAAC,WAAW,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;wBACpD,CAAC,EACD,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE;4BACvB,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;4BAC3B,SAAS,CAAC,cAAc,CAAC,WAAW,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;wBACpD,CAAC,GACD;oBACF,2CAAM,OAAO,CAAC,WAAW,CAAO,CAC5B;gBACN,uCAAK,SAAS,EAAC,YAAY,GAAG,CAC1B,CACP,CAAC,CACE,CACF;QACN,uCAAK,SAAS,EAAC,qBAAqB;YAClC,8BAAC,sBAAM,IAAC,OAAO,EAAE,MAAM,WAAe;YACtC,8BAAC,sBAAM,IAAC,SAAS,EAAC,iBAAiB,EAAC,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,QAAQ,EAAE,aAE1D;YACT,8BAAC,sBAAM,IAAC,OAAO,EAAE,QAAQ,aAAiB,CACtC,CACF,CACP,CACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,oBAAoB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport {\n Button,\n LabeledInput,\n MiddleTextTruncation,\n ProgressLinear,\n Text,\n} from \"@itwin/itwinui-react\";\nimport React, { useContext, useEffect, useState } from \"react\";\nimport type { MappingType } from \"./Mapping\";\nimport \"./ConfirmMappingsImport.scss\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { SvgStatusSuccessHollow } from \"@itwin/itwinui-icons-react\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError } from \"./utils\";\nimport { ReportingClient } from \"@itwin/insights-client\";\nimport { ApiContext } from \"./GroupingMapping\";\n\ninterface ConfirmMappingImportProps {\n sourceiModelId: string;\n selectedMappings: MappingType[];\n importing: boolean;\n setImporting: React.Dispatch<React.SetStateAction<boolean>>;\n setSelectedMappings: React.Dispatch<React.SetStateAction<MappingType[]>>;\n backFn: () => void;\n onCancel: () => void;\n onFinish: () => void;\n}\n\nconst ConfirmMappingImport = ({\n sourceiModelId,\n selectedMappings,\n importing,\n setImporting,\n setSelectedMappings,\n backFn,\n onCancel,\n onFinish,\n}: ConfirmMappingImportProps) => {\n const iModelId = useActiveIModelConnection()?.iModelId;\n const apiContext = useContext(ApiContext);\n\n const [importCount, setImportCount] = useState<number>(0);\n const [currentlyImporting, setCurrentlyImporting] = useState<string>(\"\");\n const [validator, showValidationMessage] = useValidator();\n const [errored, setErrored] = useState<boolean>(false);\n\n useEffect(() => {\n setSelectedMappings((selectedMappings) =>\n selectedMappings.map((mapping) => ({\n ...mapping,\n mappingName: `${mapping.mappingName}_Copy`,\n })),\n );\n }, [setSelectedMappings]);\n\n const handleChange = (\n e: React.ChangeEvent<HTMLInputElement>,\n index: number,\n ) => {\n const newState = [...selectedMappings];\n newState[index] = {\n ...newState[index],\n mappingName: e.target.value,\n };\n setSelectedMappings(newState);\n };\n\n const onImport = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n setImporting(true);\n try {\n const reportingClientApi = new ReportingClient(apiContext.prefix);\n for (const selectedMapping of selectedMappings) {\n setCurrentlyImporting(selectedMapping.mappingName ?? \"\");\n await reportingClientApi.copyMapping(\n apiContext.accessToken,\n sourceiModelId,\n selectedMapping.id ?? \"\",\n {\n targetIModelId: iModelId ?? \"\",\n mappingName: selectedMapping.mappingName ?? \"\",\n },\n );\n setImportCount((importCount) => importCount + 1);\n }\n } catch (error: any) {\n handleError(error);\n setErrored(true);\n }\n };\n\n return (\n <>\n {importing ? (\n <div className='import-progress-container'>\n <div className='import-progress-bar'>\n <div className='import-progress-bar-description'>\n {\n !errored ? importCount !== selectedMappings.length ? (\n <>\n <Text variant='title'>Importing</Text>\n <Text>We are currently importing the mappings.</Text>\n </>\n ) : (\n <>\n <Text variant='title'>Done!</Text>\n <Text>Your mapping(s) are ready.</Text>\n </>\n ) :\n <>\n <Text variant='title'>Error!</Text>\n <Text>Sorry, there was an error importing some or all mappings.</Text>\n </>}\n </div>\n <ProgressLinear\n value={(importCount / selectedMappings.length) * 100}\n labels={\n importCount === selectedMappings.length\n ? [\"Import done!\", <SvgStatusSuccessHollow key='0' />]\n : [\n <>\n <Text>Copying</Text>\n <MiddleTextTruncation text={currentlyImporting} />\n </>,\n `${importCount}/${selectedMappings.length}`,\n ]\n }\n status={\n !errored ?\n importCount === selectedMappings.length ? \"positive\" : undefined : \"negative\"\n }\n />\n </div>\n <div className='import-action-panel'>\n <Button\n disabled={!errored && importCount !== selectedMappings.length}\n onClick={() => {\n setImporting(false);\n setImportCount(0);\n setCurrentlyImporting(\"\");\n setErrored(false);\n }}\n >\n Back\n </Button>\n <Button\n styleType='high-visibility'\n disabled={!errored && importCount !== selectedMappings.length}\n onClick={() => onFinish()}\n >\n Close\n </Button>\n </div>\n </div>\n ) : (\n <div className='rename-confirm-container '>\n <div className='mapping-rename-container'>\n <div className='mapping-row-header-container'>\n <div className='mapping-row'>\n <Text variant='leading'>Mapping </Text>\n <Text variant='leading'>Description</Text>\n </div>\n </div>\n <div className='mapping-row-body'>\n {selectedMappings.map((mapping, index) => (\n <div className='mapping-row-container' key={mapping.id}>\n <div className='mapping-row'>\n <LabeledInput\n value={mapping.mappingName}\n name={`mapping_${mapping.id}`}\n required\n onChange={(event) => {\n handleChange(event, index);\n validator.showMessageFor(`mapping_${mapping.id}`);\n }}\n message={validator.message(\n `mapping_${mapping.id}`,\n mapping.mappingName,\n NAME_REQUIREMENTS,\n )}\n status={\n validator.message(\n `mapping_${mapping.id}`,\n mapping.mappingName,\n NAME_REQUIREMENTS,\n )\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(`mapping_${mapping.id}`);\n }}\n onBlurCapture={(event) => {\n handleChange(event, index);\n validator.showMessageFor(`mapping_${mapping.id}`);\n }}\n />\n <div>{mapping.description}</div>\n </div>\n <div className='border-div' />\n </div>\n ))}\n </div>\n </div>\n <div className='import-action-panel'>\n <Button onClick={backFn}>Back</Button>\n <Button styleType='high-visibility' onClick={async () => onImport()}>\n Import\n </Button>\n <Button onClick={onCancel}>Cancel</Button>\n </div>\n </div>\n )}\n </>\n );\n};\n\nexport default ConfirmMappingImport;\n"]}
1
+ {"version":3,"file":"ConfirmMappingsImport.js","sourceRoot":"","sources":["../../../../src/widget/components/ConfirmMappingsImport.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAM8B;AAC9B,+CAA+D;AAE/D,wCAAsC;AACtC,oDAA+D;AAC/D,oEAAoE;AACpE,sEAAwE;AACxE,mCAA0D;AAC1D,uDAA+C;AAa/C,MAAM,oBAAoB,GAAG,CAAC,EAC5B,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACR,QAAQ,GACkB,EAAE,EAAE;;IAC9B,MAAM,QAAQ,GAAG,MAAA,uCAAyB,EAAE,0CAAE,QAAQ,CAAC;IACvD,MAAM,UAAU,GAAG,kBAAU,CAAC,4BAAU,CAAC,CAAC;IAE1C,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,gBAAQ,CAAS,CAAC,CAAC,CAAC;IAC1D,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,gBAAQ,CAAS,EAAE,CAAC,CAAC;IACzE,MAAM,CAAC,SAAS,EAAE,qBAAqB,CAAC,GAAG,sBAAY,EAAE,CAAC;IAC1D,MAAM,CAAC,OAA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,kBAAe,oBAAoB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport {\n Button,\n LabeledInput,\n MiddleTextTruncation,\n ProgressLinear,\n Text,\n} from \"@itwin/itwinui-react\";\nimport React, { useContext, useEffect, useState } from \"react\";\nimport type { MappingType } from \"./Mapping\";\nimport \"./ConfirmMappingsImport.scss\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { SvgStatusSuccessHollow } from \"@itwin/itwinui-icons-react\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { getReportingClient, handleError } from \"./utils\";\nimport { ApiContext } from \"./GroupingMapping\";\n\ninterface ConfirmMappingImportProps {\n sourceiModelId: string;\n selectedMappings: MappingType[];\n importing: boolean;\n setImporting: React.Dispatch<React.SetStateAction<boolean>>;\n setSelectedMappings: React.Dispatch<React.SetStateAction<MappingType[]>>;\n backFn: () => void;\n onCancel: () => void;\n onFinish: () => void;\n}\n\nconst ConfirmMappingImport = ({\n sourceiModelId,\n selectedMappings,\n importing,\n setImporting,\n setSelectedMappings,\n backFn,\n onCancel,\n onFinish,\n}: ConfirmMappingImportProps) => {\n const iModelId = useActiveIModelConnection()?.iModelId;\n const apiContext = useContext(ApiContext);\n\n const [importCount, setImportCount] = useState<number>(0);\n const [currentlyImporting, setCurrentlyImporting] = useState<string>(\"\");\n const [validator, showValidationMessage] = useValidator();\n const [errored, setErrored] = useState<boolean>(false);\n\n useEffect(() => {\n setSelectedMappings((selectedMappings) =>\n selectedMappings.map((mapping) => ({\n ...mapping,\n mappingName: `${mapping.mappingName}_Copy`,\n })),\n );\n }, [setSelectedMappings]);\n\n const handleChange = (\n e: React.ChangeEvent<HTMLInputElement>,\n index: number,\n ) => {\n const newState = [...selectedMappings];\n newState[index] = {\n ...newState[index],\n mappingName: e.target.value,\n };\n setSelectedMappings(newState);\n };\n\n const onImport = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n setImporting(true);\n try {\n const reportingClientApi = getReportingClient(apiContext.prefix);\n for (const selectedMapping of selectedMappings) {\n setCurrentlyImporting(selectedMapping.mappingName ?? \"\");\n await reportingClientApi.copyMapping(\n apiContext.accessToken,\n sourceiModelId,\n selectedMapping.id ?? \"\",\n {\n targetIModelId: iModelId ?? \"\",\n mappingName: selectedMapping.mappingName ?? \"\",\n },\n );\n setImportCount((importCount) => importCount + 1);\n }\n } catch (error: any) {\n handleError(error);\n setErrored(true);\n }\n };\n\n return (\n <>\n {importing ? (\n <div className='import-progress-container'>\n <div className='import-progress-bar'>\n <div className='import-progress-bar-description'>\n {\n !errored ? importCount !== selectedMappings.length ? (\n <>\n <Text variant='title'>Importing</Text>\n <Text>We are currently importing the mappings.</Text>\n </>\n ) : (\n <>\n <Text variant='title'>Done!</Text>\n <Text>Your mapping(s) are ready.</Text>\n </>\n ) :\n <>\n <Text variant='title'>Error!</Text>\n <Text>Sorry, there was an error importing some or all mappings.</Text>\n </>}\n </div>\n <ProgressLinear\n value={(importCount / selectedMappings.length) * 100}\n labels={\n importCount === selectedMappings.length\n ? [\"Import done!\", <SvgStatusSuccessHollow key='0' />]\n : [\n <>\n <Text>Copying</Text>\n <MiddleTextTruncation text={currentlyImporting} />\n </>,\n `${importCount}/${selectedMappings.length}`,\n ]\n }\n status={\n !errored ?\n importCount === selectedMappings.length ? \"positive\" : undefined : \"negative\"\n }\n />\n </div>\n <div className='import-action-panel'>\n <Button\n disabled={!errored && importCount !== selectedMappings.length}\n onClick={() => {\n setImporting(false);\n setImportCount(0);\n setCurrentlyImporting(\"\");\n setErrored(false);\n }}\n >\n Back\n </Button>\n <Button\n styleType='high-visibility'\n disabled={!errored && importCount !== selectedMappings.length}\n onClick={() => onFinish()}\n >\n Close\n </Button>\n </div>\n </div>\n ) : (\n <div className='rename-confirm-container '>\n <div className='mapping-rename-container'>\n <div className='mapping-row-header-container'>\n <div className='mapping-row'>\n <Text variant='leading'>Mapping </Text>\n <Text variant='leading'>Description</Text>\n </div>\n </div>\n <div className='mapping-row-body'>\n {selectedMappings.map((mapping, index) => (\n <div className='mapping-row-container' key={mapping.id}>\n <div className='mapping-row'>\n <LabeledInput\n value={mapping.mappingName}\n name={`mapping_${mapping.id}`}\n required\n onChange={(event) => {\n handleChange(event, index);\n validator.showMessageFor(`mapping_${mapping.id}`);\n }}\n message={validator.message(\n `mapping_${mapping.id}`,\n mapping.mappingName,\n NAME_REQUIREMENTS,\n )}\n status={\n validator.message(\n `mapping_${mapping.id}`,\n mapping.mappingName,\n NAME_REQUIREMENTS,\n )\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(`mapping_${mapping.id}`);\n }}\n onBlurCapture={(event) => {\n handleChange(event, index);\n validator.showMessageFor(`mapping_${mapping.id}`);\n }}\n />\n <div>{mapping.description}</div>\n </div>\n <div className='border-div' />\n </div>\n ))}\n </div>\n </div>\n <div className='import-action-panel'>\n <Button onClick={backFn}>Back</Button>\n <Button styleType='high-visibility' onClick={async () => onImport()}>\n Import\n </Button>\n <Button onClick={onCancel}>Cancel</Button>\n </div>\n </div>\n )}\n </>\n );\n};\n\nexport default ConfirmMappingImport;\n"]}
@@ -20,7 +20,8 @@
20
20
  .import-progress-container {
21
21
  display: flex;
22
22
  flex-direction: column;
23
- height: 66vh;
23
+ flex-grow: 1;
24
+ min-height: 0;
24
25
  justify-content: center;
25
26
 
26
27
  .import-progress-bar {
@@ -52,7 +53,8 @@
52
53
  .rename-confirm-container {
53
54
  display: flex;
54
55
  flex-direction: column;
55
- height: 66vh;
56
+ flex-grow: 1;
57
+ min-height: 0;
56
58
 
57
59
  .mapping-rename-container {
58
60
  display: flex;
@@ -2,13 +2,15 @@
2
2
  import "./CalculatedPropertyAction.scss";
3
3
  import type { CustomCalculationType } from "./CustomCalculationTable";
4
4
  import "./CustomCalculationAction.scss";
5
+ import type { PropertyMap } from "../../formula/Types";
5
6
  interface CalculatedPropertyActionProps {
6
7
  iModelId: string;
7
8
  mappingId: string;
8
9
  groupId: string;
10
+ properties: PropertyMap;
9
11
  customCalculation?: CustomCalculationType;
10
- returnFn: () => Promise<void>;
12
+ returnFn: (modified: boolean) => Promise<void>;
11
13
  }
12
- declare const CustomCalculationAction: ({ iModelId, mappingId, groupId, customCalculation, returnFn, }: CalculatedPropertyActionProps) => JSX.Element;
14
+ declare const CustomCalculationAction: ({ iModelId, mappingId, groupId, properties, customCalculation, returnFn, }: CalculatedPropertyActionProps) => JSX.Element;
13
15
  export default CustomCalculationAction;
14
16
  //# sourceMappingURL=CustomCalculationAction.d.ts.map
@@ -34,9 +34,9 @@ const utils_1 = require("./utils");
34
34
  require("./CalculatedPropertyAction.scss");
35
35
  require("./CustomCalculationAction.scss");
36
36
  const GroupPropertyAction_1 = require("./GroupPropertyAction");
37
- const insights_client_1 = require("@itwin/insights-client");
37
+ const useFormulaValidation_1 = require("../hooks/useFormulaValidation");
38
38
  const GroupingMapping_1 = require("./GroupingMapping");
39
- const CustomCalculationAction = ({ iModelId, mappingId, groupId, customCalculation, returnFn, }) => {
39
+ const CustomCalculationAction = ({ iModelId, mappingId, groupId, properties, customCalculation, returnFn, }) => {
40
40
  var _a, _b, _c, _d;
41
41
  const apiContext = react_1.useContext(GroupingMapping_1.ApiContext);
42
42
  const [propertyName, setPropertyName] = react_1.useState((_a = customCalculation === null || customCalculation === void 0 ? void 0 : customCalculation.propertyName) !== null && _a !== void 0 ? _a : "");
@@ -45,15 +45,19 @@ const CustomCalculationAction = ({ iModelId, mappingId, groupId, customCalculati
45
45
  const [isLoading, setIsLoading] = react_1.useState(false);
46
46
  const [formulaErrorMessage, setFormulaErrorMessage] = react_1.useState("");
47
47
  const [validator, showValidationMessage] = useValidator_1.default();
48
+ const { isValid, forceValidation } = useFormulaValidation_1.useFormulaValidation(propertyName.toLowerCase(), formula, properties, setFormulaErrorMessage);
48
49
  const onSave = async () => {
49
50
  var _a;
50
51
  if (!validator.allValid()) {
51
52
  showValidationMessage(true);
52
53
  return;
53
54
  }
55
+ if (!forceValidation()) {
56
+ return;
57
+ }
54
58
  try {
55
59
  setIsLoading(true);
56
- const reportingClientApi = new insights_client_1.ReportingClient(apiContext.prefix);
60
+ const reportingClientApi = utils_1.getReportingClient(apiContext.prefix);
57
61
  customCalculation
58
62
  ? await reportingClientApi.updateCustomCalculation(apiContext.accessToken, iModelId, mappingId, groupId, (_a = customCalculation.id) !== null && _a !== void 0 ? _a : "", {
59
63
  propertyName,
@@ -65,7 +69,7 @@ const CustomCalculationAction = ({ iModelId, mappingId, groupId, customCalculati
65
69
  formula,
66
70
  quantityType,
67
71
  });
68
- await returnFn();
72
+ await returnFn(true);
69
73
  }
70
74
  catch (error) {
71
75
  // error instanceof Response refuses to be true when it should be.
@@ -86,7 +90,7 @@ const CustomCalculationAction = ({ iModelId, mappingId, groupId, customCalculati
86
90
  return (react_1.default.createElement(react_1.default.Fragment, null,
87
91
  react_1.default.createElement(utils_1.WidgetHeader, { title: customCalculation
88
92
  ? `${(_d = customCalculation === null || customCalculation === void 0 ? void 0 : customCalculation.propertyName) !== null && _d !== void 0 ? _d : ""}`
89
- : "Create Custom Calculation", returnFn: returnFn }),
93
+ : "Create Custom Calculation", returnFn: async () => returnFn(false) }),
90
94
  react_1.default.createElement("div", { className: 'custom-calculation-action-container' },
91
95
  react_1.default.createElement(itwinui_react_1.Fieldset, { legend: 'Custom Calculation Details', className: 'details-form' },
92
96
  react_1.default.createElement(itwinui_react_1.Small, { className: 'field-legend' }, "Asterisk * indicates mandatory fields."),
@@ -105,7 +109,7 @@ const CustomCalculationAction = ({ iModelId, mappingId, groupId, customCalculati
105
109
  setFormula(event.target.value);
106
110
  }, message: formulaErrorMessage, status: formulaErrorMessage ? "negative" : undefined }),
107
111
  react_1.default.createElement(itwinui_react_1.LabeledSelect, { label: 'Quantity Type', disabled: isLoading, options: GroupPropertyAction_1.quantityTypesSelectionOptions, value: quantityType, onChange: setQuantityType, onShow: () => { }, onHide: () => { } }))),
108
- react_1.default.createElement(ActionPanel_1.default, { onSave: onSave, onCancel: returnFn, isSavingDisabled: !(formula && propertyName), isLoading: isLoading })));
112
+ react_1.default.createElement(ActionPanel_1.default, { onSave: onSave, onCancel: async () => returnFn(false), isSavingDisabled: !(formula && propertyName && isValid), isLoading: isLoading })));
109
113
  };
110
114
  exports.default = CustomCalculationAction;
111
115
  //# sourceMappingURL=CustomCalculationAction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CustomCalculationAction.js","sourceRoot":"","sources":["../../../../src/widget/components/CustomCalculationAction.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAM8B;AAC9B,+CAAoD;AACpD,gEAAwC;AACxC,sEAAwE;AACxE,mCAAoD;AACpD,2CAAyC;AAEzC,0CAAwC;AACxC,+DAAsE;AACtE,4DAAyD;AACzD,uDAA+C;AAU/C,MAAM,uBAAuB,GAAG,CAAC,EAC/B,QAAQ,EACR,SAAS,EACT,OAAO,EACP,iBAAiB,EACjB,QAAQ,GACsB,EAAE,EAAE;;IAClC,MAAM,UAAU,GAAG,kBAAU,CAAC,4BAAU,CAAC,CAAC;IAC1C,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,gBAAQ,CAC9C,MAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,YAAY,mCAAI,EAAE,CACtC,CAAC;IACF,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,gBAAQ,CACpC,MAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,OAAO,mCAAI,EAAE,CACjC,CAAC;IACF,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,gBAAQ,CAAS,MAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,YAAY,mCAAI,WAAW,CAAC,CAAC;IACzG,MAAM,CAAC,SAAS,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,KAAK,CAAC,CAAC;wBACpC,SAAS,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;oBACnC,CAAC,GACD;gBACF,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,GACpD;gBACF,8BAAC,6BAAa,IACZ,KAAK,EAAC,eAAe,EACrB,QAAQ,EAAE,SAAS,EACnB,OAAO,EAAE,mDAA6B,EACtC,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EACjB,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,GACjB,CACO,CACP;QACN,8BAAC,qBAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,CAAC,CAAC,OAAO,IAAI,YAAY,CAAC,EAC5C,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,uBAAuB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport {\n Fieldset,\n LabeledInput,\n LabeledSelect,\n LabeledTextarea,\n Small,\n} from \"@itwin/itwinui-react\";\nimport React, { useContext, useState } from \"react\";\nimport ActionPanel from \"./ActionPanel\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError, WidgetHeader } from \"./utils\";\nimport \"./CalculatedPropertyAction.scss\";\nimport type { CustomCalculationType } from \"./CustomCalculationTable\";\nimport \"./CustomCalculationAction.scss\";\nimport { quantityTypesSelectionOptions } from \"./GroupPropertyAction\";\nimport { ReportingClient } from \"@itwin/insights-client\";\nimport { ApiContext } from \"./GroupingMapping\";\n\ninterface CalculatedPropertyActionProps {\n iModelId: string;\n mappingId: string;\n groupId: string;\n customCalculation?: CustomCalculationType;\n returnFn: () => Promise<void>;\n}\n\nconst CustomCalculationAction = ({\n iModelId,\n mappingId,\n groupId,\n customCalculation,\n returnFn,\n}: CalculatedPropertyActionProps) => {\n const apiContext = useContext(ApiContext);\n const [propertyName, setPropertyName] = useState<string>(\n customCalculation?.propertyName ?? \"\",\n );\n const [formula, setFormula] = useState<string>(\n customCalculation?.formula ?? \"\",\n );\n const [quantityType, setQuantityType] = useState<string>(customCalculation?.quantityType ?? \"Undefined\");\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [formulaErrorMessage, setFormulaErrorMessage] = useState<string>(\"\");\n const [validator, showValidationMessage] = useValidator();\n\n const onSave = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n try {\n setIsLoading(true);\n const reportingClientApi = new ReportingClient(apiContext.prefix);\n\n customCalculation\n ? await reportingClientApi.updateCustomCalculation(\n apiContext.accessToken,\n iModelId,\n mappingId,\n groupId,\n customCalculation.id ?? \"\",\n {\n propertyName,\n formula,\n quantityType,\n }\n )\n : await reportingClientApi.createCustomCalculation(\n apiContext.accessToken,\n iModelId,\n mappingId,\n groupId,\n {\n propertyName,\n formula,\n quantityType,\n }\n );\n await returnFn();\n } catch (error: any) {\n // error instanceof Response refuses to be true when it should be.\n if (error.status === 422) {\n error = error as Response;\n const erroredResponse = await error.json();\n if (\n erroredResponse.error.code === \"InvalidInsightsRequest\" &&\n erroredResponse.error.target === \"formula\"\n ) {\n setFormulaErrorMessage(erroredResponse.error.message);\n }\n } else {\n handleError(error.status);\n }\n setIsLoading(false);\n }\n };\n\n return (\n <>\n <WidgetHeader\n title={\n customCalculation\n ? `${customCalculation?.propertyName ?? \"\"}`\n : \"Create Custom Calculation\"\n }\n returnFn={returnFn}\n />\n <div className='custom-calculation-action-container'>\n <Fieldset legend='Custom Calculation Details' className='details-form'>\n <Small className='field-legend'>\n Asterisk * indicates mandatory fields.\n </Small>\n <LabeledInput\n value={propertyName}\n required\n name='name'\n label='Name'\n disabled={isLoading}\n onChange={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n message={validator.message(\"name\", propertyName, NAME_REQUIREMENTS)}\n status={\n validator.message(\"name\", propertyName, NAME_REQUIREMENTS)\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"name\");\n }}\n onBlurCapture={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n />\n <LabeledTextarea\n value={formula}\n required\n name='formula'\n label='Formula'\n disabled={isLoading}\n onChange={(event) => {\n setFormula(event.target.value);\n }}\n message={formulaErrorMessage}\n status={formulaErrorMessage ? \"negative\" : undefined}\n />\n <LabeledSelect<string>\n label='Quantity Type'\n disabled={isLoading}\n options={quantityTypesSelectionOptions}\n value={quantityType}\n onChange={setQuantityType}\n onShow={() => { }}\n onHide={() => { }}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={returnFn}\n isSavingDisabled={!(formula && propertyName)}\n isLoading={isLoading}\n />\n </>\n );\n};\n\nexport default CustomCalculationAction;\n"]}
1
+ {"version":3,"file":"CustomCalculationAction.js","sourceRoot":"","sources":["../../../../src/widget/components/CustomCalculationAction.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAM8B;AAC9B,+CAAoD;AACpD,gEAAwC;AACxC,sEAAwE;AACxE,mCAAwE;AACxE,2CAAyC;AAEzC,0CAAwC;AACxC,+DAAsE;AACtE,wEAAqE;AAErE,uDAA+C;AAW/C,MAAM,uBAA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MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,GACpD;gBACF,8BAAC,6BAAa,IACZ,KAAK,EAAC,eAAe,EACrB,QAAQ,EAAE,SAAS,EACnB,OAAO,EAAE,mDAA6B,EACtC,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EACjB,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,GACjB,CACO,CACP;QACN,8BAAC,qBAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EACrC,gBAAgB,EAAE,CAAC,CAAC,OAAO,IAAI,YAAY,IAAI,OAAO,CAAC,EACvD,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,uBAAuB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport {\n Fieldset,\n LabeledInput,\n LabeledSelect,\n LabeledTextarea,\n Small,\n} from \"@itwin/itwinui-react\";\nimport React, { useContext, useState } from \"react\";\nimport ActionPanel from \"./ActionPanel\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { getReportingClient, handleError, WidgetHeader } from \"./utils\";\nimport \"./CalculatedPropertyAction.scss\";\nimport type { CustomCalculationType } from \"./CustomCalculationTable\";\nimport \"./CustomCalculationAction.scss\";\nimport { quantityTypesSelectionOptions } from \"./GroupPropertyAction\";\nimport { useFormulaValidation } from \"../hooks/useFormulaValidation\";\nimport type { PropertyMap } from \"../../formula/Types\";\nimport { ApiContext } from \"./GroupingMapping\";\n\ninterface CalculatedPropertyActionProps {\n iModelId: string;\n mappingId: string;\n groupId: string;\n properties: PropertyMap;\n customCalculation?: CustomCalculationType;\n returnFn: (modified: boolean) => Promise<void>;\n}\n\nconst CustomCalculationAction = ({\n iModelId,\n mappingId,\n groupId,\n properties,\n customCalculation,\n returnFn,\n}: CalculatedPropertyActionProps) => {\n const apiContext = useContext(ApiContext);\n const [propertyName, setPropertyName] = useState<string>(\n customCalculation?.propertyName ?? \"\",\n );\n const [formula, setFormula] = useState<string>(\n customCalculation?.formula ?? \"\",\n );\n const [quantityType, setQuantityType] = useState<string>(customCalculation?.quantityType ?? \"Undefined\");\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [formulaErrorMessage, setFormulaErrorMessage] = useState<string>(\"\");\n const [validator, showValidationMessage] = useValidator();\n const { isValid, forceValidation } = useFormulaValidation(propertyName.toLowerCase(), formula, properties, setFormulaErrorMessage);\n\n const onSave = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n if (!forceValidation()) {\n return;\n }\n try {\n setIsLoading(true);\n const reportingClientApi = getReportingClient(apiContext.prefix);\n\n customCalculation\n ? await reportingClientApi.updateCustomCalculation(\n apiContext.accessToken,\n iModelId,\n mappingId,\n groupId,\n customCalculation.id ?? \"\",\n {\n propertyName,\n formula,\n quantityType,\n }\n )\n : await reportingClientApi.createCustomCalculation(\n apiContext.accessToken,\n iModelId,\n mappingId,\n groupId,\n {\n propertyName,\n formula,\n quantityType,\n }\n );\n await returnFn(true);\n } catch (error: any) {\n // error instanceof Response refuses to be true when it should be.\n if (error.status === 422) {\n error = error as Response;\n const erroredResponse = await error.json();\n if (\n erroredResponse.error.code === \"InvalidInsightsRequest\" &&\n erroredResponse.error.target === \"formula\"\n ) {\n setFormulaErrorMessage(erroredResponse.error.message);\n }\n } else {\n handleError(error.status);\n }\n setIsLoading(false);\n }\n };\n\n return (\n <>\n <WidgetHeader\n title={\n customCalculation\n ? `${customCalculation?.propertyName ?? \"\"}`\n : \"Create Custom Calculation\"\n }\n returnFn={async () => returnFn(false)}\n />\n <div className='custom-calculation-action-container'>\n <Fieldset legend='Custom Calculation Details' className='details-form'>\n <Small className='field-legend'>\n Asterisk * indicates mandatory fields.\n </Small>\n <LabeledInput\n value={propertyName}\n required\n name='name'\n label='Name'\n disabled={isLoading}\n onChange={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n message={validator.message(\"name\", propertyName, NAME_REQUIREMENTS)}\n status={\n validator.message(\"name\", propertyName, NAME_REQUIREMENTS)\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"name\");\n }}\n onBlurCapture={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n />\n <LabeledTextarea\n value={formula}\n required\n name='formula'\n label='Formula'\n disabled={isLoading}\n onChange={(event) => {\n setFormula(event.target.value);\n }}\n message={formulaErrorMessage}\n status={formulaErrorMessage ? \"negative\" : undefined}\n />\n <LabeledSelect<string>\n label='Quantity Type'\n disabled={isLoading}\n options={quantityTypesSelectionOptions}\n value={quantityType}\n onChange={setQuantityType}\n onShow={() => { }}\n onHide={() => { }}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={async () => returnFn(false)}\n isSavingDisabled={!(formula && propertyName && isValid)}\n isLoading={isLoading}\n />\n </>\n );\n};\n\nexport default CustomCalculationAction;\n"]}
@@ -8,11 +8,14 @@ interface CustomCalculationTableProps {
8
8
  iModelId: string;
9
9
  mappingId: string;
10
10
  groupId: string;
11
- setSelectedCustomCalculation: React.Dispatch<React.SetStateAction<CreateTypeFromInterface<CustomCalculation> | undefined>>;
11
+ setSelectedCustomCalculation: React.Dispatch<React.SetStateAction<CreateTypeFromInterface<CustomCalculationType> | undefined>>;
12
12
  setGroupModifyView: React.Dispatch<React.SetStateAction<PropertyMenuView>>;
13
13
  onCustomCalculationModify: (value: CellProps<CustomCalculationType>) => void;
14
+ isLoadingCustomCalculations: boolean;
15
+ customCalculations: CustomCalculationType[];
16
+ refreshCustomCalculations: () => Promise<void>;
14
17
  selectedCustomCalculation?: CustomCalculationType;
15
18
  }
16
- declare const CustomCalculationTable: ({ iModelId, mappingId, groupId, setSelectedCustomCalculation, setGroupModifyView, onCustomCalculationModify, selectedCustomCalculation, }: CustomCalculationTableProps) => JSX.Element;
19
+ declare const CustomCalculationTable: ({ iModelId, mappingId, groupId, setSelectedCustomCalculation, setGroupModifyView, onCustomCalculationModify, isLoadingCustomCalculations, customCalculations, refreshCustomCalculations, selectedCustomCalculation, }: CustomCalculationTableProps) => JSX.Element;
17
20
  export default CustomCalculationTable;
18
21
  //# sourceMappingURL=CustomCalculationTable.d.ts.map
@@ -31,36 +31,12 @@ const itwinui_react_1 = require("@itwin/itwinui-react");
31
31
  const react_1 = __importStar(require("react"));
32
32
  const PropertyMenu_1 = require("./PropertyMenu");
33
33
  const DeleteModal_1 = __importDefault(require("./DeleteModal"));
34
- const utils_1 = require("./utils");
35
- const insights_client_1 = require("@itwin/insights-client");
36
34
  const GroupingMapping_1 = require("./GroupingMapping");
37
- const fetchCustomCalculations = async (setCustomCalculations, iModelId, mappingId, groupId, setIsLoading, apiContext) => {
38
- try {
39
- setIsLoading(true);
40
- const reportingClientApi = new insights_client_1.ReportingClient(apiContext.prefix);
41
- const customCalculations = await reportingClientApi.getCustomCalculations(apiContext.accessToken, iModelId, mappingId, groupId);
42
- setCustomCalculations(customCalculations);
43
- }
44
- catch (error) {
45
- utils_1.handleError(error.status);
46
- }
47
- finally {
48
- setIsLoading(false);
49
- }
50
- };
51
- const CustomCalculationTable = ({ iModelId, mappingId, groupId, setSelectedCustomCalculation, setGroupModifyView, onCustomCalculationModify, selectedCustomCalculation, }) => {
35
+ const utils_1 = require("./utils");
36
+ const CustomCalculationTable = ({ iModelId, mappingId, groupId, setSelectedCustomCalculation, setGroupModifyView, onCustomCalculationModify, isLoadingCustomCalculations, customCalculations, refreshCustomCalculations, selectedCustomCalculation, }) => {
52
37
  var _a;
53
38
  const apiContext = react_1.useContext(GroupingMapping_1.ApiContext);
54
- const [isLoading, setIsLoading] = react_1.useState(true);
55
39
  const [showCustomCalculationDeleteModal, setShowCustomCalculationDeleteModal,] = react_1.useState(false);
56
- const [customCalculations, setCustomCalculations] = react_1.useState([]);
57
- react_1.useEffect(() => {
58
- void fetchCustomCalculations(setCustomCalculations, iModelId, mappingId, groupId, setIsLoading, apiContext);
59
- }, [apiContext, groupId, iModelId, mappingId, setIsLoading]);
60
- const refresh = react_1.useCallback(async () => {
61
- setCustomCalculations([]);
62
- await fetchCustomCalculations(setCustomCalculations, iModelId, mappingId, groupId, setIsLoading, apiContext);
63
- }, [apiContext, groupId, iModelId, mappingId, setCustomCalculations]);
64
40
  const CustomCalculationsColumns = react_1.useMemo(() => [
65
41
  {
66
42
  Header: "Table",
@@ -103,12 +79,12 @@ const CustomCalculationTable = ({ iModelId, mappingId, groupId, setSelectedCusto
103
79
  react_1.default.createElement(itwinui_react_1.Button, { startIcon: react_1.default.createElement(itwinui_icons_react_1.SvgAdd, null), styleType: 'high-visibility', onClick: () => {
104
80
  setGroupModifyView(PropertyMenu_1.PropertyMenuView.ADD_CUSTOM_CALCULATION);
105
81
  } }, "Add Custom Calculation"),
106
- react_1.default.createElement(itwinui_react_1.Table, { data: customCalculations, density: 'extra-condensed', columns: CustomCalculationsColumns, emptyTableContent: 'No Custom Calculations', isSortable: true, isLoading: isLoading }),
82
+ react_1.default.createElement(itwinui_react_1.Table, { data: customCalculations, density: 'extra-condensed', columns: CustomCalculationsColumns, emptyTableContent: 'No Custom Calculations', isSortable: true, isLoading: isLoadingCustomCalculations }),
107
83
  react_1.default.createElement(DeleteModal_1.default, { entityName: (_a = selectedCustomCalculation === null || selectedCustomCalculation === void 0 ? void 0 : selectedCustomCalculation.propertyName) !== null && _a !== void 0 ? _a : "", show: showCustomCalculationDeleteModal, setShow: setShowCustomCalculationDeleteModal, onDelete: async () => {
108
84
  var _a;
109
- const reportingClientApi = new insights_client_1.ReportingClient(apiContext.prefix);
85
+ const reportingClientApi = utils_1.getReportingClient(apiContext.prefix);
110
86
  await reportingClientApi.deleteCustomCalculation(apiContext.accessToken, iModelId, mappingId, groupId, (_a = selectedCustomCalculation === null || selectedCustomCalculation === void 0 ? void 0 : selectedCustomCalculation.id) !== null && _a !== void 0 ? _a : "");
111
- }, refresh: refresh })));
87
+ }, refresh: refreshCustomCalculations })));
112
88
  };
113
89
  exports.default = CustomCalculationTable;
114
90
  //# sourceMappingURL=CustomCalculationTable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CustomCalculationTable.js","sourceRoot":"","sources":["../../../../src/widget/components/CustomCalculationTable.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,oEAKoC;AACpC,wDAM8B;AAC9B,+CAAqF;AAErF,iDAAkD;AAElD,gEAAwC;AACxC,mCAAsC;AAEtC,4DAAyD;AAEzD,uDAA+C;AAK/C,MAAM,uBAAuB,GAAG,KAAK,EACnC,qBAEC,EACD,QAAgB,EAChB,SAAiB,EACjB,OAAe,EACf,YAA2D,EAC3D,UAAe,EACf,EAAE;IACF,IAAI;QACF,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,MAAM,kBAAkB,GAAG,IAAI,iCAAe,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAClE,MAAM,kBAAkB,GAAG,MAAM,kBAAkB,CAAC,qBAAqB,CACvE,UAAU,CAAC,WAAW,EACtB,QAAQ,EACR,SAAS,EACT,OAAO,CACR,CAAC;QACF,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;KAC3C;IAAC,OAAO,KAAU,EAAE;QACnB,mBAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;KAC3B;YAAS;QACR,YAAY,CAAC,KAAK,CAAC,CAAC;KACrB;AACH,CAAC,CAAC;AAiBF,MAAM,sBAAsB,GAAG,CAAC,EAC9B,QAAQ,EACR,SAAS,EACT,OAAO,EACP,4BAA4B,EAC5B,kBAAkB,EAClB,yBAAyB,EACzB,yBAAyB,GACG,EAAE,EAAE;;IACh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AAO,EAAC,iBAAiB,EACzB,OAAO,EAAE,yBAAyB,EAClC,iBAAiB,EAAC,wBAAwB,EAC1C,UAAU,QACV,SAAS,EAAE,SAAS,GACpB;QAEF,8BAAC,qBAAW,IACV,UAAU,EAAE,MAAA,yBAAyB,aAAzB,yBAAyB,uBAAzB,yBAAyB,CAAE,YAAY,mCAAI,EAAE,EACzD,IAAI,EAAE,gCAAgC,EACtC,OAAO,EAAE,mCAAmC,EAC5C,QAAQ,EAAE,KAAK,IAAI,EAAE;;gBACnB,MAAM,kBAAkB,GAAG,IAAI,iCAAe,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBAClE,MAAM,kBAAkB,CAAC,uBAAuB,CAC9C,UAAU,CAAC,WAAW,EACtB,QAAQ,EACR,SAAS,EACT,OAAO,EACP,MAAA,yBAAyB,aAAzB,yBAAyB,uBAAzB,yBAAyB,CAAE,EAAE,mCAAI,EAAE,CACpC,CAAC;YACJ,CAAC,EACD,OAAO,EAAE,OAAO,GAChB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,sBAAsB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport {\n SvgAdd,\n SvgDelete,\n SvgEdit,\n SvgMore,\n} from \"@itwin/itwinui-icons-react\";\nimport {\n Button,\n DropdownMenu,\n IconButton,\n MenuItem,\n Table,\n} from \"@itwin/itwinui-react\";\nimport React, { useCallback, useContext, useEffect, useMemo, useState } from \"react\";\nimport type { CreateTypeFromInterface } from \"../utils\";\nimport { PropertyMenuView } from \"./PropertyMenu\";\nimport type { CellProps } from \"react-table\";\nimport DeleteModal from \"./DeleteModal\";\nimport { handleError } from \"./utils\";\nimport type { CustomCalculation } from \"@itwin/insights-client\";\nimport { ReportingClient } from \"@itwin/insights-client\";\nimport type { Api } from \"./GroupingMapping\";\nimport { ApiContext } from \"./GroupingMapping\";\n\nexport type CustomCalculationType =\n CreateTypeFromInterface<CustomCalculation>;\n\nconst fetchCustomCalculations = async (\n setCustomCalculations: React.Dispatch<\n React.SetStateAction<CustomCalculationType[]>\n >,\n iModelId: string,\n mappingId: string,\n groupId: string,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,\n apiContext: Api\n) => {\n try {\n setIsLoading(true);\n const reportingClientApi = new ReportingClient(apiContext.prefix);\n const customCalculations = await reportingClientApi.getCustomCalculations(\n apiContext.accessToken,\n iModelId,\n mappingId,\n groupId,\n );\n setCustomCalculations(customCalculations);\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n};\n\ninterface CustomCalculationTableProps {\n iModelId: string;\n mappingId: string;\n groupId: string;\n\n setSelectedCustomCalculation: React.Dispatch<\n React.SetStateAction<\n CreateTypeFromInterface<CustomCalculation> | undefined\n >\n >;\n setGroupModifyView: React.Dispatch<React.SetStateAction<PropertyMenuView>>;\n onCustomCalculationModify: (value: CellProps<CustomCalculationType>) => void;\n selectedCustomCalculation?: CustomCalculationType;\n}\n\nconst CustomCalculationTable = ({\n iModelId,\n mappingId,\n groupId,\n setSelectedCustomCalculation,\n setGroupModifyView,\n onCustomCalculationModify,\n selectedCustomCalculation,\n}: CustomCalculationTableProps) => {\n const apiContext = useContext(ApiContext);\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [\n showCustomCalculationDeleteModal,\n setShowCustomCalculationDeleteModal,\n ] = useState<boolean>(false);\n const [customCalculations, setCustomCalculations] = useState<\n CustomCalculationType[]\n >([]);\n\n useEffect(() => {\n void fetchCustomCalculations(\n setCustomCalculations,\n iModelId,\n mappingId,\n groupId,\n setIsLoading,\n apiContext\n );\n }, [apiContext, groupId, iModelId, mappingId, setIsLoading]);\n\n const refresh = useCallback(async () => {\n setCustomCalculations([]);\n await fetchCustomCalculations(\n setCustomCalculations,\n iModelId,\n mappingId,\n groupId,\n setIsLoading,\n apiContext\n );\n }, [apiContext, groupId, iModelId, mappingId, setCustomCalculations]);\n\n const CustomCalculationsColumns = useMemo(\n () => [\n {\n Header: \"Table\",\n columns: [\n {\n id: \"propertyName\",\n Header: \"Custom Calculation\",\n accessor: \"propertyName\",\n Cell: (value: CellProps<CustomCalculationType>) => (\n <div\n className='iui-anchor'\n onClick={() => onCustomCalculationModify(value)}\n >\n {value.row.original.propertyName}\n </div>\n ),\n },\n {\n id: \"formula\",\n Header: \"Formula\",\n accessor: \"formula\",\n },\n {\n id: \"dropdown\",\n Header: \"\",\n width: 80,\n Cell: (value: CellProps<CustomCalculationType>) => {\n return (\n <DropdownMenu\n menuItems={(close: () => void) => [\n <MenuItem\n key={0}\n onClick={() => onCustomCalculationModify(value)}\n icon={<SvgEdit />}\n >\n Modify\n </MenuItem>,\n <MenuItem\n key={1}\n onClick={() => {\n setSelectedCustomCalculation(value.row.original);\n setShowCustomCalculationDeleteModal(true);\n close();\n }}\n icon={<SvgDelete />}\n >\n Remove\n </MenuItem>,\n ]}\n >\n <IconButton styleType='borderless'>\n <SvgMore\n style={{\n width: \"16px\",\n height: \"16px\",\n }}\n />\n </IconButton>\n </DropdownMenu>\n );\n },\n },\n ],\n },\n ],\n [onCustomCalculationModify, setSelectedCustomCalculation],\n );\n\n return (\n <>\n <Button\n startIcon={<SvgAdd />}\n styleType='high-visibility'\n onClick={() => {\n setGroupModifyView(PropertyMenuView.ADD_CUSTOM_CALCULATION);\n }}\n >\n Add Custom Calculation\n </Button>\n <Table<CustomCalculationType>\n data={customCalculations}\n density='extra-condensed'\n columns={CustomCalculationsColumns}\n emptyTableContent='No Custom Calculations'\n isSortable\n isLoading={isLoading}\n />\n\n <DeleteModal\n entityName={selectedCustomCalculation?.propertyName ?? \"\"}\n show={showCustomCalculationDeleteModal}\n setShow={setShowCustomCalculationDeleteModal}\n onDelete={async () => {\n const reportingClientApi = new ReportingClient(apiContext.prefix);\n await reportingClientApi.deleteCustomCalculation(\n apiContext.accessToken,\n iModelId,\n mappingId,\n groupId,\n selectedCustomCalculation?.id ?? \"\",\n );\n }}\n refresh={refresh}\n />\n </>\n );\n};\n\nexport default CustomCalculationTable;\n"]}
1
+ {"version":3,"file":"CustomCalculationTable.js","sourceRoot":"","sources":["../../../../src/widget/components/CustomCalculationTable.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,oEAKoC;AACpC,wDAM8B;AAC9B,+CAA6D;AAE7D,iDAAkD;AAElD,gEAAwC;AAExC,uDAA+C;AAC/C,mCAA6C;AAsB7C,MAAM,sBAAsB,GAAG,CAAC,EAC9B,QAAQ,EACR,SAAS,EACT,OAAO,EACP,4BAA4B,EAC5B,kBAAkB,EAClB,yBAAyB,EACzB,2BAA2B,EAC3B,kBAAkB,EAClB,yBAAyB,EACzB,yBAAyB,GACG,EAAE,EAAE;;IAChC,MAAM,UAAU,GAAG,kBAAU,CAAC,4BAAU,CAAC,CAAC;IAC1C,MAAM,CACJ,gCAAgC,EAChC,mCAAmC,EACpC,GAAG,gBAAQ,CAAU,KAAK,CAAC,CAAC;IAE7B,MAAM,yBAAyB,GAAG,eAAO,CACvC,GAAG,EAAE,CAAC;QACJ;YACE,MAAM,EAAE,OAAO;YACf,OAAO,EAAE;gBACP;oBACE,EAAE,EAAE,cAAc;oBAClB,MAAM,EAAE,oBAAoB;oBAC5B,QAAQ,EAAE,cAAc;oBACxB,IAAI,EAAE,CAAC,KAAuC,EAAE,EAAE,CAAC,CACjD,uCACE,SAAS,EAAC,YAAY,EACtB,OAAO,EAAE,GAAG,EAAE,CAAC,yBAAyB,CAAC,KAAK,CAAC,IAE9C,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,YAAY,CAC5B,CACP;iBACF;gBACD;oBACE,EAAE,EAAE,SAAS;oBACb,MAAM,EAAE,SAAS;oBACjB,QAAQ,EAAE,SAAS;iBACpB;gBACD;oBACE,EAAE,EAAE,UAAU;oBACd,MAAM,EAAE,EAAE;oBACV,KAAK,EA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yB,aAAzB,yBAAyB,uBAAzB,yBAAyB,CAAE,YAAY,mCAAI,EAAE,EACzD,IAAI,EAAE,gCAAgC,EACtC,OAAO,EAAE,mCAAmC,EAC5C,QAAQ,EAAE,KAAK,IAAI,EAAE;;gBACnB,MAAM,kBAAkB,GAAG,0BAAkB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBACjE,MAAM,kBAAkB,CAAC,uBAAuB,CAC9C,UAAU,CAAC,WAAW,EACtB,QAAQ,EACR,SAAS,EACT,OAAO,EACP,MAAA,yBAAyB,aAAzB,yBAAyB,uBAAzB,yBAAyB,CAAE,EAAE,mCAAI,EAAE,CACpC,CAAC;YACJ,CAAC,EACD,OAAO,EAAE,yBAAyB,GAClC,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,sBAAsB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport {\n SvgAdd,\n SvgDelete,\n SvgEdit,\n SvgMore,\n} from \"@itwin/itwinui-icons-react\";\nimport {\n Button,\n DropdownMenu,\n IconButton,\n MenuItem,\n Table,\n} from \"@itwin/itwinui-react\";\nimport React, { useContext, useMemo, useState } from \"react\";\nimport type { CreateTypeFromInterface } from \"../utils\";\nimport { PropertyMenuView } from \"./PropertyMenu\";\nimport type { CellProps } from \"react-table\";\nimport DeleteModal from \"./DeleteModal\";\nimport type { CustomCalculation } from \"@itwin/insights-client\";\nimport { ApiContext } from \"./GroupingMapping\";\nimport { getReportingClient } from \"./utils\";\n\nexport type CustomCalculationType =\n CreateTypeFromInterface<CustomCalculation>;\n\ninterface CustomCalculationTableProps {\n iModelId: string;\n mappingId: string;\n groupId: string;\n setSelectedCustomCalculation: React.Dispatch<\n React.SetStateAction<\n CreateTypeFromInterface<CustomCalculationType> | undefined\n >\n >;\n setGroupModifyView: React.Dispatch<React.SetStateAction<PropertyMenuView>>;\n onCustomCalculationModify: (value: CellProps<CustomCalculationType>) => void;\n isLoadingCustomCalculations: boolean;\n customCalculations: CustomCalculationType[];\n refreshCustomCalculations: () => Promise<void>;\n selectedCustomCalculation?: CustomCalculationType;\n}\n\nconst CustomCalculationTable = ({\n iModelId,\n mappingId,\n groupId,\n setSelectedCustomCalculation,\n setGroupModifyView,\n onCustomCalculationModify,\n isLoadingCustomCalculations,\n customCalculations,\n refreshCustomCalculations,\n selectedCustomCalculation,\n}: CustomCalculationTableProps) => {\n const apiContext = useContext(ApiContext);\n const [\n showCustomCalculationDeleteModal,\n setShowCustomCalculationDeleteModal,\n ] = useState<boolean>(false);\n\n const CustomCalculationsColumns = useMemo(\n () => [\n {\n Header: \"Table\",\n columns: [\n {\n id: \"propertyName\",\n Header: \"Custom Calculation\",\n accessor: \"propertyName\",\n Cell: (value: CellProps<CustomCalculationType>) => (\n <div\n className='iui-anchor'\n onClick={() => onCustomCalculationModify(value)}\n >\n {value.row.original.propertyName}\n </div>\n ),\n },\n {\n id: \"formula\",\n Header: \"Formula\",\n accessor: \"formula\",\n },\n {\n id: \"dropdown\",\n Header: \"\",\n width: 80,\n Cell: (value: CellProps<CustomCalculationType>) => {\n return (\n <DropdownMenu\n menuItems={(close: () => void) => [\n <MenuItem\n key={0}\n onClick={() => onCustomCalculationModify(value)}\n icon={<SvgEdit />}\n >\n Modify\n </MenuItem>,\n <MenuItem\n key={1}\n onClick={() => {\n setSelectedCustomCalculation(value.row.original);\n setShowCustomCalculationDeleteModal(true);\n close();\n }}\n icon={<SvgDelete />}\n >\n Remove\n </MenuItem>,\n ]}\n >\n <IconButton styleType='borderless'>\n <SvgMore\n style={{\n width: \"16px\",\n height: \"16px\",\n }}\n />\n </IconButton>\n </DropdownMenu>\n );\n },\n },\n ],\n },\n ],\n [onCustomCalculationModify, setSelectedCustomCalculation],\n );\n\n return (\n <>\n <Button\n startIcon={<SvgAdd />}\n styleType='high-visibility'\n onClick={() => {\n setGroupModifyView(PropertyMenuView.ADD_CUSTOM_CALCULATION);\n }}\n >\n Add Custom Calculation\n </Button>\n <Table<CustomCalculationType>\n data={customCalculations}\n density='extra-condensed'\n columns={CustomCalculationsColumns}\n emptyTableContent='No Custom Calculations'\n isSortable\n isLoading={isLoadingCustomCalculations}\n />\n\n <DeleteModal\n entityName={selectedCustomCalculation?.propertyName ?? \"\"}\n show={showCustomCalculationDeleteModal}\n setShow={setShowCustomCalculationDeleteModal}\n onDelete={async () => {\n const reportingClientApi = getReportingClient(apiContext.prefix);\n await reportingClientApi.deleteCustomCalculation(\n apiContext.accessToken,\n iModelId,\n mappingId,\n groupId,\n selectedCustomCalculation?.id ?? \"\",\n );\n }}\n refresh={refreshCustomCalculations}\n />\n </>\n );\n};\n\nexport default CustomCalculationTable;\n"]}
@@ -35,7 +35,6 @@ const GroupQueryBuilderContext_1 = require("./GroupQueryBuilderContext");
35
35
  const QueryBuilder_1 = require("./QueryBuilder");
36
36
  const viewerUtils_1 = require("./viewerUtils");
37
37
  const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
38
- const insights_client_1 = require("@itwin/insights-client");
39
38
  const GroupingMapping_1 = require("./GroupingMapping");
40
39
  const GroupAction = ({ iModelId, mappingId, group, goBack, }) => {
41
40
  var _a, _b, _c;
@@ -122,7 +121,7 @@ const GroupAction = ({ iModelId, mappingId, group, goBack, }) => {
122
121
  try {
123
122
  setIsLoading(true);
124
123
  const currentQuery = query || simpleQuery;
125
- const reportingClientApi = new insights_client_1.ReportingClient(apiContext.prefix);
124
+ const reportingClientApi = utils_1.getReportingClient(apiContext.prefix);
126
125
  group
127
126
  ? await reportingClientApi.updateGroup(apiContext.accessToken, iModelId, mappingId, (_a = group.id) !== null && _a !== void 0 ? _a : "", { ...details, query: currentQuery })
128
127
  : await reportingClientApi.createGroup(apiContext.accessToken, iModelId, mappingId, {
@@ -150,7 +149,7 @@ const GroupAction = ({ iModelId, mappingId, group, goBack, }) => {
150
149
  apiContext.accessToken,
151
150
  apiContext.prefix,
152
151
  ]);
153
- const isBlockingActions = !(details.groupName && details.description && (query || simpleQuery) && !isRendering && !isLoading);
152
+ const isBlockingActions = !(details.groupName && (query || simpleQuery) && !isRendering && !isLoading);
154
153
  return (react_1.default.createElement(react_1.default.Fragment, null,
155
154
  react_1.default.createElement(utils_1.WidgetHeader, { title: group ? (_c = group.groupName) !== null && _c !== void 0 ? _c : "" : "Add Group", returnFn: async () => {
156
155
  presentation_frontend_1.Presentation.selection.clearSelection("GroupingMappingWidget", iModelConnection);
@@ -170,16 +169,8 @@ const GroupAction = ({ iModelId, mappingId, group, goBack, }) => {
170
169
  utils_1.handleInputChange(event, details, setDetails);
171
170
  validator.showMessageFor("groupName");
172
171
  } }),
173
- react_1.default.createElement(itwinui_react_1.LabeledInput, { id: 'description', required: true, name: 'description', label: 'Description', value: details.description, onChange: (event) => {
172
+ react_1.default.createElement(itwinui_react_1.LabeledInput, { id: 'description', name: 'description', label: 'Description', value: details.description, onChange: (event) => {
174
173
  utils_1.handleInputChange(event, details, setDetails);
175
- validator.showMessageFor("description");
176
- }, message: validator.message("description", details.description, "required"), status: validator.message("description", details.description, "required")
177
- ? "negative"
178
- : undefined, onBlur: () => {
179
- validator.showMessageFor("description");
180
- }, onBlurCapture: (event) => {
181
- utils_1.handleInputChange(event, details, setDetails);
182
- validator.showMessageFor("description");
183
174
  } })),
184
175
  react_1.default.createElement(itwinui_react_1.Fieldset, { legend: 'Group By', className: 'query-builder-container' },
185
176
  react_1.default.createElement(itwinui_react_1.RadioTileGroup, { className: "radio-group-tile", required: true },