@openui5/sap.ui.fl 1.139.0 → 1.141.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 (205) hide show
  1. package/.eslint-rules/import-check.js +71 -0
  2. package/THIRDPARTY.txt +2 -2
  3. package/package.json +3 -3
  4. package/src/sap/ui/fl/.library +1 -1
  5. package/src/sap/ui/fl/FakeLrepConnectorLocalStorage.js +1 -1
  6. package/src/sap/ui/fl/FakeLrepConnectorSessionStorage.js +1 -1
  7. package/src/sap/ui/fl/FakeLrepLocalStorage.js +1 -1
  8. package/src/sap/ui/fl/LayerUtils.js +1 -1
  9. package/src/sap/ui/fl/Utils.js +1 -1
  10. package/src/sap/ui/fl/apply/_internal/DelegateMediator.js +13 -3
  11. package/src/sap/ui/fl/apply/_internal/changes/Applier.js +3 -2
  12. package/src/sap/ui/fl/apply/_internal/changes/FlexCustomData.js +1 -1
  13. package/src/sap/ui/fl/apply/_internal/changes/Reverter.js +4 -1
  14. package/src/sap/ui/fl/apply/_internal/changes/Utils.js +1 -1
  15. package/src/sap/ui/fl/apply/_internal/changes/descriptor/Preprocessor.js +2 -2
  16. package/src/sap/ui/fl/apply/_internal/changes/descriptor/Registration.js +1 -1
  17. package/src/sap/ui/fl/apply/_internal/changes/descriptor/RegistrationBuild.js +1 -1
  18. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/AddAnnotationsToOData.js +1 -1
  19. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/AddNewDataSource.js +1 -1
  20. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/AddNewInbound.js +1 -1
  21. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/AddNewOutbound.js +1 -1
  22. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/AddTechnicalAttributes.js +1 -1
  23. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/ChangeDataSource.js +1 -1
  24. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/ChangeInbound.js +1 -1
  25. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/ChangeOutbound.js +1 -1
  26. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/RemoveAllInboundsExceptOne.js +1 -1
  27. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/SetAch.js +1 -1
  28. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/SetDescription.js +1 -1
  29. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/SetTitle.js +1 -1
  30. package/src/sap/ui/fl/apply/_internal/changes/descriptor/fiori/SetAbstract.js +1 -1
  31. package/src/sap/ui/fl/apply/_internal/changes/descriptor/fiori/SetCloudDevAdaptationStatus.js +1 -1
  32. package/src/sap/ui/fl/apply/_internal/changes/descriptor/fiori/SetRegistrationIds.js +1 -1
  33. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ovp/AddNewCard.js +1 -1
  34. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ovp/ChangeCard.js +1 -1
  35. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ovp/DeleteCard.js +1 -1
  36. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddComponentUsages.js +1 -1
  37. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddLibrary.js +1 -1
  38. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddNewModel.js +1 -1
  39. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddNewModelEnhanceWith.js +1 -1
  40. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/ChangeModel.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 +14 -12
  45. package/src/sap/ui/fl/apply/_internal/extensionPoint/Processor.js +2 -2
  46. package/src/sap/ui/fl/apply/_internal/extensionPoint/Registry.js +1 -1
  47. package/src/sap/ui/fl/apply/_internal/flexObjects/AnnotationChange.js +1 -1
  48. package/src/sap/ui/fl/apply/_internal/flexObjects/AppDescriptorChange.js +1 -1
  49. package/src/sap/ui/fl/apply/_internal/flexObjects/CompVariant.js +13 -10
  50. package/src/sap/ui/fl/apply/_internal/flexObjects/ControllerExtensionChange.js +1 -1
  51. package/src/sap/ui/fl/apply/_internal/flexObjects/FlVariant.js +1 -1
  52. package/src/sap/ui/fl/apply/_internal/flexObjects/FlexObject.js +2 -2
  53. package/src/sap/ui/fl/apply/_internal/flexObjects/FlexObjectFactory.js +2 -8
  54. package/src/sap/ui/fl/apply/_internal/flexObjects/UIChange.js +1 -1
  55. package/src/sap/ui/fl/apply/_internal/flexObjects/Variant.js +2 -2
  56. package/src/sap/ui/fl/apply/_internal/flexObjects/VariantChange.js +1 -1
  57. package/src/sap/ui/fl/apply/_internal/flexObjects/VariantManagementChange.js +1 -1
  58. package/src/sap/ui/fl/apply/_internal/flexObjects/getVariantAuthor.js +6 -3
  59. package/src/sap/ui/fl/apply/_internal/flexState/DataSelector.js +5 -5
  60. package/src/sap/ui/fl/apply/_internal/flexState/FlexObjectState.js +12 -26
  61. package/src/sap/ui/fl/apply/_internal/flexState/FlexState.js +68 -229
  62. package/src/sap/ui/fl/apply/_internal/flexState/InitialPrepareFunctions.js +0 -8
  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 +3 -3
  66. package/src/sap/ui/fl/apply/_internal/flexState/changes/UIChangesState.js +1 -1
  67. package/src/sap/ui/fl/apply/_internal/flexState/communication/FLPAboutInfo.js +2 -2
  68. package/src/sap/ui/fl/apply/_internal/flexState/compVariants/CompVariantManagementState.js +287 -10
  69. package/src/sap/ui/fl/apply/_internal/flexState/compVariants/applyChangesOnVariant.js +61 -0
  70. package/src/sap/ui/fl/apply/_internal/flexState/controlVariants/Switcher.js +22 -5
  71. package/src/sap/ui/fl/apply/_internal/flexState/controlVariants/VariantManagementState.js +72 -19
  72. package/src/sap/ui/fl/apply/_internal/init.js +47 -0
  73. package/src/sap/ui/fl/apply/_internal/preprocessors/ComponentLifecycleHooks.js +17 -7
  74. package/src/sap/ui/fl/apply/api/AnnotationChangeHandlerAPI.js +2 -1
  75. package/src/sap/ui/fl/apply/api/ControlVariantApplyAPI.js +190 -53
  76. package/src/sap/ui/fl/apply/api/DelegateMediatorAPI.js +17 -1
  77. package/src/sap/ui/fl/apply/api/ExtensionPointRegistryAPI.js +2 -1
  78. package/src/sap/ui/fl/apply/api/FlexRuntimeInfoAPI.js +6 -5
  79. package/src/sap/ui/fl/apply/api/SmartVariantManagementApplyAPI.js +45 -45
  80. package/src/sap/ui/fl/apply/api/UI2PersonalizationApplyAPI.js +2 -1
  81. package/src/sap/ui/fl/changeHandler/AddIFrame.js +1 -1
  82. package/src/sap/ui/fl/changeHandler/AddXML.js +2 -2
  83. package/src/sap/ui/fl/changeHandler/AddXMLAtExtensionPoint.js +4 -4
  84. package/src/sap/ui/fl/changeHandler/Base.js +3 -2
  85. package/src/sap/ui/fl/changeHandler/BaseAddViaDelegate.js +1 -1
  86. package/src/sap/ui/fl/changeHandler/BaseAddXml.js +21 -9
  87. package/src/sap/ui/fl/changeHandler/BaseRename.js +1 -1
  88. package/src/sap/ui/fl/changeHandler/ChangeAnnotation.js +7 -2
  89. package/src/sap/ui/fl/changeHandler/HideControl.js +1 -1
  90. package/src/sap/ui/fl/changeHandler/MoveControls.js +1 -1
  91. package/src/sap/ui/fl/changeHandler/MoveElements.js +1 -1
  92. package/src/sap/ui/fl/changeHandler/PropertyBindingChange.js +1 -1
  93. package/src/sap/ui/fl/changeHandler/PropertyChange.js +1 -1
  94. package/src/sap/ui/fl/changeHandler/StashControl.js +1 -1
  95. package/src/sap/ui/fl/changeHandler/UnhideControl.js +1 -1
  96. package/src/sap/ui/fl/changeHandler/UnstashControl.js +1 -1
  97. package/src/sap/ui/fl/changeHandler/UpdateIFrame.js +1 -1
  98. package/src/sap/ui/fl/changeHandler/common/createIFrame.js +1 -4
  99. package/src/sap/ui/fl/descriptorRelated/api/DescriptorChange.js +3 -3
  100. package/src/sap/ui/fl/descriptorRelated/api/DescriptorChangeFactory.js +3 -3
  101. package/src/sap/ui/fl/descriptorRelated/api/DescriptorInlineChangeFactory.js +1 -1
  102. package/src/sap/ui/fl/descriptorRelated/api/DescriptorVariantFactory.js +1 -1
  103. package/src/sap/ui/fl/designtime/variants/VariantManagement.designtime.js +14 -12
  104. package/src/sap/ui/fl/initial/_internal/FlexConfiguration.js +1 -1
  105. package/src/sap/ui/fl/initial/_internal/Loader.js +372 -0
  106. package/src/sap/ui/fl/{apply/_internal/flexState → initial/_internal}/ManifestUtils.js +1 -1
  107. package/src/sap/ui/fl/initial/_internal/Settings.js +1 -1
  108. package/src/sap/ui/fl/initial/_internal/Storage.js +1 -1
  109. package/src/sap/ui/fl/initial/_internal/StorageFeaturesMerger.js +1 -1
  110. package/src/sap/ui/fl/initial/_internal/StorageUtils.js +67 -9
  111. package/src/sap/ui/fl/initial/_internal/changeHandlers/ChangeHandlerRegistration.js +1 -1
  112. package/src/sap/ui/fl/initial/_internal/changeHandlers/ChangeHandlerStorage.js +12 -5
  113. package/src/sap/ui/fl/initial/_internal/connectors/Utils.js +1 -1
  114. package/src/sap/ui/fl/{apply → initial}/_internal/preprocessors/ControllerExtension.js +16 -5
  115. package/src/sap/ui/fl/{apply → initial}/_internal/preprocessors/RegistrationDelegator.js +9 -40
  116. package/src/sap/ui/fl/{apply → initial}/_internal/preprocessors/XmlPreprocessor.js +29 -21
  117. package/src/sap/ui/fl/initial/_internal/storageResultDisassemble.js +1 -1
  118. package/src/sap/ui/fl/initial/api/InitialFlexAPI.js +1 -1
  119. package/src/sap/ui/fl/interfaces/BaseLoadConnector.js +1 -1
  120. package/src/sap/ui/fl/interfaces/Delegate.js +1 -1
  121. package/src/sap/ui/fl/library.js +44 -44
  122. package/src/sap/ui/fl/messagebundle_vi.properties +1 -1
  123. package/src/sap/ui/fl/support/_internal/extractChangeDependencies.js +1 -1
  124. package/src/sap/ui/fl/support/_internal/getAllUIChanges.js +2 -2
  125. package/src/sap/ui/fl/support/_internal/getChangeDependencies.js +1 -1
  126. package/src/sap/ui/fl/support/_internal/getFlexObjectInfos.js +2 -2
  127. package/src/sap/ui/fl/support/_internal/getFlexSettings.js +1 -1
  128. package/src/sap/ui/fl/support/api/SupportAPI.js +1 -1
  129. package/src/sap/ui/fl/support/apps/contentbrowser/controller/ContentDetails.controller.js +1 -1
  130. package/src/sap/ui/fl/support/apps/contentbrowser/controller/ContentDetailsEdit.controller.js +1 -1
  131. package/src/sap/ui/fl/support/apps/contentbrowser/controller/LayerContentMaster.controller.js +1 -1
  132. package/src/sap/ui/fl/support/apps/contentbrowser/controller/Layers.controller.js +1 -1
  133. package/src/sap/ui/fl/support/apps/contentbrowser/lrepConnector/LRepConnector.js +1 -1
  134. package/src/sap/ui/fl/support/apps/contentbrowser/utils/DataUtils.js +1 -1
  135. package/src/sap/ui/fl/support/apps/contentbrowser/utils/ErrorUtils.js +1 -1
  136. package/src/sap/ui/fl/transport/TransportSelection.js +1 -1
  137. package/src/sap/ui/fl/util/IFrame.js +5 -4
  138. package/src/sap/ui/fl/util/ManagedObjectModel.js +1 -1
  139. package/src/sap/ui/fl/variants/VariantManagement.js +88 -36
  140. package/src/sap/ui/fl/variants/VariantManager.js +81 -21
  141. package/src/sap/ui/fl/variants/VariantModel.js +38 -189
  142. package/src/sap/ui/fl/write/_internal/SaveAs.js +1 -1
  143. package/src/sap/ui/fl/write/_internal/Storage.js +14 -1
  144. package/src/sap/ui/fl/write/_internal/Versions.js +9 -5
  145. package/src/sap/ui/fl/write/_internal/appVariant/AppVariant.js +10 -1
  146. package/src/sap/ui/fl/write/_internal/appVariant/AppVariantFactory.js +6 -1
  147. package/src/sap/ui/fl/write/_internal/appVariant/AppVariantInlineChange.js +1 -1
  148. package/src/sap/ui/fl/write/_internal/appVariant/AppVariantInlineChangeFactory.js +1 -1
  149. package/src/sap/ui/fl/write/_internal/condenser/Condenser.js +1 -1
  150. package/src/sap/ui/fl/write/_internal/condenser/UIReconstruction.js +1 -1
  151. package/src/sap/ui/fl/write/_internal/connectors/BackendConnector.js +1 -1
  152. package/src/sap/ui/fl/write/_internal/connectors/BtpServiceConnector.js +27 -2
  153. package/src/sap/ui/fl/write/_internal/connectors/KeyUserConnector.js +1 -1
  154. package/src/sap/ui/fl/write/_internal/connectors/LrepConnector.js +4 -1
  155. package/src/sap/ui/fl/write/_internal/connectors/NeoLrepConnector.js +1 -1
  156. package/src/sap/ui/fl/write/_internal/connectors/ObjectPathConnector.js +1 -1
  157. package/src/sap/ui/fl/write/_internal/connectors/PersonalizationConnector.js +1 -1
  158. package/src/sap/ui/fl/write/_internal/connectors/Utils.js +1 -1
  159. package/src/sap/ui/fl/write/_internal/extensionPoint/Processor.js +1 -1
  160. package/src/sap/ui/fl/write/_internal/fieldExtensibility/ABAPAccess.js +1 -1
  161. package/src/sap/ui/fl/write/_internal/fieldExtensibility/ABAPExtensibilityVariant.js +1 -1
  162. package/src/sap/ui/fl/write/_internal/fieldExtensibility/ABAPExtensibilityVariantFactory.js +1 -1
  163. package/src/sap/ui/fl/write/_internal/fieldExtensibility/MultiTenantABAPExtensibilityVariant.js +1 -1
  164. package/src/sap/ui/fl/write/_internal/fieldExtensibility/ServiceValidation.js +1 -1
  165. package/src/sap/ui/fl/write/_internal/fieldExtensibility/SingleTenantABAPExtensibilityVariant.js +1 -1
  166. package/src/sap/ui/fl/write/_internal/fieldExtensibility/UriParser.js +1 -1
  167. package/src/sap/ui/fl/write/_internal/fieldExtensibility/Utils.js +1 -1
  168. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/CAPAccess.js +1 -1
  169. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/dialog/CustomFieldCAPDialog.js +1 -1
  170. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/editor/propertyEditor/booleanEditor/BooleanEditor.js +1 -1
  171. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/editor/propertyEditor/rangeEditor/RangeEditor.js +1 -1
  172. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/editor/propertyEditor/timeEditor/TimeEditor.js +1 -1
  173. package/src/sap/ui/fl/write/_internal/flexState/FlexObjectManager.js +40 -71
  174. package/src/sap/ui/fl/write/_internal/flexState/UI2Personalization/UI2PersonalizationState.js +3 -3
  175. package/src/sap/ui/fl/write/_internal/flexState/changes/UIChangeManager.js +1 -1
  176. package/src/sap/ui/fl/write/_internal/flexState/compVariants/{CompVariantState.js → CompVariantManager.js} +176 -309
  177. package/src/sap/ui/fl/write/_internal/init.js +27 -0
  178. package/src/sap/ui/fl/write/_internal/transport/TransportSelection.js +2 -2
  179. package/src/sap/ui/fl/write/_internal/transport/Transports.js +1 -1
  180. package/src/sap/ui/fl/write/api/Adaptations.js +1 -1
  181. package/src/sap/ui/fl/write/api/AppVariantWriteAPI.js +4 -2
  182. package/src/sap/ui/fl/write/api/BusinessNetworkAPI.js +60 -26
  183. package/src/sap/ui/fl/write/api/ChangesWriteAPI.js +4 -3
  184. package/src/sap/ui/fl/write/api/ContextBasedAdaptationsAPI.js +19 -23
  185. package/src/sap/ui/fl/write/api/ContextSharingAPI.js +3 -2
  186. package/src/sap/ui/fl/write/api/ControlPersonalizationWriteAPI.js +2 -1
  187. package/src/sap/ui/fl/write/api/FeaturesAPI.js +2 -1
  188. package/src/sap/ui/fl/write/api/FieldExtensibility.js +3 -2
  189. package/src/sap/ui/fl/write/api/LocalResetAPI.js +3 -2
  190. package/src/sap/ui/fl/write/api/PersistenceWriteAPI.js +23 -20
  191. package/src/sap/ui/fl/write/api/ReloadInfoAPI.js +10 -7
  192. package/src/sap/ui/fl/write/api/SACIntegrationUpdateVariant.js +8 -7
  193. package/src/sap/ui/fl/write/api/SmartBusinessWriteAPI.js +3 -2
  194. package/src/sap/ui/fl/write/api/SmartVariantManagementWriteAPI.js +26 -22
  195. package/src/sap/ui/fl/write/api/TranslationAPI.js +3 -2
  196. package/src/sap/ui/fl/write/api/UI2PersonalizationWriteAPI.js +4 -3
  197. package/src/sap/ui/fl/write/api/VersionsAPI.js +4 -3
  198. package/src/sap/ui/fl/write/api/connectors/FileListBaseConnector.js +3 -2
  199. package/src/sap/ui/fl/write/api/connectors/ObjectStorageConnector.js +4 -2
  200. package/src/sap/ui/fl/write/connectors/BaseConnector.js +13 -0
  201. package/ui5.yaml +0 -1
  202. package/src/sap/ui/fl/apply/_internal/flexState/Loader.js +0 -208
  203. package/src/sap/ui/fl/apply/_internal/flexState/compVariants/CompVariantMerger.js +0 -233
  204. package/src/sap/ui/fl/apply/_internal/flexState/compVariants/prepareCompVariantsMap.js +0 -118
  205. package/src/sap/ui/fl/util/resolveBinding.js +0 -79
@@ -0,0 +1,47 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2025 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/ui/fl/apply/_internal/DelegateMediator",
9
+ "sap/ui/fl/changeHandler/ChangeAnnotation",
10
+ "sap/ui/fl/initial/_internal/changeHandlers/ChangeHandlerRegistration"
11
+ ], function(
12
+ DelegateMediator,
13
+ ChangeAnnotation,
14
+ ChangeHandlerRegistration
15
+ ) {
16
+ "use strict";
17
+
18
+ /**
19
+ * Initialization of the apply bundle - takes care of registering change handlers
20
+ * This module must be loaded by every publicly used module of the apply bundle.
21
+ *
22
+ * @name sap.ui.fl.apply._internal.init
23
+ * @author SAP SE
24
+ * @version 1.141.0
25
+ * @since 1.141.0
26
+ * @private
27
+ */
28
+ ChangeHandlerRegistration.registerPredefinedChangeHandlers();
29
+ ChangeHandlerRegistration.getChangeHandlersOfLoadedLibsAndRegisterOnNewLoadedLibs();
30
+ ChangeHandlerRegistration.registerAnnotationChangeHandler({
31
+ changeHandler: ChangeAnnotation,
32
+ isDefaultChangeHandler: true
33
+ });
34
+
35
+ DelegateMediator.registerReadDelegate({
36
+ modelType: "sap.ui.model.odata.v4.ODataModel",
37
+ delegate: "sap/ui/fl/write/_internal/delegates/ODataV4ReadDelegate"
38
+ });
39
+ DelegateMediator.registerReadDelegate({
40
+ modelType: "sap.ui.model.odata.v2.ODataModel",
41
+ delegate: "sap/ui/fl/write/_internal/delegates/ODataV2ReadDelegate"
42
+ });
43
+ DelegateMediator.registerReadDelegate({
44
+ modelType: "sap.ui.model.odata.ODataModel",
45
+ delegate: "sap/ui/fl/write/_internal/delegates/ODataV2ReadDelegate"
46
+ });
47
+ });
@@ -12,9 +12,9 @@ sap.ui.define([
12
12
  "sap/ui/fl/apply/_internal/changes/descriptor/InlineApplier",
13
13
  "sap/ui/fl/apply/_internal/changes/Applier",
14
14
  "sap/ui/fl/apply/_internal/flexState/FlexState",
15
- "sap/ui/fl/apply/_internal/flexState/ManifestUtils",
16
15
  "sap/ui/fl/apply/api/ControlVariantApplyAPI",
17
16
  "sap/ui/fl/initial/_internal/changeHandlers/ChangeHandlerRegistration",
17
+ "sap/ui/fl/initial/_internal/ManifestUtils",
18
18
  "sap/ui/fl/variants/VariantModel",
19
19
  "sap/ui/fl/Layer",
20
20
  "sap/ui/fl/Utils",
@@ -29,9 +29,9 @@ sap.ui.define([
29
29
  InlineApplier,
30
30
  ChangesApplier,
31
31
  FlexState,
32
- ManifestUtils,
33
32
  ControlVariantApplyAPI,
34
33
  ChangeHandlerRegistration,
34
+ ManifestUtils,
35
35
  VariantModel,
36
36
  Layer,
37
37
  Utils,
@@ -41,6 +41,7 @@ sap.ui.define([
41
41
  ) {
42
42
  "use strict";
43
43
 
44
+ // TODO: Move to initial and make dependencies to apply lazy
44
45
  /**
45
46
  * @namespace sap.ui.fl.apply._internal.preprocessors.ComponentLifecycleHooks
46
47
  * @since 1.114
@@ -240,6 +241,10 @@ sap.ui.define([
240
241
  // the functionality still works without component Id, but the FlexState will be initialized again
241
242
  // once the component Id is set. This will happen in the instanceCreated hook.
242
243
  // This can only be improved once the generated component instance Id is available in the factory config
244
+ if (!oPropertyBag.factoryConfig) {
245
+ Log.error("Could not fetch Annotation changes. This can be caused by creating a component in an unsupported way");
246
+ return [];
247
+ }
243
248
  const sAppComponentId = oPropertyBag.owner?.id || oPropertyBag.factoryConfig.id || oPropertyBag.factoryConfig.settings?.id;
244
249
 
245
250
  const oComponentData = oOwnerComponent?.getComponentData()
@@ -264,11 +269,16 @@ sap.ui.define([
264
269
 
265
270
  const aReturn = [];
266
271
  for (const oAnnotationChange of aRelevantAnnotationChanges) {
267
- const oChangeHandler = await ChangeHandlerRegistration.getAnnotationChangeHandler({
268
- changeType: oAnnotationChange.getChangeType()
269
- });
270
- aReturn.push(await oChangeHandler.applyChange(oAnnotationChange));
271
- oAnnotationChange._appliedOnModel = true;
272
+ try {
273
+ const oChangeHandler = await ChangeHandlerRegistration.getAnnotationChangeHandler({
274
+ changeType: oAnnotationChange.getChangeType()
275
+ });
276
+ aReturn.push(await oChangeHandler.applyChange(oAnnotationChange));
277
+ oAnnotationChange._appliedOnModel = true;
278
+ } catch (oError) {
279
+ // Continue with next change
280
+ Log.error(`Annotation change with id ${oAnnotationChange.getId()} could not be applied to the model`, oError);
281
+ }
272
282
  }
273
283
  return aReturn;
274
284
  } catch (oError) {
@@ -5,7 +5,8 @@
5
5
  */
6
6
 
7
7
  sap.ui.define([
8
- "sap/ui/fl/initial/_internal/changeHandlers/ChangeHandlerRegistration"
8
+ "sap/ui/fl/initial/_internal/changeHandlers/ChangeHandlerRegistration",
9
+ "sap/ui/fl/apply/_internal/init"
9
10
  ], function(
10
11
  ChangeHandlerRegistration
11
12
  ) {
@@ -6,17 +6,26 @@
6
6
 
7
7
  sap.ui.define([
8
8
  "sap/base/Log",
9
+ "sap/ui/core/util/reflection/JsControlTreeModifier",
9
10
  "sap/ui/core/Component",
10
11
  "sap/ui/core/Element",
11
12
  "sap/ui/fl/apply/_internal/controlVariants/URLHandler",
13
+ "sap/ui/fl/apply/_internal/controlVariants/Utils",
12
14
  "sap/ui/fl/apply/_internal/flexState/controlVariants/VariantManagementState",
13
- "sap/ui/fl/Utils"
15
+ "sap/ui/fl/apply/_internal/flexState/FlexObjectState",
16
+ "sap/ui/fl/initial/_internal/ManifestUtils",
17
+ "sap/ui/fl/Utils",
18
+ "sap/ui/fl/apply/_internal/init"
14
19
  ], function(
15
20
  Log,
21
+ JsControlTreeModifier,
16
22
  Component,
17
23
  Element,
18
24
  URLHandler,
25
+ VariantUtil,
19
26
  VariantManagementState,
27
+ FlexObjectState,
28
+ ManifestUtils,
20
29
  Utils
21
30
  ) {
22
31
  "use strict";
@@ -41,6 +50,68 @@ sap.ui.define([
41
50
  });
42
51
  }
43
52
 
53
+ function handleInitialLoadScenario(sVMReference, oVariantManagementControl, sFlexReference) {
54
+ const aVariantChangesForVariant = VariantManagementState.getVariantChangesForVariant({
55
+ vmReference: sVMReference,
56
+ reference: sFlexReference
57
+ });
58
+
59
+ const sDefaultVariantReference = VariantManagementState.getDefaultVariantReference({
60
+ vmReference: sVMReference,
61
+ reference: sFlexReference
62
+ });
63
+
64
+ if (
65
+ oVariantManagementControl.getExecuteOnSelectionForStandardDefault()
66
+ && sDefaultVariantReference === sVMReference
67
+ && !aVariantChangesForVariant.some((oVariantChange) => oVariantChange.getChangeType() === "setExecuteOnSelect")
68
+ ) {
69
+ const oStandardVariant = VariantManagementState.getVariant({
70
+ vmReference: sVMReference,
71
+ reference: sFlexReference,
72
+ vReference: sVMReference
73
+ });
74
+ // set executeOnSelect without creating a change
75
+ oStandardVariant.instance.setExecuteOnSelection(true);
76
+ VariantManagementState.updateVariant({
77
+ reference: sFlexReference,
78
+ variant: oStandardVariant.instance
79
+ });
80
+ return true;
81
+ }
82
+ return false;
83
+ }
84
+
85
+ function waitForInitialVariantChanges(mPropertyBag) {
86
+ const aCurrentVariantChanges = VariantManagementState.getInitialUIChanges({
87
+ vmReference: mPropertyBag.vmReference,
88
+ reference: mPropertyBag.reference
89
+ });
90
+ const aSelectors = aCurrentVariantChanges.reduce((aCurrentControls, oChange) => {
91
+ const oSelector = oChange.getSelector();
92
+ const oControl = JsControlTreeModifier.bySelector(oSelector, mPropertyBag.appComponent);
93
+ if (oControl && Utils.indexOfObject(aCurrentControls, { selector: oControl }) === -1) {
94
+ aCurrentControls.push({ selector: oControl });
95
+ }
96
+ return aCurrentControls;
97
+ }, []);
98
+ return aSelectors.length ? FlexObjectState.waitForFlexObjectsToBeApplied(aSelectors) : Promise.resolve();
99
+ }
100
+
101
+ function waitForControlToBeRendered(oControl) {
102
+ return new Promise((resolve) => {
103
+ if (oControl.getDomRef()) {
104
+ resolve();
105
+ } else {
106
+ oControl.addEventDelegate({
107
+ onAfterRendering() {
108
+ resolve();
109
+ }
110
+ });
111
+ }
112
+ });
113
+ }
114
+
44
115
  /**
45
116
  * Provides an API for applications to work with control variants. See also {@link sap.ui.fl.variants.VariantManagement}.
46
117
  *
@@ -64,7 +135,7 @@ sap.ui.define([
64
135
  /**
65
136
  * Returns a promise that resolves to the variant model once it is available
66
137
  *
67
- * @param {object} oAppComponent - Application component
138
+ * @param {sap.ui.core.Component} oAppComponent - Application component
68
139
  * @returns {Promise} Promise resolving to the Variant Model
69
140
  *
70
141
  * @private
@@ -74,10 +145,26 @@ sap.ui.define([
74
145
  return waitForVariantModel(oAppComponent);
75
146
  },
76
147
 
148
+ /**
149
+ * Returns the variant management control instance for a variant management reference.
150
+ *
151
+ * @param {string} sVariantManagementReference - Reference to the variant management control
152
+ * @param {sap.ui.core.Component} oAppComponent - Application component
153
+ * @returns {sap.ui.fl.variants.VariantManagement} The variant management control instance
154
+ */
155
+ getVariantManagementControlByVMReference(sVariantManagementReference, oAppComponent) {
156
+ const sVMControlId = oAppComponent.byId(sVariantManagementReference)
157
+ ? oAppComponent.createId(sVariantManagementReference)
158
+ : sVariantManagementReference;
159
+ return Element.getElementById(sVMControlId);
160
+ },
161
+
77
162
  /**
78
163
  * Clears URL technical parameter <code>sap-ui-fl-control-variant-id</code> for control variants.
79
- * Use this method in case you normally want the variant parameter in the URL, but have a few special navigation patterns where you want to clear it.
80
- * If you don't want that parameter in general, set the <code>updateVariantInURL</code> parameter on your variant management control to <code>false</code>. SAP Fiori elements use this method.
164
+ * Use this method in case you normally want the variant parameter in the URL,
165
+ * but have a few special navigation patterns where you want to clear it.
166
+ * If you don't want that parameter in general, set the <code>updateVariantInURL</code> parameter
167
+ * on your variant management control to <code>false</code>. SAP Fiori elements use this method.
81
168
  * If a variant management control is given as a parameter, only parameters specific to that control are cleared.
82
169
  *
83
170
  * @param {object} mPropertyBag - Object with parameters as properties
@@ -116,11 +203,11 @@ sap.ui.define([
116
203
  },
117
204
 
118
205
  /**
119
- *
120
- * Activates the passed variant applicable to the passed control/component.
121
- * If the Variant is not available and the backend supports lazy loading, a backend request is made to fetch the variant.
122
- * If the flag standardVariant is set to true, the standard variant is activated and the variantReference is ignored.
123
- * In this scenario the passed element must be the variant management control.
206
+ * Activates the passed variant applicable to the passed control/component. The corresponding variant management control must be
207
+ * available when this function is called.
208
+ * If the variant is not found and the backend supports lazy loading, a backend request is made to fetch the variant.
209
+ * If the flag standardVariant is set to true, the standard variant is activated and the variantReference is ignored: in this
210
+ * scenario, the passed element must be the variant management control.
124
211
  *
125
212
  * @param {object} mPropertyBag - Object with parameters as properties
126
213
  * @param {sap.ui.base.ManagedObject|string} mPropertyBag.element - Component or control (instance or ID) on which the <code>variantModel</code> is set
@@ -132,9 +219,9 @@ sap.ui.define([
132
219
  * @public
133
220
  */
134
221
  async activateVariant(mPropertyBag) {
135
- function logAndReject(oError) {
222
+ function logAndThrowError(oError) {
136
223
  Log.error(oError);
137
- return Promise.reject(oError);
224
+ throw oError;
138
225
  }
139
226
 
140
227
  let oElement;
@@ -144,7 +231,7 @@ sap.ui.define([
144
231
  oElement = Element.getElementById(mPropertyBag.element);
145
232
 
146
233
  if (!(oElement instanceof Element)) {
147
- return logAndReject(Error("No valid component or control found for the provided ID"));
234
+ logAndThrowError(Error("No valid component or control found for the provided ID"));
148
235
  }
149
236
  }
150
237
  } else if (mPropertyBag.element instanceof Component || mPropertyBag.element instanceof Element) {
@@ -152,52 +239,71 @@ sap.ui.define([
152
239
  }
153
240
 
154
241
  const oAppComponent = Utils.getAppComponentForControl(oElement);
242
+ const sFlexReference = ManifestUtils.getFlexReferenceForControl(oElement);
155
243
  if (!oAppComponent) {
156
- return logAndReject(Error("A valid variant management control or component (instance or ID) should be passed as parameter"));
244
+ logAndThrowError(
245
+ Error("A valid variant management control or component (instance or ID) should be passed as parameter")
246
+ );
157
247
  }
158
248
 
159
249
  const oVariantModel = oAppComponent.getModel(VARIANT_MODEL_NAME);
160
250
  if (!oVariantModel) {
161
- return logAndReject(Error("No variant management model found for the passed control or application component"));
251
+ logAndThrowError(Error("No variant management model found for the passed control or application component"));
162
252
  }
163
253
 
164
254
  if (mPropertyBag.standardVariant && !oElement.isA("sap.ui.fl.variants.VariantManagement")) {
165
- return logAndReject(Error("With using standardVariant and no variantReference, a variant management control must be passed as element"));
255
+ logAndThrowError(
256
+ Error("With using standardVariant and no variantReference, a variant management control must be passed as element")
257
+ );
166
258
  }
167
259
 
168
- const sVariantReference = mPropertyBag.standardVariant
169
- ? oVariantModel.getVariantManagementReferenceForControl(mPropertyBag.element)
170
- : mPropertyBag.variantReference;
260
+ let sVariantManagementReference;
261
+ let sVariantReference;
262
+ let oVMControl;
263
+ if (mPropertyBag.standardVariant) {
264
+ sVariantManagementReference = oElement.getVariantManagementReference();
265
+ sVariantReference = sVariantManagementReference;
266
+ oVMControl = oElement;
267
+ } else {
268
+ sVariantManagementReference = VariantManagementState.getVariantManagementReferenceForVariant(
269
+ sFlexReference,
270
+ mPropertyBag.variantReference
271
+ );
272
+ sVariantReference = mPropertyBag.variantReference;
171
273
 
172
- // if the variant management reference is not available, the variant is not yet loaded
173
- if (!oVariantModel.getVariantManagementReference(sVariantReference).variantManagementReference) {
174
- try {
175
- await VariantManagementState.loadVariant({
176
- reference: oVariantModel.sFlexReference,
177
- variantReference: sVariantReference
178
- });
179
- } catch (oError) {
180
- return logAndReject(Error(`Variant with reference '${sVariantReference}' could not be found`));
181
- }
182
- }
274
+ if (!sVariantManagementReference) {
275
+ // if the variant management reference is not available, the variant is maybe not yet loaded
276
+ try {
277
+ await VariantManagementState.loadVariant({
278
+ reference: sFlexReference,
279
+ variantReference: sVariantReference
280
+ });
183
281
 
184
- const sVariantManagementReference = oVariantModel.getVariantManagementReference(sVariantReference).variantManagementReference;
185
- if (!sVariantManagementReference) {
186
- return logAndReject(Error("A valid control or component, and a valid variant/ID combination are required"));
282
+ sVariantManagementReference = VariantManagementState.getVariantManagementReferenceForVariant(
283
+ sFlexReference,
284
+ mPropertyBag.variantReference
285
+ );
286
+ } catch (oError) {
287
+ logAndThrowError(Error(`Variant with reference '${sVariantReference}' could not be found`));
288
+ }
289
+ if (!sVariantManagementReference) {
290
+ logAndThrowError(Error("Variant management reference not found. Check the passed element and variantReference"));
291
+ }
292
+ }
293
+ oVMControl = this.getVariantManagementControlByVMReference(sVariantManagementReference, oAppComponent);
187
294
  }
188
295
 
189
296
  // sap/fe is using this API very early during app start, sometimes before FlexState is initialized
190
- await oVariantModel.waitForVMControlInit(sVariantManagementReference);
297
+ await oVMControl.waitForInit();
191
298
 
192
299
  try {
193
- return oVariantModel.updateCurrentVariant({
300
+ await oVariantModel.updateCurrentVariant({
194
301
  variantManagementReference: sVariantManagementReference,
195
302
  newVariantReference: sVariantReference,
196
303
  appComponent: oAppComponent
197
304
  });
198
305
  } catch (oError) {
199
- Log.error(oError);
200
- throw oError;
306
+ logAndThrowError(oError);
201
307
  }
202
308
  },
203
309
 
@@ -216,18 +322,49 @@ sap.ui.define([
216
322
  *
217
323
  * @public
218
324
  */
219
- attachVariantApplied(mPropertyBag) {
220
- var oControl = mPropertyBag.selector.id && Element.getElementById(mPropertyBag.selector.id) || mPropertyBag.selector;
221
- var oAppComponent = Utils.getAppComponentForControl(oControl);
222
-
223
- waitForVariantModel(oAppComponent).then(function(oVariantModel) {
224
- oVariantModel.attachVariantApplied({
225
- vmControlId: mPropertyBag.vmControlId,
226
- control: oControl,
227
- callback: mPropertyBag.callback,
228
- callAfterInitialVariant: mPropertyBag.callAfterInitialVariant
325
+ async attachVariantApplied(mPropertyBag) {
326
+ const oVariantManagementControl = Element.getElementById(mPropertyBag.vmControlId);
327
+ await oVariantManagementControl.waitForInit();
328
+
329
+ const oControl = mPropertyBag.selector.id && Element.getElementById(mPropertyBag.selector.id) || mPropertyBag.selector;
330
+ const oAppComponent = Utils.getAppComponentForControl(oControl);
331
+ const sVMReference = oVariantManagementControl.getVariantManagementReference();
332
+ const sFlexReference = ManifestUtils.getFlexReferenceForControl(oVariantManagementControl);
333
+
334
+ const bInitialLoad = handleInitialLoadScenario(sVMReference, oVariantManagementControl, sFlexReference);
335
+ // if the parameter callAfterInitialVariant or initialLoad is true call the function without check
336
+ if (mPropertyBag.callAfterInitialVariant || bInitialLoad) {
337
+ waitForInitialVariantChanges({
338
+ appComponent: oAppComponent,
339
+ reference: sFlexReference,
340
+ vmReference: sVMReference
341
+ }).then(() => {
342
+ const sCurrentVariantReference = VariantManagementState.getCurrentVariantReference({
343
+ vmReference: sVMReference,
344
+ reference: sFlexReference
345
+ });
346
+ const oVariant = VariantManagementState.getVariant({
347
+ vmReference: sVMReference,
348
+ reference: sFlexReference,
349
+ vReference: sCurrentVariantReference
350
+ });
351
+ mPropertyBag.callback(oVariant);
229
352
  });
230
- });
353
+ }
354
+
355
+ // first check if the passed vmControlId is correct, then save the callback
356
+ // for this check the control has to be in the control tree already
357
+ await waitForControlToBeRendered(oControl);
358
+ if (VariantUtil.getRelevantVariantManagementControlId(oControl) === mPropertyBag.vmControlId) {
359
+ // showExecuteOnSelection is only relevant when a control can react to the variant applied event
360
+ // e.g. for ListReport, Table, etc.
361
+ oVariantManagementControl.setShowExecuteOnSelection(true);
362
+ oVariantManagementControl._addVariantAppliedListener(oControl, mPropertyBag.callback);
363
+ } else {
364
+ Log.error(
365
+ "Error in attachVariantApplied: The passed VariantManagement ID doesn't match the responsible VariantManagement control"
366
+ );
367
+ }
231
368
  },
232
369
 
233
370
  /**
@@ -239,12 +376,12 @@ sap.ui.define([
239
376
  *
240
377
  * @public
241
378
  */
242
- detachVariantApplied(mPropertyBag) {
243
- var oControl = mPropertyBag.selector.id && Element.getElementById(mPropertyBag.selector.id) || mPropertyBag.selector;
244
- var oAppComponent = Utils.getAppComponentForControl(oControl);
245
- waitForVariantModel(oAppComponent).then(function(oVariantModel) {
246
- oVariantModel.detachVariantApplied(mPropertyBag.vmControlId, oControl.getId());
247
- });
379
+ async detachVariantApplied(mPropertyBag) {
380
+ const oVariantManagementControl = Element.getElementById(mPropertyBag.vmControlId);
381
+ const oControl = mPropertyBag.selector.id && Element.getElementById(mPropertyBag.selector.id) || mPropertyBag.selector;
382
+ // Ensure that the variant attach process is finished before removing the listener
383
+ await Promise.all([oVariantManagementControl.waitForInit(), waitForControlToBeRendered(oControl)]);
384
+ oVariantManagementControl._removeVariantAppliedListener(oControl);
248
385
  }
249
386
  };
250
387
 
@@ -5,7 +5,8 @@
5
5
  */
6
6
 
7
7
  sap.ui.define([
8
- "sap/ui/fl/apply/_internal/DelegateMediator"
8
+ "sap/ui/fl/apply/_internal/DelegateMediator",
9
+ "sap/ui/fl/apply/_internal/init"
9
10
  ], function(
10
11
  DelegateMediator
11
12
  ) {
@@ -89,6 +90,21 @@ sap.ui.define([
89
90
  mPropertyBag.control,
90
91
  mPropertyBag.modifier
91
92
  );
93
+ },
94
+
95
+ /**
96
+ * Registers a handler for adjusting XML fragments. The handler will be stored without reference to the app,
97
+ * and will therefore be available for all apps.
98
+ *
99
+ * @param {object} mPropertyBag - Property bag
100
+ * @param {string} mPropertyBag.key - Key for the handler
101
+ * @param {function} mPropertyBag.handler - Handler function returning the adjusted fragment or a Promise resolving with the adjusted fragment
102
+ *
103
+ * @private
104
+ * @ui5-restricted sap.fe
105
+ */
106
+ registerAddXMLAdjustFragmentHandler(mPropertyBag) {
107
+ DelegateMediator.registerAddXMLAdjustFragmentHandler(mPropertyBag);
92
108
  }
93
109
  };
94
110
 
@@ -5,7 +5,8 @@
5
5
  */
6
6
 
7
7
  sap.ui.define([
8
- "sap/ui/fl/apply/_internal/extensionPoint/Registry"
8
+ "sap/ui/fl/apply/_internal/extensionPoint/Registry",
9
+ "sap/ui/fl/apply/_internal/init"
9
10
  ], function(
10
11
  ExtensionPointRegistry
11
12
  ) {
@@ -10,25 +10,26 @@ sap.ui.define([
10
10
  "sap/ui/fl/apply/_internal/controlVariants/Utils",
11
11
  "sap/ui/fl/apply/_internal/flexState/FlexObjectState",
12
12
  "sap/ui/fl/apply/_internal/flexState/FlexState",
13
- "sap/ui/fl/apply/_internal/flexState/ManifestUtils",
14
13
  "sap/ui/fl/initial/_internal/FlexConfiguration",
15
14
  "sap/ui/fl/initial/_internal/FlexInfoSession",
16
- "sap/ui/fl/initial/api/InitialFlexAPI",
15
+ "sap/ui/fl/initial/_internal/ManifestUtils",
17
16
  "sap/ui/fl/initial/_internal/Settings",
17
+ "sap/ui/fl/initial/api/InitialFlexAPI",
18
18
  "sap/ui/fl/Layer",
19
19
  "sap/ui/fl/Utils",
20
- "sap/ui/VersionInfo"
20
+ "sap/ui/VersionInfo",
21
+ "sap/ui/fl/apply/_internal/init"
21
22
  ], function(
22
23
  Log,
23
24
  JsControlTreeModifier,
24
25
  VariantUtils,
25
26
  FlexObjectState,
26
27
  FlexState,
27
- ManifestUtils,
28
28
  FlexConfiguration,
29
29
  FlexInfoSession,
30
- InitialFlexAPI,
30
+ ManifestUtils,
31
31
  Settings,
32
+ InitialFlexAPI,
32
33
  Layer,
33
34
  Utils,
34
35
  VersionInfo
@@ -6,47 +6,20 @@
6
6
 
7
7
  sap.ui.define([
8
8
  "sap/ui/fl/apply/_internal/flexState/compVariants/CompVariantManagementState",
9
- "sap/ui/fl/apply/_internal/flexState/compVariants/CompVariantMerger",
10
9
  "sap/ui/fl/apply/_internal/flexState/compVariants/Utils",
11
10
  "sap/ui/fl/apply/_internal/flexState/FlexState",
12
- "sap/ui/fl/apply/_internal/flexState/ManifestUtils",
13
- "sap/ui/fl/LayerUtils",
14
- "sap/ui/fl/Utils"
11
+ "sap/ui/fl/initial/_internal/ManifestUtils",
12
+ "sap/ui/fl/Utils",
13
+ "sap/ui/fl/apply/_internal/init"
15
14
  ], function(
16
15
  CompVariantManagementState,
17
- CompVariantMerger,
18
16
  CompVariantUtils,
19
17
  FlexState,
20
18
  ManifestUtils,
21
- LayerUtils,
22
19
  Utils
23
20
  ) {
24
21
  "use strict";
25
22
 
26
- function getCompEntities(mPropertyBag) {
27
- var oControl = mPropertyBag.control;
28
- var oVMControl = oControl.getVariantManagement?.() || oControl;
29
- var sSVMControlId = oVMControl.getId();
30
-
31
- return FlexState.initialize({
32
- reference: mPropertyBag.reference,
33
- componentData: {},
34
- manifest: Utils.getAppDescriptor(oControl),
35
- componentId: Utils.getAppComponentForControl(oControl).getId()
36
- }).then(function() {
37
- var mCompVariantsMap = FlexState.getCompVariantsMap(mPropertyBag.reference);
38
- // Store external input data to FlexState so they can be restored after invalidating cache
39
- FlexState.setInitialNonFlCompVariantData(
40
- mPropertyBag.reference,
41
- mPropertyBag.persistencyKey,
42
- mPropertyBag.standardVariant,
43
- mPropertyBag.variants,
44
- sSVMControlId
45
- );
46
- return mCompVariantsMap._initialize(mPropertyBag.persistencyKey, mPropertyBag.variants, sSVMControlId);
47
- });
48
- }
49
-
50
23
  /**
51
24
  * Object containing data for a SmartVariantManagement control.
52
25
  *
@@ -101,7 +74,7 @@ sap.ui.define([
101
74
  * sap.ui.comp.smarttable.SmartTable|
102
75
  * sap.ui.comp.smartchart.SmartChart} mPropertyBag.control - Variant management control to load variants for
103
76
  * @param {sap.ui.fl.apply.api.SmartVariantManagementApplyAPI.LoadVariantsInput} mPropertyBag.standardVariant - The standard variant of the control;
104
- * a standard variant is created into the response but may be replaced later if data is loaded afterwards
77
+ * a standard variant is created into the response but may be replaced later if data is loaded afterward
105
78
  * instructing the SVM to do so
106
79
  * @param {sap.ui.fl.apply.api.SmartVariantManagementApplyAPI.LoadVariantsInput[]} mPropertyBag.variants - Variant data from other data providers like an OData service
107
80
  * @returns {Promise<sap.ui.fl.apply.api.SmartVariantManagementApplyAPI.LoadVariantsResponse>} Object with the standard variant and the variants
@@ -110,24 +83,51 @@ sap.ui.define([
110
83
  * @ui5-restricted sap.ui.comp
111
84
  */
112
85
  async loadVariants(mPropertyBag) {
113
- mPropertyBag.reference = ManifestUtils.getFlexReferenceForControl(mPropertyBag.control);
114
- mPropertyBag.persistencyKey = CompVariantUtils.getPersistencyKey(mPropertyBag.control);
86
+ const oControl = mPropertyBag.control;
87
+ const sReference = ManifestUtils.getFlexReferenceForControl(oControl);
88
+ const sPersistencyKey = CompVariantUtils.getPersistencyKey(oControl);
115
89
 
116
- const mCompMaps = await getCompEntities(mPropertyBag);
90
+ const mProperties = Object.assign({
91
+ reference: sReference,
92
+ persistencyKey: sPersistencyKey,
93
+ componentId: Utils.getAppComponentForControl(oControl).getId()
94
+ }, mPropertyBag);
117
95
 
118
- const mMergedCompVariants = CompVariantMerger.merge(
119
- mPropertyBag.persistencyKey,
120
- mCompMaps,
121
- mPropertyBag.standardVariant,
122
- mPropertyBag.control
123
- );
96
+ await FlexState.initialize({
97
+ componentId: mProperties.componentId
98
+ });
99
+ FlexState.addSVMControl(sReference, oControl);
100
+ CompVariantManagementState.addExternalVariants(mProperties);
124
101
 
125
- mMergedCompVariants.defaultVariantId = CompVariantManagementState.getDefaultVariantId({
126
- persistencyKey: mPropertyBag.persistencyKey,
127
- reference: mPropertyBag.reference,
128
- variants: mMergedCompVariants.variants
102
+ const aVariants = CompVariantManagementState.assembleVariantList(mProperties);
103
+
104
+ const sDefaultVariantId = CompVariantManagementState.getDefaultVariantId({
105
+ persistencyKey: sPersistencyKey,
106
+ reference: sReference,
107
+ variants: aVariants
129
108
  });
130
- return mMergedCompVariants;
109
+
110
+ const aVariantsWithoutStandard = [];
111
+ let oStandardVariant;
112
+
113
+ aVariants.forEach((oVariant) => {
114
+ if (oVariant.getStandardVariant()) {
115
+ oStandardVariant = oVariant;
116
+ } else {
117
+ aVariantsWithoutStandard.push(oVariant);
118
+ }
119
+
120
+ // the default is always visible and thus a favorite
121
+ if (oVariant.getVariantId() === sDefaultVariantId) {
122
+ oVariant.setFavorite(true);
123
+ }
124
+ });
125
+
126
+ return {
127
+ defaultVariantId: sDefaultVariantId,
128
+ variants: aVariantsWithoutStandard,
129
+ standardVariant: oStandardVariant
130
+ };
131
131
  }
132
132
  };
133
133