@openui5/sap.ui.fl 1.129.0 → 1.130.1

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 (172) 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 +26 -38
  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 +1 -1
  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 +8 -8
  13. package/src/sap/ui/fl/apply/_internal/DelegateMediator.js +1 -1
  14. package/src/sap/ui/fl/apply/_internal/appVariant/DescriptorChangeTypes.js +2 -1
  15. package/src/sap/ui/fl/apply/_internal/changes/Applier.js +152 -197
  16. package/src/sap/ui/fl/apply/_internal/changes/FlexCustomData.js +23 -17
  17. package/src/sap/ui/fl/apply/_internal/changes/Reverter.js +27 -37
  18. package/src/sap/ui/fl/apply/_internal/changes/Utils.js +26 -31
  19. package/src/sap/ui/fl/apply/_internal/changes/descriptor/Preprocessor.js +1 -1
  20. package/src/sap/ui/fl/apply/_internal/changes/descriptor/Registration.js +3 -2
  21. package/src/sap/ui/fl/apply/_internal/changes/descriptor/RegistrationBuild.js +2 -1
  22. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/AddAnnotationsToOData.js +1 -1
  23. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/AddNewDataSource.js +1 -1
  24. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/AddNewInbound.js +1 -1
  25. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/AddNewOutbound.js +1 -1
  26. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/AddTechnicalAttributes.js +1 -1
  27. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/ChangeDataSource.js +1 -1
  28. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/ChangeInbound.js +1 -1
  29. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/ChangeOutbound.js +1 -1
  30. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/RemoveAllInboundsExceptOne.js +1 -1
  31. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/SetAch.js +1 -1
  32. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/SetDescription.js +1 -1
  33. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/SetTitle.js +1 -1
  34. package/src/sap/ui/fl/apply/_internal/changes/descriptor/fiori/SetAbstract.js +1 -1
  35. package/src/sap/ui/fl/apply/_internal/changes/descriptor/fiori/SetCloudDevAdaptationStatus.js +1 -1
  36. package/src/sap/ui/fl/apply/_internal/changes/descriptor/fiori/SetRegistrationIds.js +1 -1
  37. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ovp/AddNewCard.js +1 -1
  38. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ovp/ChangeCard.js +1 -1
  39. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ovp/DeleteCard.js +1 -1
  40. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddComponentUsages.js +1 -1
  41. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddLibrary.js +1 -1
  42. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddNewModel.js +1 -1
  43. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddNewModelEnhanceWith.js +1 -1
  44. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/ChangeModel.js +78 -0
  45. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/SetFlexExtensionPointEnabled.js +1 -1
  46. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/SetMinUI5Version.js +1 -1
  47. package/src/sap/ui/fl/apply/_internal/connectors/ObjectStorageUtils.js +1 -1
  48. package/src/sap/ui/fl/apply/_internal/extensionPoint/Processor.js +1 -1
  49. package/src/sap/ui/fl/apply/_internal/extensionPoint/Registry.js +1 -1
  50. package/src/sap/ui/fl/apply/_internal/flexObjects/AnnotationChange.js +1 -1
  51. package/src/sap/ui/fl/apply/_internal/flexObjects/AppDescriptorChange.js +1 -1
  52. package/src/sap/ui/fl/apply/_internal/flexObjects/CompVariant.js +1 -1
  53. package/src/sap/ui/fl/apply/_internal/flexObjects/ControllerExtensionChange.js +1 -1
  54. package/src/sap/ui/fl/apply/_internal/flexObjects/FlVariant.js +1 -1
  55. package/src/sap/ui/fl/apply/_internal/flexObjects/FlexObject.js +1 -1
  56. package/src/sap/ui/fl/apply/_internal/flexObjects/FlexObjectFactory.js +7 -3
  57. package/src/sap/ui/fl/apply/_internal/flexObjects/UIChange.js +1 -1
  58. package/src/sap/ui/fl/apply/_internal/flexObjects/Variant.js +1 -1
  59. package/src/sap/ui/fl/apply/_internal/flexObjects/getVariantAuthor.js +1 -1
  60. package/src/sap/ui/fl/apply/_internal/flexState/FlexObjectState.js +1 -1
  61. package/src/sap/ui/fl/apply/_internal/flexState/FlexState.js +34 -13
  62. package/src/sap/ui/fl/apply/_internal/flexState/Loader.js +1 -1
  63. package/src/sap/ui/fl/apply/_internal/flexState/ManifestUtils.js +1 -1
  64. package/src/sap/ui/fl/apply/_internal/flexState/UI2Personalization/UI2PersonalizationState.js +1 -1
  65. package/src/sap/ui/fl/apply/_internal/flexState/changes/DependencyHandler.js +1 -1
  66. package/src/sap/ui/fl/apply/_internal/flexState/changes/ExtensionPointState.js +1 -1
  67. package/src/sap/ui/fl/apply/_internal/flexState/changes/UIChangesState.js +1 -1
  68. package/src/sap/ui/fl/apply/_internal/flexState/compVariants/CompVariantManagementState.js +108 -0
  69. package/src/sap/ui/fl/apply/_internal/flexState/compVariants/CompVariantMerger.js +2 -2
  70. package/src/sap/ui/fl/apply/_internal/flexState/controlVariants/Switcher.js +1 -1
  71. package/src/sap/ui/fl/apply/_internal/flexState/controlVariants/VariantManagementState.js +57 -9
  72. package/src/sap/ui/fl/apply/_internal/preprocessors/ComponentLifecycleHooks.js +2 -2
  73. package/src/sap/ui/fl/apply/_internal/preprocessors/ControllerExtension.js +1 -1
  74. package/src/sap/ui/fl/apply/_internal/preprocessors/RegistrationDelegator.js +6 -6
  75. package/src/sap/ui/fl/apply/_internal/preprocessors/XmlPreprocessor.js +1 -1
  76. package/src/sap/ui/fl/apply/api/ControlVariantApplyAPI.js +25 -10
  77. package/src/sap/ui/fl/apply/api/SmartVariantManagementApplyAPI.js +18 -45
  78. package/src/sap/ui/fl/changeHandler/AddIFrame.js +1 -1
  79. package/src/sap/ui/fl/changeHandler/AddXML.js +1 -1
  80. package/src/sap/ui/fl/changeHandler/AddXMLAtExtensionPoint.js +1 -1
  81. package/src/sap/ui/fl/changeHandler/Base.js +1 -1
  82. package/src/sap/ui/fl/changeHandler/BaseAddViaDelegate.js +1 -1
  83. package/src/sap/ui/fl/changeHandler/BaseAddXml.js +1 -1
  84. package/src/sap/ui/fl/changeHandler/BaseRename.js +1 -1
  85. package/src/sap/ui/fl/changeHandler/HideControl.js +1 -1
  86. package/src/sap/ui/fl/changeHandler/MoveControls.js +1 -1
  87. package/src/sap/ui/fl/changeHandler/MoveElements.js +1 -1
  88. package/src/sap/ui/fl/changeHandler/PropertyBindingChange.js +1 -1
  89. package/src/sap/ui/fl/changeHandler/PropertyChange.js +1 -1
  90. package/src/sap/ui/fl/changeHandler/StashControl.js +1 -1
  91. package/src/sap/ui/fl/changeHandler/UnhideControl.js +1 -1
  92. package/src/sap/ui/fl/changeHandler/UnstashControl.js +1 -1
  93. package/src/sap/ui/fl/changeHandler/UpdateIFrame.js +1 -1
  94. package/src/sap/ui/fl/descriptorRelated/api/DescriptorChangeFactory.js +4 -4
  95. package/src/sap/ui/fl/descriptorRelated/api/DescriptorInlineChangeFactory.js +1 -1
  96. package/src/sap/ui/fl/descriptorRelated/api/DescriptorVariantFactory.js +1 -1
  97. package/src/sap/ui/fl/initial/_internal/FlexConfiguration.js +1 -1
  98. package/src/sap/ui/fl/initial/_internal/Storage.js +37 -1
  99. package/src/sap/ui/fl/initial/_internal/StorageFeaturesMerger.js +1 -1
  100. package/src/sap/ui/fl/initial/_internal/StorageUtils.js +1 -1
  101. package/src/sap/ui/fl/initial/_internal/changeHandlers/ChangeHandlerRegistration.js +3 -2
  102. package/src/sap/ui/fl/initial/_internal/changeHandlers/ChangeHandlerStorage.js +1 -1
  103. package/src/sap/ui/fl/initial/_internal/connectors/Utils.js +1 -1
  104. package/src/sap/ui/fl/initial/_internal/storageResultDisassemble.js +1 -1
  105. package/src/sap/ui/fl/interfaces/BaseLoadConnector.js +15 -1
  106. package/src/sap/ui/fl/interfaces/Delegate.js +1 -1
  107. package/src/sap/ui/fl/library.js +43 -43
  108. package/src/sap/ui/fl/support/_internal/getAllUIChanges.js +1 -1
  109. package/src/sap/ui/fl/support/_internal/getChangeDependencies.js +1 -1
  110. package/src/sap/ui/fl/support/_internal/getFlexObjectInfos.js +1 -1
  111. package/src/sap/ui/fl/support/_internal/getFlexSettings.js +1 -1
  112. package/src/sap/ui/fl/support/api/SupportAPI.js +1 -1
  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 +35 -16
  122. package/src/sap/ui/fl/util/IFrame.js +1 -1
  123. package/src/sap/ui/fl/util/ManagedObjectModel.js +1 -1
  124. package/src/sap/ui/fl/util/resolveBinding.js +1 -1
  125. package/src/sap/ui/fl/variants/VariantModel.js +33 -11
  126. package/src/sap/ui/fl/write/_internal/Storage.js +1 -1
  127. package/src/sap/ui/fl/write/_internal/Versions.js +7 -3
  128. package/src/sap/ui/fl/write/_internal/appVariant/AppVariant.js +1 -1
  129. package/src/sap/ui/fl/write/_internal/appVariant/AppVariantFactory.js +1 -1
  130. package/src/sap/ui/fl/write/_internal/appVariant/AppVariantInlineChange.js +1 -1
  131. package/src/sap/ui/fl/write/_internal/appVariant/AppVariantInlineChangeFactory.js +34 -1
  132. package/src/sap/ui/fl/write/_internal/condenser/Condenser.js +163 -176
  133. package/src/sap/ui/fl/write/_internal/condenser/UIReconstruction.js +62 -61
  134. package/src/sap/ui/fl/write/_internal/condenser/Utils.js +17 -19
  135. package/src/sap/ui/fl/write/_internal/condenser/classifications/Create.js +13 -13
  136. package/src/sap/ui/fl/write/_internal/condenser/classifications/Destroy.js +17 -19
  137. package/src/sap/ui/fl/write/_internal/condenser/classifications/Move.js +32 -35
  138. package/src/sap/ui/fl/write/_internal/condenser/classifications/Update.js +2 -10
  139. package/src/sap/ui/fl/write/_internal/connectors/BackendConnector.js +1 -1
  140. package/src/sap/ui/fl/write/_internal/connectors/BtpServiceConnector.js +1 -1
  141. package/src/sap/ui/fl/write/_internal/connectors/KeyUserConnector.js +1 -1
  142. package/src/sap/ui/fl/write/_internal/connectors/LrepConnector.js +56 -4
  143. package/src/sap/ui/fl/write/_internal/connectors/NeoLrepConnector.js +1 -1
  144. package/src/sap/ui/fl/write/_internal/connectors/ObjectPathConnector.js +1 -1
  145. package/src/sap/ui/fl/write/_internal/connectors/PersonalizationConnector.js +1 -1
  146. package/src/sap/ui/fl/write/_internal/connectors/Utils.js +1 -1
  147. package/src/sap/ui/fl/write/_internal/controlVariants/ControlVariantWriteUtils.js +59 -0
  148. package/src/sap/ui/fl/write/_internal/delegates/ODataV2ReadDelegate.js +1 -2
  149. package/src/sap/ui/fl/write/_internal/extensionPoint/Processor.js +1 -1
  150. package/src/sap/ui/fl/write/_internal/fieldExtensibility/ABAPAccess.js +1 -1
  151. package/src/sap/ui/fl/write/_internal/fieldExtensibility/ABAPExtensibilityVariant.js +1 -1
  152. package/src/sap/ui/fl/write/_internal/fieldExtensibility/ABAPExtensibilityVariantFactory.js +1 -1
  153. package/src/sap/ui/fl/write/_internal/fieldExtensibility/MultiTenantABAPExtensibilityVariant.js +1 -1
  154. package/src/sap/ui/fl/write/_internal/fieldExtensibility/ServiceValidation.js +1 -1
  155. package/src/sap/ui/fl/write/_internal/fieldExtensibility/SingleTenantABAPExtensibilityVariant.js +1 -1
  156. package/src/sap/ui/fl/write/_internal/fieldExtensibility/UriParser.js +1 -1
  157. package/src/sap/ui/fl/write/_internal/fieldExtensibility/Utils.js +1 -1
  158. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/CAPAccess.js +1 -1
  159. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/dialog/CustomFieldCAPDialog.js +1 -1
  160. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/editor/propertyEditor/booleanEditor/BooleanEditor.js +1 -1
  161. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/editor/propertyEditor/rangeEditor/RangeEditor.js +1 -1
  162. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/editor/propertyEditor/timeEditor/TimeEditor.js +1 -1
  163. package/src/sap/ui/fl/write/_internal/flexState/FlexObjectManager.js +33 -2
  164. package/src/sap/ui/fl/write/_internal/flexState/UI2Personalization/UI2PersonalizationState.js +1 -1
  165. package/src/sap/ui/fl/write/_internal/flexState/changes/UIChangeManager.js +26 -3
  166. package/src/sap/ui/fl/write/_internal/flexState/compVariants/CompVariantState.js +20 -12
  167. package/src/sap/ui/fl/write/_internal/transport/TransportSelection.js +1 -1
  168. package/src/sap/ui/fl/write/_internal/transport/Transports.js +1 -1
  169. package/src/sap/ui/fl/write/api/ChangesWriteAPI.js +73 -3
  170. package/src/sap/ui/fl/write/api/FieldExtensibility.js +1 -1
  171. package/src/sap/ui/fl/write/api/LocalResetAPI.js +17 -27
  172. package/src/sap/ui/fl/write/api/VersionsAPI.js +26 -4
@@ -21,8 +21,11 @@ sap.ui.define([
21
21
  "sap/ui/fl/apply/_internal/flexState/ManifestUtils",
22
22
  "sap/ui/fl/descriptorRelated/api/DescriptorChangeFactory",
23
23
  "sap/ui/fl/initial/_internal/changeHandlers/ChangeHandlerStorage",
24
- "sap/ui/fl/write/api/ContextBasedAdaptationsAPI",
25
24
  "sap/ui/fl/write/_internal/appVariant/AppVariantInlineChangeFactory",
25
+ "sap/ui/fl/write/_internal/controlVariants/ControlVariantWriteUtils",
26
+ "sap/ui/fl/write/_internal/flexState/FlexObjectManager",
27
+ "sap/ui/fl/write/api/ContextBasedAdaptationsAPI",
28
+ "sap/ui/fl/write/api/VersionsAPI",
26
29
  "sap/ui/fl/Layer",
27
30
  "sap/ui/fl/Utils"
28
31
  ], function(
@@ -42,8 +45,11 @@ sap.ui.define([
42
45
  ManifestUtils,
43
46
  DescriptorChangeFactory,
44
47
  ChangeHandlerStorage,
45
- ContextBasedAdaptationsAPI,
46
48
  AppVariantInlineChangeFactory,
49
+ ControlVariantWriteUtils,
50
+ FlexObjectManager,
51
+ ContextBasedAdaptationsAPI,
52
+ VersionsAPI,
47
53
  Layer,
48
54
  Utils
49
55
  ) {
@@ -99,7 +105,19 @@ sap.ui.define([
99
105
  oFlexObject.getLayer()
100
106
  )
101
107
  .then((oChangeHandler) => {
102
- return oChangeHandler.completeChangeContent(oFlexObject, mPropertyBag.changeSpecificData, {
108
+ const oChangeSpecificData = { ...mPropertyBag.changeSpecificData };
109
+ // Copy the content properties into the change specific data so any change handler can use the "settings" change structure
110
+ // TODO: consolidate in all commands/change handlers so the "content" structure is always used. todos#4
111
+ if (oChangeSpecificData.content) {
112
+ Object.keys(oChangeSpecificData.content).forEach((sKey) => {
113
+ if (!oChangeSpecificData[sKey]) {
114
+ oChangeSpecificData[sKey] = oChangeSpecificData.content[sKey];
115
+ } else {
116
+ Log.warning(`The property '${sKey}' is defined both in the change specific data and its content.`);
117
+ }
118
+ });
119
+ }
120
+ return oChangeHandler.completeChangeContent(oFlexObject, oChangeSpecificData, {
103
121
  modifier: JsControlTreeModifier,
104
122
  appComponent: mPropertyBag.appComponent,
105
123
  view: Utils.getViewForControl(mPropertyBag.selector)
@@ -314,5 +332,57 @@ sap.ui.define([
314
332
  );
315
333
  };
316
334
 
335
+ /**
336
+ * Deletes the variants and their related FlexObjects. Only variants that are in the draft or dirty state can be deleted,
337
+ * as they have no dependencies on them. Returns all FlexObjects that were deleted in the process.
338
+ *
339
+ * @param {object} mPropertyBag - Object with parameters as properties
340
+ * @param {sap.ui.core.Control} mPropertyBag.variantManagementControl - Variant management control
341
+ * @param {string[]} mPropertyBag.variants - Variant IDs to be deleted
342
+ * @param {string} mPropertyBag.layer - Layer to get the draft objects from
343
+ * @returns {sap.ui.fl.apply._internal.flexObjects.FlexObject[]} Array of deleted FlexObjects
344
+ * @private
345
+ * @ui5-restricted sap.ui.fl, sap.ui.rta, similar tools
346
+ */
347
+ ChangesWriteAPI.deleteVariantsAndRelatedObjects = function(mPropertyBag) {
348
+ if (!(mPropertyBag.variantManagementControl?.isA("sap.ui.fl.variants.VariantManagement"))) {
349
+ throw new Error("Please provide a valid Variant Management control");
350
+ }
351
+ const oVariantManagementControl = mPropertyBag.variantManagementControl;
352
+ const oAppComponent = Utils.getAppComponentForControl(oVariantManagementControl);
353
+ const sVariantManagementReference = JsControlTreeModifier.getSelector(oVariantManagementControl, oAppComponent).id;
354
+ const sFlexReference = ManifestUtils.getFlexReferenceForControl(oAppComponent);
355
+ const aDraftFilenames = VersionsAPI.getDraftFilenames({
356
+ control: oVariantManagementControl,
357
+ layer: mPropertyBag.layer
358
+ });
359
+ const aDirtyFlexObjectIds = FlexObjectState.getDirtyFlexObjects(sFlexReference).map((oFlexObject) => (
360
+ oFlexObject.getId()
361
+ ));
362
+ const aVariantsToBeDeleted = mPropertyBag.variants.filter((sVariantID) => (
363
+ aDraftFilenames.includes(sVariantID) || aDirtyFlexObjectIds.includes(sVariantID)
364
+ ));
365
+ return aVariantsToBeDeleted
366
+ .map((sVariantId) => (
367
+ ControlVariantWriteUtils.deleteVariant(sFlexReference, sVariantManagementReference, sVariantId)
368
+ ))
369
+ .flat();
370
+ };
371
+
372
+ /**
373
+ * Restores previously deleted FlexObjects. Objects are restored to the state they were in before deletion.
374
+ * If the flex object was not persisted, it is added as a dirty object again.
375
+ * Once the deletion is persisted, changes will not be restored.
376
+ *
377
+ * @param {object} mPropertyBag - Object with parameters as properties
378
+ * @param {string} mPropertyBag.reference - Flex reference of the application
379
+ * @param {sap.ui.fl.apply._internal.flexObjects.FlexObject[]} mPropertyBag.flexObjects - FlexObjects to be restored
380
+ * @private
381
+ * @ui5-restricted sap.ui.fl, sap.ui.rta, similar tools
382
+ */
383
+ ChangesWriteAPI.restoreDeletedFlexObjects = function(mPropertyBag) {
384
+ FlexObjectManager.restoreDeletedFlexObjects(mPropertyBag);
385
+ };
386
+
317
387
  return ChangesWriteAPI;
318
388
  });
@@ -22,7 +22,7 @@ sap.ui.define([
22
22
  *
23
23
  * @namespace sap.ui.fl.write.api.FieldExtensibility
24
24
  * @since 1.87
25
- * @version 1.129.0
25
+ * @version 1.130.1
26
26
  * @private
27
27
  * @ui5-restricted sap.ui.fl, sap.ui.rta, sap.ui.mdc
28
28
  */
@@ -5,25 +5,25 @@
5
5
  */
6
6
 
7
7
  sap.ui.define([
8
+ "sap/base/util/restricted/_union",
9
+ "sap/ui/core/util/reflection/JsControlTreeModifier",
8
10
  "sap/ui/fl/apply/_internal/flexObjects/States",
9
11
  "sap/ui/fl/apply/_internal/flexState/changes/UIChangesState",
10
- "sap/ui/fl/apply/_internal/flexState/FlexObjectState",
11
12
  "sap/ui/fl/apply/_internal/flexState/ManifestUtils",
12
- "sap/ui/fl/write/api/PersistenceWriteAPI",
13
+ "sap/ui/fl/write/_internal/flexState/changes/UIChangeManager",
13
14
  "sap/ui/fl/write/api/ChangesWriteAPI",
14
- "sap/ui/core/util/reflection/JsControlTreeModifier",
15
- "sap/ui/fl/Utils",
16
- "sap/base/util/restricted/_union"
15
+ "sap/ui/fl/write/api/PersistenceWriteAPI",
16
+ "sap/ui/fl/Utils"
17
17
  ], function(
18
+ union,
19
+ JsControlTreeModifier,
18
20
  States,
19
21
  UIChangesState,
20
- FlexObjectState,
21
22
  ManifestUtils,
22
- PersistenceWriteAPI,
23
+ UIChangeManager,
23
24
  ChangesWriteAPI,
24
- JsControlTreeModifier,
25
- Utils,
26
- union
25
+ PersistenceWriteAPI,
26
+ Utils
27
27
  ) {
28
28
  "use strict";
29
29
 
@@ -106,28 +106,18 @@ sap.ui.define([
106
106
  };
107
107
 
108
108
  LocalResetAPI.restoreChanges = function(aChanges, oAppComponent) {
109
- var aApplyQueue = aChanges.map(function(oChange) {
110
- return function() {
111
- oChange.restorePreviousState();
112
- var oControl = JsControlTreeModifier.bySelector(oChange.getSelector(), oAppComponent);
113
- if (oChange.getState() === States.LifecycleState.PERSISTED) {
114
- const aDirtyChanges = FlexObjectState.getDirtyFlexObjects(oAppComponent.name);
115
- var iIndex = aDirtyChanges.indexOf(oChange);
116
- if (iIndex >= 0) {
117
- aDirtyChanges.splice(iIndex, 1);
118
- }
119
- }
109
+ const sReference = ManifestUtils.getFlexReferenceForControl(oAppComponent);
110
+ UIChangeManager.restoreDeletedChanges(sReference, aChanges, oAppComponent);
111
+ const aApplyQueue = aChanges.map((oChange) =>
112
+ () => {
113
+ const oControl = JsControlTreeModifier.bySelector(oChange.getSelector(), oAppComponent);
120
114
  return ChangesWriteAPI.apply({
121
115
  change: oChange,
122
116
  element: oControl,
123
117
  modifier: JsControlTreeModifier
124
118
  });
125
- };
126
- });
127
- PersistenceWriteAPI.add({
128
- flexObjects: aChanges,
129
- selector: oAppComponent
130
- });
119
+ }
120
+ );
131
121
  return Utils.execPromiseQueueSequentially(aApplyQueue);
132
122
  };
133
123
 
@@ -147,6 +147,19 @@ sap.ui.define([
147
147
  return !!oDraft;
148
148
  };
149
149
 
150
+ /**
151
+ * Returns the list of Flex Objects file names which belong to the current draft.
152
+ *
153
+ * @param {object} mPropertyBag - Property bag
154
+ * @param {sap.ui.core.Control} mPropertyBag.control - Control for which the request is done
155
+ * @param {string} mPropertyBag.layer - Layer for which the file names should be retrieved
156
+ * @returns {string[]} List of file names for the draft
157
+ */
158
+ VersionsAPI.getDraftFilenames = function(mPropertyBag) {
159
+ const oModel = getVersionsModel(mPropertyBag);
160
+ return oModel.getProperty("/draftFilenames");
161
+ };
162
+
150
163
  /**
151
164
  * Returns a flag if the displayed version is not the active version for the current application and layer.
152
165
  *
@@ -287,6 +300,7 @@ sap.ui.define([
287
300
  * @param {object} mPropertyBag - Property bag
288
301
  * @param {sap.ui.core.Control} mPropertyBag.control - Control for which the request is done
289
302
  * @param {string} mPropertyBag.layer - Layer for which the versions should be retrieved
303
+ * @param {boolean} [mPropertyBag.discardDraftAndKeepActiveVersion] - discard draft and keep active version
290
304
  * @returns {Promise<boolean>} Promise resolving with a flag if a discarding took place;
291
305
  * rejects if an error occurs or the layer does not support draft handling
292
306
  */
@@ -310,12 +324,16 @@ sap.ui.define([
310
324
  }
311
325
  return Versions.discardDraft({
312
326
  reference: sReference,
313
- layer: mPropertyBag.layer
327
+ layer: mPropertyBag.layer,
328
+ discardDraftAndKeepActiveVersion: mPropertyBag.discardDraftAndKeepActiveVersion
314
329
  })
315
330
  .then(function(oDiscardInfo) {
316
331
  // in case of a existing draft known by the backend;
317
332
  // we remove dirty changes only after successful DELETE request
318
- const bDirtyChangesRemoved = removeDirtyChanges();
333
+ var bDirtyChangesRemoved = false;
334
+ if (!mPropertyBag.discardDraftAndKeepActiveVersion) {
335
+ bDirtyChangesRemoved = removeDirtyChanges();
336
+ }
319
337
  oDiscardInfo.dirtyChangesDiscarded = bDirtyChangesRemoved;
320
338
 
321
339
  if (oDiscardInfo.backendChangesDiscarded) {
@@ -330,12 +348,16 @@ sap.ui.define([
330
348
  const oFlexInfo = FlexInfoSession.getByReference(sReference);
331
349
  oFlexInfo.displayedAdaptationId = sDisplayedAdaptationId;
332
350
  FlexInfoSession.setByReference(oFlexInfo, sReference);
333
- FlexState.clearState(sReference);
351
+ if (!mPropertyBag.discardDraftAndKeepActiveVersion) {
352
+ FlexState.clearState(sReference);
353
+ }
334
354
  return oDiscardInfo;
335
355
  });
336
356
  }
337
357
  }
338
- FlexState.clearState(sReference);
358
+ if (!mPropertyBag.discardDraftAndKeepActiveVersion) {
359
+ FlexState.clearState(sReference);
360
+ }
339
361
  return oDiscardInfo;
340
362
  });
341
363
  };