@openui5/sap.ui.fl 1.128.0 → 1.129.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 (170) hide show
  1. package/THIRDPARTY.txt +1 -1
  2. package/package.json +3 -3
  3. package/src/sap/ui/fl/.library +1 -1
  4. package/src/sap/ui/fl/ChangePersistence.js +13 -421
  5. package/src/sap/ui/fl/ChangePersistenceFactory.js +1 -1
  6. package/src/sap/ui/fl/FakeLrepConnectorLocalStorage.js +1 -1
  7. package/src/sap/ui/fl/FakeLrepConnectorSessionStorage.js +1 -1
  8. package/src/sap/ui/fl/FakeLrepLocalStorage.js +1 -1
  9. package/src/sap/ui/fl/FlexController.js +27 -51
  10. package/src/sap/ui/fl/FlexControllerFactory.js +1 -1
  11. package/src/sap/ui/fl/LayerUtils.js +1 -1
  12. package/src/sap/ui/fl/Utils.js +1 -1
  13. package/src/sap/ui/fl/apply/_internal/DelegateMediator.js +1 -1
  14. package/src/sap/ui/fl/apply/_internal/changes/FlexCustomData.js +1 -1
  15. package/src/sap/ui/fl/apply/_internal/changes/Utils.js +1 -1
  16. package/src/sap/ui/fl/apply/_internal/changes/descriptor/Preprocessor.js +5 -5
  17. package/src/sap/ui/fl/apply/_internal/changes/descriptor/Registration.js +1 -1
  18. package/src/sap/ui/fl/apply/_internal/changes/descriptor/RegistrationBuild.js +5 -4
  19. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/AddAnnotationsToOData.js +1 -1
  20. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/AddNewDataSource.js +152 -0
  21. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/AddNewInbound.js +12 -18
  22. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/AddNewOutbound.js +67 -0
  23. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/AddTechnicalAttributes.js +1 -1
  24. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/ChangeDataSource.js +1 -1
  25. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/ChangeInbound.js +11 -9
  26. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/ChangeOutbound.js +5 -3
  27. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/RemoveAllInboundsExceptOne.js +1 -1
  28. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/SetAch.js +1 -1
  29. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/SetDescription.js +1 -1
  30. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/SetTitle.js +1 -1
  31. package/src/sap/ui/fl/apply/_internal/changes/descriptor/fiori/SetAbstract.js +1 -1
  32. package/src/sap/ui/fl/apply/_internal/changes/descriptor/fiori/SetCloudDevAdaptationStatus.js +1 -1
  33. package/src/sap/ui/fl/apply/_internal/changes/descriptor/fiori/SetRegistrationIds.js +1 -1
  34. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ovp/AddNewCard.js +1 -1
  35. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ovp/ChangeCard.js +1 -1
  36. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ovp/DeleteCard.js +1 -1
  37. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddComponentUsages.js +1 -1
  38. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddLibrary.js +1 -1
  39. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddNewModel.js +1 -1
  40. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddNewModelEnhanceWith.js +1 -1
  41. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/SetFlexExtensionPointEnabled.js +1 -1
  42. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/SetMinUI5Version.js +1 -1
  43. package/src/sap/ui/fl/apply/_internal/connectors/ObjectStorageUtils.js +1 -1
  44. package/src/sap/ui/fl/apply/_internal/controlVariants/URLHandler.js +18 -5
  45. package/src/sap/ui/fl/apply/_internal/extensionPoint/Processor.js +1 -1
  46. package/src/sap/ui/fl/apply/_internal/extensionPoint/Registry.js +1 -1
  47. package/src/sap/ui/fl/apply/_internal/flexObjects/AnnotationChange.js +2 -2
  48. package/src/sap/ui/fl/apply/_internal/flexObjects/AppDescriptorChange.js +2 -4
  49. package/src/sap/ui/fl/apply/_internal/flexObjects/CompVariant.js +19 -10
  50. package/src/sap/ui/fl/apply/_internal/flexObjects/ControllerExtensionChange.js +4 -3
  51. package/src/sap/ui/fl/apply/_internal/flexObjects/FlVariant.js +4 -3
  52. package/src/sap/ui/fl/apply/_internal/flexObjects/FlexObject.js +16 -12
  53. package/src/sap/ui/fl/apply/_internal/flexObjects/FlexObjectFactory.js +17 -20
  54. package/src/sap/ui/fl/apply/_internal/flexObjects/States.js +4 -3
  55. package/src/sap/ui/fl/apply/_internal/flexObjects/UIChange.js +6 -5
  56. package/src/sap/ui/fl/apply/_internal/flexObjects/UpdatableChange.js +1 -1
  57. package/src/sap/ui/fl/apply/_internal/flexObjects/Variant.js +4 -3
  58. package/src/sap/ui/fl/apply/_internal/flexObjects/getVariantAuthor.js +1 -1
  59. package/src/sap/ui/fl/apply/_internal/flexState/FlexObjectState.js +4 -4
  60. package/src/sap/ui/fl/apply/_internal/flexState/FlexState.js +17 -61
  61. package/src/sap/ui/fl/apply/_internal/flexState/Loader.js +1 -1
  62. package/src/sap/ui/fl/apply/_internal/flexState/ManifestUtils.js +1 -1
  63. package/src/sap/ui/fl/apply/_internal/flexState/UI2Personalization/UI2PersonalizationState.js +1 -1
  64. package/src/sap/ui/fl/apply/_internal/flexState/changes/DependencyHandler.js +1 -1
  65. package/src/sap/ui/fl/apply/_internal/flexState/changes/ExtensionPointState.js +10 -6
  66. package/src/sap/ui/fl/apply/_internal/flexState/changes/UIChangesState.js +1 -1
  67. package/src/sap/ui/fl/apply/_internal/flexState/compVariants/CompVariantMerger.js +2 -2
  68. package/src/sap/ui/fl/apply/_internal/flexState/compVariants/prepareCompVariantsMap.js +16 -15
  69. package/src/sap/ui/fl/apply/_internal/flexState/controlVariants/Switcher.js +10 -12
  70. package/src/sap/ui/fl/apply/_internal/flexState/controlVariants/VariantManagementState.js +13 -6
  71. package/src/sap/ui/fl/apply/_internal/preprocessors/ControllerExtension.js +1 -1
  72. package/src/sap/ui/fl/apply/_internal/preprocessors/RegistrationDelegator.js +1 -1
  73. package/src/sap/ui/fl/apply/_internal/preprocessors/XmlPreprocessor.js +1 -1
  74. package/src/sap/ui/fl/apply/api/AnnotationChangeHandlerAPI.js +63 -0
  75. package/src/sap/ui/fl/changeHandler/AddIFrame.js +4 -4
  76. package/src/sap/ui/fl/changeHandler/AddXML.js +1 -1
  77. package/src/sap/ui/fl/changeHandler/AddXMLAtExtensionPoint.js +2 -1
  78. package/src/sap/ui/fl/changeHandler/Base.js +1 -1
  79. package/src/sap/ui/fl/changeHandler/BaseAddViaDelegate.js +1 -1
  80. package/src/sap/ui/fl/changeHandler/BaseAddXml.js +1 -1
  81. package/src/sap/ui/fl/changeHandler/BaseRename.js +1 -1
  82. package/src/sap/ui/fl/changeHandler/HideControl.js +26 -5
  83. package/src/sap/ui/fl/changeHandler/MoveControls.js +1 -1
  84. package/src/sap/ui/fl/changeHandler/MoveElements.js +1 -1
  85. package/src/sap/ui/fl/changeHandler/PropertyBindingChange.js +1 -1
  86. package/src/sap/ui/fl/changeHandler/PropertyChange.js +1 -1
  87. package/src/sap/ui/fl/changeHandler/StashControl.js +1 -1
  88. package/src/sap/ui/fl/changeHandler/UnhideControl.js +33 -1
  89. package/src/sap/ui/fl/changeHandler/UnstashControl.js +1 -1
  90. package/src/sap/ui/fl/changeHandler/UpdateIFrame.js +1 -1
  91. package/src/sap/ui/fl/descriptorRelated/api/DescriptorChangeFactory.js +14 -13
  92. package/src/sap/ui/fl/descriptorRelated/api/DescriptorInlineChangeFactory.js +1 -1
  93. package/src/sap/ui/fl/descriptorRelated/api/DescriptorVariantFactory.js +1 -1
  94. package/src/sap/ui/fl/designtime/util/editIFrame.js +2 -1
  95. package/src/sap/ui/fl/initial/_internal/FlexConfiguration.js +1 -1
  96. package/src/sap/ui/fl/initial/_internal/Storage.js +10 -8
  97. package/src/sap/ui/fl/initial/_internal/StorageFeaturesMerger.js +1 -1
  98. package/src/sap/ui/fl/initial/_internal/StorageUtils.js +3 -3
  99. package/src/sap/ui/fl/initial/_internal/changeHandlers/ChangeHandlerRegistration.js +23 -1
  100. package/src/sap/ui/fl/initial/_internal/changeHandlers/ChangeHandlerStorage.js +54 -22
  101. package/src/sap/ui/fl/initial/_internal/connectors/Utils.js +1 -1
  102. package/src/sap/ui/fl/initial/_internal/storageResultDisassemble.js +1 -1
  103. package/src/sap/ui/fl/interfaces/BaseLoadConnector.js +1 -1
  104. package/src/sap/ui/fl/interfaces/Delegate.js +1 -1
  105. package/src/sap/ui/fl/library.js +43 -43
  106. package/src/sap/ui/fl/registry/Settings.js +1 -1
  107. package/src/sap/ui/fl/support/_internal/extractChangeDependencies.js +29 -58
  108. package/src/sap/ui/fl/support/_internal/getAllUIChanges.js +1 -1
  109. package/src/sap/ui/fl/support/_internal/getChangeDependencies.js +12 -66
  110. package/src/sap/ui/fl/support/_internal/getFlexObjectInfos.js +7 -4
  111. package/src/sap/ui/fl/support/_internal/getFlexSettings.js +30 -19
  112. package/src/sap/ui/fl/support/api/SupportAPI.js +8 -4
  113. package/src/sap/ui/fl/support/apps/contentbrowser/controller/ContentDetails.controller.js +1 -1
  114. package/src/sap/ui/fl/support/apps/contentbrowser/controller/ContentDetailsEdit.controller.js +1 -1
  115. package/src/sap/ui/fl/support/apps/contentbrowser/controller/LayerContentMaster.controller.js +1 -1
  116. package/src/sap/ui/fl/support/apps/contentbrowser/controller/Layers.controller.js +1 -1
  117. package/src/sap/ui/fl/support/apps/contentbrowser/lrepConnector/LRepConnector.js +1 -1
  118. package/src/sap/ui/fl/support/apps/contentbrowser/utils/DataUtils.js +1 -1
  119. package/src/sap/ui/fl/support/apps/contentbrowser/utils/ErrorUtils.js +1 -1
  120. package/src/sap/ui/fl/transport/TransportSelection.js +1 -1
  121. package/src/sap/ui/fl/util/DescriptorChangeCheck.js +106 -12
  122. package/src/sap/ui/fl/util/IFrame.js +3 -3
  123. package/src/sap/ui/fl/util/ManagedObjectModel.js +1 -1
  124. package/src/sap/ui/fl/util/changePropertyValueByPath.js +15 -4
  125. package/src/sap/ui/fl/util/resolveBinding.js +9 -9
  126. package/src/sap/ui/fl/variants/VariantModel.js +49 -32
  127. package/src/sap/ui/fl/variants/context/controller/ContextVisibility.controller.js +2 -2
  128. package/src/sap/ui/fl/write/_internal/SaveAs.js +12 -3
  129. package/src/sap/ui/fl/write/_internal/Storage.js +6 -6
  130. package/src/sap/ui/fl/write/_internal/Versions.js +1 -1
  131. package/src/sap/ui/fl/write/_internal/appVariant/AppVariant.js +1 -1
  132. package/src/sap/ui/fl/write/_internal/appVariant/AppVariantFactory.js +1 -1
  133. package/src/sap/ui/fl/write/_internal/appVariant/AppVariantInlineChange.js +1 -1
  134. package/src/sap/ui/fl/write/_internal/appVariant/AppVariantInlineChangeFactory.js +1 -1
  135. package/src/sap/ui/fl/write/_internal/condenser/Condenser.js +3 -3
  136. package/src/sap/ui/fl/write/_internal/condenser/UIReconstruction.js +1 -1
  137. package/src/sap/ui/fl/write/_internal/connectors/BackendConnector.js +1 -1
  138. package/src/sap/ui/fl/write/_internal/connectors/BtpServiceConnector.js +1 -1
  139. package/src/sap/ui/fl/write/_internal/connectors/KeyUserConnector.js +1 -1
  140. package/src/sap/ui/fl/write/_internal/connectors/LrepConnector.js +43 -2
  141. package/src/sap/ui/fl/write/_internal/connectors/NeoLrepConnector.js +1 -1
  142. package/src/sap/ui/fl/write/_internal/connectors/ObjectPathConnector.js +3 -3
  143. package/src/sap/ui/fl/write/_internal/connectors/PersonalizationConnector.js +1 -1
  144. package/src/sap/ui/fl/write/_internal/connectors/Utils.js +1 -1
  145. package/src/sap/ui/fl/write/_internal/extensionPoint/Processor.js +1 -1
  146. package/src/sap/ui/fl/write/_internal/fieldExtensibility/ABAPAccess.js +1 -1
  147. package/src/sap/ui/fl/write/_internal/fieldExtensibility/ABAPExtensibilityVariant.js +1 -1
  148. package/src/sap/ui/fl/write/_internal/fieldExtensibility/ABAPExtensibilityVariantFactory.js +1 -1
  149. package/src/sap/ui/fl/write/_internal/fieldExtensibility/MultiTenantABAPExtensibilityVariant.js +1 -1
  150. package/src/sap/ui/fl/write/_internal/fieldExtensibility/ServiceValidation.js +1 -1
  151. package/src/sap/ui/fl/write/_internal/fieldExtensibility/SingleTenantABAPExtensibilityVariant.js +122 -77
  152. package/src/sap/ui/fl/write/_internal/fieldExtensibility/UriParser.js +1 -1
  153. package/src/sap/ui/fl/write/_internal/fieldExtensibility/Utils.js +1 -1
  154. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/CAPAccess.js +1 -1
  155. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/dialog/CustomFieldCAPDialog.js +18 -18
  156. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/editor/propertyEditor/booleanEditor/BooleanEditor.js +1 -1
  157. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/editor/propertyEditor/rangeEditor/RangeEditor.js +12 -11
  158. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/editor/propertyEditor/timeEditor/TimeEditor.js +6 -8
  159. package/src/sap/ui/fl/write/_internal/flexState/FlexObjectManager.js +181 -5
  160. package/src/sap/ui/fl/write/_internal/flexState/UI2Personalization/UI2PersonalizationState.js +1 -1
  161. package/src/sap/ui/fl/write/_internal/flexState/changes/UIChangeManager.js +86 -0
  162. package/src/sap/ui/fl/write/_internal/flexState/compVariants/CompVariantState.js +43 -43
  163. package/src/sap/ui/fl/write/_internal/transport/TransportSelection.js +1 -1
  164. package/src/sap/ui/fl/write/_internal/transport/Transports.js +1 -1
  165. package/src/sap/ui/fl/write/api/ContextBasedAdaptationsAPI.js +22 -19
  166. package/src/sap/ui/fl/write/api/ControlPersonalizationWriteAPI.js +56 -30
  167. package/src/sap/ui/fl/write/api/FieldExtensibility.js +1 -1
  168. package/src/sap/ui/fl/write/api/PersistenceWriteAPI.js +28 -51
  169. package/src/sap/ui/fl/write/api/SmartBusinessWriteAPI.js +11 -7
  170. package/src/sap/ui/fl/write/api/VersionsAPI.js +6 -4
@@ -6,6 +6,11 @@
6
6
 
7
7
  sap.ui.define([
8
8
  "sap/base/util/restricted/_omit",
9
+ "sap/ui/core/util/reflection/JsControlTreeModifier",
10
+ "sap/ui/fl/apply/_internal/changes/Reverter",
11
+ "sap/ui/fl/apply/_internal/flexObjects/FlexObjectFactory",
12
+ "sap/ui/fl/apply/_internal/flexObjects/States",
13
+ "sap/ui/fl/apply/_internal/flexState/changes/DependencyHandler",
9
14
  "sap/ui/fl/apply/_internal/flexState/changes/UIChangesState",
10
15
  "sap/ui/fl/apply/_internal/flexState/compVariants/CompVariantMerger",
11
16
  "sap/ui/fl/apply/_internal/flexState/controlVariants/VariantManagementState",
@@ -13,12 +18,18 @@ sap.ui.define([
13
18
  "sap/ui/fl/apply/_internal/flexState/FlexState",
14
19
  "sap/ui/fl/apply/_internal/flexState/ManifestUtils",
15
20
  "sap/ui/fl/write/_internal/flexState/compVariants/CompVariantState",
21
+ "sap/ui/fl/write/_internal/Storage",
16
22
  "sap/ui/fl/write/_internal/Versions",
17
- "sap/ui/fl/FlexControllerFactory",
18
23
  "sap/ui/fl/LayerUtils",
24
+ "sap/ui/fl/requireAsync",
19
25
  "sap/ui/fl/Utils"
20
26
  ], function(
21
27
  _omit,
28
+ JsControlTreeModifier,
29
+ Reverter,
30
+ FlexObjectFactory,
31
+ States,
32
+ DependencyHandler,
22
33
  UIChangesState,
23
34
  CompVariantMerger,
24
35
  VariantManagementState,
@@ -26,22 +37,25 @@ sap.ui.define([
26
37
  FlexState,
27
38
  ManifestUtils,
28
39
  CompVariantState,
40
+ Storage,
29
41
  Versions,
30
- FlexControllerFactory,
31
42
  LayerUtils,
43
+ requireAsync,
32
44
  Utils
33
45
  ) {
34
46
  "use strict";
35
47
 
36
48
  /**
49
+ * Central class for operations on the flex states and flex objects.
50
+ *
37
51
  * @namespace
38
52
  * @alias sap.ui.fl.write._internal.flexState.FlexObjectManager
39
53
  * @since 1.83
40
- * @version 1.128.0
54
+ * @version 1.129.0
41
55
  * @private
42
56
  * @ui5-restricted sap.ui.fl
43
57
  */
44
- var FlexObjectManager = {};
58
+ const FlexObjectManager = {};
45
59
 
46
60
  function getCompVariantEntities(mPropertyBag) {
47
61
  const aEntities = [];
@@ -80,7 +94,15 @@ sap.ui.define([
80
94
  return CompVariantState.persistAll(sReference);
81
95
  }
82
96
 
83
- function saveChangePersistenceEntities(mPropertyBag, oAppComponent) {
97
+ function removeFlexObjectFromDependencyHandler(sReference, oFlexObject) {
98
+ if (oFlexObject.isValidForDependencyMap()) {
99
+ DependencyHandler.removeChangeFromMap(FlexObjectState.getLiveDependencyMap(sReference), oFlexObject.getId());
100
+ DependencyHandler.removeChangeFromDependencies(FlexObjectState.getLiveDependencyMap(sReference), oFlexObject.getId());
101
+ }
102
+ }
103
+
104
+ async function saveChangePersistenceEntities(mPropertyBag, oAppComponent) {
105
+ const FlexControllerFactory = await requireAsync("sap/ui/fl/FlexControllerFactory");
84
106
  var oFlexController = FlexControllerFactory.createForSelector(mPropertyBag.selector);
85
107
 
86
108
  return oFlexController.saveAll(
@@ -92,6 +114,16 @@ sap.ui.define([
92
114
  mPropertyBag.condenseAnyLayer
93
115
  );
94
116
  }
117
+
118
+ function getOrCreateFlexObject(vFlexObject) {
119
+ return (
120
+ typeof vFlexObject.isA === "function"
121
+ && vFlexObject.isA("sap.ui.fl.apply._internal.flexObjects.FlexObject")
122
+ )
123
+ ? vFlexObject
124
+ : FlexObjectFactory.createFromFileContent(vFlexObject);
125
+ }
126
+
95
127
  /**
96
128
  * Takes an array of FlexObjects and filters out any hidden variant and changes on those hidden variants
97
129
  *
@@ -166,6 +198,57 @@ sap.ui.define([
166
198
  return FlexObjectState.getDirtyFlexObjects(sReference).length > 0 || CompVariantState.hasDirtyChanges(sReference);
167
199
  };
168
200
 
201
+ /**
202
+ * Adds new dirty flex objects.
203
+ *
204
+ * @param {string} sReference - Flex reference of the application
205
+ * @param {object[]} aFlexObjects - JSON object representation of flex objects or flex object instances
206
+ * @returns {sap.ui.fl.apply._internal.flexObjects.FlexObject[]} The prepared flex objects
207
+ * @public
208
+ */
209
+ FlexObjectManager.addDirtyFlexObjects = function(sReference, aFlexObjects) {
210
+ return FlexState.addDirtyFlexObjects(sReference, aFlexObjects.map(getOrCreateFlexObject));
211
+ };
212
+
213
+ /**
214
+ * Removes unsaved flex objects.
215
+ *
216
+ * @param {object} mPropertyBag - Properties to determine the flex objects to be removed
217
+ * @param {string} mPropertyBag.reference - Flex reference of the application
218
+ * @param {string|string[]} [mPropertyBag.layers] - Layer or multiple layers for which flex objects shall be deleted. If omitted, flex objects on all layers are considered.
219
+ * @param {sap.ui.core.Component} [mPropertyBag.component] - Component instance, required if oControl is specified
220
+ * @param {string} [mPropertyBag.control] - Control for which the flex objects should be deleted. If omitted, all flex objects for the reference are considered.
221
+ * @param {string} [mPropertyBag.generator] - Generator of flex objects
222
+ * @param {string[]} [mPropertyBag.changeTypes] - Types of flex objects
223
+ * @returns {sap.ui.fl.apply._internal.flexObjects.FlexObject[]} The flex objects that were removed
224
+ */
225
+ FlexObjectManager.removeDirtyFlexObjects = function(mPropertyBag) {
226
+ const aLayers = [].concat(mPropertyBag.layers || []);
227
+ const aDirtyFlexObjects = FlexObjectState.getDirtyFlexObjects(mPropertyBag.reference);
228
+
229
+ const aFlexObjectsToBeRemoved = aDirtyFlexObjects.filter((oFlexObject) => {
230
+ let bChangeValid = true;
231
+
232
+ if (aLayers.length && !aLayers.includes(oFlexObject.getLayer())) {
233
+ return false;
234
+ }
235
+ if (mPropertyBag.generator && oFlexObject.getSupportInformation().generator !== mPropertyBag.generator) {
236
+ return false;
237
+ }
238
+ if (mPropertyBag.control) {
239
+ const sSelectorId = JsControlTreeModifier.getControlIdBySelector(oFlexObject.getSelector(), mPropertyBag.component);
240
+ bChangeValid = mPropertyBag.control.getId() === sSelectorId;
241
+ }
242
+ if (mPropertyBag.changeTypes) {
243
+ bChangeValid &&= mPropertyBag.changeTypes.includes(oFlexObject.getChangeType());
244
+ }
245
+
246
+ return bChangeValid;
247
+ });
248
+
249
+ return FlexState.removeDirtyFlexObjects(mPropertyBag.reference, aFlexObjectsToBeRemoved);
250
+ };
251
+
169
252
  /**
170
253
  * Save Flex objects and reload Flex State
171
254
  * @param {object} mPropertyBag - Object with parameters as properties
@@ -202,5 +285,98 @@ sap.ui.define([
202
285
  return FlexObjectManager.getFlexObjects(_omit(mPropertyBag, "skipUpdateCache"));
203
286
  };
204
287
 
288
+ /**
289
+ * Removes the provided flex objects from the FlexState and dependency handler and sets them to be deleted.
290
+ * If a flex object is dirty it will only be removed from the FlexState.
291
+ * Otherwise the next call to save dirty flex objects will remove them from the persistence.
292
+ *
293
+ * @param {object} mPropertyBag - Object with parameters as properties
294
+ * @param {string} mPropertyBag.reference - Flex reference of the application
295
+ * @param {sap.ui.fl.apply._internal.flexObjects.FlexObject[]} mPropertyBag.flexObjects - Flex objects to be deleted
296
+ */
297
+ FlexObjectManager.deleteFlexObjects = function(mPropertyBag) {
298
+ const aDirtyFlexObjects = FlexObjectState.getDirtyFlexObjects(mPropertyBag.reference);
299
+
300
+ const aToBeDeletedFlexObjects = [];
301
+ const aToBeRemovedDirtyFlexObjects = [];
302
+ mPropertyBag.flexObjects.forEach(function(oFlexObject) {
303
+ if (aDirtyFlexObjects.indexOf(oFlexObject) > -1 && oFlexObject.getState() === States.LifecycleState.NEW) {
304
+ aToBeRemovedDirtyFlexObjects.push(oFlexObject);
305
+ } else {
306
+ oFlexObject.markForDeletion();
307
+ aToBeDeletedFlexObjects.push(oFlexObject);
308
+ }
309
+ removeFlexObjectFromDependencyHandler(mPropertyBag.reference, oFlexObject);
310
+ });
311
+ FlexState.removeDirtyFlexObjects(mPropertyBag.reference, aToBeRemovedDirtyFlexObjects);
312
+ FlexObjectManager.addDirtyFlexObjects(mPropertyBag.reference, aToBeDeletedFlexObjects);
313
+ };
314
+
315
+ /**
316
+ * Reset flex objects on the server.
317
+ * If the reset is performed for an entire component, a browser reload is required.
318
+ * If the reset is performed for a control or change type, this function also triggers a reversion of deleted UI changes.
319
+ * The to be deleted flexObjects can be filtered by selectorIds, changeTypes or generator.
320
+ *
321
+ * @param {object} mPropertyBag - Object with parameters as properties
322
+ * @param {string} mPropertyBag.layer - Layer for which changes shall be deleted
323
+ * @param {sap.ui.core.UIComponent} mPropertyBag.appComponent - Component instance
324
+ * @param {string} [mPropertyBag.generator] - Generator of changes
325
+ * @param {string[]} [mPropertyBag.selectorIds] - Selector IDs in local format
326
+ * @param {string[]} [mPropertyBag.changeTypes] - Types of changes
327
+ *
328
+ * @returns {Promise<undefined>} Resolves after the deletion took place
329
+ */
330
+ FlexObjectManager.resetFlexObjects = async function(mPropertyBag) {
331
+ const sReference = ManifestUtils.getFlexReferenceForControl(mPropertyBag.appComponent);
332
+ const aFlexObjects = await FlexObjectManager.getFlexObjects({
333
+ selector: mPropertyBag.appComponent,
334
+ currentLayer: mPropertyBag.layer,
335
+ includeCtrlVariants: true
336
+ });
337
+ const mParams = {
338
+ reference: sReference,
339
+ layer: mPropertyBag.layer,
340
+ changes: aFlexObjects
341
+ };
342
+ if (mPropertyBag.generator) {
343
+ mParams.generator = mPropertyBag.generator;
344
+ }
345
+ if (mPropertyBag.selectorIds) {
346
+ mParams.selectorIds = mPropertyBag.selectorIds;
347
+ }
348
+ if (mPropertyBag.changeTypes) {
349
+ mParams.changeTypes = mPropertyBag.changeTypes;
350
+ }
351
+ const oResponse = await Storage.reset(mParams);
352
+
353
+ if (mPropertyBag.selectorIds || mPropertyBag.changeTypes || mPropertyBag.generator) {
354
+ const aFileNames = [];
355
+ if (oResponse?.response?.length > 0) {
356
+ oResponse.response.forEach(function(oChangeContent) {
357
+ aFileNames.push(oChangeContent.fileName);
358
+ });
359
+ }
360
+ const aChangesToRevert = aFlexObjects.filter(function(oChange) {
361
+ return aFileNames.indexOf(oChange.getId()) !== -1;
362
+ });
363
+ FlexState.updateStorageResponse(sReference, aChangesToRevert.map((oFlexObject) => {
364
+ return { flexObject: oFlexObject.convertToFileContent(), type: "delete" };
365
+ }));
366
+
367
+ if (aChangesToRevert.length) {
368
+ await Reverter.revertMultipleChanges(
369
+ // Always revert changes in reverse order
370
+ [...aChangesToRevert].reverse(),
371
+ {
372
+ appComponent: mPropertyBag.appComponent,
373
+ modifier: JsControlTreeModifier,
374
+ reference: sReference
375
+ }
376
+ );
377
+ }
378
+ }
379
+ };
380
+
205
381
  return FlexObjectManager;
206
382
  });
@@ -20,7 +20,7 @@ sap.ui.define([
20
20
  *
21
21
  * @namespace sap.ui.fl.write._internal.flexState.UI2Personalization.UI2PersonalizationState
22
22
  * @since 1.120
23
- * @version 1.128.0
23
+ * @version 1.129.0
24
24
  * @private
25
25
  * @ui5-restricted
26
26
  */
@@ -0,0 +1,86 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+
7
+ sap.ui.define([
8
+ "sap/base/util/restricted/_omit",
9
+ "sap/ui/core/Component",
10
+ "sap/ui/fl/apply/_internal/changes/Applier",
11
+ "sap/ui/fl/apply/_internal/flexObjects/FlexObjectFactory",
12
+ "sap/ui/fl/apply/_internal/flexState/changes/DependencyHandler",
13
+ "sap/ui/fl/apply/_internal/flexState/FlexObjectState",
14
+ "sap/ui/fl/apply/_internal/flexState/FlexState"
15
+ ], function(
16
+ _omit,
17
+ Component,
18
+ Applier,
19
+ FlexObjectFactory,
20
+ DependencyHandler,
21
+ FlexObjectState,
22
+ FlexState
23
+ ) {
24
+ "use strict";
25
+
26
+ /**
27
+ * Central class for the management of UIChanges within the flex states.
28
+ *
29
+ * @namespace
30
+ * @alias sap.ui.fl.write._internal.flexState.changes.UIChangeManager
31
+ * @since 1.129
32
+ * @version 1.129.0
33
+ * @private
34
+ * @ui5-restricted sap.ui.fl
35
+ */
36
+ const UIChangeManager = {};
37
+
38
+ function finalizeChangeCreation(sReference, oChange, oAppComponent) {
39
+ DependencyHandler.addRuntimeChangeToMap(
40
+ oChange,
41
+ oAppComponent,
42
+ FlexObjectState.getLiveDependencyMap(sReference)
43
+ );
44
+
45
+ // If the first changes were created, the propagationListener of sap.ui.fl
46
+ // might not yet be attached to the application component and must be added then
47
+ if (oAppComponent instanceof Component) {
48
+ const bNoFlPropagationListenerAttached = oAppComponent.getPropagationListeners()
49
+ .every((fnPropagationListener) => (!fnPropagationListener._bIsSapUiFlFlexControllerApplyChangesOnControl));
50
+
51
+ if (bNoFlPropagationListenerAttached) {
52
+ const fnPropagationListener = Applier.applyAllChangesForControl.bind(Applier, oAppComponent, sReference);
53
+ fnPropagationListener._bIsSapUiFlFlexControllerApplyChangesOnControl = true;
54
+ oAppComponent.addPropagationListener(fnPropagationListener);
55
+ }
56
+ }
57
+ }
58
+
59
+ function getOrCreateFlexObject(vFlexObject) {
60
+ return (
61
+ typeof vFlexObject.isA === "function"
62
+ && vFlexObject.isA("sap.ui.fl.apply._internal.flexObjects.FlexObject")
63
+ )
64
+ ? vFlexObject
65
+ : FlexObjectFactory.createFromFileContent(vFlexObject);
66
+ }
67
+
68
+ /**
69
+ * Adds new UIChanges and returns the IDs of the new UIChanges.
70
+ *
71
+ * @param {string} sReference - Flex reference of the application
72
+ * @param {object[]} aChanges - Array with complete and finalized JSON object representation of the file content of the UIChanges or UIChange instances
73
+ * @param {sap.ui.core.Component} oAppComponent - Application component instance
74
+ * @returns {sap.ui.fl.apply._internal.flexObjects.FlexObject[]} The newly added UIChanges
75
+ * @public
76
+ */
77
+ UIChangeManager.addDirtyChanges = function(sReference, aChanges, oAppComponent) {
78
+ const aAddedChanges = FlexState.addDirtyFlexObjects(sReference, aChanges.map(getOrCreateFlexObject));
79
+ aAddedChanges.forEach((oChange) => {
80
+ finalizeChangeCreation(sReference, oChange, oAppComponent);
81
+ });
82
+ return aAddedChanges;
83
+ };
84
+
85
+ return UIChangeManager;
86
+ });
@@ -192,7 +192,7 @@ sap.ui.define([
192
192
 
193
193
  function needsPersistencyCall(oFlexObject) {
194
194
  return oFlexObject &&
195
- [States.LifecycleState.NEW, States.LifecycleState.DIRTY, States.LifecycleState.DELETED].includes(oFlexObject.getState());
195
+ [States.LifecycleState.NEW, States.LifecycleState.UPDATED, States.LifecycleState.DELETED].includes(oFlexObject.getState());
196
196
  }
197
197
 
198
198
  function getAllCompVariantObjects(mCompVariantsMapByPersistencyKey) {
@@ -266,13 +266,13 @@ sap.ui.define([
266
266
  });
267
267
  revertVariantUpdate(
268
268
  oVariant,
269
- Object.assign({
269
+ {
270
270
  name: oRevertDataContent.previousName,
271
271
  content: oRevertDataContent.previousContent,
272
272
  favorite: oRevertDataContent.previousFavorite,
273
273
  executeOnSelection: oRevertDataContent.previousExecuteOnSelection,
274
274
  contexts: oRevertDataContent.previousContexts
275
- })
275
+ }
276
276
  );
277
277
  oVariant.setState(oRevertDataContent.previousState);
278
278
  }
@@ -310,7 +310,7 @@ sap.ui.define([
310
310
  *
311
311
  * @namespace sap.ui.fl.write._internal.flexState.compVariants.CompVariantState
312
312
  * @since 1.83
313
- * @version 1.128.0
313
+ * @version 1.129.0
314
314
  * @private
315
315
  * @ui5-restricted sap.ui.fl
316
316
  */
@@ -368,7 +368,7 @@ sap.ui.define([
368
368
  oChange.addRevertInfo(new RevertData({
369
369
  type: CompVariantState.operationType.NewChange
370
370
  }));
371
- FlexState.addDirtyFlexObject(mPropertyBag.reference, oChange);
371
+ FlexState.addDirtyFlexObjects(mPropertyBag.reference, [oChange]);
372
372
  } else {
373
373
  oChange.addRevertInfo(new RevertData({
374
374
  type: CompVariantState.operationType.ContentUpdate,
@@ -432,20 +432,20 @@ sap.ui.define([
432
432
  return undefined;
433
433
  }
434
434
 
435
- var oChangeSpecificData = mPropertyBag.changeSpecificData;
435
+ const oChangeSpecificData = mPropertyBag.changeSpecificData;
436
436
 
437
437
  oChangeSpecificData.layer = determineLayer(oChangeSpecificData);
438
438
  oChangeSpecificData.changeType = oChangeSpecificData.type;
439
439
  oChangeSpecificData.texts = getTexts(oChangeSpecificData);
440
440
  setAuthor(oChangeSpecificData);
441
- var oFileContent = Object.assign({}, oChangeSpecificData, _omit(mPropertyBag, "changeSpecificData"));
442
- var oFlexObject = FlexObjectFactory.createCompVariant(oFileContent);
441
+ const oFileContent = { ...oChangeSpecificData, ...(_omit(mPropertyBag, "changeSpecificData")) };
442
+ const oFlexObject = FlexObjectFactory.createCompVariant(oFileContent);
443
443
 
444
- var mCompVariantsMap = FlexState.getCompVariantsMap(mPropertyBag.reference);
445
- var oMapOfPersistencyKey = mCompVariantsMap._getOrCreate(mPropertyBag.persistencyKey);
444
+ const mCompVariantsMap = FlexState.getCompVariantsMap(mPropertyBag.reference);
445
+ const oMapOfPersistencyKey = mCompVariantsMap._getOrCreate(mPropertyBag.persistencyKey);
446
446
  oMapOfPersistencyKey.variants.push(oFlexObject);
447
447
  oMapOfPersistencyKey.byId[oFlexObject.getId()] = oFlexObject;
448
- FlexState.addDirtyFlexObject(mPropertyBag.reference, oFlexObject);
448
+ FlexState.addDirtyFlexObjects(mPropertyBag.reference, [oFlexObject]);
449
449
  if (oChangeSpecificData.layer !== Layer.USER && oChangeSpecificData.layer !== Layer.PUBLIC) {
450
450
  mPropertyBag.id = mPropertyBag.control.getCurrentVariantId();
451
451
  revertAllVariantUpdate(getVariantById(mPropertyBag));
@@ -471,7 +471,7 @@ sap.ui.define([
471
471
  * @param {object} [mPropertyBag.contexts] - Map of contexts that restrict the visibility of the variant
472
472
  * @param {string[]} [mPropertyBag.contexts.role] - List of roles which are allowed to see the variant
473
473
  * @param {sap.ui.fl.Layer} mPropertyBag.layer - Layer in which the variant removal takes place;
474
- * @param {string} mPropertyBag.adaptationId - ID of the context-based adaptation
474
+ * @param {string} [mPropertyBag.adaptationId] - ID of the context-based adaptation
475
475
  * @param {boolean} [mPropertyBag.forceCreate] - Parameter that forces a new change to be created
476
476
  * this either updates the variant from the layer or writes a change to that layer.
477
477
  * @returns {sap.ui.fl.apply._internal.flexObjects.CompVariant} The updated variant
@@ -540,12 +540,12 @@ sap.ui.define([
540
540
  }
541
541
 
542
542
  function updateChange(mPropertyBag, oVariant, oChange) {
543
- var aRevertData = oChange.getRevertData() || [];
544
- var oChangeContent = Object.assign({}, oChange.getContent());
545
- var oRevertData = {
546
- previousContent: Object.assign({}, oChangeContent),
543
+ const aRevertData = oChange.getRevertData() || [];
544
+ const oChangeContent = { ...oChange.getContent() };
545
+ const oRevertData = {
546
+ previousContent: { ...oChangeContent },
547
547
  previousState: oChange.getState(),
548
- change: _pick(Object.assign({}, mPropertyBag), ["favorite", "visible", "executeOnSelection", "contexts", "content", "name"])
548
+ change: _pick(mPropertyBag, ["favorite", "visible", "executeOnSelection", "contexts", "content", "name"])
549
549
  };
550
550
  aRevertData.push(oRevertData);
551
551
  oChange.setRevertData(aRevertData);
@@ -584,7 +584,7 @@ sap.ui.define([
584
584
  var sPersistencyKey = oChange.getSelector().persistencyKey;
585
585
  mCompVariantsMap[sPersistencyKey].changes.push(oChange);
586
586
  mCompVariantsMap[sPersistencyKey].byId[oChange.getId()] = oChange;
587
- FlexState.addDirtyFlexObject(mPropertyBag.reference, oChange);
587
+ FlexState.addDirtyFlexObjects(mPropertyBag.reference, [oChange]);
588
588
  }
589
589
 
590
590
  var oContent = {};
@@ -610,10 +610,10 @@ sap.ui.define([
610
610
  }
611
611
  });
612
612
 
613
- if (mPropertyBag.adaptationId !== undefined) {
614
- oChange.setAdaptationId(mPropertyBag.adaptationId);
615
- } else if (mPropertyBag.changeSpecificData && mPropertyBag.changeSpecificData.adaptationId !== undefined) {
616
- oChange.setAdaptationId(mPropertyBag.changeSpecificData.adaptationId);
613
+ const sAdaptationId = mPropertyBag.adaptationId || mPropertyBag?.changeSpecificData?.adaptationId;
614
+
615
+ if (sAdaptationId) {
616
+ oChange.setAdaptationId(sAdaptationId);
617
617
  }
618
618
 
619
619
  if (mPropertyBag.name) {
@@ -765,7 +765,7 @@ sap.ui.define([
765
765
  mCompVariantsMap[sPersistencyKey].changes = mCompVariantsMap[sPersistencyKey].changes.filter(function(oChangeInMap) {
766
766
  return oChangeInMap !== oChange;
767
767
  });
768
- FlexState.removeDirtyFlexObject(mPropertyBag.reference, oChange);
768
+ FlexState.removeDirtyFlexObjects(mPropertyBag.reference, [oChange]);
769
769
  }
770
770
 
771
771
  var oVariant = getVariantById(mPropertyBag);
@@ -779,15 +779,15 @@ sap.ui.define([
779
779
  case CompVariantState.operationType.ContentUpdate:
780
780
  revertVariantUpdate(
781
781
  oVariant,
782
- Object.assign({
782
+ {
783
783
  name: oRevertDataContent.previousName,
784
784
  content: oRevertDataContent.previousContent,
785
785
  favorite: oRevertDataContent.previousFavorite,
786
786
  executeOnSelection: oRevertDataContent.previousExecuteOnSelection,
787
- contexts: oRevertDataContent.previousContexts
788
- },
789
- _pick(mPropertyBag, ["reference", "persistencyKey", "id"])
790
- ));
787
+ contexts: oRevertDataContent.previousContexts,
788
+ ..._pick(mPropertyBag, ["reference", "persistencyKey", "id"])
789
+ }
790
+ );
791
791
  break;
792
792
  case CompVariantState.operationType.NewChange:
793
793
  oChange = oVariantRevertData.getChange();
@@ -795,31 +795,31 @@ sap.ui.define([
795
795
  removeChange(oChange);
796
796
  revertVariantChange(
797
797
  oVariant,
798
- Object.assign(
799
- {
800
- name: oRevertDataContent.previousName,
801
- content: oRevertDataContent.previousContent,
802
- favorite: oRevertDataContent.previousFavorite,
803
- executeOnSelection: oRevertDataContent.previousExecuteOnSelection,
804
- contexts: oRevertDataContent.previousContexts
805
- },
806
- _pick(mPropertyBag, ["reference", "persistencyKey", "id"])
807
- ));
798
+ {
799
+ name: oRevertDataContent.previousName,
800
+ content: oRevertDataContent.previousContent,
801
+ favorite: oRevertDataContent.previousFavorite,
802
+ executeOnSelection: oRevertDataContent.previousExecuteOnSelection,
803
+ contexts: oRevertDataContent.previousContexts,
804
+ ..._pick(mPropertyBag, ["reference", "persistencyKey", "id"])
805
+ }
806
+ );
808
807
  break;
809
808
  case CompVariantState.operationType.UpdateVariantViaChangeUpdate:
810
809
  oChange = oVariantRevertData.getChange();
811
810
  revertVariantChange(
812
811
  oVariant,
813
- Object.assign(
814
- {
812
+ {
813
+ ...{
815
814
  name: oRevertDataContent.previousName,
816
815
  content: oRevertDataContent.previousContent,
817
816
  favorite: oRevertDataContent.previousFavorite,
818
817
  executeOnSelection: oRevertDataContent.previousExecuteOnSelection,
819
818
  contexts: oRevertDataContent.previousContexts
820
819
  },
821
- _pick(mPropertyBag, ["reference", "persistencyKey", "id"])
822
- ));
820
+ ..._pick(mPropertyBag, ["reference", "persistencyKey", "id"])
821
+ }
822
+ );
823
823
  var oChangeRevertData = oChange.getRevertData().pop();
824
824
  oChange.setContent(oChangeRevertData.previousContent);
825
825
  oChange.setState(oChangeRevertData.previousState);
@@ -904,7 +904,7 @@ sap.ui.define([
904
904
  case States.LifecycleState.NEW:
905
905
  ifVariantClearRevertData(oFlexObject);
906
906
  return writeObjectAndAddToState(oFlexObject, oStoredResponse, sParentVersion);
907
- case States.LifecycleState.DIRTY:
907
+ case States.LifecycleState.UPDATED:
908
908
  ifVariantClearRevertData(oFlexObject);
909
909
  return updateObjectAndStorage(oFlexObject, oStoredResponse, sParentVersion, mPropertyBag.reference);
910
910
  case States.LifecycleState.DELETED:
@@ -26,7 +26,7 @@ sap.ui.define([
26
26
  * @private
27
27
  * @alias sap.ui.fl.write._internal.transport.TransportSelection
28
28
  * @author SAP SE
29
- * @version 1.128.0
29
+ * @version 1.129.0
30
30
  * @since 1.74.0
31
31
  * Helper object to select an ABAP transport for an LREP object. This is not a generic utility to select a transport request, but part
32
32
  * of the SmartVariant control.
@@ -27,7 +27,7 @@ sap.ui.define([
27
27
  * Entity that handles ABAP transport related information.
28
28
  * @alias sap.ui.fl.write._internal.transport.Transports
29
29
  * @author SAP SE
30
- * @version 1.128.0
30
+ * @version 1.129.0
31
31
  * @since 1.74.0
32
32
  * @private
33
33
  * @ui5-restricted sap.ui.fl.write._internal.transport
@@ -169,7 +169,7 @@ sap.ui.define([
169
169
  }
170
170
 
171
171
  // TODO Extract class
172
- var oModel = new JSONModel({
172
+ const oModel = new JSONModel({
173
173
  allAdaptations: [],
174
174
  adaptations: [],
175
175
  count: 0,
@@ -177,7 +177,7 @@ sap.ui.define([
177
177
  contextBasedAdaptationsEnabled: bContextBasedAdaptationsEnabled
178
178
  });
179
179
  oModel.updateAdaptations = function(aAdaptations) {
180
- var aContextBasedAdaptations = aAdaptations.filter(function(oAdaptation, iIndex) {
180
+ const aContextBasedAdaptations = aAdaptations.filter(function(oAdaptation, iIndex) {
181
181
  oAdaptation.rank = iIndex + 1; // initialize ranks
182
182
  return oAdaptation.type !== Adaptations.Type.Default;
183
183
  });
@@ -186,59 +186,62 @@ sap.ui.define([
186
186
  oModel.setProperty("/count", aContextBasedAdaptations.length);
187
187
 
188
188
  // update displayed adaptation
189
- var oDisplayedAdaptation = oModel.getProperty("/displayedAdaptation");
190
- var oCorrespondingAdaptation = aAdaptations.find(function(oAdaptation) {
189
+ let oDisplayedAdaptation = oModel.getProperty("/displayedAdaptation");
190
+ const oCorrespondingAdaptation = aAdaptations.find(function(oAdaptation) {
191
191
  return !!oDisplayedAdaptation && oAdaptation.id === oDisplayedAdaptation.id;
192
192
  });
193
193
  if (oCorrespondingAdaptation) {
194
- oDisplayedAdaptation = Object.assign({}, oCorrespondingAdaptation);
194
+ oDisplayedAdaptation = { ...oCorrespondingAdaptation };
195
195
  oModel.setProperty("/displayedAdaptation", oDisplayedAdaptation);
196
196
  }
197
197
  oModel.updateBindings(true);
198
198
  };
199
199
  oModel.insertAdaptation = function(oNewAdaptation) {
200
- var aAdaptations = oModel.getProperty("/allAdaptations");
200
+ const aAdaptations = oModel.getProperty("/allAdaptations");
201
201
  aAdaptations.splice(oNewAdaptation.priority, 0, oNewAdaptation);
202
202
  delete oNewAdaptation.priority;
203
203
  oModel.updateAdaptations(aAdaptations);
204
204
  };
205
205
  oModel.deleteAdaptation = function() {
206
- var iIndex = oModel.getProperty("/displayedAdaptation").rank - 1;
207
- var aAdaptations = oModel.getProperty("/adaptations");
208
- var iModelCount = oModel.getProperty("/count");
209
- var sToBeDisplayedAdaptationId;
206
+ const iIndex = oModel.getProperty("/displayedAdaptation").rank - 1;
207
+ const aAdaptations = oModel.getProperty("/adaptations");
208
+ const iModelCount = oModel.getProperty("/count");
209
+ let sToBeDisplayedAdaptationId;
210
210
  if (iModelCount > 1) {
211
211
  sToBeDisplayedAdaptationId = aAdaptations[iIndex + ((iIndex === iModelCount - 1) ? -1 : 1)].id;
212
212
  }
213
213
  aAdaptations.splice(iIndex, 1);
214
- var oDefaultAdaptation = oModel.getProperty("/allAdaptations").pop();
214
+ const oDefaultAdaptation = oModel.getProperty("/allAdaptations").pop();
215
215
  aAdaptations.push(oDefaultAdaptation);
216
216
  oModel.updateAdaptations(aAdaptations);
217
217
  return sToBeDisplayedAdaptationId;
218
218
  };
219
219
  oModel.switchDisplayedAdaptation = function(sAdaptationId) {
220
- var iIndex = oModel.getIndexByAdaptationId(sAdaptationId);
221
- var oNewDisplayedAdaptation = iIndex ? oModel.getProperty("/allAdaptations")[iIndex] : oModel.getProperty("/allAdaptations")[0];
220
+ const iIndex = oModel.getIndexByAdaptationId(sAdaptationId);
221
+ const oNewDisplayedAdaptation =
222
+ iIndex ?
223
+ oModel.getProperty("/allAdaptations")[iIndex] :
224
+ oModel.getProperty("/allAdaptations")[0];
222
225
  oModel.setProperty("/displayedAdaptation", oNewDisplayedAdaptation);
223
226
  oModel.updateBindings(true);
224
227
  };
225
228
  oModel.updateAdaptationContent = function(oContextBasedAdaptation) {
226
- var aAdaptations = oModel.getProperty("/allAdaptations");
227
- var oAdaptationForUpdate = aAdaptations.find(function(oAdaptation) {
229
+ const aAdaptations = oModel.getProperty("/allAdaptations");
230
+ const oAdaptationForUpdate = aAdaptations.find(function(oAdaptation) {
228
231
  return oContextBasedAdaptation.adaptationId === oAdaptation.id;
229
232
  });
230
233
  oAdaptationForUpdate.title = oContextBasedAdaptation.title;
231
234
  oAdaptationForUpdate.contexts = oContextBasedAdaptation.contexts;
232
- var iIndex = oAdaptationForUpdate.rank - 1;
235
+ const iIndex = oAdaptationForUpdate.rank - 1;
233
236
  if (iIndex !== oContextBasedAdaptation.priority) {
234
- var aDisplayedAdaptation = aAdaptations.splice(iIndex, 1);
237
+ const aDisplayedAdaptation = aAdaptations.splice(iIndex, 1);
235
238
  aAdaptations.splice(oContextBasedAdaptation.priority, 0, aDisplayedAdaptation[0]);
236
239
  }
237
240
  oModel.updateAdaptations(aAdaptations);
238
241
  };
239
242
  oModel.getIndexByAdaptationId = function(sAdaptationId) {
240
- var aAdaptations = oModel.getProperty("/allAdaptations");
241
- var iAdaptationIndex = aAdaptations.findIndex(function(oAdaptation) {
243
+ const aAdaptations = oModel.getProperty("/allAdaptations");
244
+ const iAdaptationIndex = aAdaptations.findIndex(function(oAdaptation) {
242
245
  return oAdaptation.id === sAdaptationId;
243
246
  });
244
247
  return (iAdaptationIndex > -1) ? iAdaptationIndex : undefined;