@openui5/sap.ui.fl 1.99.1 → 1.102.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/THIRDPARTY.txt +5 -5
  2. package/package.json +3 -3
  3. package/src/sap/ui/fl/.library +1 -1
  4. package/src/sap/ui/fl/Cache.js +1 -1
  5. package/src/sap/ui/fl/Change.js +27 -5
  6. package/src/sap/ui/fl/ChangePersistence.js +118 -153
  7. package/src/sap/ui/fl/ChangePersistenceFactory.js +1 -1
  8. package/src/sap/ui/fl/FakeLrepConnectorLocalStorage.js +3 -4
  9. package/src/sap/ui/fl/FakeLrepConnectorSessionStorage.js +3 -4
  10. package/src/sap/ui/fl/FakeLrepLocalStorage.js +4 -4
  11. package/src/sap/ui/fl/FlexController.js +12 -55
  12. package/src/sap/ui/fl/FlexControllerFactory.js +4 -1
  13. package/src/sap/ui/fl/LayerUtils.js +1 -1
  14. package/src/sap/ui/fl/Scenario.js +27 -0
  15. package/src/sap/ui/fl/Utils.js +9 -7
  16. package/src/sap/ui/fl/Variant.js +1 -1
  17. package/src/sap/ui/fl/apply/_internal/DelegateMediator.js +1 -1
  18. package/src/sap/ui/fl/apply/_internal/changes/Applier.js +56 -9
  19. package/src/sap/ui/fl/apply/_internal/changes/FlexCustomData.js +1 -1
  20. package/src/sap/ui/fl/apply/_internal/changes/Reverter.js +1 -1
  21. package/src/sap/ui/fl/apply/_internal/changes/Utils.js +46 -2
  22. package/src/sap/ui/fl/apply/_internal/changes/descriptor/Preprocessor.js +1 -1
  23. package/src/sap/ui/fl/apply/_internal/changes/descriptor/Registration.js +1 -1
  24. package/src/sap/ui/fl/apply/_internal/changes/descriptor/RegistrationBuild.js +1 -1
  25. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/AddAnnotationsToOData.js +1 -1
  26. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/ChangeDataSource.js +1 -1
  27. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/ChangeInbound.js +1 -1
  28. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/SetTitle.js +1 -1
  29. package/src/sap/ui/fl/apply/_internal/changes/descriptor/fiori/SetAbstract.js +1 -1
  30. package/src/sap/ui/fl/apply/_internal/changes/descriptor/fiori/SetRegistrationIds.js +1 -1
  31. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ovp/AddNewCard.js +1 -1
  32. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ovp/ChangeCard.js +1 -1
  33. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ovp/DeleteCard.js +1 -1
  34. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddComponentUsages.js +1 -1
  35. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddLibrary.js +1 -1
  36. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddNewModel.js +1 -1
  37. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddNewModelEnhanceWith.js +1 -1
  38. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/SetFlexExtensionPointEnabled.js +1 -1
  39. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/SetMinUI5Version.js +1 -1
  40. package/src/sap/ui/fl/apply/_internal/connectors/ObjectStorageUtils.js +1 -1
  41. package/src/sap/ui/fl/apply/_internal/controlVariants/Utils.js +9 -5
  42. package/src/sap/ui/fl/apply/_internal/extensionPoint/Processor.js +1 -1
  43. package/src/sap/ui/fl/apply/_internal/flexObjects/CompVariant.js +8 -0
  44. package/src/sap/ui/fl/apply/_internal/flexObjects/FlexObject.js +452 -0
  45. package/src/sap/ui/fl/apply/_internal/flexObjects/FlexObjectFactory.js +68 -0
  46. package/src/sap/ui/fl/apply/_internal/flexState/FlexState.js +28 -34
  47. package/src/sap/ui/fl/apply/_internal/flexState/Loader.js +1 -3
  48. package/src/sap/ui/fl/apply/_internal/flexState/ManifestUtils.js +1 -1
  49. package/src/sap/ui/fl/apply/_internal/flexState/UI2Personalization/UI2PersonalizationState.js +1 -1
  50. package/src/sap/ui/fl/apply/_internal/flexState/changes/DependencyHandler.js +1 -1
  51. package/src/sap/ui/fl/apply/_internal/flexState/changes/ExtensionPointState.js +12 -10
  52. package/src/sap/ui/fl/apply/_internal/flexState/compVariants/CompVariantMerger.js +2 -2
  53. package/src/sap/ui/fl/apply/_internal/flexState/controlVariants/Switcher.js +1 -1
  54. package/src/sap/ui/fl/apply/_internal/flexState/controlVariants/VariantManagementState.js +27 -16
  55. package/src/sap/ui/fl/apply/_internal/preprocessors/ControllerExtension.js +1 -1
  56. package/src/sap/ui/fl/apply/_internal/preprocessors/EventHistory.js +1 -1
  57. package/src/sap/ui/fl/apply/_internal/preprocessors/RegistrationDelegator.js +1 -1
  58. package/src/sap/ui/fl/apply/_internal/preprocessors/XmlPreprocessor.js +1 -1
  59. package/src/sap/ui/fl/apply/api/ControlVariantApplyAPI.js +1 -1
  60. package/src/sap/ui/fl/changeHandler/AddIFrame.js +1 -1
  61. package/src/sap/ui/fl/changeHandler/AddXML.js +1 -1
  62. package/src/sap/ui/fl/changeHandler/AddXMLAtExtensionPoint.js +1 -1
  63. package/src/sap/ui/fl/changeHandler/Base.js +1 -1
  64. package/src/sap/ui/fl/changeHandler/BaseAddViaDelegate.js +4 -2
  65. package/src/sap/ui/fl/changeHandler/BaseAddXml.js +1 -1
  66. package/src/sap/ui/fl/changeHandler/BaseRename.js +6 -4
  67. package/src/sap/ui/fl/changeHandler/HideControl.js +4 -2
  68. package/src/sap/ui/fl/changeHandler/MoveControls.js +10 -3
  69. package/src/sap/ui/fl/changeHandler/MoveElements.js +1 -1
  70. package/src/sap/ui/fl/changeHandler/PropertyBindingChange.js +6 -4
  71. package/src/sap/ui/fl/changeHandler/PropertyChange.js +4 -2
  72. package/src/sap/ui/fl/changeHandler/StashControl.js +17 -4
  73. package/src/sap/ui/fl/changeHandler/UnhideControl.js +6 -4
  74. package/src/sap/ui/fl/changeHandler/UnstashControl.js +7 -3
  75. package/src/sap/ui/fl/changeHandler/UpdateIFrame.js +1 -1
  76. package/src/sap/ui/fl/changeHandler/condenser/Classification.js +43 -0
  77. package/src/sap/ui/fl/codeExt/CodeExtManager.js +1 -1
  78. package/src/sap/ui/fl/descriptorRelated/api/DescriptorChangeFactory.js +4 -4
  79. package/src/sap/ui/fl/descriptorRelated/api/DescriptorInlineChangeFactory.js +1 -1
  80. package/src/sap/ui/fl/descriptorRelated/api/DescriptorVariantFactory.js +1 -1
  81. package/src/sap/ui/fl/initial/_internal/Storage.js +8 -6
  82. package/src/sap/ui/fl/initial/_internal/StorageUtils.js +1 -1
  83. package/src/sap/ui/fl/initial/_internal/changeHandlers/ChangeRegistryItem.js +1 -1
  84. package/src/sap/ui/fl/initial/_internal/connectors/Utils.js +7 -2
  85. package/src/sap/ui/fl/initial/_internal/storageResultDisassemble.js +1 -1
  86. package/src/sap/ui/fl/interfaces/BaseLoadConnector.js +1 -1
  87. package/src/sap/ui/fl/interfaces/Delegate.js +1 -1
  88. package/src/sap/ui/fl/library.js +22 -66
  89. package/src/sap/ui/fl/library.support.js +1 -1
  90. package/src/sap/ui/fl/messagebundle_fr.properties +14 -14
  91. package/src/sap/ui/fl/support/Flexibility.js +1 -1
  92. package/src/sap/ui/fl/support/_internal/getChangeDependencies.js +1 -1
  93. package/src/sap/ui/fl/support/_internal/getFlexSettings.js +1 -1
  94. package/src/sap/ui/fl/support/api/SupportAPI.js +1 -1
  95. package/src/sap/ui/fl/support/apps/contentbrowser/controller/ContentDetails.controller.js +1 -1
  96. package/src/sap/ui/fl/support/apps/contentbrowser/controller/ContentDetailsEdit.controller.js +1 -1
  97. package/src/sap/ui/fl/support/apps/contentbrowser/controller/LayerContentMaster.controller.js +1 -1
  98. package/src/sap/ui/fl/support/apps/contentbrowser/controller/Layers.controller.js +1 -1
  99. package/src/sap/ui/fl/support/apps/contentbrowser/lrepConnector/LRepConnector.js +1 -1
  100. package/src/sap/ui/fl/support/apps/contentbrowser/utils/DataUtils.js +1 -1
  101. package/src/sap/ui/fl/support/apps/contentbrowser/utils/ErrorUtils.js +1 -1
  102. package/src/sap/ui/fl/support/diagnostics/Flexibility.controller.js +1 -1
  103. package/src/sap/ui/fl/themes/base/VariantManagement.less +23 -21
  104. package/src/sap/ui/fl/transport/TransportSelection.js +1 -1
  105. package/src/sap/ui/fl/util/IFrame.js +1 -1
  106. package/src/sap/ui/fl/util/ManagedObjectModel.js +1 -1
  107. package/src/sap/ui/fl/util/resolveBinding.js +1 -1
  108. package/src/sap/ui/fl/variants/VariantManagement.js +2 -1
  109. package/src/sap/ui/fl/variants/VariantModel.js +7 -1
  110. package/src/sap/ui/fl/variants/context/Component.js +2 -6
  111. package/src/sap/ui/fl/variants/context/controller/ContextVisibility.controller.js +5 -44
  112. package/src/sap/ui/fl/variants/context/i18n/i18n.properties +3 -7
  113. package/src/sap/ui/fl/variants/context/i18n/i18n_ar.properties +2 -4
  114. package/src/sap/ui/fl/variants/context/i18n/i18n_bg.properties +2 -4
  115. package/src/sap/ui/fl/variants/context/i18n/i18n_ca.properties +2 -4
  116. package/src/sap/ui/fl/variants/context/i18n/i18n_cs.properties +2 -4
  117. package/src/sap/ui/fl/variants/context/i18n/i18n_cy.properties +2 -4
  118. package/src/sap/ui/fl/variants/context/i18n/i18n_da.properties +2 -4
  119. package/src/sap/ui/fl/variants/context/i18n/i18n_de.properties +2 -4
  120. package/src/sap/ui/fl/variants/context/i18n/i18n_el.properties +2 -4
  121. package/src/sap/ui/fl/variants/context/i18n/i18n_en.properties +2 -4
  122. package/src/sap/ui/fl/variants/context/i18n/i18n_en_GB.properties +2 -4
  123. package/src/sap/ui/fl/variants/context/i18n/i18n_en_US_sappsd.properties +2 -4
  124. package/src/sap/ui/fl/variants/context/i18n/i18n_en_US_saprigi.properties +2 -4
  125. package/src/sap/ui/fl/variants/context/i18n/i18n_en_US_saptrc.properties +2 -4
  126. package/src/sap/ui/fl/variants/context/i18n/i18n_es.properties +2 -4
  127. package/src/sap/ui/fl/variants/context/i18n/i18n_es_MX.properties +2 -4
  128. package/src/sap/ui/fl/variants/context/i18n/i18n_et.properties +2 -4
  129. package/src/sap/ui/fl/variants/context/i18n/i18n_fi.properties +2 -4
  130. package/src/sap/ui/fl/variants/context/i18n/i18n_fr.properties +2 -4
  131. package/src/sap/ui/fl/variants/context/i18n/i18n_fr_CA.properties +2 -4
  132. package/src/sap/ui/fl/variants/context/i18n/i18n_hi.properties +2 -4
  133. package/src/sap/ui/fl/variants/context/i18n/i18n_hr.properties +2 -4
  134. package/src/sap/ui/fl/variants/context/i18n/i18n_hu.properties +2 -4
  135. package/src/sap/ui/fl/variants/context/i18n/i18n_id.properties +2 -4
  136. package/src/sap/ui/fl/variants/context/i18n/i18n_it.properties +2 -4
  137. package/src/sap/ui/fl/variants/context/i18n/i18n_iw.properties +2 -4
  138. package/src/sap/ui/fl/variants/context/i18n/i18n_ja.properties +2 -4
  139. package/src/sap/ui/fl/variants/context/i18n/i18n_kk.properties +2 -4
  140. package/src/sap/ui/fl/variants/context/i18n/i18n_ko.properties +2 -4
  141. package/src/sap/ui/fl/variants/context/i18n/i18n_lt.properties +2 -4
  142. package/src/sap/ui/fl/variants/context/i18n/i18n_lv.properties +2 -4
  143. package/src/sap/ui/fl/variants/context/i18n/i18n_ms.properties +2 -4
  144. package/src/sap/ui/fl/variants/context/i18n/i18n_nl.properties +2 -4
  145. package/src/sap/ui/fl/variants/context/i18n/i18n_no.properties +2 -4
  146. package/src/sap/ui/fl/variants/context/i18n/i18n_pl.properties +2 -4
  147. package/src/sap/ui/fl/variants/context/i18n/i18n_pt.properties +2 -4
  148. package/src/sap/ui/fl/variants/context/i18n/i18n_pt_PT.properties +2 -4
  149. package/src/sap/ui/fl/variants/context/i18n/i18n_ro.properties +2 -4
  150. package/src/sap/ui/fl/variants/context/i18n/i18n_ru.properties +2 -4
  151. package/src/sap/ui/fl/variants/context/i18n/i18n_sh.properties +2 -4
  152. package/src/sap/ui/fl/variants/context/i18n/i18n_sk.properties +2 -4
  153. package/src/sap/ui/fl/variants/context/i18n/i18n_sl.properties +2 -4
  154. package/src/sap/ui/fl/variants/context/i18n/i18n_sv.properties +2 -4
  155. package/src/sap/ui/fl/variants/context/i18n/i18n_th.properties +2 -4
  156. package/src/sap/ui/fl/variants/context/i18n/i18n_tr.properties +2 -4
  157. package/src/sap/ui/fl/variants/context/i18n/i18n_uk.properties +2 -4
  158. package/src/sap/ui/fl/variants/context/i18n/i18n_vi.properties +2 -4
  159. package/src/sap/ui/fl/variants/context/i18n/i18n_zh_CN.properties +2 -4
  160. package/src/sap/ui/fl/variants/context/i18n/i18n_zh_TW.properties +2 -4
  161. package/src/sap/ui/fl/variants/context/view/ContextVisibility.view.xml +7 -6
  162. package/src/sap/ui/fl/write/_internal/Storage.js +7 -1
  163. package/src/sap/ui/fl/write/_internal/StorageFeaturesMerger.js +1 -1
  164. package/src/sap/ui/fl/write/_internal/Versions.js +85 -36
  165. package/src/sap/ui/fl/write/_internal/appVariant/AppVariant.js +5 -1
  166. package/src/sap/ui/fl/write/_internal/appVariant/AppVariantFactory.js +4 -2
  167. package/src/sap/ui/fl/write/_internal/appVariant/AppVariantInlineChange.js +1 -1
  168. package/src/sap/ui/fl/write/_internal/appVariant/AppVariantInlineChangeFactory.js +1 -1
  169. package/src/sap/ui/fl/write/_internal/condenser/Condenser.js +14 -12
  170. package/src/sap/ui/fl/write/_internal/condenser/UIReconstruction.js +5 -3
  171. package/src/sap/ui/fl/write/_internal/connectors/BackendConnector.js +1 -1
  172. package/src/sap/ui/fl/write/_internal/connectors/KeyUserConnector.js +2 -2
  173. package/src/sap/ui/fl/write/_internal/connectors/LrepConnector.js +78 -12
  174. package/src/sap/ui/fl/write/_internal/connectors/NeoLrepConnector.js +1 -1
  175. package/src/sap/ui/fl/write/_internal/connectors/ObjectPathConnector.js +1 -1
  176. package/src/sap/ui/fl/write/_internal/connectors/PersonalizationConnector.js +1 -1
  177. package/src/sap/ui/fl/write/_internal/connectors/Utils.js +1 -1
  178. package/src/sap/ui/fl/write/_internal/extensionPoint/Processor.js +1 -1
  179. package/src/sap/ui/fl/write/_internal/extensionPoint/Registry.js +1 -1
  180. package/src/sap/ui/fl/write/_internal/fieldExtensibility/ABAPAccess.js +1 -1
  181. package/src/sap/ui/fl/write/_internal/fieldExtensibility/ABAPExtensibilityVariant.js +1 -1
  182. package/src/sap/ui/fl/write/_internal/fieldExtensibility/ABAPExtensibilityVariantFactory.js +1 -1
  183. package/src/sap/ui/fl/write/_internal/fieldExtensibility/MultiTenantABAPExtensibilityVariant.js +1 -1
  184. package/src/sap/ui/fl/write/_internal/fieldExtensibility/ServiceValidation.js +1 -1
  185. package/src/sap/ui/fl/write/_internal/fieldExtensibility/SingleTenantABAPExtensibilityVariant.js +1 -1
  186. package/src/sap/ui/fl/write/_internal/fieldExtensibility/UriParser.js +1 -1
  187. package/src/sap/ui/fl/write/_internal/fieldExtensibility/Utils.js +1 -1
  188. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/CAPAccess.js +1 -1
  189. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/dialog/CustomFieldCAPDialog.js +1 -1
  190. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/editor/propertyEditor/booleanEditor/BooleanEditor.js +1 -1
  191. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/editor/propertyEditor/rangeEditor/RangeEditor.js +1 -1
  192. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/editor/propertyEditor/timeEditor/TimeEditor.js +1 -1
  193. package/src/sap/ui/fl/write/_internal/flexState/FlexObjectState.js +28 -7
  194. package/src/sap/ui/fl/write/_internal/flexState/compVariants/CompVariantState.js +98 -41
  195. package/src/sap/ui/fl/write/_internal/transport/TransportDialog.js +13 -2
  196. package/src/sap/ui/fl/write/_internal/transport/TransportSelection.js +7 -4
  197. package/src/sap/ui/fl/write/_internal/transport/Transports.js +1 -1
  198. package/src/sap/ui/fl/write/api/AppVariantWriteAPI.js +13 -4
  199. package/src/sap/ui/fl/write/api/FeaturesAPI.js +2 -2
  200. package/src/sap/ui/fl/write/api/FieldExtensibility.js +1 -1
  201. package/src/sap/ui/fl/write/api/PersistenceWriteAPI.js +49 -4
  202. package/src/sap/ui/fl/write/api/ReloadInfoAPI.js +18 -11
  203. package/src/sap/ui/fl/write/api/TranslationAPI.js +54 -17
  204. package/src/sap/ui/fl/write/api/Version.js +22 -0
  205. package/src/sap/ui/fl/write/api/VersionsAPI.js +90 -74
@@ -24,7 +24,7 @@ sap.ui.define([
24
24
  *
25
25
  * @namespace sap.ui.fl.apply._internal.changes.descriptor.ui5.AddNewModelEnhanceWith
26
26
  * @experimental
27
- * @version 1.99.1
27
+ * @version 1.102.0
28
28
  * @private
29
29
  * @ui5-restricted sap.ui.fl.apply._internal
30
30
  */
@@ -20,7 +20,7 @@ sap.ui.define([
20
20
  *
21
21
  * @namespace sap.ui.fl.apply._internal.changes.descriptor.ui5.SetFlexExtensionPointEnabled
22
22
  * @experimental
23
- * @version 1.99.1
23
+ * @version 1.102.0
24
24
  * @private
25
25
  * @ui5-restricted sap.ui.fl.apply._internal
26
26
  */
@@ -22,7 +22,7 @@ sap.ui.define([
22
22
  *
23
23
  * @namespace sap.ui.fl.apply._internal.changes.descriptor.ui5.SetMinUI5Version
24
24
  * @experimental
25
- * @version 1.99.1
25
+ * @version 1.102.0
26
26
  * @private
27
27
  * @ui5-restricted sap.ui.fl.apply._internal
28
28
  */
@@ -12,7 +12,7 @@ sap.ui.define([], function () {
12
12
  *
13
13
  * @namespace sap.ui.fl.initial._internal.connectors.Utils
14
14
  * @since 1.70
15
- * @version 1.99.1
15
+ * @version 1.102.0
16
16
  * @private
17
17
  * @ui5-restricted sap.ui.fl.initial._internal, sap.ui.fl.write._internal
18
18
  */
@@ -115,11 +115,15 @@ sap.ui.define([
115
115
  }
116
116
  var aAssociatedControlIds = aVMControlIds.reduce(function(aCurrentControlIds, sVMControlId) {
117
117
  var oVMControl = Core.byId(sVMControlId);
118
- var aForControls = oVMControl.getFor();
119
- aForControls.forEach(function(sControlId) {
120
- oAssociatedControls[sControlId] = sVMControlId;
121
- });
122
- return aCurrentControlIds.concat(aForControls);
118
+ // there could be additional VMControl Ids that are not yet available
119
+ if (oVMControl) {
120
+ var aForControls = oVMControl.getFor();
121
+ aForControls.forEach(function(sControlId) {
122
+ oAssociatedControls[sControlId] = sVMControlId;
123
+ });
124
+ aCurrentControlIds = aCurrentControlIds.concat(aForControls);
125
+ }
126
+ return aCurrentControlIds;
123
127
  }, []);
124
128
 
125
129
  var sAssociatedVMControlId = getAssociatedControlId(aAssociatedControlIds, oControl);
@@ -32,7 +32,7 @@ function(
32
32
  * @class
33
33
  * @constructor
34
34
  * @author SAP SE
35
- * @version 1.99.1
35
+ * @version 1.102.0
36
36
  */
37
37
  var Processor;
38
38
 
@@ -177,6 +177,14 @@ sap.ui.define([
177
177
 
178
178
  CompVariant.STANDARD_VARIANT_ID = "*standard*";
179
179
 
180
+ /**
181
+ * Returns the id of the variant object
182
+ * @returns {string} the id of the variant object.
183
+ */
184
+ CompVariant.prototype.getVariantId = function () {
185
+ return this.getId();
186
+ };
187
+
180
188
  /**
181
189
  * Checks whenever the variant can be renamed updating the entity or crating an <code>updateChange</code>.
182
190
  *
@@ -0,0 +1,452 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2022 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+ sap.ui.define([
7
+ "sap/base/Log",
8
+ "sap/base/util/deepClone",
9
+ "sap/base/util/isEmptyObject",
10
+ "sap/base/util/isPlainObject",
11
+ "sap/base/util/ObjectPath",
12
+ "sap/base/util/restricted/_omit",
13
+ "sap/ui/base/ManagedObject",
14
+ "sap/ui/fl/apply/_internal/flexObjects/States",
15
+ "sap/ui/fl/Layer",
16
+ "sap/ui/fl/registry/Settings",
17
+ "sap/ui/fl/Utils"
18
+ ], function(
19
+ Log,
20
+ deepClone,
21
+ isEmptyObject,
22
+ isPlainObject,
23
+ ObjectPath,
24
+ _omit,
25
+ ManagedObject,
26
+ States,
27
+ Layer,
28
+ Settings,
29
+ Utils
30
+ ) {
31
+ "use strict";
32
+
33
+ /**
34
+ * @type {sap.ui.fl.apply._internal.flexObjects.FlexObject.FlexObjectMetadata}
35
+ * @static
36
+ * @constant
37
+ * @typedef {object} sap.ui.fl.apply._internal.flexObjects.FlexObject.FlexObjectMetadata
38
+ * @property {string} reference - Application component name
39
+ * @property {string} namespace - Namespace of the flex object file
40
+ * @property {string} creation - Timestamp of creation date
41
+ * @property {string} projectId - Project ID of the flex object file
42
+ * @property {string} packageName - ABAP package name
43
+ * @property {string} moduleName - Name of the module which this flex object refers to (XML or JS)
44
+ * @private
45
+ */
46
+
47
+ /**
48
+ * @type {sap.ui.fl.apply._internal.flexObjects.FlexObject.SupportInformation}
49
+ * @static
50
+ * @constant
51
+ * @typedef {object} sap.ui.fl.apply._internal.flexObjects.FlexObject.SupportInformation
52
+ * @property {string} generator - Tool that is used to generate the flex object file
53
+ * @property {string} service - Name of the OData service
54
+ * @property {string} sourceSystem - ABAP source system
55
+ * @property {string} sourceClient - ABAP source client
56
+ * @property {string} user - Username who created the flex object
57
+ * @property {string} sapui5Version - UI5 version in which the flex object was created
58
+ * @property {string} sourceChangeFileName - File name of the source flex object in case of a copied flex object
59
+ * @property {string} compositeCommand - Unique ID that defines which flex objects belong together in a composite command
60
+ * @property {string} command - Name of the command
61
+ * @property {string} oDataInformation - Object with information about the OData service
62
+ * @property {string} originalLanguage - Language in which the flex object was created
63
+ * @private
64
+ */
65
+
66
+ /**
67
+ * Base class for any flex object.
68
+ *
69
+ * @class Base class for any flex object
70
+ * @extends sap.ui.base.ManagedObject
71
+ * @alias sap.ui.fl.apply._internal.flexObjects.FlexObject
72
+ * @since 1.100
73
+ * @version 1.102.0
74
+ * @private
75
+ * @ui5-restricted sap.ui.fl
76
+ */
77
+ var FlexObject = ManagedObject.extend("sap.ui.fl.apply._internal.flexObjects.FlexObject", /* @lends sap.ui.fl.apply._internal.flexObjects.FlexObject.prototype */ {
78
+ metadata: {
79
+ properties: {
80
+ /**
81
+ * Current state of the flex object regarding the persistence.
82
+ * See {@link sap.ui.fl.apply._internal.flexObjects.States}.
83
+ */
84
+ state: {
85
+ type: "string",
86
+ defaultValue: States.NEW
87
+ },
88
+ /**
89
+ * File type of the flex object.
90
+ * One of <code>change</code>, <code>variant</code>, <code>ctrl_variant</code>,
91
+ * <code>ctrl_variant_change</code> or <code>ctrl_variant_management_change</code>
92
+ */
93
+ fileType: {
94
+ type: "string",
95
+ defaultValue: "change"
96
+ },
97
+ /**
98
+ * Layer of the flex object.
99
+ * See {@link sap.ui.fl.Layer}.
100
+ */
101
+ layer: {
102
+ type: "string"
103
+ },
104
+ /**
105
+ * Additional metadata of the flex object.
106
+ * See {@link sap.ui.fl.apply._internal.flexObjects.FlexObject.FlexObjectMetadata}.
107
+ */
108
+ flexObjectMetadata: {
109
+ type: "object",
110
+ defaultValue: {}
111
+ },
112
+ /**
113
+ * Optional support information.
114
+ * See {@link sap.ui.fl.apply._internal.flexObjects.FlexObject.SupportInformation}.
115
+ */
116
+ supportInformation: {
117
+ type: "object",
118
+ defaultValue: {}
119
+ },
120
+ /**
121
+ * Content of the flex object that is used to apply the flex object.
122
+ */
123
+ content: {
124
+ type: "any"
125
+ },
126
+ /**
127
+ * Map of texts that should be translated.
128
+ */
129
+ texts: {
130
+ type: "object",
131
+ defaultValue: {}
132
+ }
133
+ }
134
+ },
135
+ constructor: function() {
136
+ ManagedObject.apply(this, arguments);
137
+ var oFlexObjectMetadata = this.getFlexObjectMetadata();
138
+ if (oFlexObjectMetadata.reference) {
139
+ oFlexObjectMetadata.namespace = (
140
+ oFlexObjectMetadata.namespace
141
+ || Utils.createNamespace(
142
+ { reference: oFlexObjectMetadata.reference },
143
+ this.getFileType()
144
+ )
145
+ );
146
+
147
+ if (!oFlexObjectMetadata.projectId) {
148
+ oFlexObjectMetadata.projectId = oFlexObjectMetadata.reference.replace(".Component", "");
149
+ }
150
+ }
151
+ this.setFlexObjectMetadata(oFlexObjectMetadata);
152
+
153
+ var oSupportInformation = this.getSupportInformation();
154
+ if (!oSupportInformation.originalLanguage) {
155
+ oSupportInformation.originalLanguage = Utils.getCurrentLanguage();
156
+ }
157
+ this.setSupportInformation(oSupportInformation);
158
+ }
159
+ });
160
+
161
+ /**
162
+ * Returns the mapping between flex object properties and file content properties in the back-end response.
163
+ * @returns {object} Mapping information
164
+ * @static
165
+ */
166
+ FlexObject.getMappingInfo = function () {
167
+ return Object.assign({}, {
168
+ "flexObjectMetadata.reference": "reference",
169
+ "flexObjectMetadata.namespace": "namespace",
170
+ "flexObjectMetadata.creation": "creation",
171
+ "flexObjectMetadata.projectId": "projectId",
172
+ "flexObjectMetadata.packageName": "packageName",
173
+ "flexObjectMetadata.moduleName": "moduleName",
174
+ "supportInformation.generator": "support.generator",
175
+ "supportInformation.service": "support.service",
176
+ "supportInformation.sourceSystem": "sourceSystem",
177
+ "supportInformation.sourceClient": "sourceClient",
178
+ "supportInformation.user": "support.user",
179
+ "supportInformation.sapui5Version": "support.sapui5Version",
180
+ "supportInformation.sourceChangeFileName": "support.sourceChangeFileName",
181
+ "supportInformation.compositeCommand": "support.compositeCommand",
182
+ "supportInformation.command": "support.command",
183
+ "supportInformation.oDataInformation": "oDataInformation",
184
+ "supportInformation.originalLanguage": "originalLanguage",
185
+ layer: "layer",
186
+ fileType: "fileType",
187
+ content: "content",
188
+ id: "fileName",
189
+ texts: "texts"
190
+ });
191
+ };
192
+
193
+ /**
194
+ * Returns the mapping between flex object properties and file content properties in the back-end response.
195
+ * Can be overridden to avoid access of static mapping within base methods.
196
+ * @returns {object} Mapping information
197
+ */
198
+ FlexObject.prototype.getMappingInfo = function () {
199
+ return FlexObject.getMappingInfo();
200
+ };
201
+
202
+ /**
203
+ * Sets the content of the flex object and marks the state as DIRTY.
204
+ * @param {any} oContent - Flex object content
205
+ * @returns {sap.ui.fl.apply._internal.flexObjects.FlexObject} <code>this</code> for chaining
206
+ */
207
+ FlexObject.prototype.setContent = function (oContent) {
208
+ this.setProperty("content", oContent);
209
+ this.setState(States.DIRTY);
210
+ return this;
211
+ };
212
+
213
+ /**
214
+ * Getter for additional flex object metadata.
215
+ * @returns {sap.ui.fl.apply._internal.flexObjects.FlexObject.FlexObjectMetadata} Additional metadata
216
+ */
217
+ FlexObject.prototype.getFlexObjectMetadata = function () {
218
+ return Object.assign({}, this.getProperty("flexObjectMetadata"));
219
+ };
220
+
221
+ /**
222
+ * Getter for flex object support information.
223
+ * @returns {sap.ui.fl.apply._internal.flexObjects.FlexObject.SupportInformation} Support information
224
+ */
225
+ FlexObject.prototype.getSupportInformation = function () {
226
+ return Object.assign({}, this.getProperty("supportInformation"));
227
+ };
228
+
229
+ function isValidStateChange(sNewState, sCurrentState) {
230
+ if (!Object.values(States).includes(sNewState)) {
231
+ return false;
232
+ }
233
+ // flex object state cannot move from NEW to DIRTY directly
234
+ if (
235
+ sCurrentState === States.NEW
236
+ && sNewState === States.DIRTY
237
+ ) {
238
+ return false;
239
+ }
240
+ return true;
241
+ }
242
+
243
+ /**
244
+ * Validates and sets the state of the flex object.
245
+ * @param {sap.ui.fl.States} sState - New state
246
+ * @returns {sap.ui.fl.apply._internal.flexObjects.FlexObject} <code>this</code> for chaining
247
+ */
248
+ FlexObject.prototype.setState = function (sState) {
249
+ var sCurrentState = this.getState();
250
+ if (sCurrentState !== sState && isValidStateChange(sState, sCurrentState)) {
251
+ this._sPreviousState = sCurrentState;
252
+ this.setProperty("state", sState);
253
+ }
254
+ return this;
255
+ };
256
+
257
+ /**
258
+ * Changes the state of the flex object to DELETED.
259
+ */
260
+ FlexObject.prototype.markForDeletion = function () {
261
+ this.setState(States.DELETED);
262
+ };
263
+
264
+ /**
265
+ * Restores the state before the last state change.
266
+ * Cannot go back further than the previous state.
267
+ */
268
+ FlexObject.prototype.restorePreviousState = function () {
269
+ if (this._sPreviousState) {
270
+ this.setState(this._sPreviousState);
271
+ delete this._sPreviousState;
272
+ }
273
+ };
274
+
275
+ /**
276
+ * Checks if flex object is read only because of its source system.
277
+ * @returns {boolean} <code>true</code> if the flex object is from another system
278
+ */
279
+ FlexObject.prototype.isChangeFromOtherSystem = function () {
280
+ var sSourceSystem = this.getSupportInformation().sourceSystem;
281
+ var sSourceClient = this.getSupportInformation().sourceClient;
282
+ if (!sSourceSystem || !sSourceClient) {
283
+ return false;
284
+ }
285
+ var oSettings = Settings.getInstanceOrUndef();
286
+ if (!oSettings) {
287
+ return true; // without settings the right to edit or delete a flex object cannot be determined
288
+ }
289
+ var sSystem = oSettings.getSystem();
290
+ var sClient = oSettings.getClient();
291
+ if (!sSystem || !sClient) {
292
+ return false;
293
+ }
294
+ return (sSourceSystem !== sSystem || sSourceClient !== sClient);
295
+ };
296
+
297
+ /**
298
+ * Returns <code>true</code> if the flex object is user dependent.
299
+ * @returns {boolean} <code>true</code> if the flex object is only relevant for the current user
300
+ */
301
+ FlexObject.prototype.isUserDependent = function () {
302
+ return this.getLayer() === Layer.USER;
303
+ };
304
+
305
+ /**
306
+ * Returns the text in the current language for a given ID.
307
+ * @param {string} sTextId - Text ID which was used as part of the <code>texts</code> property
308
+ * @returns {string} The text for the given text ID
309
+ */
310
+ FlexObject.prototype.getText = function (sTextId) {
311
+ var oText = this.getTexts()[sTextId] || {};
312
+ return oText.value || "";
313
+ };
314
+
315
+ /**
316
+ * Sets the new text for the given text ID.
317
+ * @param {string} sTextId - Text ID which was used as part of the <code>texts</code> property
318
+ * @param {string} sNewText - New text for the given text ID
319
+ * @returns {sap.ui.fl.apply._internal.flexObjects.FlexObject} <code>this</code> context for chaining
320
+ */
321
+ FlexObject.prototype.setText = function (sTextId, sNewText) {
322
+ var oTexts = Object.assign({}, this.getTexts());
323
+ if (oTexts[sTextId]) {
324
+ oTexts[sTextId] = Object.assign({}, oTexts[sTextId], {
325
+ value: sNewText
326
+ });
327
+ this.setTexts(oTexts);
328
+ this.setState(States.DIRTY);
329
+ }
330
+ return this;
331
+ };
332
+
333
+ function capitalize(sKey) {
334
+ return sKey.length ? sKey.charAt(0).toUpperCase() + sKey.slice(1) : sKey;
335
+ }
336
+
337
+ function getOriginalMutator(sFunctionName) {
338
+ return typeof this[sFunctionName] === "function"
339
+ ? this[sFunctionName].bind(this)
340
+ : function () {
341
+ throw new Error(sFunctionName + " is not a valid mutator");
342
+ };
343
+ }
344
+
345
+ function getMutators(sPropertyName) {
346
+ var aInstanceParts = sPropertyName.split(".");
347
+ aInstanceParts[0] = capitalize(aInstanceParts[0]);
348
+ var sFunctionName = aInstanceParts.shift();
349
+ var fnGetter = getOriginalMutator.call(this, "get" + sFunctionName);
350
+ var fnSetter = getOriginalMutator.call(this, "set" + sFunctionName);
351
+ return {
352
+ getValue: function () {
353
+ var vCurrentValue = deepClone(fnGetter());
354
+ if (aInstanceParts.length > 0) {
355
+ return ObjectPath.get(aInstanceParts, vCurrentValue);
356
+ }
357
+ return vCurrentValue;
358
+ },
359
+ setValue: function (vValue) {
360
+ var vPropertyValue = deepClone(fnGetter());
361
+ if (aInstanceParts.length > 0) {
362
+ ObjectPath.set(aInstanceParts, vValue, vPropertyValue);
363
+ } else {
364
+ vPropertyValue = vValue;
365
+ }
366
+ fnSetter(vPropertyValue);
367
+ return this;
368
+ }.bind(this)
369
+ };
370
+ }
371
+
372
+ /**
373
+ * Converts properties of the flex object to the file content format according to the mapping info.
374
+ * @returns {object} File content of the flex object that can be persisted
375
+ */
376
+ FlexObject.prototype.convertToFileContent = function() {
377
+ var oFileContent = {};
378
+ Object.entries(this.getMappingInfo()).forEach(function (aProperty) {
379
+ var oValueToSet = getMutators.call(this, aProperty[0]).getValue();
380
+ if (oValueToSet !== undefined) {
381
+ ObjectPath.set(aProperty[1], oValueToSet, oFileContent);
382
+ }
383
+ }.bind(this));
384
+ return oFileContent;
385
+ };
386
+
387
+ function updateProperty(sPropertyName, vValue) {
388
+ var oMutators = getMutators.call(this, sPropertyName);
389
+ var vCurrentValue = oMutators.getValue();
390
+ if (vCurrentValue !== vValue) {
391
+ oMutators.setValue(vValue);
392
+ }
393
+ }
394
+
395
+ /**
396
+ * Converts the file content to the properties of the flex object according to the mapping info.
397
+ * @param {object} oFileContent - File content
398
+ * @param {object} oMappingInfo - Mapping info
399
+ * @returns {object} Properties map to create a new flex object
400
+ * @static
401
+ */
402
+ FlexObject.mapFileContent = function (oFileContent, oMappingInfo) {
403
+ var aValidFileProperties = Object.values(oMappingInfo);
404
+ var mPropertyMap = {};
405
+
406
+ var fnMapProperty = function (sKey, vValue, sPath) {
407
+ var sNewPath = sPath ? sPath + "." + sKey : sKey;
408
+ var iIndex = aValidFileProperties.indexOf(sNewPath);
409
+ if (iIndex >= 0) {
410
+ var sPropertyName = Object.keys(oMappingInfo)[iIndex];
411
+ mPropertyMap[sPropertyName] = vValue;
412
+ } else if (isPlainObject(vValue)) {
413
+ Object.entries(vValue).forEach(function(aEntry) {
414
+ fnMapProperty(aEntry[0], aEntry[1], sNewPath);
415
+ });
416
+ } else {
417
+ Log.error("Missing mapping info for property " + sNewPath);
418
+ }
419
+ };
420
+
421
+ Object.entries(deepClone(oFileContent)).forEach(function (aEntry) {
422
+ fnMapProperty(aEntry[0], aEntry[1]);
423
+ });
424
+ return mPropertyMap;
425
+ };
426
+
427
+ /**
428
+ * Updates the flex object with a file content delta.
429
+ * @param {object} oFileContent - File content of the flex object
430
+ */
431
+ FlexObject.prototype.update = function (oFileContent) {
432
+ var oFilteredFileContent = _omit(oFileContent, ["fileName"]);
433
+ var mProperties = FlexObject.mapFileContent(oFilteredFileContent, this.getMappingInfo());
434
+ Object.entries(mProperties).forEach(function (aProperty) {
435
+ updateProperty.call(this, aProperty[0], aProperty[1]);
436
+ }.bind(this));
437
+ };
438
+
439
+ /**
440
+ * Sets the response from the back end after the flex object is saved.
441
+ * @param {object} oResponse - File content
442
+ */
443
+ FlexObject.prototype.setResponse = function (oResponse) {
444
+ if (!oResponse || isEmptyObject(oResponse)) {
445
+ return;
446
+ }
447
+ this.update(oResponse);
448
+ this.setState(States.PERSISTED);
449
+ };
450
+
451
+ return FlexObject;
452
+ });
@@ -0,0 +1,68 @@
1
+ /* !
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2022 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+ sap.ui.define([
7
+ "sap/base/util/ObjectPath",
8
+ "sap/ui/fl/apply/_internal/flexObjects/FlexObject"
9
+ ], function(
10
+ ObjectPath,
11
+ FlexObject
12
+ ) {
13
+ "use strict";
14
+
15
+ /**
16
+ * @enum {string}
17
+ * Valid flex object types.
18
+ *
19
+ * @alias sap.ui.fl.apply._internal.flexObjects.FlexObjectFactory.FLEX_OBJECT_TYPES
20
+ * @private
21
+ */
22
+ var FLEX_OBJECT_TYPES = {
23
+ BASE_FLEX_OBJECT: FlexObject
24
+ };
25
+
26
+ function getFlexObjectClass () {
27
+ return FLEX_OBJECT_TYPES.BASE_FLEX_OBJECT;
28
+ }
29
+
30
+ /**
31
+ * Helper class to create any flex object.
32
+ *
33
+ * @namespace sap.ui.fl.apply._internal.flexObjects.FlexObjectFactory
34
+ * @since 1.100
35
+ * @version 1.102.0
36
+ * @private
37
+ * @ui5-restricted sap.ui.fl
38
+ */
39
+ var FlexObjectFactory = {};
40
+
41
+ /**
42
+ * Creates a new flex object.
43
+ *
44
+ * @param {object} oFileContent - File content
45
+ * @returns {sap.ui.fl.apply._internal.flexObjects.FlexObject} The created flex object
46
+ */
47
+ FlexObjectFactory.createFromFileContent = function (oFileContent) {
48
+ var oNewFileContent = Object.assign({}, oFileContent);
49
+ var FlexObjectClass = getFlexObjectClass(oNewFileContent);
50
+ if (!FlexObjectClass) {
51
+ throw new Error("Unknown file type");
52
+ }
53
+ oNewFileContent.support = Object.assign(
54
+ { generator: "FlexObjectFactory.createFromFileContent" },
55
+ oNewFileContent.support || {}
56
+ );
57
+ var oMappingInfo = FlexObjectClass.getMappingInfo();
58
+ var mCreationInfo = FlexObjectClass.mapFileContent(oNewFileContent, oMappingInfo);
59
+ var mProperties = Object.entries(mCreationInfo).reduce(function (mPropertyMap, aProperty) {
60
+ ObjectPath.set(aProperty[0].split('.'), aProperty[1], mPropertyMap);
61
+ return mPropertyMap;
62
+ }, {});
63
+ var oFlexObject = new FlexObjectClass(mProperties);
64
+ return oFlexObject;
65
+ };
66
+
67
+ return FlexObjectFactory;
68
+ });