@itwin/grouping-mapping-widget 0.3.0 → 0.3.3

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 (245) 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 +135 -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/GroupingMappingWidget.d.ts +4 -0
  44. package/lib/cjs/widget/GroupingMappingWidget.js +6 -23
  45. package/lib/cjs/widget/GroupingMappingWidget.js.map +1 -1
  46. package/lib/cjs/widget/components/CalculatedPropertyAction.d.ts +3 -3
  47. package/lib/cjs/widget/components/CalculatedPropertyAction.js +15 -10
  48. package/lib/cjs/widget/components/CalculatedPropertyAction.js.map +1 -1
  49. package/lib/cjs/widget/components/CalculatedPropertyTable.d.ts +9 -6
  50. package/lib/cjs/widget/components/CalculatedPropertyTable.js +8 -33
  51. package/lib/cjs/widget/components/CalculatedPropertyTable.js.map +1 -1
  52. package/lib/cjs/widget/components/ConfirmMappingsImport.d.ts +3 -3
  53. package/lib/cjs/widget/components/ConfirmMappingsImport.js +6 -3
  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 +6 -4
  57. package/lib/cjs/widget/components/CustomCalculationAction.js +23 -12
  58. package/lib/cjs/widget/components/CustomCalculationAction.js.map +1 -1
  59. package/lib/cjs/widget/components/CustomCalculationTable.d.ts +9 -6
  60. package/lib/cjs/widget/components/CustomCalculationTable.js +8 -33
  61. package/lib/cjs/widget/components/CustomCalculationTable.js.map +1 -1
  62. package/lib/cjs/widget/components/GroupAction.d.ts +2 -2
  63. package/lib/cjs/widget/components/GroupAction.js +25 -51
  64. package/lib/cjs/widget/components/GroupAction.js.map +1 -1
  65. package/lib/cjs/widget/components/GroupPropertyAction.d.ts +1 -1
  66. package/lib/cjs/widget/components/GroupPropertyAction.js +12 -8
  67. package/lib/cjs/widget/components/GroupPropertyAction.js.map +1 -1
  68. package/lib/cjs/widget/components/GroupPropertyTable.d.ts +9 -6
  69. package/lib/cjs/widget/components/GroupPropertyTable.js +8 -33
  70. package/lib/cjs/widget/components/GroupPropertyTable.js.map +1 -1
  71. package/lib/cjs/widget/components/Grouping.d.ts +3 -3
  72. package/lib/cjs/widget/components/Grouping.js +22 -22
  73. package/lib/cjs/widget/components/Grouping.js.map +1 -1
  74. package/lib/cjs/widget/components/GroupingMapping.d.ts +12 -2
  75. package/lib/cjs/widget/components/GroupingMapping.js +18 -4
  76. package/lib/cjs/widget/components/GroupingMapping.js.map +1 -1
  77. package/lib/cjs/widget/components/Mapping.d.ts +2 -2
  78. package/lib/cjs/widget/components/Mapping.js +14 -14
  79. package/lib/cjs/widget/components/Mapping.js.map +1 -1
  80. package/lib/cjs/widget/components/MappingAction.d.ts +2 -2
  81. package/lib/cjs/widget/components/MappingAction.js +8 -13
  82. package/lib/cjs/widget/components/MappingAction.js.map +1 -1
  83. package/lib/cjs/widget/components/MappingImportWizardModal.js +2 -2
  84. package/lib/cjs/widget/components/MappingImportWizardModal.js.map +1 -1
  85. package/lib/cjs/widget/components/MappingImportWizardModal.scss +6 -2
  86. package/lib/cjs/widget/components/PropertyMenu.d.ts +2 -2
  87. package/lib/cjs/widget/components/PropertyMenu.js +68 -21
  88. package/lib/cjs/widget/components/PropertyMenu.js.map +1 -1
  89. package/lib/cjs/widget/components/SelectIModel.js +4 -8
  90. package/lib/cjs/widget/components/SelectIModel.js.map +1 -1
  91. package/lib/cjs/widget/components/SelectIModel.scss +2 -1
  92. package/lib/cjs/widget/components/SelectMapping.scss +2 -1
  93. package/lib/cjs/widget/components/SelectMappings.d.ts +2 -2
  94. package/lib/cjs/widget/components/SelectMappings.js +10 -11
  95. package/lib/cjs/widget/components/SelectMappings.js.map +1 -1
  96. package/lib/cjs/widget/components/SelectProject.js +12 -16
  97. package/lib/cjs/widget/components/SelectProject.js.map +1 -1
  98. package/lib/cjs/widget/components/SelectProject.scss +3 -8
  99. package/lib/cjs/widget/hooks/useFetchData.d.ts +9 -0
  100. package/lib/cjs/widget/hooks/useFetchData.js +41 -0
  101. package/lib/cjs/widget/hooks/useFetchData.js.map +1 -0
  102. package/lib/cjs/widget/hooks/useFormulaValidation.d.ts +6 -0
  103. package/lib/cjs/widget/hooks/useFormulaValidation.js +29 -0
  104. package/lib/cjs/widget/hooks/useFormulaValidation.js.map +1 -0
  105. package/lib/cjs/widget/utils.d.ts +1 -0
  106. package/lib/cjs/widget/utils.js +9 -0
  107. package/lib/cjs/widget/utils.js.map +1 -1
  108. package/lib/esm/formula/FormulaFunctionProvider.d.ts +18 -0
  109. package/lib/esm/formula/FormulaFunctionProvider.js +130 -0
  110. package/lib/esm/formula/FormulaFunctionProvider.js.map +1 -0
  111. package/lib/esm/formula/FormulaOperatorsProvider.d.ts +34 -0
  112. package/lib/esm/formula/FormulaOperatorsProvider.js +174 -0
  113. package/lib/esm/formula/FormulaOperatorsProvider.js.map +1 -0
  114. package/lib/esm/formula/FormulaSplitter.d.ts +2 -0
  115. package/lib/esm/formula/FormulaSplitter.js +136 -0
  116. package/lib/esm/formula/FormulaSplitter.js.map +1 -0
  117. package/lib/esm/formula/FormulaTokensValidator.d.ts +5 -0
  118. package/lib/esm/formula/FormulaTokensValidator.js +131 -0
  119. package/lib/esm/formula/FormulaTokensValidator.js.map +1 -0
  120. package/lib/esm/formula/FormulaValidator.d.ts +3 -0
  121. package/lib/esm/formula/FormulaValidator.js +31 -0
  122. package/lib/esm/formula/FormulaValidator.js.map +1 -0
  123. package/lib/esm/formula/IResult.d.ts +5 -0
  124. package/lib/esm/formula/IResult.js +2 -0
  125. package/lib/esm/formula/IResult.js.map +1 -0
  126. package/lib/esm/formula/InfixToPostfixConverter.d.ts +18 -0
  127. package/lib/esm/formula/InfixToPostfixConverter.js +295 -0
  128. package/lib/esm/formula/InfixToPostfixConverter.js.map +1 -0
  129. package/lib/esm/formula/InputStream.d.ts +12 -0
  130. package/lib/esm/formula/InputStream.js +32 -0
  131. package/lib/esm/formula/InputStream.js.map +1 -0
  132. package/lib/esm/formula/ParenthesisValidator.d.ts +7 -0
  133. package/lib/esm/formula/ParenthesisValidator.js +30 -0
  134. package/lib/esm/formula/ParenthesisValidator.js.map +1 -0
  135. package/lib/esm/formula/Queue.d.ts +11 -0
  136. package/lib/esm/formula/Queue.js +38 -0
  137. package/lib/esm/formula/Queue.js.map +1 -0
  138. package/lib/esm/formula/Stack.d.ts +14 -0
  139. package/lib/esm/formula/Stack.js +67 -0
  140. package/lib/esm/formula/Stack.js.map +1 -0
  141. package/lib/esm/formula/StringBuilder.d.ts +9 -0
  142. package/lib/esm/formula/StringBuilder.js +22 -0
  143. package/lib/esm/formula/StringBuilder.js.map +1 -0
  144. package/lib/esm/formula/Types.d.ts +8 -0
  145. package/lib/esm/formula/Types.js +2 -0
  146. package/lib/esm/formula/Types.js.map +1 -0
  147. package/lib/esm/formula/Utils.d.ts +7 -0
  148. package/lib/esm/formula/Utils.js +30 -0
  149. package/lib/esm/formula/Utils.js.map +1 -0
  150. package/lib/esm/widget/GroupingMappingWidget.d.ts +4 -0
  151. package/lib/esm/widget/GroupingMappingWidget.js +6 -4
  152. package/lib/esm/widget/GroupingMappingWidget.js.map +1 -1
  153. package/lib/esm/widget/components/CalculatedPropertyAction.d.ts +3 -3
  154. package/lib/esm/widget/components/CalculatedPropertyAction.js +16 -11
  155. package/lib/esm/widget/components/CalculatedPropertyAction.js.map +1 -1
  156. package/lib/esm/widget/components/CalculatedPropertyTable.d.ts +9 -6
  157. package/lib/esm/widget/components/CalculatedPropertyTable.js +9 -34
  158. package/lib/esm/widget/components/CalculatedPropertyTable.js.map +1 -1
  159. package/lib/esm/widget/components/ConfirmMappingsImport.d.ts +3 -3
  160. package/lib/esm/widget/components/ConfirmMappingsImport.js +7 -4
  161. package/lib/esm/widget/components/ConfirmMappingsImport.js.map +1 -1
  162. package/lib/esm/widget/components/ConfirmMappingsImport.scss +4 -2
  163. package/lib/esm/widget/components/CustomCalculationAction.d.ts +6 -4
  164. package/lib/esm/widget/components/CustomCalculationAction.js +24 -13
  165. package/lib/esm/widget/components/CustomCalculationAction.js.map +1 -1
  166. package/lib/esm/widget/components/CustomCalculationTable.d.ts +9 -6
  167. package/lib/esm/widget/components/CustomCalculationTable.js +9 -34
  168. package/lib/esm/widget/components/CustomCalculationTable.js.map +1 -1
  169. package/lib/esm/widget/components/GroupAction.d.ts +2 -2
  170. package/lib/esm/widget/components/GroupAction.js +26 -52
  171. package/lib/esm/widget/components/GroupAction.js.map +1 -1
  172. package/lib/esm/widget/components/GroupPropertyAction.d.ts +1 -1
  173. package/lib/esm/widget/components/GroupPropertyAction.js +13 -9
  174. package/lib/esm/widget/components/GroupPropertyAction.js.map +1 -1
  175. package/lib/esm/widget/components/GroupPropertyTable.d.ts +9 -6
  176. package/lib/esm/widget/components/GroupPropertyTable.js +9 -34
  177. package/lib/esm/widget/components/GroupPropertyTable.js.map +1 -1
  178. package/lib/esm/widget/components/Grouping.d.ts +3 -3
  179. package/lib/esm/widget/components/Grouping.js +23 -23
  180. package/lib/esm/widget/components/Grouping.js.map +1 -1
  181. package/lib/esm/widget/components/GroupingMapping.d.ts +12 -2
  182. package/lib/esm/widget/components/GroupingMapping.js +17 -4
  183. package/lib/esm/widget/components/GroupingMapping.js.map +1 -1
  184. package/lib/esm/widget/components/Mapping.d.ts +2 -2
  185. package/lib/esm/widget/components/Mapping.js +15 -15
  186. package/lib/esm/widget/components/Mapping.js.map +1 -1
  187. package/lib/esm/widget/components/MappingAction.d.ts +2 -2
  188. package/lib/esm/widget/components/MappingAction.js +9 -14
  189. package/lib/esm/widget/components/MappingAction.js.map +1 -1
  190. package/lib/esm/widget/components/MappingImportWizardModal.js +2 -2
  191. package/lib/esm/widget/components/MappingImportWizardModal.js.map +1 -1
  192. package/lib/esm/widget/components/MappingImportWizardModal.scss +6 -2
  193. package/lib/esm/widget/components/PropertyMenu.d.ts +2 -2
  194. package/lib/esm/widget/components/PropertyMenu.js +69 -22
  195. package/lib/esm/widget/components/PropertyMenu.js.map +1 -1
  196. package/lib/esm/widget/components/SelectIModel.js +5 -6
  197. package/lib/esm/widget/components/SelectIModel.js.map +1 -1
  198. package/lib/esm/widget/components/SelectIModel.scss +2 -1
  199. package/lib/esm/widget/components/SelectMapping.scss +2 -1
  200. package/lib/esm/widget/components/SelectMappings.d.ts +2 -2
  201. package/lib/esm/widget/components/SelectMappings.js +11 -12
  202. package/lib/esm/widget/components/SelectMappings.js.map +1 -1
  203. package/lib/esm/widget/components/SelectProject.js +13 -14
  204. package/lib/esm/widget/components/SelectProject.js.map +1 -1
  205. package/lib/esm/widget/components/SelectProject.scss +3 -8
  206. package/lib/esm/widget/hooks/useFetchData.d.ts +9 -0
  207. package/lib/esm/widget/hooks/useFetchData.js +35 -0
  208. package/lib/esm/widget/hooks/useFetchData.js.map +1 -0
  209. package/lib/esm/widget/hooks/useFormulaValidation.d.ts +6 -0
  210. package/lib/esm/widget/hooks/useFormulaValidation.js +25 -0
  211. package/lib/esm/widget/hooks/useFormulaValidation.js.map +1 -0
  212. package/lib/esm/widget/utils.d.ts +1 -0
  213. package/lib/esm/widget/utils.js +7 -1
  214. package/lib/esm/widget/utils.js.map +1 -1
  215. package/package.json +3 -2
  216. package/lib/cjs/api/generated/api.d.ts +0 -3222
  217. package/lib/cjs/api/generated/api.js +0 -5291
  218. package/lib/cjs/api/generated/api.js.map +0 -1
  219. package/lib/cjs/api/generated/configuration.d.ts +0 -56
  220. package/lib/cjs/api/generated/configuration.js +0 -30
  221. package/lib/cjs/api/generated/configuration.js.map +0 -1
  222. package/lib/cjs/api/generated/index.d.ts +0 -14
  223. package/lib/cjs/api/generated/index.js +0 -31
  224. package/lib/cjs/api/generated/index.js.map +0 -1
  225. package/lib/cjs/api/reportingClient.d.ts +0 -34
  226. package/lib/cjs/api/reportingClient.js +0 -177
  227. package/lib/cjs/api/reportingClient.js.map +0 -1
  228. package/lib/cjs/widget/hooks/useFetchAccessToken.d.ts +0 -3
  229. package/lib/cjs/widget/hooks/useFetchAccessToken.js +0 -22
  230. package/lib/cjs/widget/hooks/useFetchAccessToken.js.map +0 -1
  231. package/lib/esm/api/generated/api.d.ts +0 -3222
  232. package/lib/esm/api/generated/api.js +0 -5248
  233. package/lib/esm/api/generated/api.js.map +0 -1
  234. package/lib/esm/api/generated/configuration.d.ts +0 -56
  235. package/lib/esm/api/generated/configuration.js +0 -26
  236. package/lib/esm/api/generated/configuration.js.map +0 -1
  237. package/lib/esm/api/generated/index.d.ts +0 -14
  238. package/lib/esm/api/generated/index.js +0 -19
  239. package/lib/esm/api/generated/index.js.map +0 -1
  240. package/lib/esm/api/reportingClient.d.ts +0 -34
  241. package/lib/esm/api/reportingClient.js +0 -173
  242. package/lib/esm/api/reportingClient.js.map +0 -1
  243. package/lib/esm/widget/hooks/useFetchAccessToken.d.ts +0 -3
  244. package/lib/esm/widget/hooks/useFetchAccessToken.js +0 -20
  245. package/lib/esm/widget/hooks/useFetchAccessToken.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Types.js","sourceRoot":"","sources":["../../../src/formula/Types.ts"],"names":[],"mappings":"","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*--------------------------------------------------------------------------------------------*/\nexport type ValueType = number | string | boolean;\n\nexport type PossibleValueType = ValueType | undefined;\n\nexport type DataType = \"number\" | \"string\" | \"boolean\";\n\nexport type PossibleDataType = DataType | \"undefined\";\n\nexport interface PropertyMap { [key: string]: PossibleDataType }\n"]}
@@ -0,0 +1,7 @@
1
+ export declare function isDigit(char: string): boolean;
2
+ export declare function isLetterOrUnderscore(char: string): boolean;
3
+ export declare function isStringDelimiter(char: string): boolean;
4
+ export declare function isWhitespace(char: string): boolean;
5
+ export declare function isDecimalSeparator(char: string): boolean;
6
+ export declare function formatNumericalPositionString(num: number): string;
7
+ //# sourceMappingURL=Utils.d.ts.map
@@ -0,0 +1,30 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ export function isDigit(char) {
6
+ return /^\d/.test(char);
7
+ }
8
+ export function isLetterOrUnderscore(char) {
9
+ return /^[\p{L}_]/u.test(char);
10
+ }
11
+ export function isStringDelimiter(char) {
12
+ return ["\"", "'", "`"].includes(char);
13
+ }
14
+ export function isWhitespace(char) {
15
+ return /^\s/.test(char);
16
+ }
17
+ export function isDecimalSeparator(char) {
18
+ return char === ".";
19
+ }
20
+ export function formatNumericalPositionString(num) {
21
+ const str = num.toString();
22
+ if (str.endsWith("1") && num !== 11)
23
+ return `${str}st`;
24
+ if (str.endsWith("2") && num !== 12)
25
+ return `${str}nd`;
26
+ if (str.endsWith("3") && num !== 13)
27
+ return `${str}rd`;
28
+ return `${str}th`;
29
+ }
30
+ //# sourceMappingURL=Utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../src/formula/Utils.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,OAAO,IAAI,KAAK,GAAG,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,GAAW;IACvD,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC3B,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,EAAE;QACjC,OAAO,GAAG,GAAG,IAAI,CAAC;IACpB,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,EAAE;QACjC,OAAO,GAAG,GAAG,IAAI,CAAC;IACpB,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,EAAE;QACjC,OAAO,GAAG,GAAG,IAAI,CAAC;IAEpB,OAAO,GAAG,GAAG,IAAI,CAAC;AACpB,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*--------------------------------------------------------------------------------------------*/\nexport function isDigit(char: string): boolean {\n return /^\\d/.test(char);\n}\n\nexport function isLetterOrUnderscore(char: string): boolean {\n return /^[\\p{L}_]/u.test(char);\n}\n\nexport function isStringDelimiter(char: string): boolean {\n return [\"\\\"\", \"'\", \"`\"].includes(char);\n}\n\nexport function isWhitespace(char: string): boolean {\n return /^\\s/.test(char);\n}\n\nexport function isDecimalSeparator(char: string): boolean {\n return char === \".\";\n}\n\nexport function formatNumericalPositionString(num: number): string {\n const str = num.toString();\n if (str.endsWith(\"1\") && num !== 11)\n return `${str}st`;\n if (str.endsWith(\"2\") && num !== 12)\n return `${str}nd`;\n if (str.endsWith(\"3\") && num !== 13)\n return `${str}rd`;\n\n return `${str}th`;\n}\n"]}
@@ -1,7 +1,11 @@
1
1
  import type { AbstractWidgetProps, UiItemsProvider } from "@itwin/appui-abstract";
2
2
  import { AbstractZoneLocation, StagePanelLocation, StagePanelSection } from "@itwin/appui-abstract";
3
+ import type { AccessToken } from "@itwin/core-bentley";
3
4
  export declare class GroupingMappingProvider implements UiItemsProvider {
4
5
  readonly id = "GroupingMappingProvider";
6
+ private readonly _accessToken?;
7
+ private readonly _prefix?;
8
+ constructor(accessToken?: AccessToken, prefix?: "" | "dev" | "qa");
5
9
  provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, section?: StagePanelSection, zonelocation?: AbstractZoneLocation): ReadonlyArray<AbstractWidgetProps>;
6
10
  }
7
11
  //# sourceMappingURL=GroupingMappingWidget.d.ts.map
@@ -1,9 +1,11 @@
1
1
  import { AbstractZoneLocation, StagePanelLocation, StagePanelSection, StageUsage, } from "@itwin/appui-abstract";
2
- import * as React from "react";
2
+ import React from "react";
3
3
  import GroupingMapping from "./components/GroupingMapping";
4
4
  export class GroupingMappingProvider {
5
- constructor() {
5
+ constructor(accessToken, prefix) {
6
6
  this.id = "GroupingMappingProvider";
7
+ this._accessToken = accessToken;
8
+ this._prefix = prefix;
7
9
  }
8
10
  provideWidgets(_stageId, stageUsage, location, section, zonelocation) {
9
11
  const widgets = [];
@@ -14,8 +16,8 @@ export class GroupingMappingProvider {
14
16
  const GroupingMappingWidget = {
15
17
  id: "GroupingMappingWidget",
16
18
  label: "Grouping & Mapping",
17
- getWidgetContent() {
18
- return React.createElement(GroupingMapping, null);
19
+ getWidgetContent: () => {
20
+ return React.createElement(GroupingMapping, { accessToken: this._accessToken, prefix: this._prefix });
19
21
  },
20
22
  };
21
23
  widgets.push(GroupingMappingWidget);
@@ -1 +1 @@
1
- {"version":3,"file":"GroupingMappingWidget.js","sourceRoot":"","sources":["../../../src/widget/GroupingMappingWidget.tsx"],"names":[],"mappings":"AAOA,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,GACX,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAE3D,MAAM,OAAO,uBAAuB;IAApC;QACkB,OAAE,GAAG,yBAAyB,CAAC;IA6BjD,CAAC;IA3BQ,cAAc,CACnB,QAAgB,EAChB,UAAkB,EAClB,QAA4B,EAC5B,OAA2B,EAC3B,YAAmC;QAEnC,MAAM,OAAO,GAA0B,EAAE,CAAC;QAC1C,IACE,CAAC,QAAQ,KAAK,kBAAkB,CAAC,IAAI;YACrC,OAAO,KAAK,iBAAiB,CAAC,KAAK;YACnC,UAAU,KAAK,UAAU,CAAC,OAAO,CAAC;YAClC,YAAY,KAAK,oBAAoB,CAAC,UAAU,EAChD;YACA,MAAM,qBAAqB,GAAwB;gBACjD,EAAE,EAAE,uBAAuB;gBAC3B,KAAK,EAAE,oBAAoB;gBAC3B,gBAAgB;oBACd,OAAO,oBAAC,eAAe,OAAG,CAAC;gBAC7B,CAAC;aACF,CAAC;YAEF,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;SACrC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type {\n AbstractWidgetProps,\n UiItemsProvider} from \"@itwin/appui-abstract\";\nimport {\n AbstractZoneLocation,\n StagePanelLocation,\n StagePanelSection,\n StageUsage,\n} from \"@itwin/appui-abstract\";\n\nimport * as React from \"react\";\nimport GroupingMapping from \"./components/GroupingMapping\";\n\nexport class GroupingMappingProvider implements UiItemsProvider {\n public readonly id = \"GroupingMappingProvider\";\n\n public provideWidgets(\n _stageId: string,\n stageUsage: string,\n location: StagePanelLocation,\n section?: StagePanelSection,\n zonelocation?: AbstractZoneLocation\n ): ReadonlyArray<AbstractWidgetProps> {\n const widgets: AbstractWidgetProps[] = [];\n if (\n (location === StagePanelLocation.Left &&\n section === StagePanelSection.Start &&\n stageUsage === StageUsage.General) ||\n zonelocation === AbstractZoneLocation.CenterLeft\n ) {\n const GroupingMappingWidget: AbstractWidgetProps = {\n id: \"GroupingMappingWidget\",\n label: \"Grouping & Mapping\",\n getWidgetContent() {\n return <GroupingMapping />;\n },\n };\n\n widgets.push(GroupingMappingWidget);\n }\n\n return widgets;\n }\n}\n"]}
1
+ {"version":3,"file":"GroupingMappingWidget.js","sourceRoot":"","sources":["../../../src/widget/GroupingMappingWidget.tsx"],"names":[],"mappings":"AAQA,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,GACX,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAE3D,MAAM,OAAO,uBAAuB;IAMlC,YAAY,WAAyB,EAAE,MAA0B;QALjD,OAAE,GAAG,yBAAyB,CAAC;QAM7C,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAEM,cAAc,CACnB,QAAgB,EAChB,UAAkB,EAClB,QAA4B,EAC5B,OAA2B,EAC3B,YAAmC;QAEnC,MAAM,OAAO,GAA0B,EAAE,CAAC;QAC1C,IACE,CAAC,QAAQ,KAAK,kBAAkB,CAAC,IAAI;YACnC,OAAO,KAAK,iBAAiB,CAAC,KAAK;YACnC,UAAU,KAAK,UAAU,CAAC,OAAO,CAAC;YACpC,YAAY,KAAK,oBAAoB,CAAC,UAAU,EAChD;YACA,MAAM,qBAAqB,GAAwB;gBACjD,EAAE,EAAE,uBAAuB;gBAC3B,KAAK,EAAE,oBAAoB;gBAC3B,gBAAgB,EAAE,GAAG,EAAE;oBACrB,OAAO,oBAAC,eAAe,IAAC,WAAW,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,GAAI,CAAC;gBACnF,CAAC;aACF,CAAC;YAEF,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;SACrC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type {\n AbstractWidgetProps,\n UiItemsProvider,\n} from \"@itwin/appui-abstract\";\nimport {\n AbstractZoneLocation,\n StagePanelLocation,\n StagePanelSection,\n StageUsage,\n} from \"@itwin/appui-abstract\";\nimport type { AccessToken } from \"@itwin/core-bentley\";\nimport React from \"react\";\nimport GroupingMapping from \"./components/GroupingMapping\";\n\nexport class GroupingMappingProvider implements UiItemsProvider {\n public readonly id = \"GroupingMappingProvider\";\n\n private readonly _accessToken?: AccessToken;\n private readonly _prefix?: \"\" | \"dev\" | \"qa\";\n\n constructor(accessToken?: AccessToken, prefix?: \"\" | \"dev\" | \"qa\") {\n this._accessToken = accessToken;\n this._prefix = prefix;\n }\n\n public provideWidgets(\n _stageId: string,\n stageUsage: string,\n location: StagePanelLocation,\n section?: StagePanelSection,\n zonelocation?: AbstractZoneLocation\n ): ReadonlyArray<AbstractWidgetProps> {\n const widgets: AbstractWidgetProps[] = [];\n if (\n (location === StagePanelLocation.Left &&\n section === StagePanelSection.Start &&\n stageUsage === StageUsage.General) ||\n zonelocation === AbstractZoneLocation.CenterLeft\n ) {\n const GroupingMappingWidget: AbstractWidgetProps = {\n id: \"GroupingMappingWidget\",\n label: \"Grouping & Mapping\",\n getWidgetContent: () => {\n return <GroupingMapping accessToken={this._accessToken} prefix={this._prefix} />;\n },\n };\n\n widgets.push(GroupingMappingWidget);\n }\n\n return widgets;\n }\n}\n"]}
@@ -1,13 +1,13 @@
1
1
  /// <reference types="react" />
2
2
  import "./CalculatedPropertyAction.scss";
3
- import type { CalculatedProperty } from "./CalculatedPropertyTable";
3
+ import type { CalculatedPropertyType } from "./CalculatedPropertyTable";
4
4
  interface CalculatedPropertyActionProps {
5
5
  iModelId: string;
6
6
  mappingId: string;
7
7
  groupId: string;
8
- property?: CalculatedProperty;
8
+ property?: CalculatedPropertyType;
9
9
  ids: string[];
10
- returnFn: () => Promise<void>;
10
+ returnFn: (modified: boolean) => Promise<void>;
11
11
  }
12
12
  declare const CalculatedPropertyAction: ({ iModelId, mappingId, groupId, property, ids, returnFn, }: CalculatedPropertyActionProps) => JSX.Element;
13
13
  export default CalculatedPropertyAction;
@@ -4,16 +4,18 @@
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { IModelApp } from "@itwin/core-frontend";
6
6
  import { Fieldset, LabeledInput, LabeledSelect, MenuItem, Small, } from "@itwin/itwinui-react";
7
- import React, { useEffect, useState } from "react";
8
- import { reportingClientApi } from "../../api/reportingClient";
7
+ import React, { useContext, useEffect, useState } from "react";
9
8
  import ActionPanel from "./ActionPanel";
10
9
  import { BboxDimension, BboxDimensionsDecorator, } from "../../decorators/BboxDimensionsDecorator";
11
10
  import useValidator, { NAME_REQUIREMENTS } from "../hooks/useValidator";
12
11
  import { handleError, WidgetHeader } from "./utils";
13
12
  import { visualizeElements, zoomToElements } from "./viewerUtils";
14
13
  import "./CalculatedPropertyAction.scss";
14
+ import { ReportingClient } from "@itwin/insights-client";
15
+ import { ApiContext } from "./GroupingMapping";
15
16
  const CalculatedPropertyAction = ({ iModelId, mappingId, groupId, property, ids, returnFn, }) => {
16
17
  var _a, _b, _c;
18
+ const apiContext = useContext(ApiContext);
17
19
  const [propertyName, setPropertyName] = useState((_a = property === null || property === void 0 ? void 0 : property.propertyName) !== null && _a !== void 0 ? _a : "");
18
20
  const [type, setType] = useState((_b = property === null || property === void 0 ? void 0 : property.type) !== null && _b !== void 0 ? _b : "");
19
21
  const [bboxDecorator, setBboxDecorator] = useState();
@@ -62,14 +64,17 @@ const CalculatedPropertyAction = ({ iModelId, mappingId, groupId, property, ids,
62
64
  }
63
65
  try {
64
66
  setIsLoading(true);
65
- const calculatedProperty = {
66
- propertyName,
67
- type,
68
- };
67
+ const reportingClientApi = new ReportingClient(apiContext.prefix);
69
68
  property
70
- ? await reportingClientApi.updateCalculatedProperty(iModelId, mappingId, groupId, (_a = property.id) !== null && _a !== void 0 ? _a : "", calculatedProperty)
71
- : await reportingClientApi.createCalculatedProperty(iModelId, mappingId, groupId, calculatedProperty);
72
- await returnFn();
69
+ ? await reportingClientApi.updateCalculatedProperty(apiContext.accessToken, iModelId, mappingId, groupId, (_a = property.id) !== null && _a !== void 0 ? _a : "", {
70
+ propertyName,
71
+ type,
72
+ })
73
+ : await reportingClientApi.createCalculatedProperty(apiContext.accessToken, iModelId, mappingId, groupId, {
74
+ propertyName,
75
+ type,
76
+ });
77
+ await returnFn(true);
73
78
  }
74
79
  catch (error) {
75
80
  handleError(error.status);
@@ -83,7 +88,7 @@ const CalculatedPropertyAction = ({ iModelId, mappingId, groupId, property, ids,
83
88
  return (React.createElement(React.Fragment, null,
84
89
  React.createElement(WidgetHeader, { title: property
85
90
  ? `${(_c = property === null || property === void 0 ? void 0 : property.propertyName) !== null && _c !== void 0 ? _c : ""}`
86
- : "Create Calculated Property", returnFn: returnFn }),
91
+ : "Create Calculated Property", returnFn: async () => returnFn(false) }),
87
92
  React.createElement("div", { className: 'calculated-properties-action-container' },
88
93
  React.createElement(Fieldset, { legend: 'Calculated Property Details', className: 'details-form' },
89
94
  React.createElement(Small, { className: 'field-legend' }, "Asterisk * indicates mandatory fields."),
@@ -136,7 +141,7 @@ const CalculatedPropertyAction = ({ iModelId, mappingId, groupId, property, ids,
136
141
  getSpatialData(option.value)))), selectedItemRenderer: (option) => (React.createElement("div", { className: 'select-item' },
137
142
  React.createElement("div", null, option.label),
138
143
  getSpatialData(option.value))), onShow: () => { }, onHide: () => { } }))),
139
- React.createElement(ActionPanel, { onSave: onSave, onCancel: returnFn, isSavingDisabled: !(type && propertyName), isLoading: isLoading })));
144
+ React.createElement(ActionPanel, { onSave: onSave, onCancel: async () => returnFn(false), isSavingDisabled: !(type && propertyName), isLoading: isLoading })));
140
145
  };
141
146
  export default CalculatedPropertyAction;
142
147
  //# sourceMappingURL=CalculatedPropertyAction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CalculatedPropertyAction.js","sourceRoot":"","sources":["../../../../src/widget/components/CalculatedPropertyAction.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIjD,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,KAAK,GACN,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EACL,aAAa,EACb,uBAAuB,GACxB,MAAM,0CAA0C,CAAC;AAClD,OAAO,YAAY,EAAE,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,iCAAiC,CAAC;AAYzC,MAAM,wBAAwB,GAAG,CAAC,EAChC,QAAQ,EACR,SAAS,EACT,OAAO,EACP,QAAQ,EACR,GAAG,EACH,QAAQ,GACsB,EAAE,EAAE;;IAClC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,Q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EAAC,iBAAiB;4BAC9B,iCAAM,MAAM,CAAC,KAAK,CAAO;4BACxB,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CACzB,CACG,CACZ,EACD,oBAAoB,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,CACtD,6BAAK,SAAS,EAAC,aAAa;wBAC1B,iCAAM,MAAM,CAAC,KAAK,CAAO;wBACxB,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CACzB,CACP,EACD,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EACjB,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,GACjB,CACO,CACP;QACN,oBAAC,WAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,CAAC,CAAC,IAAI,IAAI,YAAY,CAAC,EACzC,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,wBAAwB,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 { IModelApp } from \"@itwin/core-frontend\";\nimport type {\n SelectOption,\n} from \"@itwin/itwinui-react\";\nimport {\n Fieldset,\n LabeledInput,\n LabeledSelect,\n MenuItem,\n Small,\n} from \"@itwin/itwinui-react\";\nimport React, { useEffect, useState } from \"react\";\nimport type { CalculatedPropertyCreateReportingAPI } from \"../../api/generated/api\";\nimport { reportingClientApi } from \"../../api/reportingClient\";\nimport ActionPanel from \"./ActionPanel\";\nimport {\n BboxDimension,\n BboxDimensionsDecorator,\n} from \"../../decorators/BboxDimensionsDecorator\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError, WidgetHeader } from \"./utils\";\nimport { visualizeElements, zoomToElements } from \"./viewerUtils\";\nimport \"./CalculatedPropertyAction.scss\";\nimport type { CalculatedProperty } from \"./CalculatedPropertyTable\";\n\ninterface CalculatedPropertyActionProps {\n iModelId: string;\n mappingId: string;\n groupId: string;\n property?: CalculatedProperty;\n ids: string[];\n returnFn: () => Promise<void>;\n}\n\nconst CalculatedPropertyAction = ({\n iModelId,\n mappingId,\n groupId,\n property,\n ids,\n returnFn,\n}: CalculatedPropertyActionProps) => {\n const [propertyName, setPropertyName] = useState<string>(\n property?.propertyName ?? \"\",\n );\n const [type, setType] = useState<string>(property?.type ?? \"\");\n const [bboxDecorator, setBboxDecorator] = useState<\n BboxDimensionsDecorator | undefined\n >();\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [inferredSpatialData, setInferredSpatialData] = useState<\n Map<BboxDimension, number> | undefined\n >();\n const [validator, showValidationMessage] = useValidator();\n\n useEffect(() => {\n const decorator = new BboxDimensionsDecorator();\n IModelApp.viewManager.addDecorator(decorator);\n setBboxDecorator(decorator);\n return () => {\n IModelApp.viewManager.dropDecorator(decorator);\n };\n }, []);\n\n useEffect(() => {\n if (ids.length === 0) {\n return;\n }\n visualizeElements([ids[0]], \"red\");\n void zoomToElements([ids[0]]);\n }, [ids]);\n\n useEffect(() => {\n if (ids.length === 0) {\n return;\n }\n const setContext = async () => {\n if (bboxDecorator) {\n await bboxDecorator.setContext(ids[0]);\n setInferredSpatialData(bboxDecorator.getInferredSpatialData());\n }\n };\n void setContext();\n }, [bboxDecorator, ids]);\n\n useEffect(() => {\n if (bboxDecorator && type && inferredSpatialData) {\n inferredSpatialData.has(BboxDimension[type as keyof typeof BboxDimension])\n ? bboxDecorator.drawContext(\n BboxDimension[type as keyof typeof BboxDimension],\n )\n : bboxDecorator.clearContext();\n }\n }, [bboxDecorator, inferredSpatialData, type]);\n\n const onSave = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n try {\n setIsLoading(true);\n\n const calculatedProperty: CalculatedPropertyCreateReportingAPI = {\n propertyName,\n type,\n };\n\n property\n ? await reportingClientApi.updateCalculatedProperty(\n iModelId,\n mappingId,\n groupId,\n property.id ?? \"\",\n calculatedProperty,\n )\n : await reportingClientApi.createCalculatedProperty(\n iModelId,\n mappingId,\n groupId,\n calculatedProperty,\n );\n await returnFn();\n } catch (error: any) {\n handleError(error.status);\n setIsLoading(false);\n }\n };\n\n const getSpatialData = (value: string) =>\n inferredSpatialData?.has(\n BboxDimension[value as keyof typeof BboxDimension],\n ) && (\n <div>\n {`${inferredSpatialData\n ?.get(BboxDimension[value as keyof typeof BboxDimension])\n ?.toPrecision(4)}m`}\n </div>\n );\n\n return (\n <>\n <WidgetHeader\n title={\n property\n ? `${property?.propertyName ?? \"\"}`\n : \"Create Calculated Property\"\n }\n returnFn={returnFn}\n />\n <div className='calculated-properties-action-container'>\n <Fieldset legend='Calculated Property 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 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 <LabeledSelect<string>\n label='Quantity Type'\n required\n options={[\n { value: \"Length\", label: \"Length\" },\n { value: \"Area\", label: \"Area\" },\n { value: \"Volume\", label: \"Volume\" },\n {\n value: \"BoundingBoxLongestEdgeLength\",\n label: \"Longest Edge Length\",\n },\n {\n value: \"BoundingBoxIntermediateEdgeLength\",\n label: \"Intermediate Edge Length\",\n },\n {\n value: \"BoundingBoxShortestEdgeLength\",\n label: \"Shortest Edge Length\",\n },\n {\n value: \"BoundingBoxDiagonalLength\",\n label: \"Diagonal Length\",\n },\n {\n value: \"BoundingBoxLongestFaceDiagonalLength\",\n label: \"Longest Face Diagonal Length\",\n },\n {\n value: \"BoundingBoxIntermediateFaceDiagonalLength\",\n label: \"Intermediate Face Diagonal Length\",\n },\n {\n value: \"BoundingBoxShortestFaceDiagonalLength\",\n label: \"Shortest Face Diagonal Length\",\n },\n ]}\n value={type}\n onChange={setType}\n itemRenderer={(option: SelectOption<string>) => (\n <MenuItem>\n <div className='gr-cp-menu-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n </MenuItem>\n )}\n selectedItemRenderer={(option: SelectOption<string>) => (\n <div className='select-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n )}\n onShow={() => { }}\n onHide={() => { }}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={returnFn}\n isSavingDisabled={!(type && propertyName)}\n isLoading={isLoading}\n />\n </>\n );\n};\n\nexport default CalculatedPropertyAction;\n"]}
1
+ {"version":3,"file":"CalculatedPropertyAction.js","sourceRoot":"","sources":["../../../../src/widget/components/CalculatedPropertyAction.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIjD,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,KAAK,GACN,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EACL,aAAa,EACb,uBAAuB,GACxB,MAAM,0CAA0C,CAAC;AAClD,OAAO,YAAY,EAAE,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,iCAAiC,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,MAAM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tC,KAAK,EAAE,sBAAsB;yBAC9B;wBACD;4BACE,KAAK,EAAE,2BAA2B;4BAClC,KAAK,EAAE,iBAAiB;yBACzB;wBACD;4BACE,KAAK,EAAE,sCAAsC;4BAC7C,KAAK,EAAE,8BAA8B;yBACtC;wBACD;4BACE,KAAK,EAAE,2CAA2C;4BAClD,KAAK,EAAE,mCAAmC;yBAC3C;wBACD;4BACE,KAAK,EAAE,uCAAuC;4BAC9C,KAAK,EAAE,+BAA+B;yBACvC;qBACF,EACD,KAAK,EAAE,IAAI,EACX,QAAQ,EAAE,OAAO,EACjB,YAAY,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,CAC9C,oBAAC,QAAQ;wBACP,6BAAK,SAAS,EAAC,iBAAiB;4BAC9B,iCAAM,MAAM,CAAC,KAAK,CAAO;4BACxB,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CACzB,CACG,CACZ,EACD,oBAAoB,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,CACtD,6BAAK,SAAS,EAAC,aAAa;wBAC1B,iCAAM,MAAM,CAAC,KAAK,CAAO;wBACxB,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CACzB,CACP,EACD,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EACjB,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,GACjB,CACO,CACP;QACN,oBAAC,WAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EACrC,gBAAgB,EAAE,CAAC,CAAC,IAAI,IAAI,YAAY,CAAC,EACzC,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,wBAAwB,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 { IModelApp } from \"@itwin/core-frontend\";\nimport type {\n SelectOption,\n} from \"@itwin/itwinui-react\";\nimport {\n Fieldset,\n LabeledInput,\n LabeledSelect,\n MenuItem,\n Small,\n} from \"@itwin/itwinui-react\";\nimport React, { useContext, useEffect, useState } from \"react\";\nimport ActionPanel from \"./ActionPanel\";\nimport {\n BboxDimension,\n BboxDimensionsDecorator,\n} from \"../../decorators/BboxDimensionsDecorator\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError, WidgetHeader } from \"./utils\";\nimport { visualizeElements, zoomToElements } from \"./viewerUtils\";\nimport \"./CalculatedPropertyAction.scss\";\nimport type { CalculatedPropertyType } from \"./CalculatedPropertyTable\";\nimport { ReportingClient } from \"@itwin/insights-client\";\nimport { ApiContext } from \"./GroupingMapping\";\n\ninterface CalculatedPropertyActionProps {\n iModelId: string;\n mappingId: string;\n groupId: string;\n property?: CalculatedPropertyType;\n ids: string[];\n returnFn: (modified: boolean) => Promise<void>;\n}\n\nconst CalculatedPropertyAction = ({\n iModelId,\n mappingId,\n groupId,\n property,\n ids,\n returnFn,\n}: CalculatedPropertyActionProps) => {\n const apiContext = useContext(ApiContext);\n const [propertyName, setPropertyName] = useState<string>(\n property?.propertyName ?? \"\",\n );\n const [type, setType] = useState<string>(property?.type ?? \"\");\n const [bboxDecorator, setBboxDecorator] = useState<BboxDimensionsDecorator | undefined>();\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [inferredSpatialData, setInferredSpatialData] = useState<Map<BboxDimension, number> | undefined>();\n const [validator, showValidationMessage] = useValidator();\n\n useEffect(() => {\n const decorator = new BboxDimensionsDecorator();\n IModelApp.viewManager.addDecorator(decorator);\n setBboxDecorator(decorator);\n return () => {\n IModelApp.viewManager.dropDecorator(decorator);\n };\n }, []);\n\n useEffect(() => {\n if (ids.length === 0) {\n return;\n }\n visualizeElements([ids[0]], \"red\");\n void zoomToElements([ids[0]]);\n }, [ids]);\n\n useEffect(() => {\n if (ids.length === 0) {\n return;\n }\n const setContext = async () => {\n if (bboxDecorator) {\n await bboxDecorator.setContext(ids[0]);\n setInferredSpatialData(bboxDecorator.getInferredSpatialData());\n }\n };\n void setContext();\n }, [bboxDecorator, ids]);\n\n useEffect(() => {\n if (bboxDecorator && type && inferredSpatialData) {\n inferredSpatialData.has(BboxDimension[type as keyof typeof BboxDimension])\n ? bboxDecorator.drawContext(\n BboxDimension[type as keyof typeof BboxDimension],\n )\n : bboxDecorator.clearContext();\n }\n }, [bboxDecorator, inferredSpatialData, type]);\n\n const onSave = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n try {\n setIsLoading(true);\n\n const reportingClientApi = new ReportingClient(apiContext.prefix);\n\n property\n ? await reportingClientApi.updateCalculatedProperty(\n apiContext.accessToken,\n iModelId,\n mappingId,\n groupId,\n property.id ?? \"\",\n {\n propertyName,\n type,\n },\n )\n : await reportingClientApi.createCalculatedProperty(\n apiContext.accessToken,\n iModelId,\n mappingId,\n groupId,\n {\n propertyName,\n type,\n },\n );\n await returnFn(true);\n } catch (error: any) {\n handleError(error.status);\n setIsLoading(false);\n }\n };\n\n const getSpatialData = (value: string) =>\n inferredSpatialData?.has(\n BboxDimension[value as keyof typeof BboxDimension],\n ) && (\n <div>\n {`${inferredSpatialData\n ?.get(BboxDimension[value as keyof typeof BboxDimension])\n ?.toPrecision(4)}m`}\n </div>\n );\n\n return (\n <>\n <WidgetHeader\n title={\n property\n ? `${property?.propertyName ?? \"\"}`\n : \"Create Calculated Property\"\n }\n returnFn={async () => returnFn(false)}\n />\n <div className='calculated-properties-action-container'>\n <Fieldset legend='Calculated Property 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 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 <LabeledSelect<string>\n label='Quantity Type'\n required\n options={[\n { value: \"Length\", label: \"Length\" },\n { value: \"Area\", label: \"Area\" },\n { value: \"Volume\", label: \"Volume\" },\n {\n value: \"BoundingBoxLongestEdgeLength\",\n label: \"Longest Edge Length\",\n },\n {\n value: \"BoundingBoxIntermediateEdgeLength\",\n label: \"Intermediate Edge Length\",\n },\n {\n value: \"BoundingBoxShortestEdgeLength\",\n label: \"Shortest Edge Length\",\n },\n {\n value: \"BoundingBoxDiagonalLength\",\n label: \"Diagonal Length\",\n },\n {\n value: \"BoundingBoxLongestFaceDiagonalLength\",\n label: \"Longest Face Diagonal Length\",\n },\n {\n value: \"BoundingBoxIntermediateFaceDiagonalLength\",\n label: \"Intermediate Face Diagonal Length\",\n },\n {\n value: \"BoundingBoxShortestFaceDiagonalLength\",\n label: \"Shortest Face Diagonal Length\",\n },\n ]}\n value={type}\n onChange={setType}\n itemRenderer={(option: SelectOption<string>) => (\n <MenuItem>\n <div className='gr-cp-menu-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n </MenuItem>\n )}\n selectedItemRenderer={(option: SelectOption<string>) => (\n <div className='select-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n )}\n onShow={() => { }}\n onHide={() => { }}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={async () => returnFn(false)}\n isSavingDisabled={!(type && propertyName)}\n isLoading={isLoading}\n />\n </>\n );\n};\n\nexport default CalculatedPropertyAction;\n"]}
@@ -1,18 +1,21 @@
1
1
  import React from "react";
2
- import type { CalculatedPropertyReportingAPI } from "../../api/generated/api";
3
2
  import type { CreateTypeFromInterface } from "../utils";
4
3
  import { PropertyMenuView } from "./PropertyMenu";
5
4
  import type { CellProps } from "react-table";
6
- export declare type CalculatedProperty = CreateTypeFromInterface<CalculatedPropertyReportingAPI>;
5
+ import type { CalculatedProperty } from "@itwin/insights-client";
6
+ export declare type CalculatedPropertyType = CreateTypeFromInterface<CalculatedProperty>;
7
7
  interface CalculatedPropertyTableProps {
8
8
  iModelId: string;
9
9
  mappingId: string;
10
10
  groupId: string;
11
- setSelectedCalculatedProperty: React.Dispatch<React.SetStateAction<CreateTypeFromInterface<CalculatedPropertyReportingAPI> | undefined>>;
11
+ setSelectedCalculatedProperty: React.Dispatch<React.SetStateAction<CreateTypeFromInterface<CalculatedPropertyType> | undefined>>;
12
12
  setGroupModifyView: React.Dispatch<React.SetStateAction<PropertyMenuView>>;
13
- onCalculatedPropertyModify: (value: CellProps<CalculatedProperty>) => void;
14
- selectedCalculatedProperty?: CalculatedProperty;
13
+ onCalculatedPropertyModify: (value: CellProps<CalculatedPropertyType>) => void;
14
+ isLoadingCalculatedProperties: boolean;
15
+ calculatedProperties: CalculatedPropertyType[];
16
+ refreshCalculatedProperties: () => Promise<void>;
17
+ selectedCalculatedProperty?: CalculatedPropertyType;
15
18
  }
16
- declare const CalculatedPropertyTable: ({ iModelId, mappingId, groupId, setSelectedCalculatedProperty, setGroupModifyView, onCalculatedPropertyModify, selectedCalculatedProperty, }: CalculatedPropertyTableProps) => JSX.Element;
19
+ declare const CalculatedPropertyTable: ({ iModelId, mappingId, groupId, setSelectedCalculatedProperty, setGroupModifyView, onCalculatedPropertyModify, isLoadingCalculatedProperties: isLoadingGroupProperties, calculatedProperties, refreshCalculatedProperties, selectedCalculatedProperty, }: CalculatedPropertyTableProps) => JSX.Element;
17
20
  export default CalculatedPropertyTable;
18
21
  //# sourceMappingURL=CalculatedPropertyTable.d.ts.map
@@ -4,41 +4,15 @@
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { SvgAdd, SvgDelete, SvgEdit, SvgMore, } from "@itwin/itwinui-icons-react";
6
6
  import { Button, DropdownMenu, IconButton, MenuItem, Table, } from "@itwin/itwinui-react";
7
- import React, { useCallback, useEffect, useMemo, useState } from "react";
8
- import { reportingClientApi } from "../../api/reportingClient";
7
+ import React, { useContext, useMemo, useState } from "react";
9
8
  import { PropertyMenuView } from "./PropertyMenu";
10
9
  import DeleteModal from "./DeleteModal";
11
- import { handleError } from "./utils";
12
- const fetchCalculatedProperties = async (setCalculatedProperties, iModelId, mappingId, groupId, setIsLoading) => {
10
+ import { ReportingClient } from "@itwin/insights-client";
11
+ import { ApiContext } from "./GroupingMapping";
12
+ const CalculatedPropertyTable = ({ iModelId, mappingId, groupId, setSelectedCalculatedProperty, setGroupModifyView, onCalculatedPropertyModify, isLoadingCalculatedProperties: isLoadingGroupProperties, calculatedProperties, refreshCalculatedProperties, selectedCalculatedProperty, }) => {
13
13
  var _a;
14
- try {
15
- setIsLoading(true);
16
- const calculatedProperties = await reportingClientApi.getCalculatedProperties(iModelId, mappingId, groupId);
17
- setCalculatedProperties((_a = calculatedProperties.properties) !== null && _a !== void 0 ? _a : []);
18
- }
19
- catch (error) {
20
- handleError(error.status);
21
- }
22
- finally {
23
- setIsLoading(false);
24
- }
25
- };
26
- const useFetchCalculatedProperties = (iModelId, mappingId, groupId, setIsLoading) => {
27
- const [calculatedProperties, setCalculatedProperties] = useState([]);
28
- useEffect(() => {
29
- void fetchCalculatedProperties(setCalculatedProperties, iModelId, mappingId, groupId, setIsLoading);
30
- }, [groupId, iModelId, mappingId, setIsLoading]);
31
- return [calculatedProperties, setCalculatedProperties];
32
- };
33
- const CalculatedPropertyTable = ({ iModelId, mappingId, groupId, setSelectedCalculatedProperty, setGroupModifyView, onCalculatedPropertyModify, selectedCalculatedProperty, }) => {
34
- var _a;
35
- const [isLoading, setIsLoading] = useState(true);
36
- const [calculatedProperties, setCalculatedProperties] = useFetchCalculatedProperties(iModelId, mappingId, groupId, setIsLoading);
14
+ const apiContext = useContext(ApiContext);
37
15
  const [showCalculatedPropertyDeleteModal, setShowCalculatedPropertyDeleteModal,] = useState(false);
38
- const refresh = useCallback(async () => {
39
- setCalculatedProperties([]);
40
- await fetchCalculatedProperties(setCalculatedProperties, iModelId, mappingId, groupId, setIsLoading);
41
- }, [groupId, iModelId, mappingId, setCalculatedProperties]);
42
16
  const calculatedPropertiesColumns = useMemo(() => [
43
17
  {
44
18
  Header: "Table",
@@ -76,11 +50,12 @@ const CalculatedPropertyTable = ({ iModelId, mappingId, groupId, setSelectedCalc
76
50
  React.createElement(Button, { startIcon: React.createElement(SvgAdd, null), styleType: 'high-visibility', onClick: () => {
77
51
  setGroupModifyView(PropertyMenuView.ADD_CALCULATED_PROPERTY);
78
52
  } }, "Add Calculated Property"),
79
- React.createElement(Table, { data: calculatedProperties, density: 'extra-condensed', columns: calculatedPropertiesColumns, emptyTableContent: 'No Calculated Properties', isSortable: true, isLoading: isLoading }),
53
+ React.createElement(Table, { data: calculatedProperties, density: 'extra-condensed', columns: calculatedPropertiesColumns, emptyTableContent: 'No Calculated Properties', isSortable: true, isLoading: isLoadingGroupProperties }),
80
54
  React.createElement(DeleteModal, { entityName: (_a = selectedCalculatedProperty === null || selectedCalculatedProperty === void 0 ? void 0 : selectedCalculatedProperty.propertyName) !== null && _a !== void 0 ? _a : "", show: showCalculatedPropertyDeleteModal, setShow: setShowCalculatedPropertyDeleteModal, onDelete: async () => {
81
55
  var _a;
82
- await reportingClientApi.deleteCalculatedProperty(iModelId, mappingId, groupId, (_a = selectedCalculatedProperty === null || selectedCalculatedProperty === void 0 ? void 0 : selectedCalculatedProperty.id) !== null && _a !== void 0 ? _a : "");
83
- }, refresh: refresh })));
56
+ const reportingClientApi = new ReportingClient(apiContext.prefix);
57
+ await reportingClientApi.deleteCalculatedProperty(apiContext.accessToken, iModelId, mappingId, groupId, (_a = selectedCalculatedProperty === null || selectedCalculatedProperty === void 0 ? void 0 : selectedCalculatedProperty.id) !== null && _a !== void 0 ? _a : "");
58
+ }, refresh: refreshCalculatedProperties })));
84
59
  };
85
60
  export default CalculatedPropertyTable;
86
61
  //# 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,OAAO,EACL,MAAM,EACN,SAAS,EACT,OAAO,EACP,OAAO,GACR,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,MAAM,EACN,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,KAAK,GACN,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAKtC,MAAM,yBAAyB,GAAG,KAAK,EACrC,uBAEC,EACD,QAAgB,EAChB,SAAiB,EACjB,OAAe,EACf,YAA2D,EAC3D,EAAE;;IACF,IAAI;QACF,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,MAAM,oBAAoB,GACxB,MAAM,kBAAkB,CAAC,uBAAuB,CAC9C,QAAQ,EACR,SAAS,EACT,OAAO,CACR,CAAC;QACJ,uBAAuB,CAAC,MAAA,oBAAoB,CAAC,UAAU,mCAAI,EAAE,CAAC,CAAC;KAChE;IAAC,OAAO,KAAU,EAAE;QACnB,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;KAC3B;YAAS;QACR,YAAY,CAAC,KAAK,CAAC,CAAC;KACrB;AACH,CAAC,CAAC;AAEF,MAAM,4BAA4B,GAAG,CACnC,QAAgB,EAChB,SAAiB,EACjB,OAAe,EACf,YAA2D,EAI3D,EAAE;IACF,MAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAA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AAuB,CAAC,CAAC;YAC/D,CAAC,8BAGM;QACT,oBAAC,KAAK,IACJ,IAAI,EAAE,oBAAoB,EAC1B,OAAO,EAAC,iBAAiB,EACzB,OAAO,EAAE,2BAA2B,EACpC,iBAAiB,EAAC,0BAA0B,EAC5C,UAAU,QACV,SAAS,EAAE,SAAS,GACpB;QAEF,oBAAC,WAAW,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,CAAC,wBAAwB,CAC/C,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,eAAe,uBAAuB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport {\n SvgAdd,\n SvgDelete,\n SvgEdit,\n SvgMore,\n} from \"@itwin/itwinui-icons-react\";\nimport {\n Button,\n DropdownMenu,\n IconButton,\n MenuItem,\n Table,\n} from \"@itwin/itwinui-react\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport type { CalculatedPropertyReportingAPI } from \"../../api/generated/api\";\nimport { reportingClientApi } from \"../../api/reportingClient\";\nimport type { CreateTypeFromInterface } from \"../utils\";\nimport { PropertyMenuView } from \"./PropertyMenu\";\nimport type { CellProps } from \"react-table\";\nimport DeleteModal from \"./DeleteModal\";\nimport { handleError } from \"./utils\";\n\nexport type CalculatedProperty =\n CreateTypeFromInterface<CalculatedPropertyReportingAPI>;\n\nconst fetchCalculatedProperties = async (\n setCalculatedProperties: React.Dispatch<\n React.SetStateAction<CalculatedProperty[]>\n >,\n iModelId: string,\n mappingId: string,\n groupId: string,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,\n) => {\n try {\n setIsLoading(true);\n const calculatedProperties =\n await reportingClientApi.getCalculatedProperties(\n iModelId,\n mappingId,\n groupId,\n );\n setCalculatedProperties(calculatedProperties.properties ?? []);\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n};\n\nconst useFetchCalculatedProperties = (\n iModelId: string,\n mappingId: string,\n groupId: string,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,\n): [\n CalculatedProperty[],\n React.Dispatch<React.SetStateAction<CalculatedProperty[]>>,\n] => {\n const [calculatedProperties, setCalculatedProperties] = useState<\n CalculatedProperty[]\n >([]);\n\n useEffect(() => {\n void fetchCalculatedProperties(\n setCalculatedProperties,\n iModelId,\n mappingId,\n groupId,\n setIsLoading,\n );\n }, [groupId, iModelId, mappingId, setIsLoading]);\n\n return [calculatedProperties, setCalculatedProperties];\n};\n\ninterface CalculatedPropertyTableProps {\n iModelId: string;\n mappingId: string;\n groupId: string;\n\n setSelectedCalculatedProperty: React.Dispatch<\n React.SetStateAction<\n CreateTypeFromInterface<CalculatedPropertyReportingAPI> | undefined\n >\n >;\n setGroupModifyView: React.Dispatch<React.SetStateAction<PropertyMenuView>>;\n onCalculatedPropertyModify: (value: CellProps<CalculatedProperty>) => void;\n selectedCalculatedProperty?: CalculatedProperty;\n}\n\nconst CalculatedPropertyTable = ({\n iModelId,\n mappingId,\n groupId,\n setSelectedCalculatedProperty,\n setGroupModifyView,\n onCalculatedPropertyModify,\n selectedCalculatedProperty,\n}: CalculatedPropertyTableProps) => {\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [calculatedProperties, setCalculatedProperties] =\n useFetchCalculatedProperties(iModelId, mappingId, groupId, setIsLoading);\n const [\n showCalculatedPropertyDeleteModal,\n setShowCalculatedPropertyDeleteModal,\n ] = useState<boolean>(false);\n\n const refresh = useCallback(async () => {\n setCalculatedProperties([]);\n await fetchCalculatedProperties(\n setCalculatedProperties,\n iModelId,\n mappingId,\n groupId,\n setIsLoading,\n );\n }, [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<CalculatedProperty>) => (\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<CalculatedProperty>) => {\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<CalculatedProperty>\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 await reportingClientApi.deleteCalculatedProperty(\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,OAAO,EACL,MAAM,EACN,SAAS,EACT,OAAO,EACP,OAAO,GACR,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,MAAM,EACN,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,KAAK,GACN,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAsB/C,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,UAAU,CAAC,UAAU,CAAC,CAAC;IAC1C,MAAM,CACJ,iCAAiC,EACjC,oCAAoC,EACrC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IAE7B,MAAM,2BAA2B,GAAG,OAAO,CACzC,GAAG,EAAE,CAAC;QACJ;YACE,MAAM,EAAE,OAAO;YACf,OAAO,EAAE;gBACP;oBACE,EAAE,EAAE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B,EAC3B,OAAO,EAAE,GAAG,EAAE;gBACZ,kBAAkB,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,CAAC;YAC/D,CAAC,8BAGM;QACT,oBAAC,KAAK,IACJ,IAAI,EAAE,oBAAoB,EAC1B,OAAO,EAAC,iBAAiB,EACzB,OAAO,EAAE,2BAA2B,EACpC,iBAAiB,EAAC,0BAA0B,EAC5C,UAAU,QACV,SAAS,EAAE,wBAAwB,GACnC;QAEF,oBAAC,WAAW,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,eAAe,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,2BAA2B,GACpC,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,uBAAuB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport {\n 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 { ReportingClient } from \"@itwin/insights-client\";\nimport { ApiContext } from \"./GroupingMapping\";\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 = new ReportingClient(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"]}
@@ -1,12 +1,12 @@
1
1
  import React from "react";
2
- import type { Mapping } from "./Mapping";
2
+ import type { MappingType } from "./Mapping";
3
3
  import "./ConfirmMappingsImport.scss";
4
4
  interface ConfirmMappingImportProps {
5
5
  sourceiModelId: string;
6
- selectedMappings: Mapping[];
6
+ selectedMappings: MappingType[];
7
7
  importing: boolean;
8
8
  setImporting: React.Dispatch<React.SetStateAction<boolean>>;
9
- setSelectedMappings: React.Dispatch<React.SetStateAction<Mapping[]>>;
9
+ setSelectedMappings: React.Dispatch<React.SetStateAction<MappingType[]>>;
10
10
  backFn: () => void;
11
11
  onCancel: () => void;
12
12
  onFinish: () => void;
@@ -3,16 +3,18 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { Button, LabeledInput, MiddleTextTruncation, ProgressLinear, Text, } from "@itwin/itwinui-react";
6
- import React, { useEffect, useState } from "react";
6
+ import React, { useContext, useEffect, useState } from "react";
7
7
  import "./ConfirmMappingsImport.scss";
8
- import { reportingClientApi } from "../../api/reportingClient";
9
8
  import { useActiveIModelConnection } from "@itwin/appui-react";
10
9
  import { SvgStatusSuccessHollow } from "@itwin/itwinui-icons-react";
11
10
  import useValidator, { NAME_REQUIREMENTS } from "../hooks/useValidator";
12
11
  import { handleError } from "./utils";
12
+ import { ReportingClient } from "@itwin/insights-client";
13
+ import { ApiContext } from "./GroupingMapping";
13
14
  const ConfirmMappingImport = ({ sourceiModelId, selectedMappings, importing, setImporting, setSelectedMappings, backFn, onCancel, onFinish, }) => {
14
15
  var _a;
15
16
  const iModelId = (_a = useActiveIModelConnection()) === null || _a === void 0 ? void 0 : _a.iModelId;
17
+ const apiContext = useContext(ApiContext);
16
18
  const [importCount, setImportCount] = useState(0);
17
19
  const [currentlyImporting, setCurrentlyImporting] = useState("");
18
20
  const [validator, showValidationMessage] = useValidator();
@@ -39,10 +41,11 @@ const ConfirmMappingImport = ({ sourceiModelId, selectedMappings, importing, set
39
41
  }
40
42
  setImporting(true);
41
43
  try {
44
+ const reportingClientApi = new ReportingClient(apiContext.prefix);
42
45
  for (const selectedMapping of selectedMappings) {
43
46
  setCurrentlyImporting((_a = selectedMapping.mappingName) !== null && _a !== void 0 ? _a : "");
44
- await reportingClientApi.copyMapping(sourceiModelId, (_b = selectedMapping.id) !== null && _b !== void 0 ? _b : "", {
45
- targetIModelId: iModelId,
47
+ await reportingClientApi.copyMapping(apiContext.accessToken, sourceiModelId, (_b = selectedMapping.id) !== null && _b !== void 0 ? _b : "", {
48
+ targetIModelId: iModelId !== null && iModelId !== void 0 ? iModelId : "",
46
49
  mappingName: (_c = selectedMapping.mappingName) !== null && _c !== void 0 ? _c : "",
47
50
  });
48
51
  setImportCount((importCount) => importCount + 1);
@@ -1 +1 @@
1
- {"version":3,"file":"ConfirmMappingsImport.js","sourceRoot":"","sources":["../../../../src/widget/components/ConfirmMappingsImport.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EACL,MAAM,EACN,YAAY,EACZ,oBAAoB,EACpB,cAAc,EACd,IAAI,GACL,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,8BAA8B,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,YAAY,EAAE,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAatC,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,yBAAyB,EAAE,0CAAE,QAAkB,CAAC;IAEjE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAS,CAAC,CAAC,CAAC;IAC1D,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CAAS,EAAE,CAAC,CAAC;IACzE,MAAM,CAAC,SAAS,EAAE,qBAAqB,CAAC,GAAG,YAAY,EAAE,CAAC;IAC1D,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,Q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c,CAAC,WAAW,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;wBACpD,CAAC,EACD,OAAO,EAAE,SAAS,CAAC,OAAO,CACxB,WAAW,OAAO,CAAC,EAAE,EAAE,EACvB,OAAO,CAAC,WAAW,EACnB,iBAAiB,CAClB,EACD,MAAM,EACJ,SAAS,CAAC,OAAO,CACf,WAAW,OAAO,CAAC,EAAE,EAAE,EACvB,OAAO,CAAC,WAAW,EACnB,iBAAiB,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,iCAAM,OAAO,CAAC,WAAW,CAAO,CAC5B;gBACN,6BAAK,SAAS,EAAC,YAAY,GAAG,CAC1B,CACP,CAAC,CACE,CACF;QACN,6BAAK,SAAS,EAAC,qBAAqB;YAClC,oBAAC,MAAM,IAAC,OAAO,EAAE,MAAM,WAAe;YACtC,oBAAC,MAAM,IAAC,SAAS,EAAC,iBAAiB,EAAC,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,QAAQ,EAAE,aAE1D;YACT,oBAAC,MAAM,IAAC,OAAO,EAAE,QAAQ,aAAiB,CACtC,CACF,CACP,CACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,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, { useEffect, useState } from \"react\";\nimport type { Mapping } from \"./Mapping\";\nimport \"./ConfirmMappingsImport.scss\";\nimport { reportingClientApi } from \"../../api/reportingClient\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { SvgStatusSuccessHollow } from \"@itwin/itwinui-icons-react\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError } from \"./utils\";\n\ninterface ConfirmMappingImportProps {\n sourceiModelId: string;\n selectedMappings: Mapping[];\n importing: boolean;\n setImporting: React.Dispatch<React.SetStateAction<boolean>>;\n setSelectedMappings: React.Dispatch<React.SetStateAction<Mapping[]>>;\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 as string;\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 for (const selectedMapping of selectedMappings) {\n setCurrentlyImporting(selectedMapping.mappingName ?? \"\");\n await reportingClientApi.copyMapping(\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,OAAO,EACL,MAAM,EACN,YAAY,EACZ,oBAAoB,EACpB,cAAc,EACd,IAAI,GACL,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE/D,OAAO,8BAA8B,CAAC;AACtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,YAAY,EAAE,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAa/C,MAAM,oBAAoB,GAAG,CAAC,EAC5B,cAAc,EACd,gBAAg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,CAAC,EAAE,EAAE,CAAC,CAAC;wBACpD,CAAC,GACD;oBACF,iCAAM,OAAO,CAAC,WAAW,CAAO,CAC5B;gBACN,6BAAK,SAAS,EAAC,YAAY,GAAG,CAC1B,CACP,CAAC,CACE,CACF;QACN,6BAAK,SAAS,EAAC,qBAAqB;YAClC,oBAAC,MAAM,IAAC,OAAO,EAAE,MAAM,WAAe;YACtC,oBAAC,MAAM,IAAC,SAAS,EAAC,iBAAiB,EAAC,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,QAAQ,EAAE,aAE1D;YACT,oBAAC,MAAM,IAAC,OAAO,EAAE,QAAQ,aAAiB,CACtC,CACF,CACP,CACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,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"]}
@@ -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;
@@ -1,14 +1,16 @@
1
1
  /// <reference types="react" />
2
2
  import "./CalculatedPropertyAction.scss";
3
- import type { CustomCalculation } from "./CustomCalculationTable";
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;
9
- customCalculation?: CustomCalculation;
10
- returnFn: () => Promise<void>;
10
+ properties: PropertyMap;
11
+ customCalculation?: CustomCalculationType;
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