@openui5/sap.ui.rta 1.120.7 → 1.121.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 (164) hide show
  1. package/.reuse/dep5 +23 -21
  2. package/THIRDPARTY.txt +6 -43
  3. package/package.json +6 -6
  4. package/src/sap/ui/rta/.library +1 -1
  5. package/src/sap/ui/rta/Client.js +1 -1
  6. package/src/sap/ui/rta/RuntimeAuthoring.js +507 -759
  7. package/src/sap/ui/rta/Utils.js +1 -146
  8. package/src/sap/ui/rta/appVariant/AppVariantDialog.js +1 -1
  9. package/src/sap/ui/rta/appVariant/AppVariantManager.js +1 -1
  10. package/src/sap/ui/rta/appVariant/AppVariantUtils.js +3 -3
  11. package/src/sap/ui/rta/appVariant/Utils.js +3 -3
  12. package/src/sap/ui/rta/appVariant/manageApps/webapp/controller/ManageApps.controller.js +5 -3
  13. package/src/sap/ui/rta/appVariant/manageApps/webapp/i18n/i18n_bg.properties +1 -1
  14. package/src/sap/ui/rta/appVariant/manageApps/webapp/i18n/i18n_en_US_saprigi.properties +27 -27
  15. package/src/sap/ui/rta/appVariant/manageApps/webapp/i18n/i18n_et.properties +1 -1
  16. package/src/sap/ui/rta/appVariant/manageApps/webapp/i18n/i18n_fi.properties +1 -1
  17. package/src/sap/ui/rta/appVariant/manageApps/webapp/i18n/i18n_fr.properties +1 -1
  18. package/src/sap/ui/rta/appVariant/manageApps/webapp/i18n/i18n_kk.properties +1 -1
  19. package/src/sap/ui/rta/appVariant/manageApps/webapp/i18n/i18n_lv.properties +1 -1
  20. package/src/sap/ui/rta/appVariant/manageApps/webapp/i18n/i18n_mk.properties +1 -1
  21. package/src/sap/ui/rta/appVariant/manageApps/webapp/i18n/i18n_ru.properties +1 -1
  22. package/src/sap/ui/rta/appVariant/manageApps/webapp/i18n/i18n_th.properties +1 -1
  23. package/src/sap/ui/rta/command/AddIFrame.js +1 -1
  24. package/src/sap/ui/rta/command/AddProperty.js +1 -1
  25. package/src/sap/ui/rta/command/AddXML.js +1 -1
  26. package/src/sap/ui/rta/command/AddXMLAtExtensionPoint.js +3 -3
  27. package/src/sap/ui/rta/command/AppDescriptorCommand.js +1 -1
  28. package/src/sap/ui/rta/command/BaseCommand.js +1 -1
  29. package/src/sap/ui/rta/command/BindProperty.js +1 -1
  30. package/src/sap/ui/rta/command/Combine.js +1 -1
  31. package/src/sap/ui/rta/command/CommandFactory.js +1 -1
  32. package/src/sap/ui/rta/command/CompositeCommand.js +1 -1
  33. package/src/sap/ui/rta/command/ControlVariantConfigure.js +1 -1
  34. package/src/sap/ui/rta/command/ControlVariantSave.js +1 -1
  35. package/src/sap/ui/rta/command/ControlVariantSaveAs.js +7 -5
  36. package/src/sap/ui/rta/command/ControlVariantSetTitle.js +1 -1
  37. package/src/sap/ui/rta/command/ControlVariantSwitch.js +10 -4
  38. package/src/sap/ui/rta/command/CreateContainer.js +1 -1
  39. package/src/sap/ui/rta/command/CustomAdd.js +1 -1
  40. package/src/sap/ui/rta/command/FlexCommand.js +1 -1
  41. package/src/sap/ui/rta/command/LREPSerializer.js +4 -3
  42. package/src/sap/ui/rta/command/LocalReset.js +1 -1
  43. package/src/sap/ui/rta/command/Move.js +1 -1
  44. package/src/sap/ui/rta/command/Property.js +1 -1
  45. package/src/sap/ui/rta/command/Remove.js +1 -1
  46. package/src/sap/ui/rta/command/Rename.js +1 -1
  47. package/src/sap/ui/rta/command/Resize.js +1 -1
  48. package/src/sap/ui/rta/command/Reveal.js +1 -1
  49. package/src/sap/ui/rta/command/Settings.js +1 -1
  50. package/src/sap/ui/rta/command/Split.js +1 -1
  51. package/src/sap/ui/rta/command/Stack.js +23 -1
  52. package/src/sap/ui/rta/command/appDescriptor/AddLibrary.js +1 -1
  53. package/src/sap/ui/rta/command/compVariant/CompVariantContent.js +1 -1
  54. package/src/sap/ui/rta/command/compVariant/CompVariantSaveAs.js +1 -1
  55. package/src/sap/ui/rta/command/compVariant/CompVariantSwitch.js +1 -1
  56. package/src/sap/ui/rta/command/compVariant/CompVariantUpdate.js +1 -1
  57. package/src/sap/ui/rta/enablement/elementActionTest.js +180 -258
  58. package/src/sap/ui/rta/library.js +3 -2
  59. package/src/sap/ui/rta/messagebundle.properties +8 -0
  60. package/src/sap/ui/rta/messagebundle_ar.properties +4 -0
  61. package/src/sap/ui/rta/messagebundle_bg.properties +5 -1
  62. package/src/sap/ui/rta/messagebundle_ca.properties +4 -0
  63. package/src/sap/ui/rta/messagebundle_cnr.properties +5 -1
  64. package/src/sap/ui/rta/messagebundle_cs.properties +4 -0
  65. package/src/sap/ui/rta/messagebundle_cy.properties +8 -4
  66. package/src/sap/ui/rta/messagebundle_da.properties +4 -0
  67. package/src/sap/ui/rta/messagebundle_de.properties +5 -1
  68. package/src/sap/ui/rta/messagebundle_el.properties +4 -0
  69. package/src/sap/ui/rta/messagebundle_en.properties +4 -0
  70. package/src/sap/ui/rta/messagebundle_en_GB.properties +4 -0
  71. package/src/sap/ui/rta/messagebundle_en_US_saprigi.properties +322 -318
  72. package/src/sap/ui/rta/messagebundle_es.properties +4 -0
  73. package/src/sap/ui/rta/messagebundle_es_MX.properties +5 -1
  74. package/src/sap/ui/rta/messagebundle_et.properties +6 -2
  75. package/src/sap/ui/rta/messagebundle_fi.properties +4 -0
  76. package/src/sap/ui/rta/messagebundle_fr.properties +5 -1
  77. package/src/sap/ui/rta/messagebundle_fr_CA.properties +4 -0
  78. package/src/sap/ui/rta/messagebundle_hi.properties +4 -0
  79. package/src/sap/ui/rta/messagebundle_hr.properties +6 -2
  80. package/src/sap/ui/rta/messagebundle_hu.properties +4 -0
  81. package/src/sap/ui/rta/messagebundle_id.properties +5 -1
  82. package/src/sap/ui/rta/messagebundle_it.properties +10 -6
  83. package/src/sap/ui/rta/messagebundle_iw.properties +9 -5
  84. package/src/sap/ui/rta/messagebundle_ja.properties +4 -0
  85. package/src/sap/ui/rta/messagebundle_kk.properties +4 -0
  86. package/src/sap/ui/rta/messagebundle_ko.properties +4 -0
  87. package/src/sap/ui/rta/messagebundle_lt.properties +5 -1
  88. package/src/sap/ui/rta/messagebundle_lv.properties +11 -7
  89. package/src/sap/ui/rta/messagebundle_mk.properties +15 -11
  90. package/src/sap/ui/rta/messagebundle_ms.properties +5 -1
  91. package/src/sap/ui/rta/messagebundle_nl.properties +4 -0
  92. package/src/sap/ui/rta/messagebundle_no.properties +4 -0
  93. package/src/sap/ui/rta/messagebundle_pl.properties +5 -1
  94. package/src/sap/ui/rta/messagebundle_pt.properties +4 -0
  95. package/src/sap/ui/rta/messagebundle_pt_PT.properties +4 -0
  96. package/src/sap/ui/rta/messagebundle_ro.properties +8 -4
  97. package/src/sap/ui/rta/messagebundle_ru.properties +5 -1
  98. package/src/sap/ui/rta/messagebundle_sh.properties +5 -1
  99. package/src/sap/ui/rta/messagebundle_sk.properties +4 -0
  100. package/src/sap/ui/rta/messagebundle_sl.properties +7 -3
  101. package/src/sap/ui/rta/messagebundle_sr.properties +6 -2
  102. package/src/sap/ui/rta/messagebundle_sv.properties +4 -0
  103. package/src/sap/ui/rta/messagebundle_th.properties +9 -5
  104. package/src/sap/ui/rta/messagebundle_tr.properties +7 -3
  105. package/src/sap/ui/rta/messagebundle_uk.properties +5 -1
  106. package/src/sap/ui/rta/messagebundle_vi.properties +4 -0
  107. package/src/sap/ui/rta/messagebundle_zh_CN.properties +5 -1
  108. package/src/sap/ui/rta/messagebundle_zh_TW.properties +6 -2
  109. package/src/sap/ui/rta/plugin/AddXMLAtExtensionPoint.js +16 -11
  110. package/src/sap/ui/rta/plugin/BaseCreate.js +1 -1
  111. package/src/sap/ui/rta/plugin/Combine.js +1 -1
  112. package/src/sap/ui/rta/plugin/CompVariant.js +43 -1
  113. package/src/sap/ui/rta/plugin/ControlVariant.js +3 -2
  114. package/src/sap/ui/rta/plugin/CreateContainer.js +1 -1
  115. package/src/sap/ui/rta/plugin/CutPaste.js +1 -1
  116. package/src/sap/ui/rta/plugin/DragDrop.js +1 -1
  117. package/src/sap/ui/rta/plugin/EasyAdd.js +2 -2
  118. package/src/sap/ui/rta/plugin/EasyRemove.js +1 -1
  119. package/src/sap/ui/rta/plugin/LocalReset.js +1 -1
  120. package/src/sap/ui/rta/plugin/Plugin.js +18 -10
  121. package/src/sap/ui/rta/plugin/RTAElementMover.js +1 -1
  122. package/src/sap/ui/rta/plugin/Remove.js +1 -1
  123. package/src/sap/ui/rta/plugin/Rename.js +1 -1
  124. package/src/sap/ui/rta/plugin/RenameHandler.js +2 -2
  125. package/src/sap/ui/rta/plugin/Resize.js +1 -1
  126. package/src/sap/ui/rta/plugin/Selection.js +24 -9
  127. package/src/sap/ui/rta/plugin/Settings.js +17 -15
  128. package/src/sap/ui/rta/plugin/Split.js +1 -1
  129. package/src/sap/ui/rta/plugin/Stretch.js +14 -13
  130. package/src/sap/ui/rta/plugin/additionalElements/ActionExtractor.js +1 -1
  131. package/src/sap/ui/rta/plugin/additionalElements/AddElementsDialog.js +1 -1
  132. package/src/sap/ui/rta/plugin/additionalElements/AdditionalElementsPlugin.js +134 -67
  133. package/src/sap/ui/rta/plugin/additionalElements/AdditionalElementsUtils.js +1 -1
  134. package/src/sap/ui/rta/plugin/additionalElements/CommandBuilder.js +6 -2
  135. package/src/sap/ui/rta/plugin/iframe/AddIFrame.js +2 -2
  136. package/src/sap/ui/rta/plugin/iframe/AddIFrameDialog.fragment.xml +57 -47
  137. package/src/sap/ui/rta/plugin/iframe/AddIFrameDialog.js +21 -8
  138. package/src/sap/ui/rta/plugin/iframe/AddIFrameDialogController.js +56 -41
  139. package/src/sap/ui/rta/service/Action.js +1 -1
  140. package/src/sap/ui/rta/service/ControllerExtension.js +1 -1
  141. package/src/sap/ui/rta/service/Outline.js +22 -18
  142. package/src/sap/ui/rta/service/Property.js +1 -1
  143. package/src/sap/ui/rta/service/Selection.js +1 -1
  144. package/src/sap/ui/rta/service/SupportTools.js +23 -19
  145. package/src/sap/ui/rta/toolbar/Adaptation.js +16 -18
  146. package/src/sap/ui/rta/toolbar/Base.js +1 -1
  147. package/src/sap/ui/rta/toolbar/Fiori.js +1 -1
  148. package/src/sap/ui/rta/toolbar/FioriLike.js +1 -1
  149. package/src/sap/ui/rta/toolbar/OverflowToolbarButton.js +1 -1
  150. package/src/sap/ui/rta/toolbar/Personalization.js +1 -1
  151. package/src/sap/ui/rta/toolbar/Standalone.js +1 -1
  152. package/src/sap/ui/rta/toolbar/contextBased/SaveAsAdaptation.js +1 -1
  153. package/src/sap/ui/rta/toolbar/translation/Translation.js +1 -1
  154. package/src/sap/ui/rta/toolbar/versioning/Versioning.js +12 -5
  155. package/src/sap/ui/rta/util/PluginManager.js +1 -1
  156. package/src/sap/ui/rta/util/PopupManager.js +1 -1
  157. package/src/sap/ui/rta/util/ReloadManager.js +19 -59
  158. package/src/sap/ui/rta/util/ServiceEventBus.js +1 -1
  159. package/src/sap/ui/rta/util/ServiceManager.js +193 -0
  160. package/src/sap/ui/rta/util/adaptationStarter.js +1 -1
  161. package/src/sap/ui/rta/util/changeVisualization/ChangeIndicator.js +90 -45
  162. package/src/sap/ui/rta/util/changeVisualization/ChangeIndicatorRegistry.js +32 -25
  163. package/src/sap/ui/rta/util/changeVisualization/ChangeVisualization.js +98 -132
  164. package/LICENSES/BSD-2-Clause.txt +0 -22
@@ -7,7 +7,6 @@
7
7
  // Provides class sap.ui.rta.RuntimeAuthoring.
8
8
  sap.ui.define([
9
9
  "sap/base/strings/capitalize",
10
- "sap/base/util/isPlainObject",
11
10
  "sap/base/Log",
12
11
  "sap/m/MessageBox",
13
12
  "sap/m/MessageToast",
@@ -41,7 +40,6 @@ sap.ui.define([
41
40
  "sap/ui/rta/command/BaseCommand",
42
41
  "sap/ui/rta/command/LREPSerializer",
43
42
  "sap/ui/rta/command/Stack",
44
- "sap/ui/rta/service/index",
45
43
  "sap/ui/rta/toolbar/Fiori",
46
44
  "sap/ui/rta/toolbar/FioriLike",
47
45
  "sap/ui/rta/toolbar/Personalization",
@@ -50,13 +48,12 @@ sap.ui.define([
50
48
  "sap/ui/rta/util/PluginManager",
51
49
  "sap/ui/rta/util/PopupManager",
52
50
  "sap/ui/rta/util/ReloadManager",
53
- "sap/ui/rta/util/ServiceEventBus",
51
+ "sap/ui/rta/util/ServiceManager",
54
52
  "sap/ui/rta/util/validateFlexEnabled",
55
53
  "sap/ui/rta/Utils",
56
54
  "sap/ui/Device"
57
55
  ], function(
58
56
  capitalize,
59
- isPlainObject,
60
57
  Log,
61
58
  MessageBox,
62
59
  MessageToast,
@@ -90,7 +87,6 @@ sap.ui.define([
90
87
  BaseCommand,
91
88
  LREPSerializer,
92
89
  CommandStack,
93
- ServicesIndex,
94
90
  FioriToolbar,
95
91
  FioriLikeToolbar,
96
92
  PersonalizationToolbar,
@@ -99,20 +95,17 @@ sap.ui.define([
99
95
  PluginManager,
100
96
  PopupManager,
101
97
  ReloadManager,
102
- ServiceEventBus,
98
+ ServiceManager,
103
99
  validateFlexEnabled,
104
100
  Utils,
105
101
  Device
106
102
  ) {
107
103
  "use strict";
108
104
 
109
- var STARTING = "STARTING";
110
- var STARTED = "STARTED";
111
- var STOPPED = "STOPPED";
112
- var FAILED = "FAILED";
113
- var SERVICE_STARTING = "SERVICE_STARTING";
114
- var SERVICE_STARTED = "SERVICE_STARTED";
115
- var SERVICE_FAILED = "SERVICE_FAILED";
105
+ const STARTING = "STARTING";
106
+ const STARTED = "STARTED";
107
+ const STOPPED = "STOPPED";
108
+ const FAILED = "FAILED";
116
109
 
117
110
  /**
118
111
  * Constructor for a new sap.ui.rta.RuntimeAuthoring class.
@@ -120,13 +113,13 @@ sap.ui.define([
120
113
  * @class The runtime authoring allows to adapt the fields of a running application.
121
114
  * @extends sap.ui.base.ManagedObject
122
115
  * @author SAP SE
123
- * @version 1.120.7
116
+ * @version 1.121.0
124
117
  * @constructor
125
118
  * @private
126
119
  * @since 1.30
127
120
  * @alias sap.ui.rta.RuntimeAuthoring
128
121
  */
129
- var RuntimeAuthoring = ManagedObject.extend("sap.ui.rta.RuntimeAuthoring", {
122
+ const RuntimeAuthoring = ManagedObject.extend("sap.ui.rta.RuntimeAuthoring", {
130
123
  metadata: {
131
124
  // ---- control specific ----
132
125
  library: "sap.ui.rta",
@@ -237,12 +230,12 @@ sap.ui.define([
237
230
  ManagedObject.apply(this, aArgs);
238
231
 
239
232
  this._dependents = {};
240
- this._mServices = {};
241
233
  this._mUShellServices = {};
242
234
  this._pElementModified = Promise.resolve();
243
235
 
244
236
  this.addDependent(new PluginManager(), "pluginManager");
245
237
  this.addDependent(new PopupManager(), "popupManager");
238
+ this.addDependent(new ServiceManager(), "serviceManager");
246
239
 
247
240
  if (this.getShowToolbars()) {
248
241
  this.getPopupManager().attachOpen(onPopupOpen, this);
@@ -251,13 +244,13 @@ sap.ui.define([
251
244
  // Change visualization can only be triggered from the toolbar
252
245
  this.addDependent(new ChangeVisualization(), "changeVisualization");
253
246
  }
254
-
247
+ this.pServices = Promise.resolve();
255
248
  if (window.parent !== window) {
256
- this.startService("receiver");
249
+ this.pServices = this.getService("receiver");
257
250
  }
258
- this.startService("supportTools");
251
+ this.pServices = this.pServices.then(this.getService.bind(this, "supportTools"));
259
252
 
260
- this._loadUShellServicesPromise = FlexUtils.getUShellServices(["URLParsing", "AppLifeCycle", "CrossApplicationNavigation"])
253
+ this._loadUShellServicesPromise = FlexUtils.getUShellServices(["URLParsing", "AppLifeCycle", "Navigation"])
261
254
  .then(function(mUShellServices) {
262
255
  this._mUShellServices = mUShellServices;
263
256
  ReloadManager.setUShellServices(mUShellServices);
@@ -265,55 +258,6 @@ sap.ui.define([
265
258
  }
266
259
  });
267
260
 
268
- /**
269
- * The RTA FLP plugin checks whether RTA needs to be restarted and restarts it if needed.
270
- *
271
- * @public
272
- * @static
273
- * @param {sap.ui.fl.Layer} sLayer - Active layer
274
- * @returns {boolean} Returns true if restart is needed
275
- */
276
- RuntimeAuthoring.needsRestart = function(sLayer) {
277
- return ReloadManager.needsAutomaticStart(sLayer);
278
- };
279
-
280
- /**
281
- * Enable restart of RTA
282
- * the RTA FLP plugin handles the restart
283
- *
284
- * @public
285
- * @static
286
- * @param {sap.ui.fl.Layer} sLayer - Active layer
287
- * @param {sap.ui.core.Control} oRootControl - Root control for which RTA was started
288
- */
289
- RuntimeAuthoring.enableRestart = function(sLayer, oRootControl) {
290
- ReloadManager.enableAutomaticStart(sLayer, oRootControl);
291
- };
292
-
293
- /**
294
- * Disable restart of RTA
295
- *
296
- * @public
297
- * @static
298
- * @param {sap.ui.fl.Layer} sLayer - Active layer
299
- */
300
- RuntimeAuthoring.disableRestart = function(sLayer) {
301
- ReloadManager.disableAutomaticStart(sLayer);
302
- };
303
-
304
- /**
305
- * Check if RTA is about to start or starting after a reload
306
- * e.g. when reloading without personalization changes
307
- *
308
- * @public
309
- * @static
310
- * @param {sap.ui.fl.Layer} [sLayer] - Active layer, CUSTOMER by default
311
- * @returns {boolean} Returns true if RTA is about to start or starting
312
- */
313
- RuntimeAuthoring.willRTAStartAfterReload = function(sLayer) {
314
- return ReloadManager.needsAutomaticStart(sLayer || Layer.CUSTOMER);
315
- };
316
-
317
261
  RuntimeAuthoring.prototype.addDependent = function(oObject, sName, bCreateGetter) {
318
262
  bCreateGetter = typeof bCreateGetter === "undefined" ? true : !!bCreateGetter;
319
263
  if (!(sName in this._dependents)) {
@@ -349,7 +293,7 @@ sap.ui.define([
349
293
  */
350
294
  RuntimeAuthoring.prototype.setPlugins = function(mPlugins) {
351
295
  if (this._sStatus !== STOPPED) {
352
- throw new Error("Cannot replace plugins: runtime authoring already started");
296
+ throw Error("Cannot replace plugins: runtime authoring already started");
353
297
  }
354
298
  this.getPluginManager().setPlugins(mPlugins);
355
299
  };
@@ -394,8 +338,8 @@ sap.ui.define([
394
338
  */
395
339
  RuntimeAuthoring.prototype.setFlexSettings = function(mFlexSettings) {
396
340
  // Check URI-parameters for sap-ui-layer
397
- var oUriParams = new URLSearchParams(window.location.search);
398
- var sUriLayer = oUriParams.get("sap-ui-layer");
341
+ const oUriParams = new URLSearchParams(window.location.search);
342
+ const sUriLayer = oUriParams.get("sap-ui-layer");
399
343
 
400
344
  mFlexSettings = Object.assign({}, this.getFlexSettings(), mFlexSettings);
401
345
  if (sUriLayer) {
@@ -405,7 +349,7 @@ sap.ui.define([
405
349
  // TODO: this will lead to incorrect information if this function is first called
406
350
  // with scenario or baseId and then called again without.
407
351
  if (mFlexSettings.scenario || mFlexSettings.baseId) {
408
- var sLRepRootNamespace = FlexUtils.buildLrepRootNamespace(
352
+ const sLRepRootNamespace = FlexUtils.buildLrepRootNamespace(
409
353
  mFlexSettings.baseId,
410
354
  mFlexSettings.scenario,
411
355
  mFlexSettings.projectId
@@ -444,171 +388,159 @@ sap.ui.define([
444
388
  * @returns {Promise} Returns a Promise with the initialization of RTA
445
389
  * @public
446
390
  */
447
- RuntimeAuthoring.prototype.start = function() {
448
- var bIsAutomaticRestart = RuntimeAuthoring.needsRestart(this.getLayer());
449
- var oDesignTimePromise;
450
- var vError;
391
+ RuntimeAuthoring.prototype.start = async function() {
451
392
  // Create DesignTime
452
- if (this._sStatus === STOPPED) {
453
- this._sStatus = STARTING;
454
- var oRootControl = this.getRootControlInstance();
455
- if (!oRootControl) {
456
- vError = new Error("Root control not found");
457
- Log.error(vError);
458
- return Promise.reject(vError);
459
- }
393
+ if (this._sStatus !== STOPPED) {
394
+ throw Error("RuntimeAuthoring is already started");
395
+ }
396
+ this._sStatus = STARTING;
397
+ const oRootControl = this.getRootControlInstance();
398
+ if (!oRootControl) {
399
+ throw Error("Root control not found");
400
+ }
460
401
 
461
- return this._loadUShellServicesPromise
462
- .then(initVersioning.bind(this))
463
- .then(initContextBasedAdaptations.bind(this, bIsAutomaticRestart))
464
- /*
465
- Check if the application has personalized changes and reload without them;
466
- Also Check if the application has an available draft and if yes, reload with those changes.
467
- */
468
- .then(function() {
469
- return ReloadManager.handleReloadOnStart({
470
- layer: this.getLayer(),
471
- selector: this.getRootControlInstance(),
472
- versioningEnabled: this._oVersionsModel.getProperty("/versioningEnabled"),
473
- developerMode: this.getFlexSettings().developerMode,
474
- adaptationId: this._oContextBasedAdaptationsModel.getProperty("/displayedAdaptation/id")
475
- });
476
- }.bind(this))
477
- .then(function(bReloadTriggered) {
478
- if (bReloadTriggered) {
479
- // FLP Plugin reacts on this error string and doesn't pass the error on the UI
480
- return Promise.reject("Reload triggered");
481
- }
482
- var oFlexInfoSession = PersistenceWriteAPI.getResetAndPublishInfoFromSession(this.getRootControlInstance());
483
- this.bInitialResetEnabled = !!oFlexInfoSession.isResetEnabled;
402
+ try {
403
+ await this._loadUShellServicesPromise;
404
+ await initVersioning.call(this);
405
+ await initContextBasedAdaptations.call(this, RuntimeAuthoring.needsRestart(this.getLayer()));
484
406
 
485
- this._oSerializer = new LREPSerializer({commandStack: this.getCommandStack(), rootControl: this.getRootControl()});
407
+ // Check if the application has personalized changes and reload without them;
408
+ // Also Check if the application has an available draft and if yes, reload with those changes.
409
+ const bReloadTriggered = await ReloadManager.handleReloadOnStart({
410
+ layer: this.getLayer(),
411
+ selector: this.getRootControlInstance(),
412
+ versioningEnabled: this._oVersionsModel.getProperty("/versioningEnabled"),
413
+ developerMode: this.getFlexSettings().developerMode,
414
+ adaptationId: this._oContextBasedAdaptationsModel.getProperty("/displayedAdaptation/id")
415
+ });
416
+ if (bReloadTriggered) {
417
+ // FLP Plugin reacts on this error string and doesn't pass the error on the UI
418
+ throw Error("Reload triggered");
419
+ }
420
+ PersistenceWriteAPI.setAdaptationLayer(this.getLayer(), this.getRootControlInstance());
421
+ const oFlexInfoSession = PersistenceWriteAPI.getResetAndPublishInfoFromSession(this.getRootControlInstance());
422
+ this.bInitialResetEnabled = !!oFlexInfoSession.isResetEnabled;
486
423
 
487
- this.getPluginManager().preparePlugins(
488
- this.getFlexSettings(),
489
- handleElementModified.bind(this),
490
- this.getCommandStack()
491
- );
424
+ this._oSerializer = new LREPSerializer({commandStack: this.getCommandStack(), rootControl: this.getRootControl()});
492
425
 
493
- var aPlugins = this.getPluginManager().getPluginList();
426
+ this.getPluginManager().preparePlugins(
427
+ this.getFlexSettings(),
428
+ handleElementModified.bind(this),
429
+ this.getCommandStack()
430
+ );
494
431
 
495
- oDesignTimePromise = new Promise(function(fnResolve, fnReject) {
496
- Measurement.start("rta.dt.startup", "Measurement of RTA: DesignTime start up");
497
- this._oDesignTime = new DesignTime({
498
- scope: this.getMetadataScope(),
499
- plugins: aPlugins
500
- });
432
+ const oDesignTimePromise = createDesignTime.call(this);
501
433
 
502
- addOrRemoveStyleClass(this.getRootControlInstance(), true);
434
+ // Register function for checking unsaved before leaving RTA
435
+ this._oldUnloadHandler = window.onbeforeunload;
436
+ window.onbeforeunload = this._onUnload.bind(this);
437
+ if (this.getShowToolbars()) {
438
+ // Create ToolsMenu
439
+ const mButtonsAvailability = await getToolbarButtonsVisibility(
440
+ this.getRootControlInstance(), this.getLayer(), this._oSerializer
441
+ );
442
+ await createToolsMenu.call(this, mButtonsAvailability);
443
+ }
444
+ // this is needed to initially check if undo is available, e.g. when the stack gets initialized with changes
445
+ await onStackModified.call(this);
503
446
 
504
- // add root control is triggering overlay creation, so we need to wait for the scope to be set.
505
- this._oDesignTime.addRootElement(this._oRootControl);
447
+ // Resolve the CSS variable set in themes/base/OverlayWithScrollbar.css
448
+ Overlay.getOverlayContainer().get(0).style.setProperty(
449
+ "--sap-ui-rta-scrollbar-scrollWidth",
450
+ `${DOMUtil.getScrollbarWidth()}px`
451
+ );
452
+ Overlay.getOverlayContainer().get(0).style.setProperty(
453
+ "--sap-ui-rta-scrollbar-scrollWidthPlusTwo",
454
+ `${DOMUtil.getScrollbarWidth() + 2}px`
455
+ );
456
+ await oDesignTimePromise;
506
457
 
507
- // TODO: remove when Overlay.getOverlayContainer() does not return jQuery any more
508
- Overlay.getOverlayContainer().get(0).classList.add("sapUiRta");
509
- if (this.getLayer() === Layer.USER) {
510
- Overlay.getOverlayContainer().get(0).classList.add("sapUiRtaPersonalize");
511
- } else {
512
- // RTA Visual Improvements
513
- document.body.classList.add("sapUiRtaMode");
514
- }
515
- this._oDesignTime.getSelectionManager().attachChange(function(oEvent) {
516
- this.fireSelectionChange({selection: oEvent.getParameter("selection")});
517
- }, this);
458
+ // needed to access the connected elements (e.g. section/anchor bar) in CViz
459
+ if (this.getChangeVisualization) {
460
+ this.getChangeVisualization()._oDesignTime = this._oDesignTime;
461
+ }
518
462
 
519
- this._oDesignTime.attachEventOnce("synced", function() {
520
- fnResolve();
521
- Measurement.end("rta.dt.startup", "Measurement of RTA: DesignTime start up");
522
- }, this);
463
+ // PopupManager sets the toolbar to already open popups' autoCloseAreas
464
+ // Since at this point the toolbar is not available, it waits for RTA to start,
465
+ // before adding it to the autoCloseAreas of the open popups
466
+ this.getPopupManager().setRta(this);
523
467
 
524
- this._oDesignTime.attachEventOnce("syncFailed", function(oEvent) {
525
- fnReject(oEvent.getParameter("error"));
526
- });
527
- }.bind(this));
468
+ if (this.getShowToolbars()) {
469
+ // the show() method of the toolbar relies on this RTA instance being set on the PopupManager
470
+ await this.getToolbar().show();
471
+ }
472
+ if (Device.browser.name === "ff") {
473
+ // in FF shift+f10 also opens a browser context menu.
474
+ // It seems that the only way to get rid of it is to completely turn off context menu in ff..
475
+ jQuery(document).on("contextmenu", ffContextMenuHandler);
476
+ }
477
+ this.fnKeyDown = onKeyDown.bind(this);
478
+ jQuery(document).on("keydown", this.fnKeyDown);
479
+ this.fnOnPersonalizationChangeCreation = onPersonalizationChangeCreation.bind(this);
480
+ ControlPersonalizationWriteAPI.attachChangeCreation(
481
+ this.getRootControlInstance(),
482
+ this.fnOnPersonalizationChangeCreation
483
+ );
484
+ await checkFlexEnabled.call(this);
528
485
 
529
- // Register function for checking unsaved before leaving RTA
530
- this._oldUnloadHandler = window.onbeforeunload;
531
- window.onbeforeunload = this._onUnload.bind(this);
532
- return undefined;
533
- }.bind(this))
534
- .then(function() {
535
- if (this.getShowToolbars()) {
536
- // Create ToolsMenu
537
- return getToolbarButtonsVisibility(this.getRootControlInstance(), this.getLayer(), this._oSerializer)
538
- .then(createToolsMenu.bind(this));
539
- }
540
- return undefined;
541
- }.bind(this))
542
- // this is needed to initially check if undo is available, e.g. when the stack gets initialized with changes
543
- .then(onStackModified.bind(this))
544
- .then(function() {
545
- // Resolve the CSS variable set in themes/base/OverlayWithScrollbar.css
546
- Overlay.getOverlayContainer().get(0).style.setProperty(
547
- "--sap-ui-rta-scrollbar-scrollWidth",
548
- `${DOMUtil.getScrollbarWidth()}px`
549
- );
550
- Overlay.getOverlayContainer().get(0).style.setProperty(
551
- "--sap-ui-rta-scrollbar-scrollWidthPlusTwo",
552
- `${DOMUtil.getScrollbarWidth() + 2}px`
553
- );
554
- return oDesignTimePromise;
555
- })
556
- .then(function() {
557
- // PopupManager sets the toolbar to already open popups' autoCloseAreas
558
- // Since at this point the toolbar is not available, it waits for RTA to start,
559
- // before adding it to the autoCloseAreas of the open popups
560
- this.getPopupManager().setRta(this);
561
- if (this.getShowToolbars()) {
562
- // the show() method of the toolbar relies on this RTA instance being set on the PopupManager
563
- return this.getToolbar().show();
564
- }
565
- return undefined;
566
- }.bind(this))
567
- .then(function() {
568
- if (Device.browser.name === "ff") {
569
- // in FF shift+f10 also opens a browser context menu.
570
- // It seems that the only way to get rid of it is to completely turn off context menu in ff..
571
- jQuery(document).on("contextmenu", ffContextMenuHandler);
572
- }
573
- })
574
- .then(function() {
575
- this.fnKeyDown = onKeyDown.bind(this);
576
- jQuery(document).on("keydown", this.fnKeyDown);
577
- this.fnOnPersonalizationChangeCreation = onPersonalizationChangeCreation.bind(this);
578
- ControlPersonalizationWriteAPI.attachChangeCreation(
579
- this.getRootControlInstance(),
580
- this.fnOnPersonalizationChangeCreation
581
- );
582
- }.bind(this))
583
- .then(shouldValidateFlexEnabled)
584
- .then(function(bShouldValidateFlexEnabled) {
585
- if (bShouldValidateFlexEnabled) {
586
- validateFlexEnabled(this);
587
- }
588
- this._sStatus = STARTED;
589
- RuntimeAuthoring.disableRestart(this.getLayer());
590
- this.fireStart({
591
- editablePluginsCount: this.getPluginManager().getEditableOverlaysCount()
592
- });
593
- }.bind(this))
594
- .catch(function(vError) {
595
- if (vError === "Reload triggered") {
596
- // destroy rta when reload is triggered - otherwise the consumer needs to take care of this
597
- this.destroy();
598
- } else {
599
- this._sStatus = FAILED;
600
- this.fireFailed({error: vError});
601
- }
602
- return Promise.reject(vError);
603
- }.bind(this));
486
+ this._sStatus = STARTED;
487
+ RuntimeAuthoring.disableRestart(this.getLayer());
488
+ this.fireStart({
489
+ editablePluginsCount: this.getPluginManager().getEditableOverlaysCount()
490
+ });
491
+ await this.pServices;
492
+ } catch (vError) {
493
+ if (vError.message === "Reload triggered") {
494
+ // destroy rta when reload is triggered - otherwise the consumer needs to take care of this
495
+ this.destroy();
496
+ } else {
497
+ this._sStatus = FAILED;
498
+ this.fireFailed({vError: vError.message});
499
+ }
500
+ throw Error(vError.message);
604
501
  }
605
- return Promise.reject("RuntimeAuthoring is already started");
606
502
  };
607
503
 
504
+ function createDesignTime() {
505
+ const aPlugins = this.getPluginManager().getPluginList();
506
+ return new Promise(function(fnResolve, fnReject) {
507
+ Measurement.start("rta.dt.startup", "Measurement of RTA: DesignTime start up");
508
+ this._oDesignTime = new DesignTime({
509
+ scope: this.getMetadataScope(),
510
+ plugins: aPlugins
511
+ });
512
+
513
+ addOrRemoveStyleClass(this.getRootControlInstance(), true);
514
+
515
+ // add root control is triggering overlay creation, so we need to wait for the scope to be set.
516
+ this._oDesignTime.addRootElement(this._oRootControl);
517
+
518
+ Overlay.getOverlayContainer().get(0).classList.add("sapUiRta");
519
+ if (this.getLayer() === Layer.USER) {
520
+ Overlay.getOverlayContainer().get(0).classList.add("sapUiRtaPersonalize");
521
+ } else {
522
+ // RTA Visual Improvements
523
+ document.body.classList.add("sapUiRtaMode");
524
+ }
525
+ this._oDesignTime.getSelectionManager().attachChange(function(oEvent) {
526
+ this.fireSelectionChange({selection: oEvent.getParameter("selection")});
527
+ }, this);
528
+
529
+ this._oDesignTime.attachEventOnce("synced", function() {
530
+ fnResolve();
531
+ Measurement.end("rta.dt.startup", "Measurement of RTA: DesignTime start up");
532
+ }, this);
533
+
534
+ this._oDesignTime.attachEventOnce("syncFailed", function(oEvent) {
535
+ fnReject(oEvent.getParameter("error"));
536
+ });
537
+ }.bind(this));
538
+ }
539
+
608
540
  function showSaveConfirmation() {
609
- var bVersionEnabled = this._oVersionsModel.getProperty("/versioningEnabled");
610
- var sWarningMessageKey = bVersionEnabled ? "MSG_UNSAVED_DRAFT_CHANGES_ON_CLOSE" : "MSG_UNSAVED_CHANGES_ON_CLOSE";
611
- var sSaveButtonTextKey = bVersionEnabled ? "BTN_UNSAVED_DRAFT_CHANGES_ON_CLOSE_SAVE" : "BTN_UNSAVED_CHANGES_ON_CLOSE_SAVE";
541
+ const bVersionEnabled = this._oVersionsModel.getProperty("/versioningEnabled");
542
+ const sWarningMessageKey = bVersionEnabled ? "MSG_UNSAVED_DRAFT_CHANGES_ON_CLOSE" : "MSG_UNSAVED_CHANGES_ON_CLOSE";
543
+ const sSaveButtonTextKey = bVersionEnabled ? "BTN_UNSAVED_DRAFT_CHANGES_ON_CLOSE_SAVE" : "BTN_UNSAVED_CHANGES_ON_CLOSE_SAVE";
612
544
  return Utils.showMessageBox("warning", sWarningMessageKey, {
613
545
  titleKey: "TIT_UNSAVED_CHANGES_ON_CLOSE",
614
546
  actionKeys: [
@@ -628,34 +560,23 @@ sap.ui.define([
628
560
  * @param {boolean} bSkipRestart - Stop RTA with or w/o checking if a reload is needed to apply e.g. personalization/app descriptor changes
629
561
  * @returns {Promise} Resolves with undefined
630
562
  */
631
- RuntimeAuthoring.prototype.stop = function(bSkipSave, bSkipRestart) {
632
- var bUserCancelled;
633
- var oReloadInfo;
563
+ RuntimeAuthoring.prototype.stop = async function(bSkipSave, bSkipRestart) {
564
+ let bUserCancelled;
634
565
  checkToolbarAndExecuteFunction.call(this, "setBusy", true);
635
- return waitForPendingActions.call(this)
636
- .then(function() {
637
- var sLayer = this.getLayer();
566
+ try {
567
+ await waitForPendingActions.call(this);
568
+ const sLayer = this.getLayer();
638
569
  if (sLayer !== Layer.USER && !bSkipSave && this.canSave()) {
639
- return showSaveConfirmation.call(this)
640
- .then(function(sAction) {
641
- if (sAction === MessageBox.Action.CANCEL) {
642
- bUserCancelled = true;
643
- return Promise.reject();
644
- }
645
- if (sAction === this._getTextResources().getText("BTN_UNSAVED_CHANGES_ON_CLOSE_DONT_SAVE")) {
646
- return this._oSerializer.clearCommandStack(/* bRemoveChanges = */true);
647
- }
648
- return undefined;
649
- }.bind(this));
650
- }
651
- return undefined;
652
- }.bind(this))
653
- .then(function() {
654
- if (bSkipRestart) {
655
- return {};
570
+ const sAction = await showSaveConfirmation.call(this);
571
+ if (sAction === MessageBox.Action.CANCEL) {
572
+ bUserCancelled = true;
573
+ throw Error();
574
+ }
575
+ if (sAction === this._getTextResources().getText("BTN_UNSAVED_CHANGES_ON_CLOSE_DONT_SAVE")) {
576
+ await this._oSerializer.clearCommandStack(/* bRemoveChanges = */true);
577
+ }
656
578
  }
657
- // Reload check must happen before _serializeToLrep is called
658
- return ReloadManager.checkReloadOnExit({
579
+ const oReloadInfo = bSkipRestart ? {} : await ReloadManager.checkReloadOnExit({
659
580
  layer: this.getLayer(),
660
581
  selector: this.getRootControlInstance(),
661
582
  isDraftAvailable: this._oVersionsModel.getProperty("/draftAvailable"),
@@ -663,43 +584,35 @@ sap.ui.define([
663
584
  activeVersion: this._oVersionsModel.getProperty("/activeVersion"),
664
585
  changesNeedReloadPromise: this._bSavedChangesNeedReload ? Promise.resolve(true) : this._oSerializer.needsReload()
665
586
  });
666
- }.bind(this))
667
- .then(function(oReturn) {
668
- oReloadInfo = oReturn;
587
+
669
588
  if (!bSkipSave) {
670
589
  // serializeToLrep has to be called on exit even when no changes were made -> to invalidate cache
671
- return this._serializeToLrep(/* bCondenseAnyLayer= */false, /* bIsExit= */true);
590
+ await this._serializeToLrep(/* bCondenseAnyLayer= */false, /* bIsExit= */true);
672
591
  }
673
- return undefined;
674
- }.bind(this))
675
- .then(function() {
592
+
676
593
  checkToolbarAndExecuteFunction.call(this, "hide", bSkipSave);
677
594
  this.fireStop();
678
595
  if (!bSkipRestart) {
679
- ReloadManager.handleUrlParametersOnExit(oReloadInfo);
596
+ ReloadManager.handleReloadOnExit(oReloadInfo);
680
597
  }
681
598
  VersionsAPI.clearInstances();
682
- }.bind(this))
683
- .catch(function(vError) {
684
- if (!bUserCancelled) {
685
- return showTechnicalError(vError);
686
- }
687
- return undefined;
688
- })
689
- .then(function() {
690
- checkToolbarAndExecuteFunction.call(this, "setBusy", false);
599
+ } catch (vError) {
691
600
  if (!bUserCancelled) {
692
- this._sStatus = STOPPED;
693
- document.body.classList.remove("sapUiRtaMode");
601
+ showTechnicalError(vError);
694
602
  }
695
- }.bind(this));
603
+ }
604
+ checkToolbarAndExecuteFunction.call(this, "setBusy", false);
605
+ if (!bUserCancelled) {
606
+ this._sStatus = STOPPED;
607
+ document.body.classList.remove("sapUiRtaMode");
608
+ }
696
609
  };
697
610
 
698
611
  /**
699
612
  * @override
700
613
  */
701
614
  RuntimeAuthoring.prototype.setCommandStack = function(oCommandStack) {
702
- var oOldCommandStack = this.getProperty("commandStack");
615
+ const oOldCommandStack = this.getProperty("commandStack");
703
616
  if (oOldCommandStack) {
704
617
  oOldCommandStack.detachModified(onStackModified, this);
705
618
  }
@@ -709,7 +622,7 @@ sap.ui.define([
709
622
  delete this._oInternalCommandStack;
710
623
  }
711
624
 
712
- var oResult = this.setProperty("commandStack", oCommandStack);
625
+ const oResult = this.setProperty("commandStack", oCommandStack);
713
626
 
714
627
  if (oCommandStack) {
715
628
  oCommandStack.attachModified(onStackModified, this);
@@ -726,7 +639,7 @@ sap.ui.define([
726
639
  * @override
727
640
  */
728
641
  RuntimeAuthoring.prototype.getCommandStack = function() {
729
- var oCommandStack = this.getProperty("commandStack");
642
+ let oCommandStack = this.getProperty("commandStack");
730
643
  if (!oCommandStack) {
731
644
  oCommandStack = new CommandStack();
732
645
  this._oInternalCommandStack = oCommandStack;
@@ -740,10 +653,10 @@ sap.ui.define([
740
653
  * @override
741
654
  */
742
655
  RuntimeAuthoring.prototype.setMode = function(sNewMode) {
743
- var sCurrentMode = this.getMode();
656
+ const sCurrentMode = this.getMode();
744
657
  if (sCurrentMode !== sNewMode) {
745
- var oTabHandlingPlugin = this.getPluginManager().getPlugin("tabHandling");
746
- var oSelectionPlugin = this.getPluginManager().getPlugin("selection");
658
+ const oTabHandlingPlugin = this.getPluginManager().getPlugin("tabHandling");
659
+ const oSelectionPlugin = this.getPluginManager().getPlugin("selection");
747
660
 
748
661
  // Switch between another mode and navigation -> toggle overlay & App-TabIndex enablement
749
662
  if (sCurrentMode === "navigation" || sNewMode === "navigation") {
@@ -751,7 +664,7 @@ sap.ui.define([
751
664
  oTabHandlingPlugin[(sNewMode === "navigation") ? "restoreTabIndex" : "removeTabIndex"]();
752
665
  }
753
666
 
754
- var oChangeVisualization = this.getChangeVisualization && this.getChangeVisualization();
667
+ const oChangeVisualization = this.getChangeVisualization?.();
755
668
  if (sNewMode === "visualization" || sCurrentMode === "visualization") {
756
669
  DtUtil.waitForSynced(this._oDesignTime)()
757
670
  .then(function() {
@@ -803,17 +716,13 @@ sap.ui.define([
803
716
  * @protected
804
717
  */
805
718
  RuntimeAuthoring.prototype.destroy = function(...aArgs) {
806
- var aDependentKeys = Object.keys(this._dependents);
719
+ const aDependentKeys = Object.keys(this._dependents);
807
720
  aDependentKeys.forEach(function(sDependentKey) {
808
721
  // Destroy should be called with suppress invalidate = true here to prevent static UI Area invalidation
809
722
  this._dependents[sDependentKey].destroy(true);
810
723
  this.removeDependent(sDependentKey);
811
724
  }.bind(this));
812
725
 
813
- Object.keys(this._mServices).forEach(function(sServiceName) {
814
- this.stopService(sServiceName);
815
- }, this);
816
-
817
726
  if (this._oDesignTime) {
818
727
  this._oDesignTime.destroy();
819
728
  this._oDesignTime = null;
@@ -835,10 +744,6 @@ sap.ui.define([
835
744
 
836
745
  this.setCommandStack(null);
837
746
 
838
- if (this._oServiceEventBus) {
839
- this._oServiceEventBus.destroy();
840
- }
841
-
842
747
  if (Device.browser.name === "ff") {
843
748
  jQuery(document).off("contextmenu", ffContextMenuHandler);
844
749
  }
@@ -850,6 +755,55 @@ sap.ui.define([
850
755
 
851
756
  // ---- API ----
852
757
 
758
+ /**
759
+ * The RTA FLP plugin checks whether RTA needs to be restarted and restarts it if needed.
760
+ *
761
+ * @public
762
+ * @static
763
+ * @param {sap.ui.fl.Layer} sLayer - Active layer
764
+ * @returns {boolean} Returns true if restart is needed
765
+ */
766
+ RuntimeAuthoring.needsRestart = function(sLayer) {
767
+ return ReloadManager.needsAutomaticStart(sLayer);
768
+ };
769
+
770
+ /**
771
+ * Enable restart of RTA
772
+ * the RTA FLP plugin handles the restart
773
+ *
774
+ * @public
775
+ * @static
776
+ * @param {sap.ui.fl.Layer} sLayer - Active layer
777
+ * @param {sap.ui.core.Control} oRootControl - Root control for which RTA was started
778
+ */
779
+ RuntimeAuthoring.enableRestart = function(sLayer, oRootControl) {
780
+ ReloadManager.enableAutomaticStart(sLayer, oRootControl);
781
+ };
782
+
783
+ /**
784
+ * Disable restart of RTA
785
+ *
786
+ * @public
787
+ * @static
788
+ * @param {sap.ui.fl.Layer} sLayer - Active layer
789
+ */
790
+ RuntimeAuthoring.disableRestart = function(sLayer) {
791
+ ReloadManager.disableAutomaticStart(sLayer);
792
+ };
793
+
794
+ /**
795
+ * Check if RTA is about to start or starting after a reload
796
+ * e.g. when reloading without personalization changes
797
+ *
798
+ * @public
799
+ * @static
800
+ * @param {sap.ui.fl.Layer} [sLayer] - Active layer, CUSTOMER by default
801
+ * @returns {boolean} Returns true if RTA is about to start or starting
802
+ */
803
+ RuntimeAuthoring.willRTAStartAfterReload = function(sLayer) {
804
+ return ReloadManager.needsAutomaticStart(sLayer || Layer.CUSTOMER);
805
+ };
806
+
853
807
  /**
854
808
  * Returns the selected overlays from the DesignTime. Used by VisualEditor
855
809
  * @returns {sap.ui.dt.Overlay[]} Selected overlays
@@ -870,11 +824,11 @@ sap.ui.define([
870
824
  * @returns {Promise} Resolves when Message Box is closed.
871
825
  */
872
826
  RuntimeAuthoring.prototype.restore = function() {
873
- var sLayer = this.getLayer();
874
- var sMessageKey = sLayer === Layer.USER
827
+ const sLayer = this.getLayer();
828
+ const sMessageKey = sLayer === Layer.USER
875
829
  ? "FORM_PERS_RESET_MESSAGE_PERSONALIZATION"
876
830
  : "FORM_PERS_RESET_MESSAGE";
877
- var sTitleKey = sLayer === Layer.USER
831
+ const sTitleKey = sLayer === Layer.USER
878
832
  ? "BTN_RESTORE"
879
833
  : "FORM_PERS_RESET_TITLE";
880
834
 
@@ -923,16 +877,16 @@ sap.ui.define([
923
877
  // ---- API ----
924
878
 
925
879
  // this function is used to save in the Visual Editor
926
- RuntimeAuthoring.prototype._serializeToLrep = function(bCondenseAnyLayer, bIsExit) {
880
+ RuntimeAuthoring.prototype._serializeToLrep = function(bCondenseAnyLayer, bIsExit, bActivateVersion) {
927
881
  // when saving a change that requires a reload, the information has to be cached
928
882
  // to do the reload when exiting UI Adaptation as then the change will not be available anymore
929
883
  if (!this._bSavedChangesNeedReload) {
930
884
  return this._oSerializer.needsReload().then(function(bReloadNeeded) {
931
885
  this._bSavedChangesNeedReload = bReloadNeeded;
932
- return serializeAndSave.call(this, undefined, bCondenseAnyLayer, bIsExit);
886
+ return serializeAndSave.call(this, bActivateVersion, bCondenseAnyLayer, bIsExit);
933
887
  }.bind(this));
934
888
  }
935
- return serializeAndSave.call(this, undefined, bCondenseAnyLayer, bIsExit);
889
+ return serializeAndSave.call(this, bActivateVersion, bCondenseAnyLayer, bIsExit);
936
890
  };
937
891
 
938
892
  /**
@@ -965,16 +919,16 @@ sap.ui.define([
965
919
  return undefined;
966
920
  };
967
921
 
968
- function shouldValidateFlexEnabled() {
969
- var sUriParam = new URLSearchParams(window.location.search).get("sap-ui-rta-skip-flex-validation");
970
- return Settings.getInstance()
971
- .then(function(oSettings) {
972
- return !oSettings.isCustomerSystem() && sUriParam !== "true";
973
- });
922
+ async function checkFlexEnabled() {
923
+ const sUriParam = new URLSearchParams(window.location.search).get("sap-ui-rta-skip-flex-validation");
924
+ const oSettings = await Settings.getInstance();
925
+ if (!oSettings.isCustomerSystem() && sUriParam !== "true") {
926
+ validateFlexEnabled(this);
927
+ }
974
928
  }
975
929
 
976
930
  function onPopupOpen(oEvent) {
977
- var oOpenedPopup = oEvent.getParameters().getSource();
931
+ const oOpenedPopup = oEvent.getParameters().getSource();
978
932
  if (
979
933
  oOpenedPopup.isA("sap.m.Dialog")
980
934
  && this.getToolbar().type === "fiori"
@@ -1000,7 +954,7 @@ sap.ui.define([
1000
954
  }
1001
955
 
1002
956
  function showMessageToast(sMessageKey, mOptions) {
1003
- var sMessage = this._getTextResources().getText(sMessageKey);
957
+ const sMessage = this._getTextResources().getText(sMessageKey);
1004
958
 
1005
959
  MessageToast.show(sMessage, mOptions || {});
1006
960
  }
@@ -1032,40 +986,29 @@ sap.ui.define([
1032
986
  * @param {sap.ui.rta.command.LREPSerializer} oSerializer - LREP Serializer
1033
987
  * @returns {Promise<map>} with publishAvailable, publishAppVariantSupported and draftAvailable values
1034
988
  */
1035
- function getToolbarButtonsVisibility(oRootControl, sLayer, oSerializer) {
1036
- return Promise.all([
1037
- FeaturesAPI.isPublishAvailable(),
1038
- RtaAppVariantFeature.isSaveAsAvailable(oRootControl, sLayer, oSerializer),
1039
- FeaturesAPI.isContextBasedAdaptationAvailable(sLayer),
1040
- FlexUtils.getUShellService("AppLifeCycle").then(function(oAppLifeCycle) {
1041
- if (oAppLifeCycle) {
1042
- var mRunningApp = oAppLifeCycle.getCurrentApplication();
1043
- return mRunningApp ? mRunningApp.homePage : false;
1044
- }
1045
- return false;
1046
- })
1047
- ]).then(function(aRtaFeaturesAvailability) {
1048
- var bIsPublishAvailable = aRtaFeaturesAvailability[0];
1049
- var bIsSaveAsAvailable = aRtaFeaturesAvailability[1];
1050
- var bIsContextBasedAdaptationAvailable = aRtaFeaturesAvailability[2];
1051
- var bIsHomePage = aRtaFeaturesAvailability[3];
1052
- var oManifest = FlexUtils.getAppDescriptor(oRootControl);
1053
- // context based adaptation is not supported for overview pages
1054
- var bIsContextBasedAdaptationSupported = oManifest && !ManifestUtils.getOvpEntry(oManifest);
1055
- return {
1056
- publishAvailable: bIsPublishAvailable,
1057
- saveAsAvailable: !bIsHomePage && bIsPublishAvailable && bIsSaveAsAvailable,
1058
- contextBasedAdaptationAvailable: !bIsHomePage && bIsContextBasedAdaptationSupported && bIsContextBasedAdaptationAvailable
1059
- };
1060
- });
989
+ async function getToolbarButtonsVisibility(oRootControl, sLayer, oSerializer) {
990
+ const bIsPublishAvailable = await FeaturesAPI.isPublishAvailable();
991
+ const bIsSaveAsAvailable = await RtaAppVariantFeature.isSaveAsAvailable(oRootControl, sLayer, oSerializer);
992
+ const bIsContextBasedAdaptationAvailable = await FeaturesAPI.isContextBasedAdaptationAvailable(sLayer);
993
+ const oAppLifeCycleService = await FlexUtils.getUShellService("AppLifeCycle");
994
+ const bIsHomePage = oAppLifeCycleService?.getCurrentApplication()?.homePage || false;
995
+ const oManifest = FlexUtils.getAppDescriptor(oRootControl);
996
+ // context based adaptation is not supported for overview pages
997
+ const bIsContextBasedAdaptationSupported = oManifest && !ManifestUtils.getOvpEntry(oManifest);
998
+
999
+ return {
1000
+ publishAvailable: bIsPublishAvailable,
1001
+ saveAsAvailable: !bIsHomePage && bIsPublishAvailable && bIsSaveAsAvailable,
1002
+ contextBasedAdaptationAvailable: !bIsHomePage && bIsContextBasedAdaptationSupported && bIsContextBasedAdaptationAvailable
1003
+ };
1061
1004
  }
1062
1005
 
1063
1006
  function showTechnicalError(vError) {
1064
1007
  BusyIndicator.hide();
1065
- var sErrorMessage = vError.userMessage || vError.stack || vError.message || vError.status || vError;
1066
- var oTextResources = Lib.getResourceBundleFor("sap.ui.rta");
1008
+ const sErrorMessage = vError.userMessage || vError.stack || vError.message || vError.status || vError;
1009
+ const oTextResources = Lib.getResourceBundleFor("sap.ui.rta");
1067
1010
  Log.error("Failed to transfer changes", sErrorMessage);
1068
- var sMsg = `${oTextResources.getText("MSG_LREP_TRANSFER_ERROR")}
1011
+ const sMsg = `${oTextResources.getText("MSG_LREP_TRANSFER_ERROR")}
1069
1012
  ${oTextResources.getText("MSG_ERROR_REASON", [sErrorMessage])}`;
1070
1013
  MessageBox.error(sMsg, {
1071
1014
  styleClass: Utils.getRtaStyleClassName()
@@ -1076,17 +1019,17 @@ sap.ui.define([
1076
1019
  * Adapt the enablement of undo/redo/reset button
1077
1020
  */
1078
1021
  function onStackModified() {
1079
- var bOnlySwitchVersion = !this.getShowToolbars() || !this.getCommandStack().canUndo();
1022
+ const bOnlySwitchVersion = !this.getShowToolbars() || !this.getCommandStack().canUndo();
1080
1023
  // warn the user: the existing draft would be discarded in case the user saves
1081
1024
  Utils.checkDraftOverwrite(this._oVersionsModel, bOnlySwitchVersion)
1082
1025
  .then(() => {
1083
1026
  if (this.getShowToolbars()) {
1084
- var oCommandStack = this.getCommandStack();
1085
- var bCanUndo = oCommandStack.canUndo();
1086
- var bCanRedo = oCommandStack.canRedo();
1087
- var bCanSave = oCommandStack.canSave();
1088
- var bWasSaved = oCommandStack.getSaved();
1089
- var bTranslationRelevantDirtyChange = this._oToolbarControlsModel.getProperty("/translation/visible") &&
1027
+ const oCommandStack = this.getCommandStack();
1028
+ const bCanUndo = oCommandStack.canUndo();
1029
+ const bCanRedo = oCommandStack.canRedo();
1030
+ const bCanSave = oCommandStack.canSave();
1031
+ const bWasSaved = oCommandStack.getSaved();
1032
+ const bTranslationRelevantDirtyChange = this._oToolbarControlsModel.getProperty("/translation/visible") &&
1090
1033
  TranslationAPI.hasTranslationRelevantDirtyChanges({layer: Layer.CUSTOMER, selector: this.getRootControlInstance()});
1091
1034
 
1092
1035
  // TODO: move to the setter to the ChangesState
@@ -1114,31 +1057,29 @@ sap.ui.define([
1114
1057
  return undefined;
1115
1058
  }
1116
1059
 
1117
- function waitForPendingActions() {
1118
- return Promise.resolve(this._oDesignTime && this._oDesignTime.waitForBusyPlugins())
1119
- .then(function() {
1120
- return this._pElementModified;
1121
- }.bind(this));
1060
+ async function waitForPendingActions() {
1061
+ await this._oDesignTime?.waitForBusyPlugins();
1062
+ return this._pElementModified;
1122
1063
  }
1123
1064
 
1124
1065
  function onKeyDown(oEvent) {
1125
1066
  // if for example the addField Dialog/reset Popup is open, we don't want the user to be able to undo/redo
1126
- var bMacintosh = Device.os.macintosh;
1127
- var bFocusInsideOverlayContainer = Overlay.getOverlayContainer().get(0).contains(document.activeElement);
1128
- var bFocusInsideRtaToolbar = this.getShowToolbars() && this.getToolbar().getDomRef().contains(document.activeElement);
1129
- var bFocusOnContextMenu = false;
1067
+ const bMacintosh = Device.os.macintosh;
1068
+ const bFocusInsideOverlayContainer = Overlay.getOverlayContainer().get(0).contains(document.activeElement);
1069
+ const bFocusInsideRtaToolbar = this.getShowToolbars() && this.getToolbar().getDomRef().contains(document.activeElement);
1070
+ let bFocusOnContextMenu = false;
1130
1071
  // there might be two divs with that style-class (compact and expanded context menu)
1131
1072
  document.querySelectorAll(".sapUiDtContextMenu").forEach(function(oNode) {
1132
1073
  if (oNode.contains(document.activeElement)) {
1133
1074
  bFocusOnContextMenu = true;
1134
1075
  }
1135
1076
  });
1136
- var bFocusOnBody = document.body === document.activeElement;
1137
- var bFocusInsideRenameField = DOMUtil.getParents(document.activeElement, ".sapUiRtaEditableField").length > 0;
1077
+ const bFocusOnBody = document.body === document.activeElement;
1078
+ const bFocusInsideRenameField = DOMUtil.getParents(document.activeElement, ".sapUiRtaEditableField").length > 0;
1138
1079
 
1139
1080
  if ((bFocusInsideOverlayContainer || bFocusInsideRtaToolbar || bFocusOnContextMenu || bFocusOnBody) && !bFocusInsideRenameField) {
1140
1081
  // OSX: replace CTRL with CMD
1141
- var bCtrlKey = bMacintosh ? oEvent.metaKey : oEvent.ctrlKey;
1082
+ const bCtrlKey = bMacintosh ? oEvent.metaKey : oEvent.ctrlKey;
1142
1083
  if (
1143
1084
  oEvent.keyCode === KeyCodes.Z
1144
1085
  && oEvent.shiftKey === false
@@ -1165,8 +1106,8 @@ sap.ui.define([
1165
1106
  }
1166
1107
 
1167
1108
  function saveOnly(oEvent) {
1168
- var fnCallback = oEvent.getParameter("callback") || function() {};
1169
- var bVersionsEnabled = this._oVersionsModel.getProperty("/versioningEnabled");
1109
+ const fnCallback = oEvent.getParameter("callback") || function() {};
1110
+ const bVersionsEnabled = this._oVersionsModel.getProperty("/versioningEnabled");
1170
1111
  return this.save()
1171
1112
  .then(function() {
1172
1113
  showMessageToast.call(
@@ -1181,19 +1122,19 @@ sap.ui.define([
1181
1122
  .then(fnCallback);
1182
1123
  }
1183
1124
 
1184
- function serializeAndSave(bActivateVersion, bCondenseAnyLayer, bIsExit) {
1125
+ async function serializeAndSave(bActivateVersion, bCondenseAnyLayer, bIsExit) {
1185
1126
  if (this.getShowToolbars()) {
1186
1127
  this.bPersistedDataTranslatable = this._oToolbarControlsModel.getProperty("/translation/enabled");
1187
1128
  }
1188
1129
 
1189
- var mPropertyBag = {
1130
+ const mPropertyBag = {
1190
1131
  layer: this.getLayer(),
1191
1132
  removeOtherLayerChanges: true,
1192
1133
  condenseAnyLayer: bCondenseAnyLayer
1193
1134
  };
1194
1135
 
1195
1136
  if (this._oVersionsModel.getProperty("/versioningEnabled")) {
1196
- var sVersion = bActivateVersion ? this._oVersionsModel.getProperty("/displayedVersion") : undefined;
1137
+ let sVersion = bActivateVersion ? this._oVersionsModel.getProperty("/displayedVersion") : undefined;
1197
1138
 
1198
1139
  // If a draft is being processed, saving without exiting must retrieve the updated state of the draft version
1199
1140
  sVersion ||= bIsExit ? undefined : Version.Number.Draft;
@@ -1207,79 +1148,69 @@ sap.ui.define([
1207
1148
  mPropertyBag.adaptationId = bIsExit ? undefined : this._oContextBasedAdaptationsModel.getProperty("/displayedAdaptation/id");
1208
1149
  }
1209
1150
 
1210
- return this._oSerializer.saveCommands(mPropertyBag)
1211
- .then(function() {
1212
- if (!bIsExit) {
1213
- // clean CViz after Save
1214
- var oToolbar = this.getToolbar();
1215
- var oChangeVisualization = this.getChangeVisualization();
1216
- oChangeVisualization.updateAfterSave(oToolbar);
1217
- }
1218
- }.bind(this));
1151
+ await this._oSerializer.saveCommands(mPropertyBag);
1152
+ if (!bIsExit && this.getChangeVisualization) {
1153
+ // clean CViz after Save
1154
+ const oToolbar = this.getToolbar();
1155
+ const oChangeVisualization = this.getChangeVisualization();
1156
+ oChangeVisualization.updateAfterSave(oToolbar);
1157
+ }
1219
1158
  }
1220
1159
 
1221
- function onActivate(oEvent) {
1222
- var sVersionTitle = oEvent.getParameter("versionTitle");
1160
+ async function onActivate(oEvent) {
1161
+ const sVersionTitle = oEvent.getParameter("versionTitle");
1223
1162
  if (isOldVersionDisplayed.call(this) && isDraftAvailable.call(this)) {
1224
- return Utils.showMessageBox("warning", "MSG_DRAFT_DISCARD_ON_REACTIVATE_DIALOG", {
1163
+ const sAction = await Utils.showMessageBox("warning", "MSG_DRAFT_DISCARD_ON_REACTIVATE_DIALOG", {
1225
1164
  titleKey: "TIT_DRAFT_DISCARD_ON_REACTIVATE_DIALOG",
1226
1165
  actions: [MessageBox.Action.OK, MessageBox.Action.CANCEL],
1227
1166
  emphasizedAction: MessageBox.Action.OK
1228
- })
1229
- .then(function(sAction) {
1230
- if (sAction === MessageBox.Action.OK) {
1231
- return activate.call(this, sVersionTitle);
1232
- }
1233
- return undefined;
1234
- }.bind(this));
1167
+ });
1168
+ if (sAction === MessageBox.Action.OK) {
1169
+ return activate.call(this, sVersionTitle);
1170
+ }
1235
1171
  }
1236
1172
  return activate.call(this, sVersionTitle);
1237
1173
  }
1238
1174
 
1239
- function activate(sVersionTitle) {
1240
- var sLayer = this.getLayer();
1241
- var oSelector = this.getRootControlInstance();
1242
- var sDisplayedVersion = this._oVersionsModel.getProperty("/displayedVersion");
1243
- return serializeAndSave.call(this, true)
1244
- .then(function() {
1245
- return VersionsAPI.activate({
1175
+ async function activate(sVersionTitle) {
1176
+ const sLayer = this.getLayer();
1177
+ const oSelector = this.getRootControlInstance();
1178
+ const sDisplayedVersion = this._oVersionsModel.getProperty("/displayedVersion");
1179
+ try {
1180
+ await this._serializeToLrep(false, false, /* bActivateVersion= */true);
1181
+ await VersionsAPI.activate({
1246
1182
  layer: sLayer,
1247
1183
  control: oSelector,
1248
1184
  title: sVersionTitle,
1249
1185
  displayedVersion: sDisplayedVersion
1250
1186
  });
1251
- }).then(function() {
1252
1187
  showMessageToast.call(this, "MSG_DRAFT_ACTIVATION_SUCCESS");
1253
1188
  this.bInitialResetEnabled = true;
1254
1189
  this._oToolbarControlsModel.setProperty("/restore/enabled", true);
1255
1190
  this.getCommandStack().removeAllCommands();
1256
- }.bind(this))
1257
- .catch(function(oError) {
1191
+ } catch (oError) {
1258
1192
  Utils.showMessageBox("error", "MSG_DRAFT_ACTIVATION_FAILED", {error: oError});
1259
- });
1193
+ }
1260
1194
  }
1261
1195
 
1262
- function onDiscardDraft() {
1263
- return Utils.showMessageBox("warning", "MSG_DRAFT_DISCARD_DIALOG", {
1196
+ async function onDiscardDraft() {
1197
+ const sAction = await Utils.showMessageBox("warning", "MSG_DRAFT_DISCARD_DIALOG", {
1264
1198
  actions: [MessageBox.Action.OK, MessageBox.Action.CANCEL],
1265
1199
  emphasizedAction: MessageBox.Action.OK
1266
- })
1267
- .then(function(sAction) {
1268
- if (sAction === MessageBox.Action.OK) {
1269
- return VersionsAPI.discardDraft({
1270
- layer: this.getLayer(),
1271
- control: this.getRootControlInstance(),
1272
- updateState: true
1273
- })
1274
- .then(handleDiscard.bind(this));
1275
- }
1276
- return undefined;
1277
- }.bind(this));
1200
+ });
1201
+ if (sAction === MessageBox.Action.OK) {
1202
+ await VersionsAPI.discardDraft({
1203
+ layer: this.getLayer(),
1204
+ control: this.getRootControlInstance(),
1205
+ updateState: true
1206
+ });
1207
+ await handleDiscard.call(this);
1208
+ }
1278
1209
  }
1279
1210
 
1280
1211
  function handleDiscard() {
1281
- var sLayer = this.getLayer();
1282
- var oReloadInfo = {
1212
+ const sLayer = this.getLayer();
1213
+ const oReloadInfo = {
1283
1214
  layer: sLayer,
1284
1215
  removeDraft: true,
1285
1216
  selector: this.getRootControlInstance()
@@ -1319,54 +1250,54 @@ sap.ui.define([
1319
1250
  control: this.getRootControlInstance(),
1320
1251
  layer: this.getLayer(),
1321
1252
  adaptationId: this._oContextBasedAdaptationsModel.getProperty("/displayedAdaptation/id")
1322
- }).then(function() {
1253
+ })
1254
+ .then(function() {
1323
1255
  BusyIndicator.hide();
1324
- var sAdaptationId = this._oContextBasedAdaptationsModel.deleteAdaptation();
1256
+ const sAdaptationId = this._oContextBasedAdaptationsModel.deleteAdaptation();
1325
1257
  switchAdaptation.call(this, sAdaptationId);
1326
1258
  Measurement.end("onCBADeleteAdaptation");
1327
1259
  if (Measurement.getActive()) {
1328
1260
  Log.info(`onCBADeleteAdaptation: ${Measurement.getMeasurement("onCBADeleteAdaptation").time} ms`);
1329
1261
  }
1330
- }.bind(this)).catch(function(oError) {
1262
+ }.bind(this))
1263
+ .catch(function(oError) {
1331
1264
  BusyIndicator.hide();
1332
1265
  Log.error(oError.stack);
1333
- var sMessage = "MSG_LREP_TRANSFER_ERROR";
1334
- var oOptions = { titleKey: "DAC_DIALOG_HEADER" };
1266
+ const sMessage = "MSG_LREP_TRANSFER_ERROR";
1267
+ const oOptions = { titleKey: "DAC_DIALOG_HEADER" };
1335
1268
  oOptions.details = oError.userMessage;
1336
1269
  Utils.showMessageBox("error", sMessage, oOptions);
1337
1270
  });
1338
1271
  }
1339
1272
 
1340
- function handleDataLoss(sMessageKey, sTitleKey, callbackFn) {
1273
+ async function handleDataLoss(sMessageKey, sTitleKey, fnCallback) {
1341
1274
  if (this.canSave()) {
1342
- Utils.showMessageBox("warning", sMessageKey, {
1275
+ const sAction = await Utils.showMessageBox("warning", sMessageKey, {
1343
1276
  titleKey: sTitleKey,
1344
1277
  actions: [MessageBox.Action.YES, MessageBox.Action.NO, MessageBox.Action.CANCEL],
1345
1278
  emphasizedAction: MessageBox.Action.YES
1346
- }).then(function(sAction) {
1347
- if (sAction === MessageBox.Action.YES) {
1348
- return this._serializeToLrep()
1349
- .then(callbackFn);
1350
- } else if (sAction === MessageBox.Action.NO) {
1351
- // avoids the data loss popup; a reload is triggered later and will destroy RTA & the command stack
1352
- this.getCommandStack().removeAllCommands(true);
1353
- return callbackFn();
1354
- }
1355
- return Promise.resolve();
1356
- }.bind(this));
1357
- return Promise.resolve();
1279
+ });
1280
+ if (sAction === MessageBox.Action.YES) {
1281
+ await this._serializeToLrep();
1282
+ await fnCallback();
1283
+ } else if (sAction === MessageBox.Action.NO) {
1284
+ // avoids the data loss popup; a reload is triggered later and will destroy RTA & the command stack
1285
+ this.getCommandStack().removeAllCommands(true);
1286
+ await fnCallback();
1287
+ }
1288
+ } else {
1289
+ await fnCallback();
1358
1290
  }
1359
- return callbackFn();
1360
1291
  }
1361
1292
 
1362
1293
  function onSwitchAdaptation(oEvent) {
1363
1294
  Measurement.start("onCBASwitchAdaptation", "Measurement of switching a context-based adaptation");
1364
- var fnCallback = oEvent.getParameter("callback") || function() {};
1295
+ const fnCallback = oEvent.getParameter("callback") || function() {};
1365
1296
  if (oEvent.getParameter("trigger") === "SaveAs") {
1366
1297
  // remove all changes from command stack when triggered from saveAs dialog as they are already saved in a new adaptation
1367
1298
  this.getCommandStack().removeAllCommands(true);
1368
1299
  }
1369
- var sAdaptationId = oEvent.getParameter("adaptationId");
1300
+ const sAdaptationId = oEvent.getParameter("adaptationId");
1370
1301
  this._sSwitchToAdaptationId = sAdaptationId;
1371
1302
  return handleDataLoss.call(this, "MSG_SWITCH_VERSION_DIALOG", "BTN_SWITCH_ADAPTATIONS",
1372
1303
  switchAdaptation.bind(this, this._sSwitchToAdaptationId))
@@ -1384,14 +1315,14 @@ sap.ui.define([
1384
1315
  }
1385
1316
 
1386
1317
  function switchAdaptation(sAdaptationId) {
1387
- var sVersion = this._oVersionsModel.getProperty("/displayedVersion");
1318
+ const sVersion = this._oVersionsModel.getProperty("/displayedVersion");
1388
1319
  return switchVersion.call(this, sVersion, sAdaptationId);
1389
1320
  }
1390
1321
 
1391
1322
  function onSwitchVersion(oEvent) {
1392
- var fnCallback = oEvent.getParameter("callback") || function() {};
1393
- var sVersion = oEvent.getParameter("version");
1394
- var sDisplayedVersion = this._oVersionsModel.getProperty("/displayedVersion");
1323
+ const fnCallback = oEvent.getParameter("callback") || function() {};
1324
+ const sVersion = oEvent.getParameter("version");
1325
+ const sDisplayedVersion = this._oVersionsModel.getProperty("/displayedVersion");
1395
1326
 
1396
1327
  if (sVersion === sDisplayedVersion) {
1397
1328
  // already displayed version needs no switch
@@ -1417,7 +1348,7 @@ sap.ui.define([
1417
1348
  version: sVersion,
1418
1349
  adaptationId: sAdaptationId
1419
1350
  }).then(function() {
1420
- var oReloadInfo = {
1351
+ const oReloadInfo = {
1421
1352
  versionSwitch: true,
1422
1353
  version: sVersion,
1423
1354
  selector: this.getRootControlInstance()
@@ -1486,153 +1417,137 @@ sap.ui.define([
1486
1417
  }.bind(this));
1487
1418
  }
1488
1419
 
1489
- function createToolsMenu(mButtonsAvailability) {
1490
- if (!this.getDependent("toolbar")) {
1491
- var bUserLayer = this.getLayer() === Layer.USER;
1492
- var oProperties = {
1493
- rtaInformation: {
1494
- flexSettings: this.getFlexSettings(),
1495
- rootControl: this.getRootControlInstance(),
1496
- commandStack: this.getCommandStack()
1497
- },
1498
- textResources: this._getTextResources(),
1499
- restore: this.restore.bind(this),
1500
- exit: this.stop.bind(this, false, bUserLayer)
1501
- };
1502
-
1503
- if (!bUserLayer) {
1504
- oProperties.publishVersion = onPublishVersion.bind(this);
1505
- oProperties.undo = this.undo.bind(this);
1506
- oProperties.redo = this.redo.bind(this);
1507
- oProperties.modeChange = onModeChange.bind(this);
1508
- oProperties.activate = onActivate.bind(this);
1509
- oProperties.discardDraft = onDiscardDraft.bind(this);
1510
- oProperties.switchVersion = onSwitchVersion.bind(this);
1511
- oProperties.switchAdaptation = onSwitchAdaptation.bind(this);
1512
- oProperties.deleteAdaptation = onDeleteAdaptation.bind(this);
1513
- oProperties.openChangeCategorySelectionPopover = this.getChangeVisualization
1514
- ? this.getChangeVisualization().openChangeCategorySelectionPopover.bind(this.getChangeVisualization())
1515
- : function() {};
1516
- oProperties.save = saveOnly.bind(this);
1517
- }
1420
+ async function createToolsMenu(mButtonsAvailability) {
1421
+ if (this.getDependent("toolbar")) {
1422
+ return;
1423
+ }
1518
1424
 
1519
- var oToolbar;
1520
- if (bUserLayer) {
1521
- oToolbar = new PersonalizationToolbar(oProperties);
1522
- } else if (Utils.isOriginalFioriToolbarAccessible()) {
1523
- oToolbar = new FioriToolbar(oProperties);
1524
- } else if (Utils.getFiori2Renderer()) {
1525
- oToolbar = new FioriLikeToolbar(oProperties);
1526
- } else {
1527
- oToolbar = new StandaloneToolbar(oProperties);
1528
- }
1529
- this.addDependent(oToolbar, "toolbar");
1530
-
1531
- return Promise.all([oToolbar.onFragmentLoaded(), FeaturesAPI.isKeyUserTranslationEnabled(this.getLayer())])
1532
- .then(function(aArguments) {
1533
- var bTranslationAvailable = aArguments[1];
1534
- var bAppVariantsAvailable = mButtonsAvailability.saveAsAvailable;
1535
- var bExtendedOverview = bAppVariantsAvailable && RtaAppVariantFeature.isOverviewExtended();
1536
- var oUriParameters = new URLSearchParams(window.location.search);
1537
- // the "Visualization" tab should not be visible if the "fiori-tools-rta-mode" URL-parameter is set to any value but "false"
1538
- var bVisualizationButtonVisible;
1539
- bVisualizationButtonVisible = !oUriParameters.has("fiori-tools-rta-mode")
1540
- || oUriParameters.get("fiori-tools-rta-mode") === "false";
1541
- var bFeedbackButtonVisible = FlexRuntimeInfoAPI.getConfiguredFlexServices().some(function(oFlexibilityService) {
1542
- return oFlexibilityService.connector !== "LocalStorageConnector";
1543
- });
1544
- this.bPersistedDataTranslatable = false;
1545
-
1546
- this._oToolbarControlsModel = new JSONModel({
1547
- modeSwitcher: this.getMode(),
1548
- undo: {
1549
- enabled: false
1550
- },
1551
- redo: {
1552
- enabled: false
1553
- },
1554
- save: {
1555
- enabled: false
1556
- },
1557
- translation: {
1558
- visible: bTranslationAvailable,
1559
- enabled: this.bPersistedDataTranslatable
1560
- },
1561
- appVariantMenu: {
1562
- visible: bAppVariantsAvailable,
1563
- enabled: bAppVariantsAvailable,
1564
- overview: {
1565
- visible: bAppVariantsAvailable && bExtendedOverview,
1566
- enabled: bAppVariantsAvailable && bExtendedOverview
1567
- },
1568
- manageApps: {
1569
- visible: bAppVariantsAvailable && !bExtendedOverview,
1570
- enabled: bAppVariantsAvailable && !bExtendedOverview
1571
- },
1572
- saveAs: {
1573
- visible: bAppVariantsAvailable,
1574
- enabled: bAppVariantsAvailable
1575
- }
1576
- },
1577
- restore: {
1578
- visible: !this._oVersionsModel.getProperty("/versioningEnabled"),
1579
- enabled: this.bInitialResetEnabled
1580
- },
1581
- contextBasedAdaptation: {
1582
- visible: mButtonsAvailability.contextBasedAdaptationAvailable,
1583
- enabled: mButtonsAvailability.contextBasedAdaptationAvailable
1584
- },
1585
- actionsMenuButton: {
1586
- enabled: true
1587
- },
1588
- visualizationButton: {
1589
- visible: bVisualizationButtonVisible,
1590
- enabled: bVisualizationButtonVisible
1591
- },
1592
- feedbackButton: {
1593
- visible: bFeedbackButtonVisible
1594
- }
1595
- });
1425
+ const bUserLayer = this.getLayer() === Layer.USER;
1426
+ const oProperties = {
1427
+ rtaInformation: {
1428
+ flexSettings: this.getFlexSettings(),
1429
+ rootControl: this.getRootControlInstance(),
1430
+ commandStack: this.getCommandStack()
1431
+ },
1432
+ textResources: this._getTextResources(),
1433
+ restore: this.restore.bind(this),
1434
+ exit: this.stop.bind(this, false, bUserLayer)
1435
+ };
1596
1436
 
1597
- this._oVersionsModel.setProperty("/publishVersionVisible", mButtonsAvailability.publishAvailable);
1437
+ if (!bUserLayer) {
1438
+ oProperties.publishVersion = onPublishVersion.bind(this);
1439
+ oProperties.undo = this.undo.bind(this);
1440
+ oProperties.redo = this.redo.bind(this);
1441
+ oProperties.modeChange = onModeChange.bind(this);
1442
+ oProperties.activate = onActivate.bind(this);
1443
+ oProperties.discardDraft = onDiscardDraft.bind(this);
1444
+ oProperties.switchVersion = onSwitchVersion.bind(this);
1445
+ oProperties.switchAdaptation = onSwitchAdaptation.bind(this);
1446
+ oProperties.deleteAdaptation = onDeleteAdaptation.bind(this);
1447
+ oProperties.openChangeCategorySelectionPopover = this.getChangeVisualization
1448
+ ? this.getChangeVisualization().openChangeCategorySelectionPopover.bind(this.getChangeVisualization())
1449
+ : function() {};
1450
+ oProperties.save = saveOnly.bind(this);
1451
+ }
1598
1452
 
1599
- var oTranslationPromise = new Promise(function(resolve) {
1600
- if (!bTranslationAvailable) {
1601
- resolve();
1602
- return;
1603
- }
1453
+ let oToolbar;
1454
+ if (bUserLayer) {
1455
+ oToolbar = new PersonalizationToolbar(oProperties);
1456
+ } else if (Utils.isOriginalFioriToolbarAccessible()) {
1457
+ oToolbar = new FioriToolbar(oProperties);
1458
+ } else if (Utils.getFiori2Renderer()) {
1459
+ oToolbar = new FioriLikeToolbar(oProperties);
1460
+ } else {
1461
+ oToolbar = new StandaloneToolbar(oProperties);
1462
+ }
1463
+ this.addDependent(oToolbar, "toolbar");
1464
+
1465
+ await oToolbar.onFragmentLoaded();
1466
+ const bTranslationAvailable = await FeaturesAPI.isKeyUserTranslationEnabled(this.getLayer());
1467
+
1468
+ const bAppVariantsAvailable = mButtonsAvailability.saveAsAvailable;
1469
+ const bExtendedOverview = bAppVariantsAvailable && RtaAppVariantFeature.isOverviewExtended();
1470
+ const oUriParameters = new URLSearchParams(window.location.search);
1471
+ // the "Visualization" tab should not be visible if the "fiori-tools-rta-mode" URL-parameter is set to any value but "false"
1472
+ const bVisualizationButtonVisible = !oUriParameters.has("fiori-tools-rta-mode")
1473
+ || oUriParameters.get("fiori-tools-rta-mode") === "false";
1474
+ const bFeedbackButtonVisible = FlexRuntimeInfoAPI.getConfiguredFlexServices().some(function(oFlexibilityService) {
1475
+ return oFlexibilityService.connector !== "LocalStorageConnector";
1476
+ });
1477
+ this.bPersistedDataTranslatable = false;
1604
1478
 
1605
- TranslationAPI.getSourceLanguages({selector: this.getRootControlInstance(), layer: this.getLayer()})
1606
- .then(function(aSourceLanguages) {
1607
- this.bPersistedDataTranslatable = aSourceLanguages.length > 0;
1608
- this._oToolbarControlsModel.setProperty("/translation/enabled", this.bPersistedDataTranslatable);
1609
- }.bind(this)).finally(resolve);
1610
- }.bind(this));
1479
+ this._oToolbarControlsModel = new JSONModel({
1480
+ modeSwitcher: this.getMode(),
1481
+ undo: {
1482
+ enabled: false
1483
+ },
1484
+ redo: {
1485
+ enabled: false
1486
+ },
1487
+ save: {
1488
+ enabled: false
1489
+ },
1490
+ translation: {
1491
+ visible: bTranslationAvailable,
1492
+ enabled: this.bPersistedDataTranslatable
1493
+ },
1494
+ appVariantMenu: {
1495
+ visible: bAppVariantsAvailable,
1496
+ enabled: bAppVariantsAvailable,
1497
+ overview: {
1498
+ visible: bAppVariantsAvailable && bExtendedOverview,
1499
+ enabled: bAppVariantsAvailable && bExtendedOverview
1500
+ },
1501
+ manageApps: {
1502
+ visible: bAppVariantsAvailable && !bExtendedOverview,
1503
+ enabled: bAppVariantsAvailable && !bExtendedOverview
1504
+ },
1505
+ saveAs: {
1506
+ visible: bAppVariantsAvailable,
1507
+ enabled: bAppVariantsAvailable
1508
+ }
1509
+ },
1510
+ restore: {
1511
+ visible: !this._oVersionsModel.getProperty("/versioningEnabled"),
1512
+ enabled: this.bInitialResetEnabled
1513
+ },
1514
+ contextBasedAdaptation: {
1515
+ visible: mButtonsAvailability.contextBasedAdaptationAvailable,
1516
+ enabled: mButtonsAvailability.contextBasedAdaptationAvailable
1517
+ },
1518
+ actionsMenuButton: {
1519
+ enabled: true
1520
+ },
1521
+ visualizationButton: {
1522
+ visible: bVisualizationButtonVisible,
1523
+ enabled: bVisualizationButtonVisible
1524
+ },
1525
+ feedbackButton: {
1526
+ visible: bFeedbackButtonVisible
1527
+ }
1528
+ });
1611
1529
 
1612
- var oSaveAsPromise = new Promise(function(resolve) {
1613
- if (!bAppVariantsAvailable) {
1614
- resolve();
1615
- return;
1616
- }
1530
+ this._oVersionsModel.setProperty("/publishVersionVisible", mButtonsAvailability.publishAvailable);
1617
1531
 
1618
- RtaAppVariantFeature.isManifestSupported().then(function(bResult) {
1619
- if (FlexUtils.isVariantByStartupParameter(this.getRootControlInstance())) {
1620
- bResult = false;
1621
- }
1622
- this._oToolbarControlsModel.setProperty("/appVariantMenu/saveAs/enabled", bResult);
1623
- this._oToolbarControlsModel.setProperty("/appVariantMenu/overview/enabled", bResult);
1624
- this._oToolbarControlsModel.setProperty("/appVariantMenu/manageApps/enabled", bResult);
1625
- }.bind(this)).finally(resolve);
1626
- }.bind(this));
1532
+ this.getToolbar().setModel(this._oVersionsModel, "versions");
1533
+ this.getToolbar().setModel(this._oContextBasedAdaptationsModel, "contextBasedAdaptations");
1534
+ this.getToolbar().setModel(this._oToolbarControlsModel, "controls");
1627
1535
 
1628
- this.getToolbar().setModel(this._oVersionsModel, "versions");
1629
- this.getToolbar().setModel(this._oContextBasedAdaptationsModel, "contextBasedAdaptations");
1630
- this.getToolbar().setModel(this._oToolbarControlsModel, "controls");
1536
+ if (bTranslationAvailable) {
1537
+ const aSourceLanguages = await TranslationAPI.getSourceLanguages(
1538
+ {selector: this.getRootControlInstance(), layer: this.getLayer()}
1539
+ );
1540
+ this.bPersistedDataTranslatable = aSourceLanguages.length > 0;
1541
+ this._oToolbarControlsModel.setProperty("/translation/enabled", this.bPersistedDataTranslatable);
1542
+ }
1631
1543
 
1632
- return Promise.all([oTranslationPromise, oSaveAsPromise]);
1633
- }.bind(this));
1544
+ if (bAppVariantsAvailable) {
1545
+ const bIsAppVariantSupported = FlexUtils.isVariantByStartupParameter(this.getRootControlInstance()) ?
1546
+ false : await RtaAppVariantFeature.isManifestSupported();
1547
+ this._oToolbarControlsModel.setProperty("/appVariantMenu/saveAs/enabled", bIsAppVariantSupported);
1548
+ this._oToolbarControlsModel.setProperty("/appVariantMenu/overview/enabled", bIsAppVariantSupported);
1549
+ this._oToolbarControlsModel.setProperty("/appVariantMenu/manageApps/enabled", bIsAppVariantSupported);
1634
1550
  }
1635
- return Promise.resolve();
1636
1551
  }
1637
1552
 
1638
1553
  /**
@@ -1644,8 +1559,8 @@ sap.ui.define([
1644
1559
  * @returns {Promise} Resolves when change persistence is reset
1645
1560
  */
1646
1561
  function deleteChanges() {
1647
- var sLayer = this.getLayer();
1648
- var oSelector = FlexUtils.getAppComponentForControl(this.getRootControlInstance());
1562
+ const sLayer = this.getLayer();
1563
+ const oSelector = FlexUtils.getAppComponentForControl(this.getRootControlInstance());
1649
1564
  return PersistenceWriteAPI.reset({
1650
1565
  selector: oSelector,
1651
1566
  layer: sLayer
@@ -1653,7 +1568,7 @@ sap.ui.define([
1653
1568
  // avoids the data loss popup; a reload is triggered later and will destroy RTA & the command stack
1654
1569
  this.getCommandStack().removeAllCommands(true);
1655
1570
  ReloadInfoAPI.removeInfoSessionStorage(oSelector);
1656
- var oReloadInfo = {
1571
+ const oReloadInfo = {
1657
1572
  layer: sLayer,
1658
1573
  ignoreMaxLayerParameter: true,
1659
1574
  triggerHardReload: true
@@ -1675,7 +1590,7 @@ sap.ui.define([
1675
1590
  */
1676
1591
  function scheduleOnCreated(sNewControlID, fnCallback) {
1677
1592
  function onElementOverlayCreated(oEvent) {
1678
- var oNewOverlay = oEvent.getParameter("elementOverlay");
1593
+ const oNewOverlay = oEvent.getParameter("elementOverlay");
1679
1594
  if (oNewOverlay.getElement().getId() === sNewControlID) {
1680
1595
  this._oDesignTime.detachEvent("elementOverlayCreated", onElementOverlayCreated, this);
1681
1596
  fnCallback(oNewOverlay);
@@ -1693,7 +1608,7 @@ sap.ui.define([
1693
1608
  */
1694
1609
  function scheduleOnCreatedAndVisible(sNewControlID, fnCallback) {
1695
1610
  function onGeometryChanged(oEvent) {
1696
- var oElementOverlay = oEvent.getSource();
1611
+ const oElementOverlay = oEvent.getSource();
1697
1612
  if (oElementOverlay.getGeometry() && oElementOverlay.getGeometry().visible) {
1698
1613
  oElementOverlay.detachEvent("geometryChanged", onGeometryChanged);
1699
1614
  fnCallback(oElementOverlay);
@@ -1730,25 +1645,23 @@ sap.ui.define([
1730
1645
  * @param {string} sNewContainerName - The name of the newly created container
1731
1646
  */
1732
1647
  function scheduleRenameOnCreatedContainer(vAction, sNewControlID, sNewContainerName) {
1733
- var fnStartEdit = function(oElementOverlay) {
1648
+ const fnStartEdit = function(oElementOverlay) {
1734
1649
  oElementOverlay.setSelected(true);
1735
1650
  this.getPluginManager().getPlugin("rename").startEdit(oElementOverlay);
1736
1651
  }.bind(this);
1737
1652
 
1738
- scheduleOnCreatedAndVisible.call(this, sNewControlID, function(oElementOverlay) {
1653
+ scheduleOnCreatedAndVisible.call(this, sNewControlID, async function(oElementOverlay) {
1739
1654
  // get container of the new control for rename
1740
- var sNewContainerID = this.getPluginManager().getPlugin("createContainer").getCreatedContainerId(
1655
+ const sNewContainerID = this.getPluginManager().getPlugin("createContainer").getCreatedContainerId(
1741
1656
  vAction,
1742
1657
  oElementOverlay.getElement().getId()
1743
1658
  );
1744
- var oContainerElementOverlay = OverlayRegistry.getOverlay(sNewContainerID);
1659
+ const oContainerElementOverlay = OverlayRegistry.getOverlay(sNewContainerID);
1745
1660
  if (oContainerElementOverlay) {
1746
1661
  if (sNewContainerName) {
1747
- this.getPluginManager().getPlugin("rename").createRenameCommand(oContainerElementOverlay, sNewContainerName)
1748
- .then(function() {
1749
- // The create container and rename must be a single command in the stack
1750
- this.getCommandStack().compositeLastTwoCommands();
1751
- }.bind(this));
1662
+ await this.getPluginManager().getPlugin("rename").createRenameCommand(oContainerElementOverlay, sNewContainerName);
1663
+ // The create container and rename must be a single command in the stack
1664
+ this.getCommandStack().compositeLastTwoCommands();
1752
1665
  } else {
1753
1666
  fnStartEdit(oContainerElementOverlay);
1754
1667
  }
@@ -1766,10 +1679,10 @@ sap.ui.define([
1766
1679
  */
1767
1680
  function handleElementModified(oEvent) {
1768
1681
  // events are synchronously reset after the handlers are called
1769
- var oCommand = oEvent.getParameter("command");
1770
- var sNewControlID = oEvent.getParameter("newControlId");
1771
- var vAction = oEvent.getParameter("action");
1772
- var sContainerTitle = oEvent.getParameter("title");
1682
+ const oCommand = oEvent.getParameter("command");
1683
+ const sNewControlID = oEvent.getParameter("newControlId");
1684
+ const vAction = oEvent.getParameter("action");
1685
+ const sContainerTitle = oEvent.getParameter("title");
1773
1686
 
1774
1687
  this._pElementModified = this._pElementModified.then(function() {
1775
1688
  this.getPluginManager().handleStopCutPaste();
@@ -1777,8 +1690,8 @@ sap.ui.define([
1777
1690
  if (oCommand instanceof BaseCommand) {
1778
1691
  if (sNewControlID) {
1779
1692
  scheduleOnCreated.call(this, sNewControlID, function(oElementOverlay) {
1780
- var oDesignTimeMetadata = oElementOverlay.getDesignTimeMetadata();
1781
- var fnSelect = oDesignTimeMetadata.getData().select;
1693
+ const oDesignTimeMetadata = oElementOverlay.getDesignTimeMetadata();
1694
+ const fnSelect = oDesignTimeMetadata.getData().select;
1782
1695
  if (typeof fnSelect === "function") {
1783
1696
  fnSelect(oElementOverlay.getElement());
1784
1697
  }
@@ -1805,196 +1718,31 @@ sap.ui.define([
1805
1718
  this.setMode(oEvent.getParameter("item").getKey());
1806
1719
  }
1807
1720
 
1808
- function resolveServiceLocation(sName) {
1809
- if (ServicesIndex.hasOwnProperty(sName)) {
1810
- return ServicesIndex[sName].replace(/\./g, "/");
1811
- }
1812
- return undefined;
1813
- }
1814
-
1815
1721
  /**
1816
- * Starts a service
1722
+ * Gets a service by name (and starts it if it's not running)
1817
1723
  * @param {string} sName - Registered service name
1818
1724
  * @returns {Promise} - Promise is resolved with service api or rejected in case of any error.
1819
1725
  */
1820
- RuntimeAuthoring.prototype.startService = function(sName) {
1726
+ RuntimeAuthoring.prototype.getService = function(sName) {
1821
1727
  if (this._sStatus !== STARTED) {
1822
- return new Promise(function(fnResolve, fnReject) {
1728
+ return new Promise((fnResolve, fnReject) => {
1823
1729
  this.attachEventOnce("start", fnResolve);
1824
1730
  this.attachEventOnce("failed", fnReject);
1825
- }.bind(this))
1826
- .then(
1827
- function() {
1828
- return this.startService(sName);
1829
- }.bind(this),
1830
- function() {
1831
- return Promise.reject(
1832
- DtUtil.createError(
1833
- "RuntimeAuthoring#startService",
1834
- `Can't start the service '${sName}' because RTA startup failed`,
1835
- "sap.ui.rta"
1836
- )
1837
- );
1838
- }
1839
- );
1840
- }
1841
-
1842
- var sServiceLocation = resolveServiceLocation(sName);
1843
- var mService;
1844
-
1845
- if (!sServiceLocation) {
1846
- return Promise.reject(
1847
- DtUtil.createError(
1848
- "RuntimeAuthoring#startService",
1849
- `Unknown service. Can't find any registered service by name '${sName}'`,
1850
- "sap.ui.rta"
1851
- )
1852
- );
1853
- }
1854
-
1855
- mService = this._mServices[sName];
1856
- if (mService) {
1857
- switch (mService.status) {
1858
- case SERVICE_STARTED: {
1859
- return Promise.resolve(mService.exports);
1860
- }
1861
- case SERVICE_STARTING: {
1862
- return mService.initPromise;
1863
- }
1864
- case SERVICE_FAILED: {
1865
- return mService.initPromise;
1866
- }
1867
- default: {
1868
- return Promise.reject(
1869
- DtUtil.createError(
1870
- "RuntimeAuthoring#startService",
1871
- `Unknown service status. Service name = '${sName}'`,
1872
- "sap.ui.rta"
1873
- )
1874
- );
1875
- }
1876
- }
1877
- } else {
1878
- this._mServices[sName] = mService = {};
1879
- mService.status = SERVICE_STARTING;
1880
- mService.location = sServiceLocation;
1881
- mService.initPromise = new Promise(function(fnResolve, fnReject) {
1882
- sap.ui.require(
1883
- [sServiceLocation],
1884
- function(fnServiceFactory) {
1885
- mService.factory = fnServiceFactory;
1886
-
1887
- this._oServiceEventBus ||= new ServiceEventBus();
1888
-
1889
- DtUtil.wrapIntoPromise(fnServiceFactory)(
1890
- this,
1891
- this._oServiceEventBus.publish.bind(this._oServiceEventBus, sName)
1892
- )
1893
- .then(function(oService) {
1894
- if (this.bIsDestroyed) {
1895
- throw DtUtil.createError(
1896
- "RuntimeAuthoring#startService",
1897
- `RuntimeAuthoring instance is destroyed while initializing the service '${sName}'`,
1898
- "sap.ui.rta"
1899
- );
1900
- }
1901
- if (!isPlainObject(oService)) {
1902
- throw DtUtil.createError(
1903
- "RuntimeAuthoring#startService",
1904
- `Invalid service format. Service should return simple javascript object after initialization. Service name = '${sName}'`,
1905
- "sap.ui.rta"
1906
- );
1907
- }
1908
-
1909
- mService.service = oService;
1910
- mService.exports = {};
1911
-
1912
- // Expose events API if there is at least one event
1913
- if (Array.isArray(oService.events) && oService.events.length > 0) {
1914
- Object.assign(mService.exports, {
1915
- attachEvent: this._oServiceEventBus.subscribe.bind(this._oServiceEventBus, sName),
1916
- detachEvent: this._oServiceEventBus.unsubscribe.bind(this._oServiceEventBus, sName),
1917
- attachEventOnce: this._oServiceEventBus.subscribeOnce.bind(this._oServiceEventBus, sName)
1918
- });
1919
- }
1920
-
1921
- // Expose methods/properties from exports object if any
1922
- var mExports = oService.exports || {};
1923
- Object.assign(
1924
- mService.exports,
1925
- Object.keys(mExports).reduce(function(mResult, sKey) {
1926
- var vValue = mExports[sKey];
1927
- mResult[sKey] = typeof vValue === "function"
1928
- ? DtUtil.waitForSynced(this._oDesignTime, vValue)
1929
- : vValue;
1930
- return mResult;
1931
- }.bind(this), {})
1932
- );
1933
-
1934
- mService.status = SERVICE_STARTED;
1935
- fnResolve(Object.freeze(mService.exports));
1936
- }.bind(this))
1937
- .catch(fnReject);
1938
- }.bind(this),
1939
- function(vError) {
1940
- mService.status = SERVICE_FAILED;
1941
- fnReject(
1942
- DtUtil.propagateError(
1943
- vError,
1944
- "RuntimeAuthoring#startService",
1945
- `Can't load service '${sName}' by its name: ${sServiceLocation}`,
1946
- "sap.ui.rta"
1947
- )
1948
- );
1949
- }
1950
- );
1951
- }.bind(this))
1952
- .catch(function(vError) {
1953
- mService.status = SERVICE_FAILED;
1954
- return Promise.reject(
1955
- DtUtil.propagateError(
1956
- vError,
1957
- "RuntimeAuthoring#startService",
1958
- `Error initializing service '${sName}'`,
1731
+ })
1732
+ .then(() => {
1733
+ return this.getServiceManager().startService(sName, this);
1734
+ })
1735
+ .catch(() => {
1736
+ throw Error(
1737
+ DtUtil.createError(
1738
+ "RuntimeAuthoring#getService",
1739
+ `Can't start the service '${sName}' because RTA startup failed`,
1959
1740
  "sap.ui.rta"
1960
1741
  )
1961
1742
  );
1962
1743
  });
1963
-
1964
- return mService.initPromise;
1965
1744
  }
1966
- };
1967
-
1968
- /**
1969
- * Stops a service
1970
- * @param {string} sName - Started service name
1971
- */
1972
- RuntimeAuthoring.prototype.stopService = function(sName) {
1973
- var oService = this._mServices[sName];
1974
-
1975
- if (oService) {
1976
- if (oService.status === SERVICE_STARTED) {
1977
- if (typeof oService.service.destroy === "function") {
1978
- oService.service.destroy();
1979
- }
1980
- }
1981
- delete this._mServices[sName];
1982
- } else {
1983
- throw DtUtil.createError(
1984
- "RuntimeAuthoring#stopService",
1985
- `Can't destroy service: unable to find service with name '${sName}'`,
1986
- "sap.ui.rta"
1987
- );
1988
- }
1989
- };
1990
-
1991
- /**
1992
- * Gets a service by name (and starts it if it's not running)
1993
- * @param {string} sName - Registered service name
1994
- * @returns {Promise} - Promise is resolved with service api or rejected in case of any error.
1995
- */
1996
- RuntimeAuthoring.prototype.getService = function(sName) {
1997
- return this.startService(sName);
1745
+ return this.getServiceManager().startService(sName, this);
1998
1746
  };
1999
1747
 
2000
1748
  return RuntimeAuthoring;