@sapui5/sap.fe.core 1.102.3 → 1.105.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (359) hide show
  1. package/package.json +6 -6
  2. package/src/sap/fe/core/.library +1 -1
  3. package/src/sap/fe/core/ActionRuntime.js +120 -0
  4. package/src/sap/fe/core/ActionRuntime.ts +108 -0
  5. package/src/sap/fe/core/AppComponent.js +81 -35
  6. package/src/sap/fe/core/AppComponent.ts +68 -44
  7. package/src/sap/fe/core/AppStateHandler.js +82 -70
  8. package/src/sap/fe/core/AppStateHandler.ts +32 -37
  9. package/src/sap/fe/core/BaseController.js +12 -10
  10. package/src/sap/fe/core/BaseController.ts +15 -13
  11. package/src/sap/fe/core/CommonUtils.js +291 -218
  12. package/src/sap/fe/core/CommonUtils.ts +315 -251
  13. package/src/sap/fe/core/ExtensionAPI.js +25 -28
  14. package/src/sap/fe/core/ExtensionAPI.ts +36 -38
  15. package/src/sap/fe/core/PageController.js +5 -5
  16. package/src/sap/fe/core/PageController.ts +4 -5
  17. package/src/sap/fe/core/TemplateComponent.js +21 -10
  18. package/src/sap/fe/core/TemplateComponent.ts +9 -6
  19. package/src/sap/fe/core/TemplateModel.js +2 -2
  20. package/src/sap/fe/core/TemplateModel.ts +1 -1
  21. package/src/sap/fe/core/buildingBlocks/AttributeModel.js +11 -3
  22. package/src/sap/fe/core/buildingBlocks/AttributeModel.ts +8 -2
  23. package/src/sap/fe/core/buildingBlocks/BuildingBlock.js +197 -43
  24. package/src/sap/fe/core/buildingBlocks/BuildingBlock.ts +164 -24
  25. package/src/sap/fe/core/buildingBlocks/BuildingBlockFormatter.js +14 -0
  26. package/src/sap/fe/core/buildingBlocks/BuildingBlockFormatter.ts +5 -0
  27. package/src/sap/fe/core/buildingBlocks/BuildingBlockRuntime.js +609 -230
  28. package/src/sap/fe/core/buildingBlocks/BuildingBlockRuntime.ts +275 -128
  29. package/src/sap/fe/core/buildingBlocks/TraceInfo.js +30 -30
  30. package/src/sap/fe/core/buildingBlocks/TraceInfo.ts +32 -29
  31. package/src/sap/fe/core/controllerextensions/BusyLocker.js +1 -1
  32. package/src/sap/fe/core/controllerextensions/EditFlow.js +761 -700
  33. package/src/sap/fe/core/controllerextensions/EditFlow.ts +478 -514
  34. package/src/sap/fe/core/controllerextensions/IntentBasedNavigation.js +10 -10
  35. package/src/sap/fe/core/controllerextensions/IntentBasedNavigation.ts +10 -10
  36. package/src/sap/fe/core/controllerextensions/InternalEditFlow.js +104 -75
  37. package/src/sap/fe/core/controllerextensions/InternalEditFlow.ts +71 -79
  38. package/src/sap/fe/core/controllerextensions/InternalIntentBasedNavigation.js +68 -68
  39. package/src/sap/fe/core/controllerextensions/InternalIntentBasedNavigation.ts +76 -76
  40. package/src/sap/fe/core/controllerextensions/InternalRouting.js +162 -102
  41. package/src/sap/fe/core/controllerextensions/InternalRouting.ts +177 -121
  42. package/src/sap/fe/core/controllerextensions/KPIManagement.js +67 -69
  43. package/src/sap/fe/core/controllerextensions/KPIManagement.ts +106 -123
  44. package/src/sap/fe/core/controllerextensions/MassEdit.js +10 -10
  45. package/src/sap/fe/core/controllerextensions/MassEdit.ts +20 -27
  46. package/src/sap/fe/core/controllerextensions/MessageHandler.js +21 -13
  47. package/src/sap/fe/core/controllerextensions/MessageHandler.ts +21 -14
  48. package/src/sap/fe/core/controllerextensions/PageReady.js +98 -26
  49. package/src/sap/fe/core/controllerextensions/PageReady.ts +98 -34
  50. package/src/sap/fe/core/controllerextensions/Paginator.js +31 -32
  51. package/src/sap/fe/core/controllerextensions/Paginator.ts +33 -34
  52. package/src/sap/fe/core/controllerextensions/Placeholder.js +5 -7
  53. package/src/sap/fe/core/controllerextensions/Placeholder.ts +12 -14
  54. package/src/sap/fe/core/controllerextensions/Routing.js +11 -12
  55. package/src/sap/fe/core/controllerextensions/Routing.ts +12 -13
  56. package/src/sap/fe/core/controllerextensions/RoutingListener.js +1 -1
  57. package/src/sap/fe/core/controllerextensions/Share.js +171 -140
  58. package/src/sap/fe/core/controllerextensions/Share.ts +117 -118
  59. package/src/sap/fe/core/controllerextensions/SideEffects.js +47 -51
  60. package/src/sap/fe/core/controllerextensions/SideEffects.ts +56 -60
  61. package/src/sap/fe/core/controllerextensions/ViewState.js +201 -132
  62. package/src/sap/fe/core/controllerextensions/ViewState.ts +141 -148
  63. package/src/sap/fe/core/controllerextensions/collaboration/ActivityBase.js +5 -5
  64. package/src/sap/fe/core/controllerextensions/collaboration/ActivityBase.ts +8 -7
  65. package/src/sap/fe/core/controllerextensions/collaboration/ActivitySync.js +13 -12
  66. package/src/sap/fe/core/controllerextensions/collaboration/ActivitySync.ts +17 -20
  67. package/src/sap/fe/core/controllerextensions/collaboration/CollaborationCommon.js +13 -12
  68. package/src/sap/fe/core/controllerextensions/collaboration/CollaborationCommon.ts +15 -15
  69. package/src/sap/fe/core/controllerextensions/collaboration/Manage.js +57 -18
  70. package/src/sap/fe/core/controllerextensions/collaboration/Manage.ts +60 -28
  71. package/src/sap/fe/core/controllerextensions/collaboration/ManageDialog.fragment.xml +29 -21
  72. package/src/sap/fe/core/controllerextensions/editFlow/TransactionHelper.js +1424 -940
  73. package/src/sap/fe/core/controllerextensions/editFlow/TransactionHelper.ts +799 -836
  74. package/src/sap/fe/core/controllerextensions/editFlow/draft.js +410 -377
  75. package/src/sap/fe/core/controllerextensions/editFlow/draft.ts +275 -358
  76. package/src/sap/fe/core/controllerextensions/editFlow/draftDataLossPopup.js +309 -0
  77. package/src/sap/fe/core/controllerextensions/editFlow/draftDataLossPopup.ts +320 -0
  78. package/src/sap/fe/core/controllerextensions/editFlow/operations.js +752 -579
  79. package/src/sap/fe/core/controllerextensions/editFlow/operations.ts +631 -599
  80. package/src/sap/fe/core/controllerextensions/editFlow/sticky.js +92 -74
  81. package/src/sap/fe/core/controllerextensions/editFlow/sticky.ts +49 -52
  82. package/src/sap/fe/core/controllerextensions/messageHandler/messageHandling.js +78 -41
  83. package/src/sap/fe/core/controllerextensions/messageHandler/messageHandling.ts +110 -84
  84. package/src/sap/fe/core/controllerextensions/routing/RouterProxy.js +69 -81
  85. package/src/sap/fe/core/controllerextensions/routing/RouterProxy.ts +64 -73
  86. package/src/sap/fe/core/controls/ActionParameterDialog.fragment.xml +18 -2
  87. package/src/sap/fe/core/controls/ActionParameterDialogFieldValueHelp.fragment.xml +35 -0
  88. package/src/sap/fe/core/controls/ActionParameterDialogValueHelp.fragment.xml +25 -24
  89. package/src/sap/fe/core/controls/Any.js +9 -5
  90. package/src/sap/fe/core/controls/Any.ts +10 -4
  91. package/src/sap/fe/core/controls/CommandExecution.js +12 -26
  92. package/src/sap/fe/core/controls/CommandExecution.ts +11 -25
  93. package/src/sap/fe/core/controls/ConditionalWrapper.js +3 -3
  94. package/src/sap/fe/core/controls/ConditionalWrapper.ts +3 -3
  95. package/src/sap/fe/core/controls/CustomFilterFieldContentWrapper.js +26 -26
  96. package/src/sap/fe/core/controls/CustomFilterFieldContentWrapper.ts +25 -24
  97. package/src/sap/fe/core/controls/CustomQuickViewPage.js +3 -3
  98. package/src/sap/fe/core/controls/CustomQuickViewPage.ts +2 -2
  99. package/src/sap/fe/core/controls/DataLossOrDraftDiscard/DataLossOrDraftDiscardHandler.js +3 -3
  100. package/src/sap/fe/core/controls/DataLossOrDraftDiscard/DataLossOrDraftDiscardHandler.ts +5 -5
  101. package/src/sap/fe/core/controls/FieldWrapper.js +3 -3
  102. package/src/sap/fe/core/controls/FieldWrapper.ts +3 -3
  103. package/src/sap/fe/core/controls/FileWrapper.js +9 -4
  104. package/src/sap/fe/core/controls/FileWrapper.ts +16 -12
  105. package/src/sap/fe/core/controls/FilterBar.js +7 -3
  106. package/src/sap/fe/core/controls/FilterBar.ts +13 -9
  107. package/src/sap/fe/core/controls/FormElementWrapper.js +2 -2
  108. package/src/sap/fe/core/controls/FormElementWrapper.ts +2 -2
  109. package/src/sap/fe/core/controls/MassEditSelect.js +1 -1
  110. package/src/sap/fe/core/controls/MassEditSelect.ts +0 -4
  111. package/src/sap/fe/core/controls/MultiValueParameterDelegate.js +1 -1
  112. package/src/sap/fe/core/controls/NonComputedVisibleKeyFieldsDialog.fragment.xml +44 -19
  113. package/src/sap/fe/core/controls/filterbar/FilterContainer.js +2 -2
  114. package/src/sap/fe/core/controls/filterbar/VisualFilter.js +17 -13
  115. package/src/sap/fe/core/controls/filterbar/VisualFilter.ts +20 -22
  116. package/src/sap/fe/core/controls/filterbar/VisualFilterContainer.js +4 -4
  117. package/src/sap/fe/core/controls/filterbar/VisualFilterContainer.ts +8 -8
  118. package/src/sap/fe/core/controls/filterbar/utils/VisualFilterUtils.js +49 -49
  119. package/src/sap/fe/core/controls/filterbar/utils/VisualFilterUtils.ts +54 -54
  120. package/src/sap/fe/core/controls/massEdit/MassEditDialog.fragment.xml +8 -2
  121. package/src/sap/fe/core/controls/massEdit/MassEditField.fragment.xml +22 -35
  122. package/src/sap/fe/core/controls/massEdit/MassEditHandlers.js +89 -88
  123. package/src/sap/fe/core/controls/massEdit/MassEditHandlers.ts +107 -106
  124. package/src/sap/fe/core/converters/ConverterContext.js +48 -34
  125. package/src/sap/fe/core/converters/ConverterContext.ts +81 -67
  126. package/src/sap/fe/core/converters/ManifestSettings.js +1 -1
  127. package/src/sap/fe/core/converters/ManifestSettings.ts +18 -15
  128. package/src/sap/fe/core/converters/ManifestWrapper.js +59 -45
  129. package/src/sap/fe/core/converters/ManifestWrapper.ts +55 -45
  130. package/src/sap/fe/core/converters/MetaModelConverter.js +74 -40
  131. package/src/sap/fe/core/converters/MetaModelConverter.ts +176 -140
  132. package/src/sap/fe/core/converters/TemplateConverter.js +21 -20
  133. package/src/sap/fe/core/converters/TemplateConverter.ts +27 -24
  134. package/src/sap/fe/core/converters/annotations/DataField.js +58 -35
  135. package/src/sap/fe/core/converters/annotations/DataField.ts +102 -76
  136. package/src/sap/fe/core/converters/common/AnnotationConverter.js +1956 -1494
  137. package/src/sap/fe/core/converters/controls/Common/Action.js +78 -51
  138. package/src/sap/fe/core/converters/controls/Common/Action.ts +87 -52
  139. package/src/sap/fe/core/converters/controls/Common/Chart.js +22 -16
  140. package/src/sap/fe/core/converters/controls/Common/Chart.ts +42 -43
  141. package/src/sap/fe/core/converters/controls/Common/Criticality.js +3 -3
  142. package/src/sap/fe/core/converters/controls/Common/Criticality.ts +4 -4
  143. package/src/sap/fe/core/converters/controls/Common/DataVisualization.js +65 -29
  144. package/src/sap/fe/core/converters/controls/Common/DataVisualization.ts +93 -62
  145. package/src/sap/fe/core/converters/controls/Common/Form.js +31 -31
  146. package/src/sap/fe/core/converters/controls/Common/Form.ts +46 -57
  147. package/src/sap/fe/core/converters/controls/Common/KPI.js +11 -11
  148. package/src/sap/fe/core/converters/controls/Common/KPI.ts +49 -52
  149. package/src/sap/fe/core/converters/controls/Common/Table.js +251 -264
  150. package/src/sap/fe/core/converters/controls/Common/Table.ts +344 -370
  151. package/src/sap/fe/core/converters/controls/Common/table/StandardActions.js +119 -119
  152. package/src/sap/fe/core/converters/controls/Common/table/StandardActions.ts +147 -144
  153. package/src/sap/fe/core/converters/controls/ListReport/FilterBar.js +89 -59
  154. package/src/sap/fe/core/converters/controls/ListReport/FilterBar.ts +118 -71
  155. package/src/sap/fe/core/converters/controls/ListReport/VisualFilters.js +28 -26
  156. package/src/sap/fe/core/converters/controls/ListReport/VisualFilters.ts +46 -43
  157. package/src/sap/fe/core/converters/controls/ObjectPage/Avatar.js +9 -9
  158. package/src/sap/fe/core/converters/controls/ObjectPage/Avatar.ts +14 -13
  159. package/src/sap/fe/core/converters/controls/ObjectPage/HeaderFacet.js +131 -95
  160. package/src/sap/fe/core/converters/controls/ObjectPage/HeaderFacet.ts +123 -87
  161. package/src/sap/fe/core/converters/controls/ObjectPage/SubSection.js +98 -87
  162. package/src/sap/fe/core/converters/controls/ObjectPage/SubSection.ts +121 -117
  163. package/src/sap/fe/core/converters/helpers/Aggregation.js +2 -4
  164. package/src/sap/fe/core/converters/helpers/Aggregation.ts +12 -15
  165. package/src/sap/fe/core/converters/helpers/BindingHelper.js +31 -31
  166. package/src/sap/fe/core/converters/helpers/BindingHelper.ts +30 -29
  167. package/src/sap/fe/core/converters/helpers/ConfigurableObject.js +8 -6
  168. package/src/sap/fe/core/converters/helpers/ConfigurableObject.ts +18 -10
  169. package/src/sap/fe/core/converters/helpers/DataFieldHelper.js +136 -0
  170. package/src/sap/fe/core/converters/helpers/DataFieldHelper.ts +139 -0
  171. package/src/sap/fe/core/converters/helpers/ID.js +48 -46
  172. package/src/sap/fe/core/converters/helpers/ID.ts +26 -25
  173. package/src/sap/fe/core/converters/helpers/IssueManager.js +1 -1
  174. package/src/sap/fe/core/converters/helpers/Key.js +7 -7
  175. package/src/sap/fe/core/converters/helpers/Key.ts +7 -7
  176. package/src/sap/fe/core/converters/helpers/SelectionVariantHelper.js +1 -1
  177. package/src/sap/fe/core/converters/helpers/SelectionVariantHelper.ts +4 -5
  178. package/src/sap/fe/core/converters/objectPage/FormMenuActions.js +6 -6
  179. package/src/sap/fe/core/converters/objectPage/FormMenuActions.ts +10 -10
  180. package/src/sap/fe/core/converters/objectPage/HeaderAndFooterAction.js +53 -75
  181. package/src/sap/fe/core/converters/objectPage/HeaderAndFooterAction.ts +59 -90
  182. package/src/sap/fe/core/converters/templates/ListReportConverter.js +58 -57
  183. package/src/sap/fe/core/converters/templates/ListReportConverter.ts +93 -86
  184. package/src/sap/fe/core/converters/templates/ObjectPageConverter.js +58 -44
  185. package/src/sap/fe/core/converters/templates/ObjectPageConverter.ts +87 -80
  186. package/src/sap/fe/core/designtime/AppComponent.designtime.js +4 -4
  187. package/src/sap/fe/core/designtime/AppComponent.designtime.ts +4 -4
  188. package/src/sap/fe/core/formatters/CollaborationFormatter.js +2 -2
  189. package/src/sap/fe/core/formatters/CollaborationFormatter.ts +3 -3
  190. package/src/sap/fe/core/formatters/FPMFormatter.js +5 -5
  191. package/src/sap/fe/core/formatters/FPMFormatter.ts +10 -10
  192. package/src/sap/fe/core/formatters/KPIFormatter.js +7 -7
  193. package/src/sap/fe/core/formatters/KPIFormatter.ts +10 -10
  194. package/src/sap/fe/core/formatters/StandardFormatter.js +96 -0
  195. package/src/sap/fe/core/formatters/StandardFormatter.ts +70 -0
  196. package/src/sap/fe/core/formatters/TableFormatter.js +11 -11
  197. package/src/sap/fe/core/formatters/TableFormatter.ts +12 -12
  198. package/src/sap/fe/core/formatters/TableFormatterTypes.js +1 -1
  199. package/src/sap/fe/core/formatters/ValueFormatter.js +8 -8
  200. package/src/sap/fe/core/formatters/ValueFormatter.ts +9 -9
  201. package/src/sap/fe/core/fpm/Component.js +33 -7
  202. package/src/sap/fe/core/fpm/Component.ts +14 -0
  203. package/src/sap/fe/core/helpers/AnnotationEnum.js +1 -1
  204. package/src/sap/fe/core/helpers/AppStartupHelper.js +19 -18
  205. package/src/sap/fe/core/helpers/AppStartupHelper.ts +41 -43
  206. package/src/sap/fe/core/helpers/BindingToolkit.js +1836 -0
  207. package/src/sap/fe/core/helpers/{BindingExpression.ts → BindingToolkit.ts} +397 -270
  208. package/src/sap/fe/core/helpers/ClassSupport.js +49 -12
  209. package/src/sap/fe/core/helpers/ClassSupport.ts +37 -10
  210. package/src/sap/fe/core/helpers/DynamicAnnotationPathHelper.js +2 -2
  211. package/src/sap/fe/core/helpers/DynamicAnnotationPathHelper.ts +1 -1
  212. package/src/sap/fe/core/helpers/EditState.js +1 -6
  213. package/src/sap/fe/core/helpers/EditState.ts +5 -10
  214. package/src/sap/fe/core/helpers/ExcelFormatHelper.js +2 -2
  215. package/src/sap/fe/core/helpers/ExcelFormatHelper.ts +4 -4
  216. package/src/sap/fe/core/helpers/FPMHelper.js +1 -1
  217. package/src/sap/fe/core/helpers/FPMHelper.ts +2 -2
  218. package/src/sap/fe/core/helpers/KeepAliveHelper.js +31 -31
  219. package/src/sap/fe/core/helpers/KeepAliveHelper.ts +52 -56
  220. package/src/sap/fe/core/helpers/KeepAliveRefreshTypes.js +1 -1
  221. package/src/sap/fe/core/helpers/MassEditHelper.js +306 -280
  222. package/src/sap/fe/core/helpers/MassEditHelper.ts +380 -360
  223. package/src/sap/fe/core/helpers/MessageStrip.js +81 -0
  224. package/src/sap/fe/core/helpers/MessageStrip.ts +79 -0
  225. package/src/sap/fe/core/helpers/ModelHelper.js +25 -25
  226. package/src/sap/fe/core/helpers/ModelHelper.ts +34 -32
  227. package/src/sap/fe/core/helpers/PasteHelper.js +3 -10
  228. package/src/sap/fe/core/helpers/PasteHelper.ts +20 -25
  229. package/src/sap/fe/core/helpers/SemanticDateOperators.js +1 -1
  230. package/src/sap/fe/core/helpers/SemanticDateOperators.ts +11 -11
  231. package/src/sap/fe/core/helpers/SemanticKeyHelper.js +3 -3
  232. package/src/sap/fe/core/helpers/SemanticKeyHelper.ts +8 -8
  233. package/src/sap/fe/core/helpers/StableIdHelper.js +12 -12
  234. package/src/sap/fe/core/helpers/StableIdHelper.ts +12 -12
  235. package/src/sap/fe/core/helpers/Synchronization.js +1 -1
  236. package/src/sap/fe/core/helpers/ToES6Promise.js +32 -0
  237. package/src/sap/fe/core/helpers/ToES6Promise.ts +19 -0
  238. package/src/sap/fe/core/jsx-runtime/Fragment.js +16 -0
  239. package/src/sap/fe/core/jsx-runtime/Fragment.ts +3 -0
  240. package/src/sap/fe/core/jsx-runtime/ViewLoader.js +109 -0
  241. package/src/sap/fe/core/jsx-runtime/ViewLoader.tsx +47 -0
  242. package/src/sap/fe/core/jsx-runtime/jsx-control.js +110 -0
  243. package/src/sap/fe/core/jsx-runtime/jsx-control.ts +92 -0
  244. package/src/sap/fe/core/jsx-runtime/jsx-xml.js +105 -0
  245. package/src/sap/fe/core/jsx-runtime/jsx-xml.ts +89 -0
  246. package/src/sap/fe/core/jsx-runtime/jsx.js +12 -90
  247. package/src/sap/fe/core/jsx-runtime/jsx.ts +24 -85
  248. package/src/sap/fe/core/jsx-runtime/jsxs.js +1 -1
  249. package/src/sap/fe/core/jsx-runtime/useMDXComponents.js +179 -0
  250. package/src/sap/fe/core/jsx-runtime/useMDXComponents.tsx +150 -0
  251. package/src/sap/fe/core/library.js +42 -3
  252. package/src/sap/fe/core/library.support.js +1 -1
  253. package/src/sap/fe/core/library.ts +38 -0
  254. package/src/sap/fe/core/manifestMerger/ChangePageConfiguration.js +3 -3
  255. package/src/sap/fe/core/manifestMerger/ChangePageConfiguration.ts +2 -2
  256. package/src/sap/fe/core/messagebundle.properties +39 -67
  257. package/src/sap/fe/core/messagebundle_ar.properties +27 -44
  258. package/src/sap/fe/core/messagebundle_bg.properties +27 -44
  259. package/src/sap/fe/core/messagebundle_ca.properties +27 -44
  260. package/src/sap/fe/core/messagebundle_cs.properties +27 -44
  261. package/src/sap/fe/core/messagebundle_cy.properties +26 -43
  262. package/src/sap/fe/core/messagebundle_da.properties +27 -44
  263. package/src/sap/fe/core/messagebundle_de.properties +25 -42
  264. package/src/sap/fe/core/messagebundle_el.properties +28 -45
  265. package/src/sap/fe/core/messagebundle_en.properties +27 -44
  266. package/src/sap/fe/core/messagebundle_en_GB.properties +27 -44
  267. package/src/sap/fe/core/messagebundle_en_US_sappsd.properties +25 -42
  268. package/src/sap/fe/core/messagebundle_en_US_saprigi.properties +26 -40
  269. package/src/sap/fe/core/messagebundle_en_US_saptrc.properties +25 -42
  270. package/src/sap/fe/core/messagebundle_es.properties +27 -44
  271. package/src/sap/fe/core/messagebundle_es_MX.properties +27 -44
  272. package/src/sap/fe/core/messagebundle_et.properties +27 -44
  273. package/src/sap/fe/core/messagebundle_fi.properties +27 -44
  274. package/src/sap/fe/core/messagebundle_fr.properties +26 -43
  275. package/src/sap/fe/core/messagebundle_fr_CA.properties +25 -42
  276. package/src/sap/fe/core/messagebundle_hi.properties +27 -44
  277. package/src/sap/fe/core/messagebundle_hr.properties +27 -44
  278. package/src/sap/fe/core/messagebundle_hu.properties +27 -44
  279. package/src/sap/fe/core/messagebundle_id.properties +27 -44
  280. package/src/sap/fe/core/messagebundle_it.properties +43 -60
  281. package/src/sap/fe/core/messagebundle_iw.properties +27 -44
  282. package/src/sap/fe/core/messagebundle_ja.properties +27 -44
  283. package/src/sap/fe/core/messagebundle_kk.properties +27 -44
  284. package/src/sap/fe/core/messagebundle_ko.properties +30 -47
  285. package/src/sap/fe/core/messagebundle_lt.properties +27 -44
  286. package/src/sap/fe/core/messagebundle_lv.properties +27 -44
  287. package/src/sap/fe/core/messagebundle_ms.properties +27 -44
  288. package/src/sap/fe/core/messagebundle_nl.properties +29 -46
  289. package/src/sap/fe/core/messagebundle_no.properties +27 -44
  290. package/src/sap/fe/core/messagebundle_pl.properties +28 -45
  291. package/src/sap/fe/core/messagebundle_pt.properties +28 -45
  292. package/src/sap/fe/core/messagebundle_pt_PT.properties +27 -44
  293. package/src/sap/fe/core/messagebundle_ro.properties +27 -44
  294. package/src/sap/fe/core/messagebundle_ru.properties +27 -44
  295. package/src/sap/fe/core/messagebundle_sh.properties +27 -44
  296. package/src/sap/fe/core/messagebundle_sk.properties +27 -44
  297. package/src/sap/fe/core/messagebundle_sl.properties +27 -44
  298. package/src/sap/fe/core/messagebundle_sv.properties +27 -44
  299. package/src/sap/fe/core/messagebundle_th.properties +25 -42
  300. package/src/sap/fe/core/messagebundle_tr.properties +27 -44
  301. package/src/sap/fe/core/messagebundle_uk.properties +27 -44
  302. package/src/sap/fe/core/messagebundle_vi.properties +27 -44
  303. package/src/sap/fe/core/messagebundle_zh_CN.properties +27 -44
  304. package/src/sap/fe/core/messagebundle_zh_TW.properties +27 -44
  305. package/src/sap/fe/core/services/AsyncComponentServiceFactory.js +3 -3
  306. package/src/sap/fe/core/services/AsyncComponentServiceFactory.ts +5 -5
  307. package/src/sap/fe/core/services/CacheHandlerServiceFactory.js +103 -75
  308. package/src/sap/fe/core/services/CacheHandlerServiceFactory.ts +72 -73
  309. package/src/sap/fe/core/services/EnvironmentServiceFactory.js +2 -2
  310. package/src/sap/fe/core/services/EnvironmentServiceFactory.ts +3 -2
  311. package/src/sap/fe/core/services/NavigationServiceFactory.js +62 -50
  312. package/src/sap/fe/core/services/NavigationServiceFactory.ts +63 -52
  313. package/src/sap/fe/core/services/ResourceModelServiceFactory.js +3 -3
  314. package/src/sap/fe/core/services/ResourceModelServiceFactory.ts +4 -4
  315. package/src/sap/fe/core/services/RoutingServiceFactory.js +56 -56
  316. package/src/sap/fe/core/services/RoutingServiceFactory.ts +67 -65
  317. package/src/sap/fe/core/services/ShellServicesFactory.js +93 -77
  318. package/src/sap/fe/core/services/ShellServicesFactory.ts +95 -82
  319. package/src/sap/fe/core/services/SideEffectsServiceFactory.js +64 -64
  320. package/src/sap/fe/core/services/SideEffectsServiceFactory.ts +102 -92
  321. package/src/sap/fe/core/services/TemplatedViewServiceFactory.js +232 -200
  322. package/src/sap/fe/core/services/TemplatedViewServiceFactory.ts +145 -142
  323. package/src/sap/fe/core/services/view/TemplatingErrorPage.controller.js +2 -2
  324. package/src/sap/fe/core/support/AnnotationIssue.support.js +1 -1
  325. package/src/sap/fe/core/support/CollectionFacetMissingID.support.js +1 -1
  326. package/src/sap/fe/core/support/CollectionFacetUnsupportedLevel.support.js +1 -1
  327. package/src/sap/fe/core/support/CommonHelper.js +3 -2
  328. package/src/sap/fe/core/support/CommonHelper.ts +9 -13
  329. package/src/sap/fe/core/support/Diagnostics.js +1 -1
  330. package/src/sap/fe/core/support/Diagnostics.ts +5 -5
  331. package/src/sap/fe/core/support/InvalidAnnotationColumnKey.support.js +1 -1
  332. package/src/sap/fe/core/templating/CommonFormatters.js +85 -0
  333. package/src/sap/fe/core/templating/CommonFormatters.ts +90 -0
  334. package/src/sap/fe/core/templating/CriticalityFormatters.js +31 -31
  335. package/src/sap/fe/core/templating/CriticalityFormatters.ts +42 -40
  336. package/src/sap/fe/core/templating/DataFieldFormatters.js +8 -8
  337. package/src/sap/fe/core/templating/DataFieldFormatters.ts +13 -10
  338. package/src/sap/fe/core/templating/DataModelPathHelper.js +23 -15
  339. package/src/sap/fe/core/templating/DataModelPathHelper.ts +47 -34
  340. package/src/sap/fe/core/templating/DisplayModeFormatter.js +1 -1
  341. package/src/sap/fe/core/templating/DisplayModeFormatter.ts +2 -3
  342. package/src/sap/fe/core/templating/EntitySetHelper.js +7 -7
  343. package/src/sap/fe/core/templating/EntitySetHelper.ts +6 -8
  344. package/src/sap/fe/core/templating/FieldControlHelper.js +35 -34
  345. package/src/sap/fe/core/templating/FieldControlHelper.ts +29 -46
  346. package/src/sap/fe/core/templating/FilterHelper.js +18 -17
  347. package/src/sap/fe/core/templating/FilterHelper.ts +18 -18
  348. package/src/sap/fe/core/templating/FilterTemplating.js +1 -1
  349. package/src/sap/fe/core/templating/FilterTemplating.ts +3 -3
  350. package/src/sap/fe/core/templating/PropertyFormatters.js +7 -7
  351. package/src/sap/fe/core/templating/PropertyFormatters.ts +21 -19
  352. package/src/sap/fe/core/templating/PropertyHelper.js +25 -25
  353. package/src/sap/fe/core/templating/PropertyHelper.ts +25 -26
  354. package/src/sap/fe/core/templating/UIFormatters.js +152 -95
  355. package/src/sap/fe/core/templating/UIFormatters.ts +202 -128
  356. package/src/sap/fe/core/type/DateTimeWithTimezone.js +2 -2
  357. package/src/sap/fe/core/type/Email.js +3 -3
  358. package/src/sap/fe/core/type/Email.ts +2 -2
  359. package/src/sap/fe/core/helpers/BindingExpression.js +0 -1732
@@ -1,7 +1,6 @@
1
- import ResourceBundle from "sap/base/i18n/ResourceBundle";
1
+ import type ResourceBundle from "sap/base/i18n/ResourceBundle";
2
2
  import Log from "sap/base/Log";
3
- import UriParameters from "sap/base/util/UriParameters";
4
- import AppComponent from "sap/fe/core/AppComponent";
3
+ import type AppComponent from "sap/fe/core/AppComponent";
5
4
  import CommonUtils from "sap/fe/core/CommonUtils";
6
5
  import BusyLocker from "sap/fe/core/controllerextensions/BusyLocker";
7
6
  import draft from "sap/fe/core/controllerextensions/editFlow/draft";
@@ -9,7 +8,8 @@ import operations from "sap/fe/core/controllerextensions/editFlow/operations";
9
8
  import sticky from "sap/fe/core/controllerextensions/editFlow/sticky";
10
9
  import messageHandling from "sap/fe/core/controllerextensions/messageHandler/messageHandling";
11
10
  import FPMHelper from "sap/fe/core/helpers/FPMHelper";
12
- import ModelHelper, { InternalModelContext } from "sap/fe/core/helpers/ModelHelper";
11
+ import type { InternalModelContext } from "sap/fe/core/helpers/ModelHelper";
12
+ import ModelHelper from "sap/fe/core/helpers/ModelHelper";
13
13
  import FELibrary from "sap/fe/core/library";
14
14
  import Button from "sap/m/Button";
15
15
  import CheckBox from "sap/m/CheckBox";
@@ -22,13 +22,16 @@ import VBox from "sap/m/VBox";
22
22
  import Core from "sap/ui/core/Core";
23
23
  import Fragment from "sap/ui/core/Fragment";
24
24
  import coreLibrary from "sap/ui/core/library";
25
- import View from "sap/ui/core/mvc/View";
25
+ import type View from "sap/ui/core/mvc/View";
26
26
  import XMLPreprocessor from "sap/ui/core/util/XMLPreprocessor";
27
27
  import XMLTemplateProcessor from "sap/ui/core/XMLTemplateProcessor";
28
- import Context from "sap/ui/model/Context";
28
+ import type Context from "sap/ui/model/Context";
29
29
  import JSONModel from "sap/ui/model/json/JSONModel";
30
- import ODataMetaModel from "sap/ui/model/odata/v4/ODataMetaModel";
31
- import { CoreEx } from "types/extension_types";
30
+ import type ODataV4Context from "sap/ui/model/odata/v4/Context";
31
+ import type ODataMetaModel from "sap/ui/model/odata/v4/ODataMetaModel";
32
+ import type ODataModel from "sap/ui/model/odata/v4/ODataModel";
33
+ import type { CoreEx, ODataListBinding, V4Context } from "types/extension_types";
34
+ import toES6Promise from "../../helpers/ToES6Promise";
32
35
 
33
36
  const CreationMode = FELibrary.CreationMode;
34
37
  const ProgrammingModel = FELibrary.ProgrammingModel;
@@ -71,7 +74,7 @@ class TransactionHelper {
71
74
  return ProgrammingModel.NonDraft;
72
75
  }
73
76
  }
74
- return this.sProgrammingModel as typeof ProgrammingModel;
77
+ return this.sProgrammingModel;
75
78
  }
76
79
 
77
80
  /**
@@ -79,16 +82,16 @@ class TransactionHelper {
79
82
  *
80
83
  * @memberof sap.fe.core.TransactionHelper
81
84
  * @static
82
- * @param {sap.ui.model.odata.v4.Context} oContext Context of the document to be validated
83
- * @param {object} [mParameters] Can contain the following attributes:
84
- * * @param {object} [mParameters.data] A map of data that should be validated
85
- * * @param {string} [mParameters.customValidationFunction] A string representing the path to the validation function
86
- * @param {object} oView Contains the object of the current view
87
- * @returns {Promise} Promise resolves with result of the custom validation function
85
+ * @param oContext Context of the document to be validated
86
+ * @param [mParameters] Can contain the following attributes:
87
+ * @param [mParameters.data] A map of data that should be validated
88
+ * @param [mParameters.customValidationFunction] A string representing the path to the validation function
89
+ * @param oView Contains the object of the current view
90
+ * @returns Promise resolves with result of the custom validation function
88
91
  * @ui5-restricted
89
92
  * @final
90
93
  */
91
- validateDocument(oContext: any, mParameters: any, oView: View): Promise<any> {
94
+ validateDocument(oContext: V4Context, mParameters: any, oView: View): Promise<any> {
92
95
  const sCustomValidationFunction = mParameters && mParameters.customValidationFunction;
93
96
  if (sCustomValidationFunction) {
94
97
  const sModule = sCustomValidationFunction.substring(0, sCustomValidationFunction.lastIndexOf(".") || -1).replace(/\./gi, "/"),
@@ -108,31 +111,30 @@ class TransactionHelper {
108
111
  *
109
112
  * @memberof sap.fe.core.TransactionHelper
110
113
  * @static
111
- * @param {sap.ui.model.odata.v4.ODataListBinding} oMainListBinding OData V4 ListBinding object
112
- * @param {object} [mInParameters] Optional, can contain the following attributes:
113
- * @param {map} [mInParameters.data] A map of data that should be sent within the POST
114
- * @param {string} [mInParameters.busyMode] Global (default), Local, None TODO: to be refactored
115
- * @param {map} [mInParameters.keepTransientContextOnFailed] If set, the context stays in the list if the POST failed and POST will be repeated with the next change
116
- * @param {map} [mInParameters.inactive] If set, the context is set as inactive for empty rows
114
+ * @param oMainListBinding OData V4 ListBinding object
115
+ * @param [mInParameters] Optional, can contain the following attributes:
116
+ * @param [mInParameters.data] A map of data that should be sent within the POST
117
+ * @param [mInParameters.busyMode] Global (default), Local, None TODO: to be refactored
118
+ * @param [mInParameters.keepTransientContextOnFailed] If set, the context stays in the list if the POST failed and POST will be repeated with the next change
119
+ * @param [mInParameters.inactive] If set, the context is set as inactive for empty rows
117
120
  * @param oResourceBundle
118
121
  * @param messageHandler
119
122
  * @param bFromCopyPaste
120
123
  * @param oView The current view
121
- * @returns {Promise} Promise resolves with new binding context
124
+ * @returns Promise resolves with new binding context
122
125
  * @ui5-restricted
123
126
  * @final
124
127
  */
125
- createDocument(
126
- oMainListBinding: any,
128
+ async createDocument(
129
+ oMainListBinding: ODataListBinding,
127
130
  mInParameters: { data?: any; busyMode?: string | undefined; keepTransientContextOnFailed?: any; inactive?: boolean } | undefined,
128
131
  oResourceBundle: any,
129
132
  messageHandler: any,
130
133
  bFromCopyPaste: boolean = false,
131
134
  oView: any
132
- ) {
135
+ ): Promise<ODataV4Context> {
133
136
  // eslint-disable-next-line @typescript-eslint/no-this-alias
134
- const that = this,
135
- oModel = oMainListBinding.getModel(),
137
+ const oModel = oMainListBinding.getModel(),
136
138
  oMetaModel = oModel.getMetaModel(),
137
139
  sMetaPath = oMetaModel.getMetaPath(oMainListBinding.getHeaderContext().getPath()),
138
140
  sCreateHash = this._getAppComponent().getRouterProxy().getHash(),
@@ -141,20 +143,19 @@ class TransactionHelper {
141
143
  sNewAction = !oMainListBinding.isRelative()
142
144
  ? this._getNewAction(oStartupParameters, sCreateHash, oMetaModel, sMetaPath)
143
145
  : undefined;
144
- let oCreationPromise;
145
146
  const mBindingParameters: any = { "$$patchWithoutSideEffects": true };
146
- const sMessagesPath = oMetaModel.getObject(sMetaPath + "/@com.sap.vocabularies.Common.v1.Messages/$Path");
147
+ const sMessagesPath = oMetaModel.getObject(`${sMetaPath}/@com.sap.vocabularies.Common.v1.Messages/$Path`);
147
148
  let sBusyPath = "/busy";
148
149
  let sFunctionName =
149
- oMetaModel.getObject(sMetaPath + "@com.sap.vocabularies.Common.v1.DefaultValuesFunction") ||
150
+ oMetaModel.getObject(`${sMetaPath}@com.sap.vocabularies.Common.v1.DefaultValuesFunction`) ||
150
151
  oMetaModel.getObject(
151
- ModelHelper.getTargetEntitySet(oMetaModel.getContext(sMetaPath)) + "@com.sap.vocabularies.Common.v1.DefaultValuesFunction"
152
+ `${ModelHelper.getTargetEntitySet(oMetaModel.getContext(sMetaPath))}@com.sap.vocabularies.Common.v1.DefaultValuesFunction`
152
153
  );
153
154
  let bFunctionOnNavProp;
154
- let oNewDocumentContext: any;
155
+ let oNewDocumentContext: ODataV4Context | undefined;
155
156
  if (sFunctionName) {
156
157
  if (
157
- oMetaModel.getObject(sMetaPath + "@com.sap.vocabularies.Common.v1.DefaultValuesFunction") &&
158
+ oMetaModel.getObject(`${sMetaPath}@com.sap.vocabularies.Common.v1.DefaultValuesFunction`) &&
158
159
  ModelHelper.getTargetEntitySet(oMetaModel.getContext(sMetaPath)) !== sMetaPath
159
160
  ) {
160
161
  bFunctionOnNavProp = true;
@@ -167,176 +168,158 @@ class TransactionHelper {
167
168
  }
168
169
  const mParameters = getParameters(mInParameters);
169
170
  if (!oMainListBinding) {
170
- return Promise.reject("Binding required for new document creation");
171
+ throw new Error("Binding required for new document creation");
171
172
  }
172
173
  const sProgrammingModel = this.getProgrammingModel(oMainListBinding);
173
174
  if (sProgrammingModel !== ProgrammingModel.Draft && sProgrammingModel !== ProgrammingModel.Sticky) {
174
- return Promise.reject("Create document only allowed for draft or sticky session supported services");
175
+ throw new Error("Create document only allowed for draft or sticky session supported services");
175
176
  }
176
177
  if (mParameters.busyMode === "Local") {
177
178
  // in case of local busy mode we use the list binding name
178
179
  // there's no APY yet so we have to use the .sId TODO provide a public method?
179
- sBusyPath = "/busyLocal/" + oMainListBinding.sId;
180
+ sBusyPath = `/busyLocal/${oMainListBinding.sId}`;
180
181
  }
181
182
  mParameters.beforeCreateCallBack = bFromCopyPaste ? null : mParameters.beforeCreateCallBack;
182
183
  BusyLocker.lock(this.oLockObject, sBusyPath);
183
184
  const oResourceBundleCore = (Core as CoreEx).getLibraryResourceBundle("sap.fe.core");
184
- if (sNewAction) {
185
- oCreationPromise = this.callAction(
186
- sNewAction,
187
- {
188
- contexts: oMainListBinding.getHeaderContext(),
189
- showActionParameterDialog: true,
190
- label: this._getSpecificCreateActionDialogLabel(
191
- oMetaModel,
192
- sMetaPath,
193
- sNewAction,
194
- oResourceBundleCore as ResourceBundle
195
- ),
196
- bindingParameters: mBindingParameters,
197
- parentControl: mParameters.parentControl,
198
- bIsCreateAction: true
199
- },
200
- null,
201
- messageHandler
202
- );
203
- } else {
204
- const bIsNewPageCreation =
205
- mParameters.creationMode !== CreationMode.CreationRow && mParameters.creationMode !== CreationMode.Inline;
206
- const aNonComputedVisibleKeyFields = bIsNewPageCreation
207
- ? CommonUtils.getNonComputedVisibleFields(oMetaModel, sMetaPath, oView)
208
- : [];
209
- sFunctionName = bFromCopyPaste ? null : sFunctionName;
210
- let sFunctionPath, oFunctionContext;
211
- if (sFunctionName) {
212
- //bound to the source entity:
213
- if (bFunctionOnNavProp) {
214
- sFunctionPath =
215
- oMainListBinding.getContext() &&
216
- oMetaModel.getMetaPath(oMainListBinding.getContext().getPath()) + "/" + sFunctionName;
217
- oFunctionContext = oMainListBinding.getContext();
218
- } else {
219
- sFunctionPath =
220
- oMainListBinding.getHeaderContext() &&
221
- oMetaModel.getMetaPath(oMainListBinding.getHeaderContext().getPath()) + "/" + sFunctionName;
222
- oFunctionContext = oMainListBinding.getHeaderContext();
223
- }
224
- }
225
- const oFunction = sFunctionPath && oMetaModel.createBindingContext(sFunctionPath);
226
- if (oFunction && oFunction.getObject() && oFunction.getObject()[0].$IsBound) {
227
- oCreationPromise = operations.callBoundFunction(sFunctionName, oFunctionContext, oModel);
228
- } else {
229
- oCreationPromise = operations.callFunctionImport(sFunctionName, oModel);
230
- }
185
+ let oResult: any;
231
186
 
232
- oCreationPromise = oCreationPromise
233
- .then(function (oContext: any) {
234
- if (oContext) {
235
- return oContext.getObject();
187
+ try {
188
+ if (sNewAction) {
189
+ oResult = await this.callAction(
190
+ sNewAction,
191
+ {
192
+ contexts: oMainListBinding.getHeaderContext(),
193
+ showActionParameterDialog: true,
194
+ label: this._getSpecificCreateActionDialogLabel(oMetaModel, sMetaPath, sNewAction, oResourceBundleCore),
195
+ bindingParameters: mBindingParameters,
196
+ parentControl: mParameters.parentControl,
197
+ bIsCreateAction: true
198
+ },
199
+ null,
200
+ messageHandler
201
+ );
202
+ } else {
203
+ const bIsNewPageCreation =
204
+ mParameters.creationMode !== CreationMode.CreationRow && mParameters.creationMode !== CreationMode.Inline;
205
+ const aNonComputedVisibleKeyFields = bIsNewPageCreation
206
+ ? CommonUtils.getNonComputedVisibleFields(oMetaModel, sMetaPath, oView)
207
+ : [];
208
+ sFunctionName = bFromCopyPaste ? null : sFunctionName;
209
+ let sFunctionPath, oFunctionContext;
210
+ if (sFunctionName) {
211
+ //bound to the source entity:
212
+ if (bFunctionOnNavProp) {
213
+ sFunctionPath =
214
+ oMainListBinding.getContext() &&
215
+ `${oMetaModel.getMetaPath(oMainListBinding.getContext().getPath())}/${sFunctionName}`;
216
+ oFunctionContext = oMainListBinding.getContext();
236
217
  } else {
237
- return undefined;
218
+ sFunctionPath =
219
+ oMainListBinding.getHeaderContext() &&
220
+ `${oMetaModel.getMetaPath(oMainListBinding.getHeaderContext().getPath())}/${sFunctionName}`;
221
+ oFunctionContext = oMainListBinding.getHeaderContext();
222
+ }
223
+ }
224
+ const oFunction = sFunctionPath && (oMetaModel.createBindingContext(sFunctionPath) as any);
225
+
226
+ try {
227
+ let oData: any;
228
+ try {
229
+ const oContext =
230
+ oFunction && oFunction.getObject() && oFunction.getObject()[0].$IsBound
231
+ ? await operations.callBoundFunction(sFunctionName, oFunctionContext, oModel)
232
+ : await operations.callFunctionImport(sFunctionName, oModel);
233
+ if (oContext) {
234
+ oData = oContext.getObject();
235
+ }
236
+ } catch (oError: any) {
237
+ Log.error(`Error while executing the function ${sFunctionName}`, oError);
238
+ throw oError;
238
239
  }
239
- })
240
- .catch(function (oError: any) {
241
- Log.error("Error while executing the function " + sFunctionName, oError);
242
- throw oError;
243
- })
244
- .then(function (oData: any) {
245
240
  mParameters.data = oData ? Object.assign({}, oData, mParameters.data) : mParameters.data;
246
241
  if (mParameters.data) {
247
242
  delete mParameters.data["@odata.context"];
248
243
  }
249
244
  if (aNonComputedVisibleKeyFields.length > 0) {
250
- return that
251
- ._launchDialogWithKeyFields(oMainListBinding, aNonComputedVisibleKeyFields, oModel, mParameters, messageHandler)
252
- .then((oResult) => {
253
- oNewDocumentContext = oResult.newContext;
254
- return oResult;
255
- });
245
+ oResult = await this._launchDialogWithKeyFields(
246
+ oMainListBinding,
247
+ aNonComputedVisibleKeyFields,
248
+ oModel,
249
+ mParameters,
250
+ messageHandler
251
+ );
252
+ oNewDocumentContext = oResult.newContext;
256
253
  } else {
257
- let onBeforeCreatePromise;
258
254
  if (mParameters.beforeCreateCallBack) {
259
- onBeforeCreatePromise = mParameters.beforeCreateCallBack({
260
- contextPath: oMainListBinding && oMainListBinding.getPath()
261
- });
262
- } else {
263
- onBeforeCreatePromise = Promise.resolve();
264
- }
265
- return onBeforeCreatePromise.then(function () {
266
- oNewDocumentContext = oMainListBinding.create(
267
- mParameters.data,
268
- true,
269
- mParameters.createAtEnd,
270
- mParameters.inactive
255
+ await toES6Promise(
256
+ mParameters.beforeCreateCallBack({
257
+ contextPath: oMainListBinding && oMainListBinding.getPath()
258
+ })
271
259
  );
272
- if (!mParameters.inactive) {
273
- return that.onAfterCreateCompletion(oMainListBinding, oNewDocumentContext, mParameters);
274
- }
275
- });
260
+ }
261
+
262
+ oNewDocumentContext = oMainListBinding.create(
263
+ mParameters.data,
264
+ true,
265
+ mParameters.createAtEnd,
266
+ mParameters.inactive
267
+ );
268
+ if (!mParameters.inactive) {
269
+ oResult = await this.onAfterCreateCompletion(oMainListBinding, oNewDocumentContext, mParameters);
270
+ }
276
271
  }
277
- })
278
- .catch(function (oError: any) {
272
+ } catch (oError: any) {
279
273
  Log.error("Error while creating the new document", oError);
280
274
  throw oError;
281
- });
282
- }
283
- return oCreationPromise
284
- .then(function (oResult: any) {
285
- if (!oMainListBinding.isRelative()) {
286
- // the create mode shall currently only be set on creating a root document
287
- that._bCreateMode = true;
288
- }
289
- oNewDocumentContext = oNewDocumentContext || (oResult && oResult.response);
290
- // TODO: where does this one coming from???
291
- if (oResult && oResult.bConsiderDocumentModified) {
292
- that.handleDocumentModifications();
293
275
  }
294
- return messageHandler.showMessageDialog().then(function () {
295
- return oNewDocumentContext;
296
- });
297
- })
298
- .catch(function (oError: any) {
299
- return messageHandler.showMessageDialog().then(function () {
300
- // for instance, on cancel of create dialog, the promise is rejected
301
- // a return here would restore the promise chain and result in errors while routing
302
- // solution - reject here as well
303
- if (oError && oError.bDeleteTransientContext && oNewDocumentContext?.isTransient()) {
304
- // This is a workaround suggested by model as Context.delete results in an error
305
- // TODO: remove the $direct once model resolves this issue
306
- // this line shows the expected console error Uncaught (in promise) Error: Request canceled: POST Travel; group: submitLater
307
- oNewDocumentContext.delete("$direct");
308
- }
309
- return Promise.reject(oError);
310
- });
311
- })
312
- .finally(function () {
313
- BusyLocker.unlock(that.oLockObject, sBusyPath);
314
- });
276
+ }
277
+
278
+ if (!oMainListBinding.isRelative()) {
279
+ // the create mode shall currently only be set on creating a root document
280
+ this._bCreateMode = true;
281
+ }
282
+ oNewDocumentContext = oNewDocumentContext || (oResult && oResult.response);
283
+ // TODO: where does this one coming from???
284
+ if (oResult && oResult.bConsiderDocumentModified) {
285
+ this.handleDocumentModifications();
286
+ }
287
+ await messageHandler.showMessageDialog();
288
+ return oNewDocumentContext!;
289
+ } catch (oError: any) {
290
+ await messageHandler.showMessageDialog();
291
+ if (oError && oError.bDeleteTransientContext && oNewDocumentContext?.isTransient()) {
292
+ // This is a workaround suggested by model as Context.delete results in an error
293
+ // TODO: remove the $direct once model resolves this issue
294
+ // this line shows the expected console error Uncaught (in promise) Error: Request canceled: POST Travel; group: submitLater
295
+ oNewDocumentContext.delete("$direct");
296
+ }
297
+ throw oError;
298
+ } finally {
299
+ BusyLocker.unlock(this.oLockObject, sBusyPath);
300
+ }
315
301
  }
316
302
  /**
317
303
  * Find the active contexts of the documents, only for the draft roots.
318
304
  *
319
305
  * @memberof sap.fe.core.TransactionHelper
320
306
  * @static
321
- * @param {sap.ui.model.odata.v4.Context[]} aContexts Contexts Either one context or an array with contexts to be deleted
307
+ * @param aContexts Contexts Either one context or an array with contexts to be deleted
322
308
  * @param bFindActiveContexts
323
- * @returns {Array} Array of the active contexts
309
+ * @returns Array of the active contexts
324
310
  */
325
- findActiveDraftRootContexts(aContexts: any[], bFindActiveContexts: any) {
311
+ findActiveDraftRootContexts(aContexts: V4Context[], bFindActiveContexts: any) {
326
312
  if (!bFindActiveContexts) {
327
313
  return Promise.resolve();
328
314
  }
329
315
  const activeContexts = aContexts.reduce(function (aResult: any, oContext: any) {
330
316
  const oMetaModel = oContext.getModel().getMetaModel();
331
317
  const sMetaPath = oMetaModel.getMetaPath(oContext.getPath());
332
- if (oMetaModel.getObject(sMetaPath + "@com.sap.vocabularies.Common.v1.DraftRoot")) {
318
+ if (oMetaModel.getObject(`${sMetaPath}@com.sap.vocabularies.Common.v1.DraftRoot`)) {
333
319
  const bIsActiveEntity = oContext.getObject().IsActiveEntity,
334
320
  bHasActiveEntity = oContext.getObject().HasActiveEntity;
335
321
  if (!bIsActiveEntity && bHasActiveEntity) {
336
- const oActiveContext = oContext
337
- .getModel()
338
- .bindContext(oContext.getPath() + "/SiblingEntity")
339
- .getBoundContext();
322
+ const oActiveContext = oContext.getModel().bindContext(`${oContext.getPath()}/SiblingEntity`).getBoundContext();
340
323
  aResult.push(oActiveContext);
341
324
  }
342
325
  }
@@ -344,14 +327,9 @@ class TransactionHelper {
344
327
  }, []);
345
328
  return Promise.all(
346
329
  activeContexts.map(function (oContext: any) {
347
- return oContext.requestCanonicalPath().then(
348
- function () {
349
- return oContext;
350
- },
351
- function () {
352
- return;
353
- }
354
- );
330
+ return oContext.requestCanonicalPath().then(function () {
331
+ return oContext;
332
+ });
355
333
  })
356
334
  );
357
335
  }
@@ -378,7 +356,7 @@ class TransactionHelper {
378
356
  if (aContexts.length === 1) {
379
357
  MessageToast.show(
380
358
  CommonUtils.getTranslatedText(
381
- "C_TRANSACTION_HELPER_OBJECT_PAGE_DELETE_TOAST_SINGULAR",
359
+ "C_TRANSACTION_HELPER_DELETE_TOAST_SINGULAR",
382
360
  oResourceBundle,
383
361
  null,
384
362
  mParameters.entitySetName
@@ -386,12 +364,7 @@ class TransactionHelper {
386
364
  );
387
365
  } else {
388
366
  MessageToast.show(
389
- CommonUtils.getTranslatedText(
390
- "C_TRANSACTION_HELPER_OBJECT_PAGE_DELETE_TOAST_PLURAL",
391
- oResourceBundle,
392
- null,
393
- mParameters.entitySetName
394
- )
367
+ CommonUtils.getTranslatedText("C_TRANSACTION_HELPER_DELETE_TOAST_PLURAL", oResourceBundle, null, mParameters.entitySetName)
395
368
  );
396
369
  }
397
370
  }
@@ -400,20 +373,18 @@ class TransactionHelper {
400
373
  *
401
374
  * @memberof sap.fe.core.TransactionHelper
402
375
  * @static
403
- * @param {sap.ui.model.odata.v4.Context} vContexts Contexts Either one context or an array with contexts to be deleted
404
- * @param {object} mParameters Optional, can contain the following attributes:
405
- * @param {string} mParameters.title Title of the object to be deleted
406
- * @param {string} mParameters.description Description of the object to be deleted
407
- * @param {integer} mParameters.numberOfSelectedContexts Number of objects selected
408
- * @param {boolean} mParameters.noDialog To disable the confirmation dialog
376
+ * @param vInContexts Contexts Either one context or an array with contexts to be deleted
377
+ * @param mParameters Optional, can contain the following attributes:
378
+ * @param mParameters.title Title of the object to be deleted
379
+ * @param mParameters.description Description of the object to be deleted
380
+ * @param mParameters.numberOfSelectedContexts Number of objects selected
381
+ * @param mParameters.noDialog To disable the confirmation dialog
409
382
  * @param oResourceBundle
410
383
  * @param messageHandler
411
- * @returns {Promise}
384
+ * @returns A Promise resolved once the document are deleted
412
385
  */
413
- deleteDocument(vContexts: any, mParameters: any, oResourceBundle: any, messageHandler: any) {
414
- let fnReject: Function,
415
- fnResolve: Function,
416
- aDeletableContexts: any[] = [],
386
+ deleteDocument(vInContexts: V4Context, mParameters: any, oResourceBundle: any, messageHandler: any) {
387
+ let aDeletableContexts: any[] = [],
417
388
  isCheckBoxVisible = false,
418
389
  isLockedTextVisible = false,
419
390
  cannotBeDeletedTextVisible = false,
@@ -421,18 +392,23 @@ class TransactionHelper {
421
392
  bDialogConfirmed = false;
422
393
  // eslint-disable-next-line @typescript-eslint/no-this-alias
423
394
  const that = this,
424
- oResourceBundleCore = (Core as CoreEx).getLibraryResourceBundle("sap.fe.core") as ResourceBundle;
395
+ oResourceBundleCore = (Core as CoreEx).getLibraryResourceBundle("sap.fe.core");
425
396
  let aParams;
426
397
  let oDeleteMessage: any = {
427
- title: oResourceBundleCore.getText("C_COMMON_OBJECT_PAGE_DELETE")
398
+ title: oResourceBundleCore.getText("C_COMMON_DELETE")
428
399
  };
429
400
  messageHandling.removeBoundTransitionMessages();
430
401
  BusyLocker.lock(this.oLockObject);
431
- if (!Array.isArray(vContexts)) {
432
- vContexts = [vContexts];
402
+ let vContexts: V4Context[];
403
+ if (Array.isArray(vInContexts)) {
404
+ vContexts = vInContexts;
405
+ } else {
406
+ vContexts = [vInContexts];
433
407
  }
434
- Promise.resolve(this.getProgrammingModel(vContexts[0]))
435
- .then(function (sProgrammingModel: any) {
408
+
409
+ return new Promise<void>((resolve, reject) => {
410
+ try {
411
+ const sProgrammingModel = this.getProgrammingModel(vContexts[0]);
436
412
  if (mParameters) {
437
413
  if (!mParameters.numberOfSelectedContexts) {
438
414
  if (sProgrammingModel === ProgrammingModel.Draft) {
@@ -445,14 +421,21 @@ class TransactionHelper {
445
421
  oContextData.DraftAdministrativeData.InProcessByUser &&
446
422
  !oContextData.DraftAdministrativeData.DraftIsCreatedByMe
447
423
  ) {
424
+ let sLockedUser = "";
425
+ const draftAdminData = oContextData && oContextData.DraftAdministrativeData;
426
+ if (draftAdminData) {
427
+ sLockedUser = draftAdminData["InProcessByUser"];
428
+ }
429
+ aParams = [sLockedUser];
448
430
  MessageBox.show(
449
431
  CommonUtils.getTranslatedText(
450
- "C_TRANSACTION_HELPER_OBJECT_PAGE_CONFIRM_DELETE_WITH_SINGLE_OBJECT_LOCKED",
451
- oResourceBundle
432
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_SINGLE_OBJECT_LOCKED",
433
+ oResourceBundle,
434
+ aParams
452
435
  ),
453
436
  {
454
- title: oResourceBundleCore.getText("C_COMMON_OBJECT_PAGE_DELETE"),
455
- onClose: fnReject
437
+ title: oResourceBundleCore.getText("C_COMMON_DELETE"),
438
+ onClose: reject
456
439
  }
457
440
  );
458
441
  return;
@@ -462,35 +445,72 @@ class TransactionHelper {
462
445
  mParameters = getParameters(mParameters);
463
446
  if (mParameters.title) {
464
447
  if (mParameters.description) {
465
- aParams = [mParameters.title, mParameters.description];
448
+ aParams = [mParameters.title + " ", mParameters.description];
466
449
  } else {
467
450
  aParams = [mParameters.title, ""];
468
451
  }
469
452
  oDeleteMessage.text = CommonUtils.getTranslatedText(
470
- "C_TRANSACTION_HELPER_OBJECT_PAGE_CONFIRM_DELETE_WITH_OBJECTINFO",
453
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTINFO",
471
454
  oResourceBundle,
472
455
  aParams,
473
456
  mParameters.entitySetName
474
457
  );
475
458
  } else {
476
459
  oDeleteMessage.text = CommonUtils.getTranslatedText(
477
- "C_TRANSACTION_HELPER_OBJECT_PAGE_CONFIRM_DELETE_WITH_OBJECTTITLE_SINGULAR",
460
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTTITLE_SINGULAR",
478
461
  oResourceBundle
479
462
  );
480
463
  }
481
464
  aDeletableContexts = vContexts;
482
465
  } else {
483
466
  oDeleteMessage = {
484
- title: oResourceBundleCore.getText("C_COMMON_OBJECT_PAGE_DELETE")
467
+ title: oResourceBundleCore.getText("C_COMMON_DELETE")
485
468
  };
486
469
  if (mParameters.numberOfSelectedContexts === 1 && mParameters.numberOfSelectedContexts === vContexts.length) {
487
470
  aDeletableContexts = vContexts;
488
- oDeleteMessage.text = CommonUtils.getTranslatedText(
489
- "C_TRANSACTION_HELPER_OBJECT_PAGE_CONFIRM_DELETE_WITH_OBJECTTITLE_SINGULAR",
490
- oResourceBundle,
491
- null,
492
- mParameters.entitySetName
493
- );
471
+ const oLineContextData = vContexts[0].getObject();
472
+ const oTable = mParameters.parentControl;
473
+ const sKey = oTable && oTable.getParent().getIdentifierColumn();
474
+ if (sKey) {
475
+ const sKeyValue = sKey ? oLineContextData[sKey] : undefined;
476
+ const sDescription =
477
+ mParameters.description && mParameters.description.path
478
+ ? oLineContextData[mParameters.description.path]
479
+ : undefined;
480
+ if (sKeyValue) {
481
+ if (sDescription) {
482
+ aParams = [sKeyValue + " ", sDescription];
483
+ } else {
484
+ aParams = [sKeyValue, ""];
485
+ }
486
+ oDeleteMessage.text = CommonUtils.getTranslatedText(
487
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTINFO",
488
+ oResourceBundle,
489
+ aParams,
490
+ mParameters.entitySetName
491
+ );
492
+ } else if (sKeyValue) {
493
+ aParams = [sKeyValue, ""];
494
+ oDeleteMessage.text = CommonUtils.getTranslatedText(
495
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTINFO",
496
+ oResourceBundle,
497
+ aParams,
498
+ mParameters.entitySetName
499
+ );
500
+ } else {
501
+ oDeleteMessage.text = CommonUtils.getTranslatedText(
502
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTTITLE_SINGULAR",
503
+ oResourceBundle
504
+ );
505
+ }
506
+ } else {
507
+ oDeleteMessage.text = CommonUtils.getTranslatedText(
508
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTTITLE_SINGULAR",
509
+ oResourceBundle,
510
+ null,
511
+ mParameters.entitySetName
512
+ );
513
+ }
494
514
  } else if (mParameters.numberOfSelectedContexts === 1 && mParameters.unSavedContexts.length === 1) {
495
515
  //only one unsaved object
496
516
  aDeletableContexts = mParameters.unSavedContexts;
@@ -502,7 +522,7 @@ class TransactionHelper {
502
522
  }
503
523
  aParams = [sLastChangedByUser];
504
524
  oDeleteMessage.text = CommonUtils.getTranslatedText(
505
- "C_TRANSACTION_HELPER_OBJECT_PAGE_CONFIRM_DELETE_WITH_UNSAVED_CHANGES",
525
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_UNSAVED_CHANGES",
506
526
  oResourceBundle,
507
527
  aParams
508
528
  );
@@ -510,7 +530,7 @@ class TransactionHelper {
510
530
  //only multiple unsaved objects
511
531
  aDeletableContexts = mParameters.unSavedContexts;
512
532
  oDeleteMessage.text = CommonUtils.getTranslatedText(
513
- "C_TRANSACTION_HELPER_OBJECT_PAGE_CONFIRM_DELETE_WITH_UNSAVED_CHANGES_MULTIPLE_OBJECTS",
533
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_UNSAVED_CHANGES_MULTIPLE_OBJECTS",
514
534
  oResourceBundle
515
535
  );
516
536
  } else if (
@@ -522,13 +542,13 @@ class TransactionHelper {
522
542
  oDeleteMessage.text =
523
543
  aDeletableContexts.length === 1
524
544
  ? CommonUtils.getTranslatedText(
525
- "C_TRANSACTION_HELPER_OBJECT_PAGE_CONFIRM_DELETE_WITH_OBJECTTITLE_SINGULAR",
545
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTTITLE_SINGULAR",
526
546
  oResourceBundle,
527
547
  null,
528
548
  mParameters.entitySetName
529
549
  )
530
550
  : CommonUtils.getTranslatedText(
531
- "C_TRANSACTION_HELPER_OBJECT_PAGE_CONFIRM_DELETE_WITH_OBJECTTITLE_PLURAL",
551
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTTITLE_PLURAL",
532
552
  oResourceBundle,
533
553
  null,
534
554
  mParameters.entitySetName
@@ -540,31 +560,24 @@ class TransactionHelper {
540
560
  oDeleteMessage.text =
541
561
  aDeletableContexts.length === 1
542
562
  ? CommonUtils.getTranslatedText(
543
- "C_TRANSACTION_HELPER_OBJECT_PAGE_CONFIRM_DELETE_WITH_OBJECTTITLE_SINGULAR_NON_DELETABLE",
563
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTTITLE_SINGULAR_NON_DELETABLE",
544
564
  oResourceBundle,
545
565
  null,
546
566
  mParameters.entitySetName
547
567
  )
548
568
  : CommonUtils.getTranslatedText(
549
- "C_TRANSACTION_HELPER_OBJECT_PAGE_CONFIRM_DELETE_WITH_OBJECTTITLE_PLURAL_NON_DELETABLE",
569
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTTITLE_PLURAL_NON_DELETABLE",
550
570
  oResourceBundle,
551
- null,
571
+ [aDeletableContexts.length],
552
572
  mParameters.entitySetName
553
573
  );
554
- oDeleteMessage.nonDeletableText = CommonUtils.getTranslatedText(
555
- "C_TRANSACTION_HELPER_OBJECT_PAGE_CONFIRM_DELETE_WITH_OBJECTINFO_AND_FEW_OBJECTS_NON_DELETABLE",
556
- oResourceBundle,
557
- [
558
- mParameters.numberOfSelectedContexts - vContexts.concat(mParameters.unSavedContexts).length,
559
- mParameters.numberOfSelectedContexts
560
- ]
561
- );
574
+ oDeleteMessage.nonDeletableText = that._getNonDeletableText(mParameters, vContexts, oResourceBundle);
562
575
  }
563
576
  if (mParameters.lockedContexts.length == 1) {
564
577
  //setting the locked text if locked objects exist
565
578
  isLockedTextVisible = true;
566
579
  oDeleteMessage.nonDeletableText = CommonUtils.getTranslatedText(
567
- "C_TRANSACTION_HELPER_OBJECT_PAGE_CONFIRM_DELETE_WITH_OBJECTINFO_AND_ONE_OBJECT_LOCKED",
580
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTINFO_AND_ONE_OBJECT_LOCKED",
568
581
  oResourceBundle,
569
582
  [mParameters.numberOfSelectedContexts]
570
583
  );
@@ -573,7 +586,7 @@ class TransactionHelper {
573
586
  //setting the locked text if locked objects exist
574
587
  isLockedTextVisible = true;
575
588
  oDeleteMessage.nonDeletableText = CommonUtils.getTranslatedText(
576
- "C_TRANSACTION_HELPER_OBJECT_PAGE_CONFIRM_DELETE_WITH_OBJECTINFO_AND_FEW_OBJECTS_LOCKED",
589
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTINFO_AND_FEW_OBJECTS_LOCKED",
577
590
  oResourceBundle,
578
591
  [mParameters.lockedContexts.length, mParameters.numberOfSelectedContexts]
579
592
  );
@@ -591,24 +604,24 @@ class TransactionHelper {
591
604
  aDeletableContexts = mParameters.unSavedContexts;
592
605
  if (mParameters.unSavedContexts.length === 1) {
593
606
  oDeleteMessage.text = CommonUtils.getTranslatedText(
594
- "C_TRANSACTION_HELPER_OBJECT_PAGE_CONFIRM_DELETE_WITH_UNSAVED_AND_FEW_OBJECTS_LOCKED_SINGULAR",
607
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_UNSAVED_AND_FEW_OBJECTS_LOCKED_SINGULAR",
595
608
  oResourceBundle
596
609
  );
597
610
  } else {
598
611
  oDeleteMessage.text = CommonUtils.getTranslatedText(
599
- "C_TRANSACTION_HELPER_OBJECT_PAGE_CONFIRM_DELETE_WITH_UNSAVED_AND_FEW_OBJECTS_LOCKED_PLURAL",
612
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_UNSAVED_AND_FEW_OBJECTS_LOCKED_PLURAL",
600
613
  oResourceBundle
601
614
  );
602
615
  }
603
616
  } else {
604
617
  if (mParameters.unSavedContexts.length === 1) {
605
618
  oDeleteMessage.checkBoxText = CommonUtils.getTranslatedText(
606
- "C_TRANSACTION_HELPER_OBJECT_PAGE_CONFIRM_DELETE_WITH_OBJECTINFO_AND_FEW_OBJECTS_UNSAVED_SINGULAR",
619
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTINFO_AND_FEW_OBJECTS_UNSAVED_SINGULAR",
607
620
  oResourceBundle
608
621
  );
609
622
  } else {
610
623
  oDeleteMessage.checkBoxText = CommonUtils.getTranslatedText(
611
- "C_TRANSACTION_HELPER_OBJECT_PAGE_CONFIRM_DELETE_WITH_OBJECTINFO_AND_FEW_OBJECTS_UNSAVED_PLURAL",
624
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTINFO_AND_FEW_OBJECTS_UNSAVED_PLURAL",
612
625
  oResourceBundle
613
626
  );
614
627
  }
@@ -616,31 +629,28 @@ class TransactionHelper {
616
629
  }
617
630
  }
618
631
  if (cannotBeDeletedTextVisible && isLockedTextVisible) {
632
+ //if non-deletable objects exist along with deletable objects
633
+ const sNonDeletableContextText = that._getNonDeletableText(mParameters, vContexts, oResourceBundle);
619
634
  //if both locked and non-deletable objects exist along with deletable objects
620
635
  if (mParameters.unSavedContexts.length > 1) {
621
- oDeleteMessage.nonDeletableText = CommonUtils.getTranslatedText(
622
- "C_TRANSACTION_HELPER_OBJECT_PAGE_CONFIRM_DELETE_WITH_OBJECTINFO_AND_FEW_OBJECTS_LOCKED_AND_NON_DELETABLE",
623
- oResourceBundle,
624
- [
625
- mParameters.numberOfSelectedContexts -
626
- vContexts.concat(mParameters.unSavedContexts).length -
627
- mParameters.lockedContexts.length,
628
- mParameters.lockedContexts.length,
629
- mParameters.numberOfSelectedContexts
630
- ]
631
- );
636
+ oDeleteMessage.nonDeletableText =
637
+ sNonDeletableContextText +
638
+ " " +
639
+ CommonUtils.getTranslatedText(
640
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTINFO_AND_FEW_OBJECTS_LOCKED",
641
+ oResourceBundle,
642
+ [mParameters.lockedContexts.length, mParameters.numberOfSelectedContexts]
643
+ );
632
644
  }
633
645
  if (mParameters.unSavedContexts.length == 1) {
634
- oDeleteMessage.nonDeletableText = CommonUtils.getTranslatedText(
635
- "C_TRANSACTION_HELPER_OBJECT_PAGE_CONFIRM_DELETE_WITH_OBJECTINFO_AND_ONE_OBJECT_LOCKED_AND_NON_DELETABLE",
636
- oResourceBundle,
637
- [
638
- mParameters.numberOfSelectedContexts -
639
- vContexts.concat(mParameters.unSavedContexts).length -
640
- mParameters.lockedContexts.length,
641
- mParameters.numberOfSelectedContexts
642
- ]
643
- );
646
+ oDeleteMessage.nonDeletableText =
647
+ sNonDeletableContextText +
648
+ " " +
649
+ CommonUtils.getTranslatedText(
650
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTINFO_AND_ONE_OBJECT_LOCKED",
651
+ oResourceBundle,
652
+ [mParameters.numberOfSelectedContexts]
653
+ );
644
654
  }
645
655
  }
646
656
  }
@@ -672,60 +682,55 @@ class TransactionHelper {
672
682
  })
673
683
  ]
674
684
  });
675
- const sTitle = oResourceBundleCore.getText("C_COMMON_OBJECT_PAGE_DELETE");
676
- const fnConfirm = function () {
685
+ const sTitle = oResourceBundleCore.getText("C_COMMON_DELETE");
686
+ const fnConfirm = async function () {
677
687
  bDialogConfirmed = true;
678
688
  BusyLocker.lock(that.oLockObject);
679
689
  const aContexts = aDeletableContexts;
680
- let onBeforeDeletePromise;
681
- if (mParameters.beforeDeleteCallBack) {
682
- onBeforeDeletePromise = mParameters.beforeDeleteCallBack({ contexts: aContexts });
683
- } else {
684
- onBeforeDeletePromise = Promise.resolve();
685
- }
686
- return onBeforeDeletePromise
687
- .then(that.findActiveDraftRootContexts.bind(that, aContexts, mParameters.bFindActiveContexts))
688
- .then(function (activeContexts: any) {
689
- //make sure to fetch the active contexts before deleting the drafts
690
- return Promise.all(
690
+
691
+ try {
692
+ if (mParameters.beforeDeleteCallBack) {
693
+ await mParameters.beforeDeleteCallBack({ contexts: aContexts });
694
+ }
695
+ const activeContexts = await that.findActiveDraftRootContexts(aContexts, mParameters.bFindActiveContexts);
696
+
697
+ try {
698
+ await Promise.all(
691
699
  aContexts.map(function (oContext: any) {
692
700
  //delete the draft
693
701
  const bEnableStrictHandling = aContexts.length === 1 ? true : false;
694
- return draft.deleteDraft(oContext, bEnableStrictHandling);
702
+ return draft.deleteDraft(oContext, that._oAppComponent, bEnableStrictHandling);
695
703
  })
696
- )
697
- .catch(function (oError: any) {
698
- return messageHandler.showMessages().then(function () {
699
- // re-throw error to enforce rejecting the general promise
700
- throw oError;
701
- });
704
+ );
705
+ } catch (oError: any) {
706
+ await messageHandler.showMessages();
707
+ // re-throw error to enforce rejecting the general promise
708
+ throw oError;
709
+ }
710
+ const checkBox = {
711
+ "isCheckBoxVisible": isCheckBoxVisible,
712
+ "isCheckBoxSelected": isCheckBoxSelected
713
+ };
714
+ if (activeContexts && activeContexts.length) {
715
+ await Promise.all(
716
+ activeContexts.map(function (oContext: any) {
717
+ return oContext.delete();
702
718
  })
703
- .then(function () {
704
- const checkBox = {
705
- "isCheckBoxVisible": isCheckBoxVisible,
706
- "isCheckBoxSelected": isCheckBoxSelected
707
- };
708
- if (activeContexts && activeContexts.length) {
709
- return Promise.all(
710
- activeContexts.map(function (oContext: any) {
711
- return oContext.delete();
712
- })
713
- ).then(function () {
714
- that.afterDeleteProcess(mParameters, checkBox, aContexts, oResourceBundle);
715
- return messageHandler.showMessageDialog().then(fnResolve);
716
- });
717
- } else {
718
- that.afterDeleteProcess(mParameters, checkBox, aContexts, oResourceBundle);
719
- return messageHandler.showMessageDialog().then(fnResolve);
720
- }
721
- });
722
- })
723
- .catch(function () {
724
- fnReject();
725
- })
726
- .finally(function () {
727
- BusyLocker.unlock(that.oLockObject);
728
- });
719
+ );
720
+
721
+ that.afterDeleteProcess(mParameters, checkBox, aContexts, oResourceBundle);
722
+ await messageHandler.showMessageDialog();
723
+ resolve();
724
+ } else {
725
+ that.afterDeleteProcess(mParameters, checkBox, aContexts, oResourceBundle);
726
+ await messageHandler.showMessageDialog();
727
+ resolve();
728
+ }
729
+ } catch (oError: any) {
730
+ reject();
731
+ } finally {
732
+ BusyLocker.unlock(that.oLockObject);
733
+ }
729
734
  };
730
735
  const oDialog = new Dialog({
731
736
  title: sTitle,
@@ -735,11 +740,11 @@ class TransactionHelper {
735
740
  ? [oNonDeletableMessageTextControl, oDeleteMessageTextControl]
736
741
  : oDeleteMessageTextControl,
737
742
  beginButton: new Button({
738
- text: oResourceBundleCore.getText("C_COMMON_OBJECT_PAGE_DELETE"),
743
+ text: oResourceBundleCore.getText("C_COMMON_DELETE"),
739
744
  type: "Emphasized",
740
745
  press: function () {
741
746
  oDialog.close();
742
- return fnConfirm();
747
+ fnConfirm();
743
748
  }
744
749
  }),
745
750
  endButton: new Button({
@@ -752,27 +757,19 @@ class TransactionHelper {
752
757
  oDialog.destroy();
753
758
  // if dialog is closed unconfirmed (e.g. via "Cancel" or Escape button), ensure to reject promise
754
759
  if (!bDialogConfirmed) {
755
- fnReject();
760
+ reject();
756
761
  }
757
762
  }
758
763
  } as any);
759
764
  if (mParameters.noDialog) {
760
- return fnConfirm();
765
+ fnConfirm();
761
766
  } else {
762
767
  oDialog.addStyleClass("sapUiContentPadding");
763
768
  oDialog.open();
764
769
  }
765
- })
766
- .finally(function () {
770
+ } finally {
767
771
  BusyLocker.unlock(that.oLockObject);
768
- })
769
- .catch(function () {
770
- Log.warning("Couldn't get Programming model");
771
- fnReject();
772
- });
773
- return new Promise(function (resolve: (value: any) => void, reject: (reason?: any) => void) {
774
- fnReject = reject;
775
- fnResolve = resolve;
772
+ }
776
773
  });
777
774
  }
778
775
  /**
@@ -780,260 +777,210 @@ class TransactionHelper {
780
777
  *
781
778
  * @memberof sap.fe.core.TransactionHelper
782
779
  * @static
783
- * @param {sap.ui.model.odata.v4.Context} oContext Context of the active document
784
- * @param {object} oView Current view
780
+ * @param oContext Context of the active document
781
+ * @param oView Current view
785
782
  * @param messageHandler
786
- * @returns {Promise} Promise resolves with the new draft context in case of draft programming model
783
+ * @returns Promise resolves with the new draft context in case of draft programming model
787
784
  * @ui5-restricted
788
785
  * @final
789
786
  */
790
- editDocument(oContext: any, oView: object, messageHandler: any) {
787
+ async editDocument(oContext: V4Context, oView: View, messageHandler: any): Promise<V4Context> {
791
788
  // eslint-disable-next-line @typescript-eslint/no-this-alias
792
789
  const that = this;
793
790
  const sProgrammingModel = this.getProgrammingModel(oContext);
794
- let oEditPromise;
795
791
  if (!oContext) {
796
- return Promise.reject(new Error("Binding context to active document is required"));
792
+ throw new Error("Binding context to active document is required");
793
+ }
794
+ if (sProgrammingModel !== ProgrammingModel.Draft && sProgrammingModel !== ProgrammingModel.Sticky) {
795
+ throw new Error("Edit is only allowed for draft or sticky session supported services");
797
796
  }
798
797
  this._bIsModified = false;
799
798
  BusyLocker.lock(that.oLockObject);
800
799
  // before triggering the edit action we'll have to remove all bound transition messages
801
800
  messageHandler.removeTransitionMessages();
802
- if (sProgrammingModel === ProgrammingModel.Draft) {
803
- oEditPromise = draft.createDraftFromActiveDocument(oContext, this._getAppComponent(), {
804
- bPreserveChanges: true,
805
- oView: oView
806
- } as any);
807
- } else if (sProgrammingModel === ProgrammingModel.Sticky) {
808
- oEditPromise = sticky.editDocumentInStickySession(oContext, this._getAppComponent());
809
- } else {
801
+
802
+ try {
803
+ const oNewContext: V4Context =
804
+ sProgrammingModel === ProgrammingModel.Draft
805
+ ? await draft.createDraftFromActiveDocument(oContext, this._getAppComponent(), {
806
+ bPreserveChanges: true,
807
+ oView: oView
808
+ } as any)
809
+ : await sticky.editDocumentInStickySession(oContext, this._getAppComponent());
810
+
811
+ this._bCreateMode = false;
812
+ await messageHandler.showMessageDialog();
813
+ return oNewContext;
814
+ } catch (err: any) {
815
+ await messageHandler.showMessages({ concurrentEditFlag: true });
816
+ throw err;
817
+ } finally {
810
818
  BusyLocker.unlock(that.oLockObject);
811
- return Promise.reject(new Error("Edit is only allowed for draft or sticky session supported services"));
812
819
  }
813
- return oEditPromise
814
- .then(function (oNewContext: any) {
815
- that._bCreateMode = false;
816
- return messageHandler.showMessageDialog().then(function () {
817
- return oNewContext;
818
- });
819
- })
820
- .catch(function (err: any) {
821
- return messageHandler.showMessages({ concurrentEditFlag: true }).then(function () {
822
- return Promise.reject(err);
823
- });
824
- })
825
- .finally(function () {
826
- BusyLocker.unlock(that.oLockObject);
827
- });
828
820
  }
829
821
  /**
830
822
  * Cancel 'edit' mode of a document.
831
823
  *
832
824
  * @memberof sap.fe.core.TransactionHelper
833
825
  * @static
834
- * @param {sap.ui.model.odata.v4.Context} oContext Context of the document to be canceled or deleted
835
- * @param {object} [mInParameters] Optional, can contain the following attributes:
836
- * @param {sap.m.Button} mInParameters.cancelButton Cancel Button of the discard popover (mandatory for now)
837
- * @param {boolean} mInParameters.skipDiscardPopover Optional, supresses the discard popover incase of draft applications while navigating out of OP
826
+ * @param oContext Context of the document to be canceled or deleted
827
+ * @param [mInParameters] Optional, can contain the following attributes:
828
+ * @param mInParameters.cancelButton Cancel Button of the discard popover (mandatory for now)
829
+ * @param mInParameters.skipDiscardPopover Optional, supresses the discard popover incase of draft applications while navigating out of OP
838
830
  * @param oResourceBundle
839
831
  * @param messageHandler
840
- * @returns {Promise} Promise resolves with ???
832
+ * @returns Promise resolves with ???
841
833
  * @ui5-restricted
842
834
  * @final
843
835
  */
844
- cancelDocument(
845
- oContext: any,
836
+ async cancelDocument(
837
+ oContext: V4Context,
846
838
  mInParameters: { cancelButton: any; skipDiscardPopover: boolean } | undefined,
847
839
  oResourceBundle: any,
848
840
  messageHandler: any
849
- ) {
850
- // eslint-disable-next-line @typescript-eslint/no-this-alias
851
- const that = this;
852
- let sProgrammingModel: typeof ProgrammingModel;
841
+ ): Promise<V4Context | boolean> {
853
842
  //context must always be passed - mandatory parameter
854
843
  if (!oContext) {
855
- return Promise.reject("No context exists. Pass a meaningful context");
844
+ throw new Error("No context exists. Pass a meaningful context");
856
845
  }
857
- BusyLocker.lock(that.oLockObject);
846
+ BusyLocker.lock(this.oLockObject);
858
847
  const mParameters = getParameters(mInParameters);
859
- const oParamsContext = oContext,
860
- oCancelButton = mParameters.cancelButton,
861
- oModel = oParamsContext.getModel();
862
- let onBeforeCancelPromise, sCanonicalPath: string;
863
- return Promise.resolve(this.getProgrammingModel(oContext))
864
- .then(function (sPModel: any) {
865
- sProgrammingModel = sPModel;
866
- if (sPModel === ProgrammingModel.Draft) {
867
- const draftDataContext = oModel.bindContext(oParamsContext.getPath() + "/DraftAdministrativeData").getBoundContext();
868
- if (!that._bIsModified) {
869
- return draftDataContext.requestObject().then(function (draftAdminData: any) {
870
- if (draftAdminData) {
871
- that._bIsModified = !(draftAdminData.CreationDateTime === draftAdminData.LastChangeDateTime);
872
- }
873
- });
848
+ const oModel = oContext.getModel();
849
+ const sProgrammingModel = this.getProgrammingModel(oContext);
850
+
851
+ try {
852
+ let returnedValue: V4Context | boolean = false;
853
+
854
+ if (sProgrammingModel === ProgrammingModel.Draft) {
855
+ const draftDataContext = oModel.bindContext(`${oContext.getPath()}/DraftAdministrativeData`).getBoundContext();
856
+ if (!this._bIsModified) {
857
+ const draftAdminData = await draftDataContext.requestObject();
858
+ if (draftAdminData) {
859
+ this._bIsModified = !(draftAdminData.CreationDateTime === draftAdminData.LastChangeDateTime);
874
860
  }
875
861
  }
876
- })
877
- .then(function () {
878
- if (!mParameters.skipDiscardPopover) {
879
- return that._showDiscardPopover(oCancelButton, that._bIsModified, oResourceBundle);
880
- } else {
881
- return Promise.resolve();
882
- }
883
- })
884
- .then(function () {
885
- if (mParameters.beforeCancelCallBack) {
886
- onBeforeCancelPromise = mParameters.beforeCancelCallBack({ context: oContext });
887
- } else {
888
- onBeforeCancelPromise = Promise.resolve();
889
- }
890
- return onBeforeCancelPromise;
891
- })
892
- .then(function () {
893
- // eslint-disable-next-line default-case
894
- switch (sProgrammingModel) {
895
- case ProgrammingModel.Draft:
896
- return oParamsContext.requestObject("HasActiveEntity").then(function (bHasActiveEntity: any) {
897
- let oDeletePromise;
898
- if (!bHasActiveEntity) {
899
- if (oParamsContext && oParamsContext.hasPendingChanges()) {
900
- oParamsContext.getBinding().resetChanges();
901
- }
902
- oDeletePromise = draft.deleteDraft(oParamsContext);
903
- return oDeletePromise;
904
- } else {
905
- let oActiveContext = oModel.bindContext(oParamsContext.getPath() + "/SiblingEntity").getBoundContext();
906
- return oActiveContext
907
- .requestCanonicalPath()
908
- .then(
909
- function (sPath: any) {
910
- sCanonicalPath = sPath;
911
- if (oParamsContext && oParamsContext.hasPendingChanges()) {
912
- oParamsContext.getBinding().resetChanges();
913
- }
914
- oDeletePromise = draft.deleteDraft(oParamsContext);
915
- return oDeletePromise;
916
- },
917
- function () {
918
- draft.deleteDraft(oParamsContext);
919
- return;
920
- }
921
- )
922
- .then(function () {
923
- //oParamsContext.delete() in the previous promise doesnt return anything upon success.
924
- if (!sCanonicalPath) {
925
- return;
926
- }
927
- if (oActiveContext.getPath() !== sCanonicalPath) {
928
- // the active context is using the sibling entity - this path is not accessible anymore as we deleted the draft
929
- // document - therefore we need to create a new context with the canonical path
930
- oActiveContext = oModel.bindContext(sCanonicalPath).getBoundContext();
931
- }
932
- return oActiveContext;
933
- });
934
- }
935
- });
936
- case ProgrammingModel.Sticky:
937
- return sticky.discardDocument(oContext).then(function (oContext: any) {
938
- if (oContext) {
939
- if (oContext.hasPendingChanges()) {
940
- oContext.getBinding().resetChanges();
941
- }
942
- if (!that._bCreateMode) {
943
- oContext.refresh();
944
- return oContext;
945
- }
862
+ }
863
+ if (!mParameters.skipDiscardPopover) {
864
+ await this._showDiscardPopover(mParameters.cancelButton, this._bIsModified, oResourceBundle);
865
+ }
866
+ if (mParameters.beforeCancelCallBack) {
867
+ await mParameters.beforeCancelCallBack({ context: oContext });
868
+ }
869
+ switch (sProgrammingModel) {
870
+ case ProgrammingModel.Draft:
871
+ const bHasActiveEntity = await oContext.requestObject("HasActiveEntity");
872
+ if (!bHasActiveEntity) {
873
+ if (oContext && oContext.hasPendingChanges()) {
874
+ oContext.getBinding().resetChanges();
875
+ }
876
+ returnedValue = await draft.deleteDraft(oContext, this._oAppComponent);
877
+ } else {
878
+ const oSiblingContext = oModel.bindContext(`${oContext.getPath()}/SiblingEntity`).getBoundContext();
879
+ try {
880
+ const sCanonicalPath = await oSiblingContext.requestCanonicalPath();
881
+ if (oContext && oContext.hasPendingChanges()) {
882
+ oContext.getBinding().resetChanges();
946
883
  }
947
- return false;
948
- });
949
- default:
950
- return Promise.reject("Cancel document only allowed for draft or sticky session supported services");
951
- }
952
- })
953
- .then(function (context: any) {
954
- that._bIsModified = false;
955
- // remove existing bound transition messages
956
- messageHandler.removeTransitionMessages();
957
- // show unbound messages
958
- return messageHandler.showMessages().then(function () {
959
- return context;
960
- });
961
- })
962
- .catch(function (err: any) {
963
- return messageHandler.showMessages().then(function () {
964
- return Promise.reject(err);
965
- });
966
- })
967
- .finally(function () {
968
- BusyLocker.unlock(that.oLockObject);
969
- });
884
+ returnedValue = oModel.bindContext(sCanonicalPath).getBoundContext();
885
+ } finally {
886
+ await draft.deleteDraft(oContext, this._oAppComponent);
887
+ }
888
+ }
889
+ break;
890
+
891
+ case ProgrammingModel.Sticky:
892
+ const discardedContext = await sticky.discardDocument(oContext);
893
+ if (discardedContext) {
894
+ if (discardedContext.hasPendingChanges()) {
895
+ discardedContext.getBinding().resetChanges();
896
+ }
897
+ if (!this._bCreateMode) {
898
+ discardedContext.refresh();
899
+ returnedValue = discardedContext;
900
+ }
901
+ }
902
+ break;
903
+
904
+ default:
905
+ throw new Error("Cancel document only allowed for draft or sticky session supported services");
906
+ }
907
+
908
+ this._bIsModified = false;
909
+ // remove existing bound transition messages
910
+ messageHandler.removeTransitionMessages();
911
+ // show unbound messages
912
+ await messageHandler.showMessages();
913
+ return returnedValue;
914
+ } catch (err: any) {
915
+ await messageHandler.showMessages();
916
+ throw err;
917
+ } finally {
918
+ BusyLocker.unlock(this.oLockObject);
919
+ }
970
920
  }
921
+
971
922
  /**
972
923
  * Saves the document.
973
924
  *
974
925
  * @memberof sap.fe.core.TransactionHelper
975
926
  * @static
976
- * @param {sap.ui.model.odata.v4.Context} oContext Context of the document to be saved
927
+ * @param oContext Context of the document to be saved
977
928
  * @param oResourceBundle
978
929
  * @param bExecuteSideEffectsOnError
979
930
  * @param aBindings
980
931
  * @param messageHandler
981
- * @returns {Promise} Promise resolves with ???
932
+ * @returns Promise resolves with ???
982
933
  * @ui5-restricted
983
934
  * @final
984
935
  */
985
- saveDocument(oContext: any, oResourceBundle: any, bExecuteSideEffectsOnError: any, aBindings: any, messageHandler: any) {
986
- // eslint-disable-next-line @typescript-eslint/no-this-alias
987
- const that = this;
988
- const sProgrammingModel = this.getProgrammingModel(oContext);
989
- let oSavePromise;
936
+ async saveDocument(
937
+ oContext: V4Context,
938
+ oResourceBundle: any,
939
+ bExecuteSideEffectsOnError: any,
940
+ aBindings: any,
941
+ messageHandler: any
942
+ ): Promise<V4Context> {
990
943
  if (!oContext) {
991
944
  return Promise.reject(new Error("Binding context to draft document is required"));
992
945
  }
946
+ const sProgrammingModel = this.getProgrammingModel(oContext);
947
+ if (sProgrammingModel !== ProgrammingModel.Sticky && sProgrammingModel !== ProgrammingModel.Draft) {
948
+ throw new Error("Save is only allowed for draft or sticky session supported services");
949
+ }
993
950
  // in case of saving / activating the bound transition messages shall be removed before the PATCH/POST
994
951
  // is sent to the backend
995
952
  messageHandler.removeTransitionMessages();
996
- BusyLocker.lock(that.oLockObject);
997
- if (sProgrammingModel === ProgrammingModel.Draft) {
998
- oSavePromise = draft.activateDocument(oContext, this._getAppComponent(), {});
999
- } else if (sProgrammingModel === ProgrammingModel.Sticky) {
1000
- const bEnableStrictHandling = UriParameters.fromQuery(window.location.search).get("sap-fe-save-strict-mode") === "true";
1001
- oSavePromise = sticky.activateDocument(oContext, bEnableStrictHandling);
1002
- } else {
1003
- BusyLocker.unlock(that.oLockObject);
1004
- return Promise.reject(new Error("Save is only allowed for draft or sticky session supported services"));
1005
- }
1006
- return oSavePromise
1007
- .then(function (oActiveDocument: any) {
1008
- const bNewObject =
1009
- that.sProgrammingModel === ProgrammingModel.Sticky ? that._bCreateMode : !oContext.getObject().HasActiveEntity;
1010
- MessageToast.show(
1011
- bNewObject
1012
- ? CommonUtils.getTranslatedText("C_TRANSACTION_HELPER_OBJECT_CREATED", oResourceBundle)
1013
- : CommonUtils.getTranslatedText("C_TRANSACTION_HELPER_OBJECT_SAVED", oResourceBundle)
1014
- );
1015
- that._bIsModified = false;
1016
- return messageHandler.showMessageDialog().then(function () {
1017
- return oActiveDocument;
1018
- });
1019
- })
1020
- .catch(function (err: any) {
1021
- if (aBindings && aBindings.length > 0) {
1022
- /* The sideEffects are executed only for table items in transient state */
1023
- aBindings.forEach(function (oListBinding: any) {
1024
- if (!CommonUtils.hasTransientContext(oListBinding) && bExecuteSideEffectsOnError) {
1025
- const oAppComponent = that._getAppComponent();
1026
- oAppComponent.getSideEffectsService().requestSideEffectsForNavigationProperty(oListBinding.getPath(), oContext);
1027
- }
1028
- });
1029
- }
1030
- return messageHandler.showMessages().then(function () {
1031
- return Promise.reject(err);
953
+
954
+ try {
955
+ BusyLocker.lock(this.oLockObject);
956
+ const oActiveDocument =
957
+ sProgrammingModel === ProgrammingModel.Draft
958
+ ? await draft.activateDocument(oContext, this._getAppComponent(), {}, messageHandler)
959
+ : await sticky.activateDocument(oContext, this._getAppComponent());
960
+
961
+ const bNewObject = sProgrammingModel === ProgrammingModel.Sticky ? this._bCreateMode : !oContext.getObject().HasActiveEntity;
962
+ MessageToast.show(
963
+ bNewObject
964
+ ? CommonUtils.getTranslatedText("C_TRANSACTION_HELPER_OBJECT_CREATED", oResourceBundle)
965
+ : CommonUtils.getTranslatedText("C_TRANSACTION_HELPER_OBJECT_SAVED", oResourceBundle)
966
+ );
967
+ this._bIsModified = false;
968
+ return oActiveDocument;
969
+ } catch (err: any) {
970
+ if (aBindings && aBindings.length > 0) {
971
+ /* The sideEffects are executed only for table items in transient state */
972
+ aBindings.forEach((oListBinding: any) => {
973
+ if (!CommonUtils.hasTransientContext(oListBinding) && bExecuteSideEffectsOnError) {
974
+ const oAppComponent = this._getAppComponent();
975
+ oAppComponent.getSideEffectsService().requestSideEffectsForNavigationProperty(oListBinding.getPath(), oContext);
976
+ }
1032
977
  });
1033
- })
1034
- .finally(function () {
1035
- BusyLocker.unlock(that.oLockObject);
1036
- });
978
+ }
979
+ await messageHandler.showMessages();
980
+ throw err;
981
+ } finally {
982
+ BusyLocker.unlock(this.oLockObject);
983
+ }
1037
984
  }
1038
985
  /**
1039
986
  * Calls a bound or unbound action.
@@ -1042,27 +989,27 @@ class TransactionHelper {
1042
989
  * @static
1043
990
  * @name sap.fe.core.TransactionHelper.callAction
1044
991
  * @memberof sap.fe.core.TransactionHelper
1045
- * @param {string} sActionName The name of the action to be called
1046
- * @param {map} [mParameters] Contains the following attributes:
1047
- * @param {sap.ui.model.odata.v4.Context} [mParameters.contexts] Mandatory for a bound action: Either one context or an array with contexts for which the action is to be called
1048
- * @param {sap.ui.model.odata.v4.ODataModel} [mParameters.model] Mandatory for an unbound action: An instance of an OData V4 model
1049
- * @param {string} [mParameters.invocationGrouping] Mode how actions are to be called: 'ChangeSet' to put all action calls into one changeset, 'Isolated' to put them into separate changesets
1050
- * @param {string} [mParameters.label] A human-readable label for the action
1051
- * @param {boolean} [mParameters.bGetBoundContext] If specified, the action promise returns the bound context
1052
- * @param {object} oView Contains the object of the current view
992
+ * @param sActionName The name of the action to be called
993
+ * @param [mParameters] Contains the following attributes:
994
+ * @param [mParameters.contexts] Mandatory for a bound action: Either one context or an array with contexts for which the action is to be called
995
+ * @param [mParameters.model] Mandatory for an unbound action: An instance of an OData V4 model
996
+ * @param [mParameters.invocationGrouping] Mode how actions are to be called: 'ChangeSet' to put all action calls into one changeset, 'Isolated' to put them into separate changesets
997
+ * @param [mParameters.label] A human-readable label for the action
998
+ * @param [mParameters.bGetBoundContext] If specified, the action promise returns the bound context
999
+ * @param oView Contains the object of the current view
1053
1000
  * @param messageHandler
1054
- * @returns {Promise} Promise resolves with an array of response objects (TODO: to be changed)
1001
+ * @returns Promise resolves with an array of response objects (TODO: to be changed)
1055
1002
  * @ui5-restricted
1056
1003
  * @final
1057
- **/
1058
- callAction(sActionName: string, mParameters: any, oView: View | null, messageHandler: any) {
1004
+ */
1005
+ async callAction(sActionName: string, mParameters: any, oView: View | null, messageHandler: any): Promise<any> {
1059
1006
  mParameters = getParameters(mParameters);
1060
1007
  // eslint-disable-next-line @typescript-eslint/no-this-alias
1061
1008
  const that = this;
1062
- let oContext, oModel: any, oPromise;
1009
+ let oContext, oModel: any;
1063
1010
  const mBindingParameters = mParameters.bindingParameters;
1064
1011
  if (!sActionName) {
1065
- return Promise.reject("Provide name of action to be executed");
1012
+ throw new Error("Provide name of action to be executed");
1066
1013
  }
1067
1014
  // action imports are not directly obtained from the metaModel by it is present inside the entityContainer
1068
1015
  // and the acions it refers to present outside the entitycontainer, hence to obtain kind of the action
@@ -1079,28 +1026,20 @@ class TransactionHelper {
1079
1026
  oModel = mParameters.model;
1080
1027
  }
1081
1028
  if (!oModel) {
1082
- return Promise.reject("Pass a context for a bound action or pass the model for an unbound action");
1029
+ throw new Error("Pass a context for a bound action or pass the model for an unbound action");
1083
1030
  }
1084
1031
  // get the binding parameters $select and $expand for the side effect on this action
1085
1032
  // also gather additional property paths to be requested such as text associations
1086
1033
  const oAppComponent = that._getAppComponent();
1087
1034
  const mSideEffectsParameters = oAppComponent.getSideEffectsService().getODataActionSideEffects(sActionName, oContext) || {};
1088
- if (oContext && oModel) {
1089
- oPromise = new Promise<void>(function (resolve, reject) {
1090
- let oApplicableContextDialog: Dialog;
1091
- const oController = {
1092
- onClose: function () {
1093
- // User cancels action
1094
- oApplicableContextDialog.close();
1095
- resolve();
1096
- },
1097
- onContinue: function () {
1098
- // Users continues the action with the bound contexts
1099
- oApplicableContextDialog.close();
1100
- resolve(mParameters.applicableContext);
1101
- }
1102
- };
1103
- const fnOpenAndFillDialog = function () {
1035
+
1036
+ const displayUnapplicableContextsDialog = (): Promise<V4Context[] | void> => {
1037
+ if (!mParameters.notApplicableContext || mParameters.notApplicableContext.length === 0) {
1038
+ return Promise.resolve(mParameters.contexts);
1039
+ }
1040
+
1041
+ return new Promise(async (resolve, reject) => {
1042
+ const fnOpenAndFillDialog = function (oDlg: Dialog) {
1104
1043
  let oDialogContent;
1105
1044
  const nNotApplicable = mParameters.notApplicableContext.length,
1106
1045
  aNotApplicableItems = [];
@@ -1110,52 +1049,76 @@ class TransactionHelper {
1110
1049
  }
1111
1050
  const oNotApplicableItemsModel = new JSONModel(aNotApplicableItems);
1112
1051
  const oTotals = new JSONModel({ total: nNotApplicable, label: mParameters.label });
1113
- oApplicableContextDialog.setModel(oNotApplicableItemsModel, "notApplicable");
1114
- oApplicableContextDialog.setModel(oTotals, "totals");
1115
- oApplicableContextDialog.open();
1052
+ oDlg.setModel(oNotApplicableItemsModel, "notApplicable");
1053
+ oDlg.setModel(oTotals, "totals");
1054
+ oDlg.open();
1116
1055
  };
1117
- if (mParameters.notApplicableContext && mParameters.notApplicableContext.length >= 1) {
1118
- // Show the contexts that are not applicable and will not therefore be processed
1119
- const sFragmentName = "sap.fe.core.controls.ActionPartial";
1120
- const oDialogFragment = XMLTemplateProcessor.loadTemplate(sFragmentName, "fragment");
1121
- const oMetaModel = oModel.getMetaModel();
1122
- const sCanonicalPath = mParameters.contexts[0].getCanonicalPath();
1123
- const sEntitySet = sCanonicalPath.substr(0, sCanonicalPath.indexOf("(")) + "/";
1124
- const oDialogLabelModel = new JSONModel({
1125
- title: mParameters.label
1126
- });
1127
- Promise.resolve(
1128
- XMLPreprocessor.process(
1129
- oDialogFragment,
1130
- { name: sFragmentName },
1131
- {
1132
- bindingContexts: {
1133
- entityType: oMetaModel.createBindingContext(sEntitySet),
1134
- label: oDialogLabelModel.createBindingContext("/")
1135
- },
1136
- models: {
1137
- entityType: oMetaModel,
1138
- metaModel: oMetaModel,
1139
- label: oDialogLabelModel
1140
- }
1056
+ // Show the contexts that are not applicable and will not therefore be processed
1057
+ const sFragmentName = "sap.fe.core.controls.ActionPartial";
1058
+ const oDialogFragment = XMLTemplateProcessor.loadTemplate(sFragmentName, "fragment");
1059
+ const oMetaModel = oModel.getMetaModel();
1060
+ const sCanonicalPath = mParameters.contexts[0].getCanonicalPath();
1061
+ const sEntitySet = `${sCanonicalPath.substr(0, sCanonicalPath.indexOf("("))}/`;
1062
+ const oDialogLabelModel = new JSONModel({
1063
+ title: mParameters.label
1064
+ });
1065
+
1066
+ try {
1067
+ const oFragment = await XMLPreprocessor.process(
1068
+ oDialogFragment,
1069
+ { name: sFragmentName },
1070
+ {
1071
+ bindingContexts: {
1072
+ entityType: oMetaModel.createBindingContext(sEntitySet),
1073
+ label: oDialogLabelModel.createBindingContext("/")
1074
+ },
1075
+ models: {
1076
+ entityType: oMetaModel,
1077
+ metaModel: oMetaModel,
1078
+ label: oDialogLabelModel
1141
1079
  }
1142
- )
1143
- )
1144
- .then(function (oFragment: any) {
1145
- return Fragment.load({ definition: oFragment, controller: oController });
1146
- })
1147
- .then(function (oPopover: any) {
1148
- oApplicableContextDialog = oPopover;
1149
- mParameters.parentControl.addDependent(oPopover);
1150
- fnOpenAndFillDialog();
1151
- })
1152
- .catch(reject);
1153
- } else {
1154
- resolve(mParameters.contexts);
1080
+ }
1081
+ );
1082
+ // eslint-disable-next-line prefer-const
1083
+ let oDialog: Dialog;
1084
+ const oController = {
1085
+ onClose: function () {
1086
+ // User cancels action
1087
+ oDialog.close();
1088
+ resolve();
1089
+ },
1090
+ onContinue: function () {
1091
+ // Users continues the action with the bound contexts
1092
+ oDialog.close();
1093
+ resolve(mParameters.applicableContext);
1094
+ }
1095
+ };
1096
+ oDialog = (await Fragment.load({ definition: oFragment, controller: oController })) as Dialog;
1097
+ oController.onClose = function () {
1098
+ // User cancels action
1099
+ oDialog.close();
1100
+ resolve();
1101
+ };
1102
+ oController.onContinue = function () {
1103
+ // Users continues the action with the bound contexts
1104
+ oDialog.close();
1105
+ resolve(mParameters.applicableContext);
1106
+ };
1107
+
1108
+ mParameters.parentControl.addDependent(oDialog);
1109
+ fnOpenAndFillDialog(oDialog);
1110
+ } catch (oError) {
1111
+ reject(oError);
1155
1112
  }
1156
- }).then(function (contextToProcess: any) {
1113
+ });
1114
+ };
1115
+
1116
+ try {
1117
+ let oResult: any;
1118
+ if (oContext && oModel) {
1119
+ const contextToProcess = await displayUnapplicableContextsDialog();
1157
1120
  if (contextToProcess) {
1158
- return operations.callBoundAction(sActionName, contextToProcess, oModel, oAppComponent, {
1121
+ oResult = await operations.callBoundAction(sActionName, contextToProcess, oModel, oAppComponent, {
1159
1122
  invocationGrouping: mParameters.invocationGrouping,
1160
1123
  label: mParameters.label,
1161
1124
  showActionParameterDialog: true,
@@ -1177,44 +1140,38 @@ class TransactionHelper {
1177
1140
  bGetBoundContext: mParameters.bGetBoundContext,
1178
1141
  bObjectPage: mParameters.bObjectPage,
1179
1142
  messageHandler: messageHandler,
1180
- defaultValuesExtensionFunction: mParameters.defaultValuesExtensionFunction
1143
+ defaultValuesExtensionFunction: mParameters.defaultValuesExtensionFunction,
1144
+ selectedItems: mParameters.contexts
1181
1145
  });
1182
1146
  } else {
1183
- return null;
1147
+ oResult = null;
1184
1148
  }
1185
- });
1186
- } else {
1187
- // TODO: confirm if action import needs side effects.
1188
- oPromise = operations.callActionImport(sActionName, oModel, oAppComponent, {
1189
- label: mParameters.label,
1190
- showActionParameterDialog: true,
1191
- bindingParameters: mBindingParameters,
1192
- entitySetName: mParameters.entitySetName,
1193
- onSubmitted: function () {
1194
- BusyLocker.lock(that.oLockObject);
1195
- },
1196
- onResponse: function () {
1197
- BusyLocker.unlock(that.oLockObject);
1198
- },
1199
- parentControl: mParameters.parentControl,
1200
- internalModelContext: mParameters.internalModelContext,
1201
- operationAvailableMap: mParameters.operationAvailableMap,
1202
- messageHandler: messageHandler,
1203
- bObjectPage: mParameters.bObjectPage
1204
- });
1205
- }
1206
- return oPromise
1207
- .then(function (oResult: any) {
1208
- // Succeeded
1209
- return that._handleActionResponse(messageHandler, mParameters, sActionName).then(function () {
1210
- return oResult;
1211
- });
1212
- })
1213
- .catch(function (err: any) {
1214
- return that._handleActionResponse(messageHandler, mParameters, sActionName).then(function () {
1215
- return Promise.reject(err);
1149
+ } else {
1150
+ oResult = await operations.callActionImport(sActionName, oModel, oAppComponent, {
1151
+ label: mParameters.label,
1152
+ showActionParameterDialog: true,
1153
+ bindingParameters: mBindingParameters,
1154
+ entitySetName: mParameters.entitySetName,
1155
+ onSubmitted: function () {
1156
+ BusyLocker.lock(that.oLockObject);
1157
+ },
1158
+ onResponse: function () {
1159
+ BusyLocker.unlock(that.oLockObject);
1160
+ },
1161
+ parentControl: mParameters.parentControl,
1162
+ internalModelContext: mParameters.internalModelContext,
1163
+ operationAvailableMap: mParameters.operationAvailableMap,
1164
+ messageHandler: messageHandler,
1165
+ bObjectPage: mParameters.bObjectPage
1216
1166
  });
1217
- });
1167
+ }
1168
+
1169
+ await this._handleActionResponse(messageHandler, mParameters, sActionName);
1170
+ return oResult;
1171
+ } catch (err: any) {
1172
+ await this._handleActionResponse(messageHandler, mParameters, sActionName);
1173
+ throw err;
1174
+ }
1218
1175
  }
1219
1176
  /**
1220
1177
  * Handles messages for action call.
@@ -1223,9 +1180,9 @@ class TransactionHelper {
1223
1180
  * @name sap.fe.core.TransactionHelper#_handleActionResponse
1224
1181
  * @memberof sap.fe.core.TransactionHelper
1225
1182
  * @param messageHandler
1226
- * @param {object} mParameters Parameters to be considered for the action.
1227
- * @param {string} sActionName The name of the action to be called
1228
- * @returns {Promise} Promise after message dialog is opened if required.
1183
+ * @param mParameters Parameters to be considered for the action.
1184
+ * @param sActionName The name of the action to be called
1185
+ * @returns Promise after message dialog is opened if required.
1229
1186
  * @ui5-restricted
1230
1187
  * @final
1231
1188
  */
@@ -1263,13 +1220,14 @@ class TransactionHelper {
1263
1220
  * Shows a popover if it needs to be shown.
1264
1221
  * TODO: Popover is shown if user has modified any data.
1265
1222
  * TODO: Popover is shown if there's a difference from draft admin data.
1223
+ *
1266
1224
  * @static
1267
1225
  * @name sap.fe.core.TransactionHelper._showDiscardPopover
1268
1226
  * @memberof sap.fe.core.TransactionHelper
1269
- * @param {sap.ui.core.Control} oCancelButton The control which will open the popover
1227
+ * @param oCancelButton The control which will open the popover
1270
1228
  * @param bIsModified
1271
1229
  * @param oResourceBundle
1272
- * @returns {Promise} Promise resolves if user confirms discard, rejects if otherwise, rejects if no control passed to open popover
1230
+ * @returns Promise resolves if user confirms discard, rejects if otherwise, rejects if no control passed to open popover
1273
1231
  * @ui5-restricted
1274
1232
  * @final
1275
1233
  */
@@ -1355,10 +1313,10 @@ class TransactionHelper {
1355
1313
  * @private
1356
1314
  * @name sap.fe.core.TransactionHelper._getOwnerComponent
1357
1315
  * @memberof sap.fe.core.TransactionHelper
1358
- * @returns {sap.fe.core.AppComponent} The app component
1316
+ * @returns The app component
1359
1317
  * @ui5-restricted
1360
1318
  * @final
1361
- **/
1319
+ */
1362
1320
  _getAppComponent() {
1363
1321
  return this._oAppComponent;
1364
1322
  }
@@ -1373,6 +1331,7 @@ class TransactionHelper {
1373
1331
  // Setting value of field as '' in case of value help and validating other fields
1374
1332
  oField.setValue(value);
1375
1333
  fnValidateRequiredProperties();
1334
+
1376
1335
  return oField.getValue();
1377
1336
  })
1378
1337
  .catch(function (value: any) {
@@ -1387,245 +1346,249 @@ class TransactionHelper {
1387
1346
  });
1388
1347
  }
1389
1348
  }
1349
+ _getNonDeletableText(mParameters: any, vContexts: any, oResourceBundle: any) {
1350
+ const aNonDeletableContexts = mParameters.numberOfSelectedContexts - vContexts.concat(mParameters.unSavedContexts).length;
1351
+ return aNonDeletableContexts === 1
1352
+ ? CommonUtils.getTranslatedText(
1353
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTINFO_AND_ONE_OBJECT_NON_DELETABLE",
1354
+ oResourceBundle,
1355
+ [mParameters.numberOfSelectedContexts]
1356
+ )
1357
+ : CommonUtils.getTranslatedText(
1358
+ "C_TRANSACTION_HELPER_CONFIRM_DELETE_WITH_OBJECTINFO_AND_FEW_OBJECTS_NON_DELETABLE",
1359
+ oResourceBundle,
1360
+ [
1361
+ mParameters.numberOfSelectedContexts - vContexts.concat(mParameters.unSavedContexts).length,
1362
+ mParameters.numberOfSelectedContexts
1363
+ ]
1364
+ );
1365
+ }
1390
1366
 
1391
- _launchDialogWithKeyFields(oListBinding: any, mFields: any, oModel: any, mParameters: any, messageHandler: any) {
1392
- // eslint-disable-next-line @typescript-eslint/no-this-alias
1393
- const that = this;
1367
+ _launchDialogWithKeyFields(oListBinding: ODataListBinding, mFields: any, oModel: ODataModel, mParameters: any, messageHandler: any) {
1394
1368
  let oDialog: Dialog;
1395
1369
  const oParentControl = mParameters.parentControl,
1396
1370
  bSuccess = false;
1397
1371
 
1398
- // Create a fake (transient) listBinding and context, just for the binding context of the dialog
1372
+ // Crate a fake (transient) listBinding and context, just for the binding context of the dialog
1399
1373
  const oTransientListBinding = oModel.bindList(oListBinding.getPath(), oListBinding.getContext(), [], [], {
1400
1374
  $$updateGroupId: "submitLater"
1401
- });
1375
+ }) as ODataListBinding;
1402
1376
  oTransientListBinding.refreshInternal = function () {
1403
1377
  /* */
1404
1378
  };
1405
1379
  const oTransientContext = oTransientListBinding.create(mParameters.data, true);
1406
1380
 
1407
- return new Promise(function (resolve: (value: any) => void, reject: (reason?: any) => void) {
1381
+ return new Promise(async (resolve, reject) => {
1408
1382
  const sFragmentName = "sap/fe/core/controls/NonComputedVisibleKeyFieldsDialog";
1409
1383
  const oFragment = XMLTemplateProcessor.loadTemplate(sFragmentName, "fragment"),
1410
1384
  oResourceBundle = oParentControl.getController().oResourceBundle,
1411
1385
  oMetaModel = oModel.getMetaModel(),
1412
1386
  aImmutableFields: any[] = [],
1413
- oAppComponent = that._getAppComponent(),
1414
- sPath = oListBinding.isRelative() ? oListBinding.getResolvedPath() : oListBinding.getPath(),
1415
- oEntitySetContext = oMetaModel.createBindingContext(sPath),
1387
+ oAppComponent = this._getAppComponent(),
1388
+ sPath = (oListBinding.isRelative() ? oListBinding.getResolvedPath() : oListBinding.getPath()) as string,
1389
+ oEntitySetContext = oMetaModel.createBindingContext(sPath) as Context,
1416
1390
  sMetaPath = oMetaModel.getMetaPath(sPath);
1417
1391
  for (const i in mFields) {
1418
- aImmutableFields.push(oMetaModel.createBindingContext(sMetaPath + "/" + mFields[i]));
1392
+ aImmutableFields.push(oMetaModel.createBindingContext(`${sMetaPath}/${mFields[i]}`));
1419
1393
  }
1420
1394
  const oImmutableCtxModel = new JSONModel(aImmutableFields);
1421
1395
  const oImmutableCtx = oImmutableCtxModel.createBindingContext("/") as Context;
1422
- return Promise.resolve(
1423
- XMLPreprocessor.process(
1424
- oFragment,
1425
- { name: sFragmentName },
1426
- {
1427
- bindingContexts: {
1428
- entitySet: oEntitySetContext,
1429
- fields: oImmutableCtx
1430
- },
1431
- models: {
1432
- entitySet: oEntitySetContext.getModel(),
1433
- fields: oImmutableCtx.getModel(),
1434
- metaModel: oMetaModel
1435
- }
1396
+ const aRequiredProperties = CommonUtils.getRequiredPropertiesFromInsertRestrictions(sMetaPath, oMetaModel);
1397
+ const oRequiredPropertyPathsCtxModel = new JSONModel(aRequiredProperties);
1398
+ const oRequiredPropertyPathsCtx = oRequiredPropertyPathsCtxModel.createBindingContext("/") as Context;
1399
+ const oNewFragment = await XMLPreprocessor.process(
1400
+ oFragment,
1401
+ { name: sFragmentName },
1402
+ {
1403
+ bindingContexts: {
1404
+ entitySet: oEntitySetContext,
1405
+ fields: oImmutableCtx,
1406
+ requiredProperties: oRequiredPropertyPathsCtx
1407
+ },
1408
+ models: {
1409
+ entitySet: oEntitySetContext.getModel(),
1410
+ fields: oImmutableCtx.getModel(),
1411
+ metaModel: oMetaModel,
1412
+ requiredProperties: oRequiredPropertyPathsCtxModel
1436
1413
  }
1437
- )
1438
- ).then(function (oFragment: any) {
1439
- let aFormElements: any[] = [];
1440
- const mFieldValueMap: any = {};
1441
- let oCreateButton: Button;
1442
- const validateRequiredProperties = function () {
1443
- return Promise.all(
1414
+ }
1415
+ );
1416
+
1417
+ let aFormElements: any[] = [];
1418
+ const mFieldValueMap: any = {};
1419
+ // eslint-disable-next-line prefer-const
1420
+ let oCreateButton: Button;
1421
+
1422
+ const validateRequiredProperties = async function () {
1423
+ let bEnabled = false;
1424
+ try {
1425
+ const aResults = await Promise.all(
1444
1426
  aFormElements
1445
1427
  .map(function (oFormElement: any) {
1446
1428
  return oFormElement.getFields()[0];
1447
1429
  })
1448
1430
  .filter(function (oField: any) {
1449
- // The continue button should remain disabled in case of error in any field of the create dialog
1450
- return oField.getRequired() || (oField.getValueState() === ValueState.Error && oField.getValue() !== "");
1431
+ // The continue button should remain disabled in case of empty required fields.
1432
+ return oField.getRequired() || oField.getValueState() === ValueState.Error;
1451
1433
  })
1452
- .map(function (oField: any) {
1434
+ .map(async function (oField: any) {
1453
1435
  const sFieldId = oField.getId();
1454
1436
  if (sFieldId in mFieldValueMap) {
1455
- return Promise.resolve(mFieldValueMap[sFieldId])
1456
- .then(function (vValue: any) {
1457
- return oField.getValueState() === ValueState.Error ? undefined : vValue;
1458
- })
1459
- .catch(function () {
1460
- return undefined;
1461
- });
1437
+ try {
1438
+ const vValue = await mFieldValueMap[sFieldId];
1439
+ return oField.getValue() === "" ? undefined : vValue;
1440
+ } catch (err) {
1441
+ return undefined;
1442
+ }
1462
1443
  }
1463
- return oField.getValueState() === ValueState.Error ? undefined : oField.getValue();
1444
+ return oField.getValue() === "" ? undefined : oField.getValue();
1464
1445
  })
1465
- )
1466
- .then(function (aResults: any[]) {
1467
- return aResults.every(function (vValue: any) {
1468
- return vValue !== undefined && vValue !== null && vValue !== "";
1469
- });
1470
- })
1471
- .catch(function () {
1472
- return false;
1473
- })
1474
- .then(function (bEnabled: boolean) {
1475
- oCreateButton.setEnabled(bEnabled);
1476
- });
1477
- };
1478
- const oController = {
1479
- /*
1480
- fired on focus out from field or on selecting a value from the valuehelp.
1481
- the create button is enabled when a value is added.
1482
- liveChange is not fired when value is added from valuehelp.
1483
- value validation is not done for create button enablement.
1484
- */
1485
- handleChange: function (oEvent: any) {
1486
- const sFieldId = oEvent.getParameter("id");
1487
- mFieldValueMap[sFieldId] = that._onFieldChange(oEvent, oCreateButton, messageHandler, validateRequiredProperties);
1488
- },
1489
- /*
1490
- fired on key press. the create button is enabled when a value is added.
1491
- liveChange is not fired when value is added from valuehelp.
1492
- value validation is not done for create button enablement.
1493
- */
1494
- handleLiveChange: function (oEvent: any) {
1495
- const sFieldId = oEvent.getParameter("id");
1496
- const vValue = oEvent.getParameter("value");
1497
- mFieldValueMap[sFieldId] = vValue;
1498
- validateRequiredProperties();
1499
- }
1500
- };
1501
- return Fragment.load({
1502
- definition: oFragment,
1503
- controller: oController
1504
- }).then(function (oDialogContent: any) {
1505
- oDialog = new Dialog({
1506
- title: CommonUtils.getTranslatedText("C_TRANSACTION_HELPER_SAPFE_ACTION_CREATE", oResourceBundle),
1507
- content: [oDialogContent],
1508
- beginButton: {
1509
- text: CommonUtils.getTranslatedText("C_TRANSACTION_HELPER_SAPFE_ACTION_CREATE_BUTTON", oResourceBundle),
1510
- type: "Emphasized",
1511
- press: function (oEvent: any) {
1512
- const oCreateButton = oEvent.getSource();
1513
- let oNewDocumentContext: any;
1514
- oCreateButton.setEnabled(false);
1515
- BusyLocker.lock(oDialog);
1516
- mParameters.bIsCreateDialog = true;
1517
- return Promise.all(
1518
- Object.keys(mFieldValueMap).map(function (sKey: string) {
1519
- return mFieldValueMap[sKey].then(function (oValue: any) {
1520
- const oDialogValue: any = {};
1521
- oDialogValue[sKey] = oValue;
1522
- return oDialogValue;
1523
- });
1524
- })
1525
- )
1526
- .then(function (aValues: any[]) {
1527
- let onBeforeCreatePromise;
1528
- if (mParameters.beforeCreateCallBack) {
1529
- onBeforeCreatePromise = mParameters.beforeCreateCallBack({
1530
- contextPath: oListBinding && oListBinding.getPath(),
1531
- createParameters: aValues
1532
- });
1533
- } else {
1534
- onBeforeCreatePromise = Promise.resolve();
1535
- }
1536
- return onBeforeCreatePromise;
1537
- })
1538
- .then(function () {
1539
- const transientData = oTransientContext.getObject();
1540
- const createData: any = {};
1541
- Object.keys(transientData).forEach(function (sPropertyPath: string) {
1542
- const oProperty = oMetaModel.getObject(`${sMetaPath}/${sPropertyPath}`);
1543
- // ensure navigation properties are not part of the payload, deep create not supported
1544
- if (oProperty && oProperty.$kind === "NavigationProperty") {
1545
- return;
1546
- }
1547
- createData[sPropertyPath] = transientData[sPropertyPath];
1548
- });
1549
- oNewDocumentContext = oListBinding.create(
1550
- createData,
1551
- true,
1552
- mParameters.createAtEnd,
1553
- mParameters.inactive
1554
- );
1555
-
1556
- const oPromise = that.onAfterCreateCompletion(oListBinding, oNewDocumentContext, mParameters);
1446
+ );
1447
+ bEnabled = aResults.every(function (vValue: any) {
1448
+ if (Array.isArray(vValue)) {
1449
+ vValue = vValue[0];
1450
+ }
1451
+ return vValue !== undefined && vValue !== null && vValue !== "";
1452
+ });
1453
+ } catch (err) {
1454
+ bEnabled = false;
1455
+ }
1456
+ oCreateButton.setEnabled(bEnabled);
1457
+ };
1458
+ const oController = {
1459
+ /*
1460
+ fired on focus out from field or on selecting a value from the valuehelp.
1461
+ the create button is enabled when a value is added.
1462
+ liveChange is not fired when value is added from valuehelp.
1463
+ value validation is not done for create button enablement.
1464
+ */
1465
+ handleChange: (oEvent: any) => {
1466
+ const sFieldId = oEvent.getParameter("id");
1467
+ mFieldValueMap[sFieldId] = this._onFieldChange(oEvent, oCreateButton, messageHandler, validateRequiredProperties);
1468
+ },
1469
+ /*
1470
+ fired on key press. the create button is enabled when a value is added.
1471
+ liveChange is not fired when value is added from valuehelp.
1472
+ value validation is not done for create button enablement.
1473
+ */
1474
+ handleLiveChange: (oEvent: any) => {
1475
+ const sFieldId = oEvent.getParameter("id");
1476
+ const vValue = oEvent.getParameter("value");
1477
+ mFieldValueMap[sFieldId] = vValue;
1478
+ validateRequiredProperties();
1479
+ }
1480
+ };
1557
1481
 
1558
- return oPromise;
1559
- })
1560
- .then(function (oResponse: any) {
1561
- if (!oResponse || (oResponse && oResponse.bKeepDialogOpen !== true)) {
1562
- oResponse = oResponse ?? {};
1563
- oDialog.setBindingContext(null as any);
1564
- oDialog.close();
1565
- oResponse.newContext = oNewDocumentContext;
1566
- resolve(oResponse);
1567
- }
1568
- })
1569
- .catch(function (oError: any) {
1570
- reject(oError);
1482
+ const oDialogContent: any = await Fragment.load({
1483
+ definition: oNewFragment,
1484
+ controller: oController
1485
+ });
1486
+ oDialog = new Dialog({
1487
+ title: CommonUtils.getTranslatedText("C_TRANSACTION_HELPER_SAPFE_ACTION_CREATE", oResourceBundle),
1488
+ content: [oDialogContent],
1489
+ beginButton: {
1490
+ text: CommonUtils.getTranslatedText("C_TRANSACTION_HELPER_SAPFE_ACTION_CREATE_BUTTON", oResourceBundle),
1491
+ type: "Emphasized",
1492
+ press: async (oEvent: any) => {
1493
+ const createButton = oEvent.getSource();
1494
+ createButton.setEnabled(false);
1495
+ BusyLocker.lock(oDialog);
1496
+ mParameters.bIsCreateDialog = true;
1497
+ try {
1498
+ const aValues = await Promise.all(
1499
+ Object.keys(mFieldValueMap).map(async function (sKey: string) {
1500
+ const oValue = await mFieldValueMap[sKey];
1501
+ const oDialogValue: any = {};
1502
+ oDialogValue[sKey] = oValue;
1503
+ return oDialogValue;
1504
+ })
1505
+ );
1506
+ if (mParameters.beforeCreateCallBack) {
1507
+ await toES6Promise(
1508
+ mParameters.beforeCreateCallBack({
1509
+ contextPath: oListBinding && oListBinding.getPath(),
1510
+ createParameters: aValues
1571
1511
  })
1572
- .finally(function () {
1573
- BusyLocker.unlock(oDialog);
1574
- oCreateButton.setEnabled(true);
1575
- return messageHandler.showMessages();
1576
- });
1512
+ );
1577
1513
  }
1578
- },
1579
- endButton: {
1580
- text: CommonUtils.getTranslatedText("C_COMMON_ACTION_PARAMETER_DIALOG_CANCEL", oResourceBundle),
1581
- press: function () {
1514
+ const transientData = oTransientContext.getObject();
1515
+ const createData: any = {};
1516
+ Object.keys(transientData).forEach(function (sPropertyPath: string) {
1517
+ const oProperty = oMetaModel.getObject(`${sMetaPath}/${sPropertyPath}`);
1518
+ // ensure navigation properties are not part of the payload, deep create not supported
1519
+ if (oProperty && oProperty.$kind === "NavigationProperty") {
1520
+ return;
1521
+ }
1522
+ createData[sPropertyPath] = transientData[sPropertyPath];
1523
+ });
1524
+ const oNewDocumentContext = oListBinding.create(
1525
+ createData,
1526
+ true,
1527
+ mParameters.createAtEnd,
1528
+ mParameters.inactive
1529
+ );
1530
+
1531
+ const oPromise = this.onAfterCreateCompletion(oListBinding, oNewDocumentContext, mParameters);
1532
+ let oResponse: any = await oPromise;
1533
+ if (!oResponse || (oResponse && oResponse.bKeepDialogOpen !== true)) {
1534
+ oResponse = oResponse ?? {};
1535
+ oDialog.setBindingContext(null as any);
1582
1536
  oDialog.close();
1537
+ oResponse.newContext = oNewDocumentContext;
1538
+ resolve(oResponse);
1583
1539
  }
1584
- },
1585
- afterClose: function () {
1586
- // show footer as per UX guidelines when dialog is not open
1587
- (oDialog.getBindingContext("internal") as InternalModelContext)?.setProperty("isCreateDialogOpen", false);
1588
- oDialog.destroy();
1589
- oTransientListBinding.destroy();
1590
- if (!bSuccess) {
1591
- reject({
1592
- bDeleteTransientContext: true,
1593
- navigateBackFromTransientState: true
1594
- });
1595
- }
1540
+ } catch (oError: any) {
1541
+ reject(oError);
1542
+ } finally {
1543
+ BusyLocker.unlock(oDialog);
1544
+ createButton.setEnabled(true);
1545
+ messageHandler.showMessages();
1596
1546
  }
1597
- } as any);
1598
- aFormElements = oDialogContent
1599
- .getAggregation("form")
1600
- .getAggregation("formContainers")[0]
1601
- .getAggregation("formElements");
1602
- if (oParentControl && oParentControl.addDependent) {
1603
- // if there is a parent control specified add the dialog as dependent
1604
- oParentControl.addDependent(oDialog);
1605
1547
  }
1606
- oCreateButton = oDialog.getBeginButton();
1607
- oDialog.setBindingContext(oTransientContext);
1608
- return CommonUtils.setUserDefaults(
1609
- oAppComponent,
1610
- aImmutableFields,
1611
- oTransientContext,
1612
- false,
1613
- mParameters.createAction,
1614
- mParameters.data
1615
- )
1616
- .then(function () {
1617
- validateRequiredProperties();
1618
- // footer must not be visible when the dialog is open as per UX guidelines
1619
- (oDialog.getBindingContext("internal") as InternalModelContext).setProperty("isCreateDialogOpen", true);
1620
- oDialog.open();
1621
- })
1622
- .catch(function (oError: any) {
1623
- return messageHandler.showMessages().then(function () {
1624
- return Promise.reject(oError);
1625
- });
1548
+ },
1549
+ endButton: {
1550
+ text: CommonUtils.getTranslatedText("C_COMMON_ACTION_PARAMETER_DIALOG_CANCEL", oResourceBundle),
1551
+ press: function () {
1552
+ oDialog.close();
1553
+ }
1554
+ },
1555
+ afterClose: function () {
1556
+ // show footer as per UX guidelines when dialog is not open
1557
+ (oDialog.getBindingContext("internal") as InternalModelContext)?.setProperty("isCreateDialogOpen", false);
1558
+ oDialog.destroy();
1559
+ oTransientListBinding.destroy();
1560
+ if (!bSuccess) {
1561
+ reject({
1562
+ bDeleteTransientContext: true,
1563
+ navigateBackFromTransientState: true
1626
1564
  });
1627
- });
1628
- });
1565
+ }
1566
+ }
1567
+ } as any);
1568
+ aFormElements = oDialogContent?.getAggregation("form").getAggregation("formContainers")[0].getAggregation("formElements");
1569
+ if (oParentControl && oParentControl.addDependent) {
1570
+ // if there is a parent control specified add the dialog as dependent
1571
+ oParentControl.addDependent(oDialog);
1572
+ }
1573
+ oCreateButton = oDialog.getBeginButton();
1574
+ oDialog.setBindingContext(oTransientContext);
1575
+ try {
1576
+ await CommonUtils.setUserDefaults(
1577
+ oAppComponent,
1578
+ aImmutableFields,
1579
+ oTransientContext,
1580
+ false,
1581
+ mParameters.createAction,
1582
+ mParameters.data
1583
+ );
1584
+ validateRequiredProperties();
1585
+ // footer must not be visible when the dialog is open as per UX guidelines
1586
+ (oDialog.getBindingContext("internal") as InternalModelContext).setProperty("isCreateDialogOpen", true);
1587
+ oDialog.open();
1588
+ } catch (oError: any) {
1589
+ await messageHandler.showMessages();
1590
+ throw oError;
1591
+ }
1629
1592
  });
1630
1593
  }
1631
1594
  onAfterCreateCompletion(oListBinding: any, oNewDocumentContext: any, mParameters: any) {
@@ -1685,14 +1648,14 @@ class TransactionHelper {
1685
1648
  * @private
1686
1649
  * @name sap.fe.core.TransactionHelper._getNewAction
1687
1650
  * @memberof sap.fe.core.TransactionHelper
1688
- * @param {object} oStartupParameters Startup parameters of the application
1689
- * @param {string} sCreateHash Hash to be checked for action type
1690
- * @param {object} oMetaModel The MetaModel used to check for NewAction parameter
1691
- * @param {string} sMetaPath The MetaPath
1692
- * @returns {string} The name of the action
1651
+ * @param oStartupParameters Startup parameters of the application
1652
+ * @param sCreateHash Hash to be checked for action type
1653
+ * @param oMetaModel The MetaModel used to check for NewAction parameter
1654
+ * @param sMetaPath The MetaPath
1655
+ * @returns The name of the action
1693
1656
  * @ui5-restricted
1694
1657
  * @final
1695
- **/
1658
+ */
1696
1659
  _getNewAction(oStartupParameters: any, sCreateHash: string, oMetaModel: ODataMetaModel, sMetaPath: string) {
1697
1660
  let sNewAction;
1698
1661
 
@@ -1703,8 +1666,8 @@ class TransactionHelper {
1703
1666
  } else {
1704
1667
  sNewAction =
1705
1668
  oMetaModel && oMetaModel.getObject !== undefined
1706
- ? oMetaModel.getObject(sMetaPath + "@com.sap.vocabularies.Session.v1.StickySessionSupported/NewAction") ||
1707
- oMetaModel.getObject(sMetaPath + "@com.sap.vocabularies.Common.v1.DraftRoot/NewAction")
1669
+ ? oMetaModel.getObject(`${sMetaPath}@com.sap.vocabularies.Session.v1.StickySessionSupported/NewAction`) ||
1670
+ oMetaModel.getObject(`${sMetaPath}@com.sap.vocabularies.Common.v1.DraftRoot/NewAction`)
1708
1671
  : undefined;
1709
1672
  }
1710
1673
  return sNewAction;
@@ -1722,14 +1685,14 @@ class TransactionHelper {
1722
1685
  * @private
1723
1686
  * @name sap.fe.core.TransactionHelper._getSpecificCreateActionDialogLabel
1724
1687
  * @memberof sap.fe.core.TransactionHelper
1725
- * @param {object} oMetaModel The MetaModel used to check for the NewAction parameter
1726
- * @param {string} sMetaPath The MetaPath
1727
- * @param {string} sNewAction Contains the name of the action to be executed
1728
- * @param {object} oResourceBundleCore ResourceBundle to access the default Create label
1729
- * @returns {string} The label for the Create Action Dialog
1688
+ * @param oMetaModel The MetaModel used to check for the NewAction parameter
1689
+ * @param sMetaPath The MetaPath
1690
+ * @param sNewAction Contains the name of the action to be executed
1691
+ * @param oResourceBundleCore ResourceBundle to access the default Create label
1692
+ * @returns The label for the Create Action Dialog
1730
1693
  * @ui5-restricted
1731
1694
  * @final
1732
- **/
1695
+ */
1733
1696
  _getSpecificCreateActionDialogLabel(
1734
1697
  oMetaModel: ODataMetaModel,
1735
1698
  sMetaPath: string,
@@ -1737,15 +1700,15 @@ class TransactionHelper {
1737
1700
  oResourceBundleCore: ResourceBundle
1738
1701
  ) {
1739
1702
  const fnGetLabelFromLineItemAnnotation = function () {
1740
- if (oMetaModel && oMetaModel.getObject(sMetaPath + "/@com.sap.vocabularies.UI.v1.LineItem")) {
1703
+ if (oMetaModel && oMetaModel.getObject(`${sMetaPath}/@com.sap.vocabularies.UI.v1.LineItem`)) {
1741
1704
  const iLineItemIndex = oMetaModel
1742
- .getObject(sMetaPath + "/@com.sap.vocabularies.UI.v1.LineItem")
1705
+ .getObject(`${sMetaPath}/@com.sap.vocabularies.UI.v1.LineItem`)
1743
1706
  .findIndex(function (oLineItem: any) {
1744
1707
  const aLineItemAction = oLineItem.Action ? oLineItem.Action.split("(") : undefined;
1745
1708
  return aLineItemAction ? aLineItemAction[0] === sNewAction : false;
1746
1709
  });
1747
1710
  return iLineItemIndex > -1
1748
- ? oMetaModel.getObject(sMetaPath + "/@com.sap.vocabularies.UI.v1.LineItem")[iLineItemIndex].Label
1711
+ ? oMetaModel.getObject(`${sMetaPath}/@com.sap.vocabularies.UI.v1.LineItem`)[iLineItemIndex].Label
1749
1712
  : undefined;
1750
1713
  } else {
1751
1714
  return undefined;
@@ -1754,7 +1717,7 @@ class TransactionHelper {
1754
1717
 
1755
1718
  return (
1756
1719
  fnGetLabelFromLineItemAnnotation() ||
1757
- (oMetaModel && oMetaModel.getObject(sMetaPath + "/" + sNewAction + "@com.sap.vocabularies.Common.v1.Label")) ||
1720
+ (oMetaModel && oMetaModel.getObject(`${sMetaPath}/${sNewAction}@com.sap.vocabularies.Common.v1.Label`)) ||
1758
1721
  (oResourceBundleCore && oResourceBundleCore.getText("C_TRANSACTION_HELPER_SAPFE_ACTION_CREATE"))
1759
1722
  );
1760
1723
  }