@openui5/sap.ui.fl 1.113.0 → 1.114.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.
- package/THIRDPARTY.txt +1 -1
- package/package.json +3 -3
- package/src/sap/ui/fl/.library +1 -1
- package/src/sap/ui/fl/Cache.js +1 -1
- package/src/sap/ui/fl/ChangePersistence.js +1 -1
- package/src/sap/ui/fl/ChangePersistenceFactory.js +3 -55
- package/src/sap/ui/fl/FakeLrepConnectorLocalStorage.js +1 -1
- package/src/sap/ui/fl/FakeLrepConnectorSessionStorage.js +1 -1
- package/src/sap/ui/fl/FakeLrepLocalStorage.js +1 -1
- package/src/sap/ui/fl/FlexController.js +1 -1
- package/src/sap/ui/fl/FlexControllerFactory.js +7 -159
- package/src/sap/ui/fl/LayerUtils.js +1 -1
- package/src/sap/ui/fl/Utils.js +1 -1
- package/src/sap/ui/fl/apply/_internal/ChangesController.js +0 -2
- package/src/sap/ui/fl/apply/_internal/DelegateMediator.js +4 -1
- package/src/sap/ui/fl/apply/_internal/appVariant/DescriptorChangeTypes.js +2 -1
- package/src/sap/ui/fl/apply/_internal/changes/FlexCustomData.js +1 -1
- package/src/sap/ui/fl/apply/_internal/changes/Utils.js +12 -7
- package/src/sap/ui/fl/apply/_internal/changes/descriptor/Preprocessor.js +1 -1
- package/src/sap/ui/fl/apply/_internal/changes/descriptor/Registration.js +1 -1
- package/src/sap/ui/fl/apply/_internal/changes/descriptor/RegistrationBuild.js +1 -1
- package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/AddAnnotationsToOData.js +1 -1
- package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/AddNewInbound.js +1 -1
- package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/ChangeDataSource.js +1 -1
- package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/ChangeInbound.js +1 -1
- package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/RemoveAllInboundsExceptOne.js +1 -1
- package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/SetTitle.js +1 -1
- package/src/sap/ui/fl/apply/_internal/changes/descriptor/fiori/SetAbstract.js +1 -1
- package/src/sap/ui/fl/apply/_internal/changes/descriptor/fiori/SetRegistrationIds.js +1 -1
- package/src/sap/ui/fl/apply/_internal/changes/descriptor/ovp/AddNewCard.js +1 -1
- package/src/sap/ui/fl/apply/_internal/changes/descriptor/ovp/ChangeCard.js +1 -1
- package/src/sap/ui/fl/apply/_internal/changes/descriptor/ovp/DeleteCard.js +1 -1
- package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddComponentUsages.js +1 -1
- package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddLibrary.js +1 -1
- package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddNewModel.js +1 -1
- package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddNewModelEnhanceWith.js +1 -1
- package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/SetFlexExtensionPointEnabled.js +1 -1
- package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/SetMinUI5Version.js +1 -1
- package/src/sap/ui/fl/apply/_internal/connectors/ObjectStorageUtils.js +1 -1
- package/src/sap/ui/fl/apply/_internal/extensionPoint/Processor.js +1 -1
- package/src/sap/ui/fl/apply/_internal/flexObjects/AppDescriptorChange.js +1 -1
- package/src/sap/ui/fl/apply/_internal/flexObjects/CompVariant.js +33 -13
- package/src/sap/ui/fl/apply/_internal/flexObjects/ControllerExtensionChange.js +1 -1
- package/src/sap/ui/fl/apply/_internal/flexObjects/FlVariant.js +8 -15
- package/src/sap/ui/fl/apply/_internal/flexObjects/FlexObject.js +44 -25
- package/src/sap/ui/fl/apply/_internal/flexObjects/FlexObjectFactory.js +2 -1
- package/src/sap/ui/fl/apply/_internal/flexObjects/UIChange.js +1 -1
- package/src/sap/ui/fl/apply/_internal/flexObjects/Variant.js +20 -2
- package/src/sap/ui/fl/apply/_internal/flexState/FlexState.js +11 -9
- package/src/sap/ui/fl/apply/_internal/flexState/Loader.js +4 -2
- package/src/sap/ui/fl/apply/_internal/flexState/ManifestUtils.js +2 -2
- package/src/sap/ui/fl/apply/_internal/flexState/UI2Personalization/UI2PersonalizationState.js +1 -1
- package/src/sap/ui/fl/apply/_internal/flexState/changes/DependencyHandler.js +1 -1
- package/src/sap/ui/fl/apply/_internal/flexState/changes/ExtensionPointState.js +1 -1
- package/src/sap/ui/fl/apply/_internal/flexState/compVariants/CompVariantMerger.js +21 -2
- package/src/sap/ui/fl/apply/_internal/flexState/controlVariants/Switcher.js +1 -1
- package/src/sap/ui/fl/apply/_internal/flexState/controlVariants/VariantManagementState.js +1 -1
- package/src/sap/ui/fl/apply/_internal/preprocessors/ComponentLifecycleHooks.js +219 -0
- package/src/sap/ui/fl/apply/_internal/preprocessors/ControllerExtension.js +1 -1
- package/src/sap/ui/fl/apply/_internal/preprocessors/EventHistory.js +1 -1
- package/src/sap/ui/fl/apply/_internal/preprocessors/RegistrationDelegator.js +7 -9
- package/src/sap/ui/fl/apply/_internal/preprocessors/XmlPreprocessor.js +1 -1
- package/src/sap/ui/fl/apply/api/ControlVariantApplyAPI.js +29 -9
- package/src/sap/ui/fl/apply/api/DelegateMediatorAPI.js +6 -0
- package/src/sap/ui/fl/changeHandler/AddIFrame.js +1 -1
- package/src/sap/ui/fl/changeHandler/AddXML.js +1 -1
- package/src/sap/ui/fl/changeHandler/AddXMLAtExtensionPoint.js +1 -1
- package/src/sap/ui/fl/changeHandler/Base.js +1 -1
- package/src/sap/ui/fl/changeHandler/BaseAddViaDelegate.js +1 -1
- package/src/sap/ui/fl/changeHandler/BaseAddXml.js +1 -1
- package/src/sap/ui/fl/changeHandler/BaseRename.js +1 -1
- package/src/sap/ui/fl/changeHandler/HideControl.js +1 -1
- package/src/sap/ui/fl/changeHandler/MoveControls.js +6 -1
- package/src/sap/ui/fl/changeHandler/MoveElements.js +1 -1
- package/src/sap/ui/fl/changeHandler/PropertyBindingChange.js +1 -1
- package/src/sap/ui/fl/changeHandler/PropertyChange.js +1 -1
- package/src/sap/ui/fl/changeHandler/StashControl.js +1 -1
- package/src/sap/ui/fl/changeHandler/UnhideControl.js +1 -1
- package/src/sap/ui/fl/changeHandler/UnstashControl.js +1 -1
- package/src/sap/ui/fl/changeHandler/UpdateIFrame.js +1 -1
- package/src/sap/ui/fl/descriptorRelated/api/DescriptorChangeFactory.js +4 -4
- package/src/sap/ui/fl/descriptorRelated/api/DescriptorInlineChangeFactory.js +1 -1
- package/src/sap/ui/fl/descriptorRelated/api/DescriptorVariantFactory.js +1 -1
- package/src/sap/ui/fl/initial/_internal/Storage.js +3 -1
- package/src/sap/ui/fl/initial/_internal/StorageResultMerger.js +3 -22
- package/src/sap/ui/fl/initial/_internal/StorageUtils.js +1 -1
- package/src/sap/ui/fl/initial/_internal/changeHandlers/ChangeHandlerRegistration.js +1 -1
- package/src/sap/ui/fl/initial/_internal/changeHandlers/ChangeHandlerStorage.js +40 -12
- package/src/sap/ui/fl/initial/_internal/connectors/LrepConnector.js +3 -1
- package/src/sap/ui/fl/initial/_internal/connectors/Utils.js +1 -1
- package/src/sap/ui/fl/initial/_internal/storageResultDisassemble.js +1 -1
- package/src/sap/ui/fl/interfaces/BaseLoadConnector.js +1 -1
- package/src/sap/ui/fl/interfaces/Delegate.js +1 -1
- package/src/sap/ui/fl/library.js +43 -43
- package/src/sap/ui/fl/messagebundle.properties +4 -1
- package/src/sap/ui/fl/requireAsync.js +6 -0
- package/src/sap/ui/fl/support/_internal/getChangeDependencies.js +1 -1
- package/src/sap/ui/fl/support/_internal/getFlexSettings.js +1 -1
- package/src/sap/ui/fl/support/api/SupportAPI.js +1 -1
- package/src/sap/ui/fl/support/apps/contentbrowser/controller/ContentDetails.controller.js +1 -1
- package/src/sap/ui/fl/support/apps/contentbrowser/controller/ContentDetailsEdit.controller.js +1 -1
- package/src/sap/ui/fl/support/apps/contentbrowser/controller/LayerContentMaster.controller.js +1 -1
- package/src/sap/ui/fl/support/apps/contentbrowser/controller/Layers.controller.js +1 -1
- package/src/sap/ui/fl/support/apps/contentbrowser/lrepConnector/LRepConnector.js +1 -1
- package/src/sap/ui/fl/support/apps/contentbrowser/utils/DataUtils.js +1 -1
- package/src/sap/ui/fl/support/apps/contentbrowser/utils/ErrorUtils.js +1 -1
- package/src/sap/ui/fl/transport/TransportSelection.js +1 -1
- package/src/sap/ui/fl/util/IFrame.js +1 -1
- package/src/sap/ui/fl/util/ManagedObjectModel.js +1 -1
- package/src/sap/ui/fl/util/resolveBinding.js +1 -1
- package/src/sap/ui/fl/variants/VariantModel.js +77 -3
- package/src/sap/ui/fl/variants/context/Component.js +11 -0
- package/src/sap/ui/fl/variants/context/controller/ContextVisibility.controller.js +4 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n.properties +2 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_ar.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_bg.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_ca.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_cs.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_cy.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_da.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_de.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_el.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_en.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_en_GB.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_en_US_sappsd.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_en_US_saprigi.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_en_US_saptrc.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_es.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_es_MX.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_et.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_fi.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_fr.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_fr_CA.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_hi.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_hr.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_hu.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_id.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_it.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_iw.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_ja.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_kk.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_ko.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_lt.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_lv.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_ms.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_nl.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_no.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_pl.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_pt.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_pt_PT.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_ro.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_ru.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_sh.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_sk.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_sl.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_sv.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_th.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_tr.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_uk.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_vi.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_zh_CN.properties +1 -0
- package/src/sap/ui/fl/variants/context/i18n/i18n_zh_TW.properties +1 -0
- package/src/sap/ui/fl/variants/context/view/ContextVisibility.view.xml +1 -1
- package/src/sap/ui/fl/write/_internal/Storage.js +20 -2
- package/src/sap/ui/fl/write/_internal/StorageFeaturesMerger.js +1 -1
- package/src/sap/ui/fl/write/_internal/Versions.js +133 -107
- package/src/sap/ui/fl/write/_internal/appVariant/AppVariant.js +1 -1
- package/src/sap/ui/fl/write/_internal/appVariant/AppVariantFactory.js +1 -1
- package/src/sap/ui/fl/write/_internal/appVariant/AppVariantInlineChange.js +1 -1
- package/src/sap/ui/fl/write/_internal/appVariant/AppVariantInlineChangeFactory.js +23 -1
- package/src/sap/ui/fl/write/_internal/condenser/Condenser.js +35 -8
- package/src/sap/ui/fl/write/_internal/condenser/UIReconstruction.js +17 -2
- package/src/sap/ui/fl/write/_internal/condenser/classifications/Destroy.js +8 -5
- package/src/sap/ui/fl/write/_internal/condenser/classifications/Move.js +6 -0
- package/src/sap/ui/fl/write/_internal/connectors/BackendConnector.js +1 -1
- package/src/sap/ui/fl/write/_internal/connectors/KeyUserConnector.js +1 -1
- package/src/sap/ui/fl/write/_internal/connectors/LrepConnector.js +17 -5
- package/src/sap/ui/fl/write/_internal/connectors/NeoLrepConnector.js +1 -1
- package/src/sap/ui/fl/write/_internal/connectors/ObjectPathConnector.js +1 -1
- package/src/sap/ui/fl/write/_internal/connectors/PersonalizationConnector.js +1 -1
- package/src/sap/ui/fl/write/_internal/connectors/Utils.js +1 -1
- package/src/sap/ui/fl/write/_internal/extensionPoint/Processor.js +1 -1
- package/src/sap/ui/fl/write/_internal/extensionPoint/Registry.js +11 -3
- package/src/sap/ui/fl/write/_internal/fieldExtensibility/ABAPAccess.js +1 -1
- package/src/sap/ui/fl/write/_internal/fieldExtensibility/ABAPExtensibilityVariant.js +1 -1
- package/src/sap/ui/fl/write/_internal/fieldExtensibility/ABAPExtensibilityVariantFactory.js +1 -1
- package/src/sap/ui/fl/write/_internal/fieldExtensibility/MultiTenantABAPExtensibilityVariant.js +1 -1
- package/src/sap/ui/fl/write/_internal/fieldExtensibility/ServiceValidation.js +1 -1
- package/src/sap/ui/fl/write/_internal/fieldExtensibility/SingleTenantABAPExtensibilityVariant.js +1 -1
- package/src/sap/ui/fl/write/_internal/fieldExtensibility/UriParser.js +1 -1
- package/src/sap/ui/fl/write/_internal/fieldExtensibility/Utils.js +1 -1
- package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/CAPAccess.js +1 -1
- package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/dialog/CustomFieldCAPDialog.js +1 -1
- package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/editor/propertyEditor/booleanEditor/BooleanEditor.js +1 -1
- package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/editor/propertyEditor/rangeEditor/RangeEditor.js +1 -1
- package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/editor/propertyEditor/timeEditor/TimeEditor.js +1 -1
- package/src/sap/ui/fl/write/_internal/flexState/FlexObjectState.js +21 -10
- package/src/sap/ui/fl/write/_internal/flexState/compVariants/CompVariantState.js +39 -11
- package/src/sap/ui/fl/write/_internal/transport/TransportSelection.js +1 -1
- package/src/sap/ui/fl/write/_internal/transport/Transports.js +1 -1
- package/src/sap/ui/fl/write/api/Adaptations.js +23 -0
- package/src/sap/ui/fl/write/api/ChangesWriteAPI.js +16 -2
- package/src/sap/ui/fl/write/api/ContextBasedAdaptationsAPI.js +809 -56
- package/src/sap/ui/fl/write/api/ContextSharingAPI.js +7 -1
- package/src/sap/ui/fl/write/api/FieldExtensibility.js +1 -1
- package/src/sap/ui/fl/write/api/PersistenceWriteAPI.js +5 -2
- package/src/sap/ui/fl/write/api/ReloadInfoAPI.js +10 -0
- package/src/sap/ui/fl/write/api/SmartVariantManagementWriteAPI.js +29 -0
- package/src/sap/ui/fl/write/api/VersionsAPI.js +73 -10
- package/src/sap/ui/fl/write/connectors/BaseConnector.js +6 -0
- package/src/sap/ui/fl/initial/_internal/changeHandlers/ChangeRegistryItem.js +0 -115
|
@@ -5,16 +5,38 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
sap.ui.define([
|
|
8
|
-
"sap/ui/fl/
|
|
8
|
+
"sap/ui/fl/write/api/Adaptations",
|
|
9
|
+
"sap/ui/fl/write/api/FeaturesAPI",
|
|
10
|
+
"sap/ui/fl/apply/_internal/flexObjects/FlexObjectFactory",
|
|
11
|
+
"sap/ui/fl/apply/_internal/flexState/FlexState",
|
|
9
12
|
"sap/ui/fl/apply/_internal/flexState/ManifestUtils",
|
|
13
|
+
"sap/ui/fl/apply/api/ControlVariantApplyAPI",
|
|
14
|
+
"sap/ui/fl/Layer",
|
|
15
|
+
"sap/ui/fl/LayerUtils",
|
|
10
16
|
"sap/ui/fl/Utils",
|
|
17
|
+
"sap/ui/fl/write/_internal/FlexInfoSession",
|
|
18
|
+
"sap/ui/fl/write/_internal/flexState/FlexObjectState",
|
|
19
|
+
"sap/ui/fl/apply/_internal/flexState/compVariants/CompVariantMerger",
|
|
20
|
+
"sap/ui/fl/write/_internal/flexState/compVariants/CompVariantState",
|
|
21
|
+
"sap/ui/fl/apply/_internal/flexState/controlVariants/VariantManagementState",
|
|
11
22
|
"sap/ui/fl/write/_internal/Storage",
|
|
12
23
|
"sap/ui/fl/write/_internal/Versions",
|
|
13
24
|
"sap/ui/model/json/JSONModel"
|
|
14
|
-
], function
|
|
15
|
-
|
|
25
|
+
], function(
|
|
26
|
+
Adaptations,
|
|
27
|
+
FeaturesAPI,
|
|
28
|
+
FlexObjectFactory,
|
|
29
|
+
FlexState,
|
|
16
30
|
ManifestUtils,
|
|
31
|
+
ControlVariantApplyAPI,
|
|
32
|
+
Layer,
|
|
33
|
+
LayerUtils,
|
|
17
34
|
FlexUtils,
|
|
35
|
+
FlexInfoSession,
|
|
36
|
+
FlexObjectState,
|
|
37
|
+
CompVariantMerger,
|
|
38
|
+
CompVariantState,
|
|
39
|
+
VariantManagementState,
|
|
18
40
|
Storage,
|
|
19
41
|
Versions,
|
|
20
42
|
JSONModel
|
|
@@ -23,6 +45,9 @@ sap.ui.define([
|
|
|
23
45
|
|
|
24
46
|
var _mInstances = {};
|
|
25
47
|
|
|
48
|
+
var _oResourceBundle;
|
|
49
|
+
var aMigrationLayers = [Layer.VENDOR, Layer.PARTNER, Layer.CUSTOMER_BASE, Layer.CUSTOMER];
|
|
50
|
+
|
|
26
51
|
/**
|
|
27
52
|
* Provides an API for creating and managing context-based adaptation.
|
|
28
53
|
*
|
|
@@ -43,24 +68,31 @@ sap.ui.define([
|
|
|
43
68
|
}
|
|
44
69
|
|
|
45
70
|
/**
|
|
46
|
-
* Processing the response to
|
|
71
|
+
* Processing the response to create/read/update/delete adaptations if the expected status is contained in the response object
|
|
72
|
+
* In case of a deletion the version list is reloaded because the draft might have been deleted on the backend
|
|
47
73
|
* @param {object} oResponse - Object with response data
|
|
48
74
|
* @param {number} oResponse.status - HTTP response code
|
|
49
|
-
* @param {number} nExpectedStatus - Expected HTTP response code
|
|
50
75
|
* @param {object} mPropertyBag - Object with parameters as properties
|
|
51
|
-
* @param {string} mPropertyBag.
|
|
76
|
+
* @param {string} mPropertyBag.appId - Reference of the application
|
|
52
77
|
* @param {string} mPropertyBag.layer - Layer
|
|
53
|
-
* @
|
|
78
|
+
* @param {boolean} [bDelete=false] - Indicator whether the response was from a delete
|
|
79
|
+
* @returns {Promise<object>} Object with response data
|
|
54
80
|
*/
|
|
55
|
-
function handleResponseForVersioning(oResponse,
|
|
56
|
-
if (
|
|
57
|
-
Versions.
|
|
58
|
-
reference: mPropertyBag.
|
|
59
|
-
layer: mPropertyBag.layer
|
|
60
|
-
|
|
81
|
+
function handleResponseForVersioning(oResponse, mPropertyBag, bDelete) {
|
|
82
|
+
if (bDelete) {
|
|
83
|
+
return Versions.updateModelFromBackend({
|
|
84
|
+
reference: mPropertyBag.appId,
|
|
85
|
+
layer: mPropertyBag.layer
|
|
86
|
+
}).then(function() {
|
|
87
|
+
return oResponse;
|
|
61
88
|
});
|
|
62
89
|
}
|
|
63
|
-
|
|
90
|
+
Versions.onAllChangesSaved({
|
|
91
|
+
reference: mPropertyBag.appId,
|
|
92
|
+
layer: mPropertyBag.layer,
|
|
93
|
+
contextBasedAdaptation: true
|
|
94
|
+
});
|
|
95
|
+
return Promise.resolve(oResponse);
|
|
64
96
|
}
|
|
65
97
|
|
|
66
98
|
/**
|
|
@@ -68,9 +100,12 @@ sap.ui.define([
|
|
|
68
100
|
* @param {object} mPropertyBag - Object with parameters as properties
|
|
69
101
|
* @param {sap.ui.core.Control} mPropertyBag.control - Control for which the request is done
|
|
70
102
|
* @param {string} mPropertyBag.layer - Layer
|
|
71
|
-
* @returns {sap.ui.model.json.JSONModel}
|
|
103
|
+
* @returns {Promise<sap.ui.model.json.JSONModel>} Model of adaptations enhanced with additional properties
|
|
72
104
|
*/
|
|
73
|
-
ContextBasedAdaptationsAPI.initialize = function
|
|
105
|
+
ContextBasedAdaptationsAPI.initialize = function(mPropertyBag) {
|
|
106
|
+
if (!_oResourceBundle) {
|
|
107
|
+
_oResourceBundle = sap.ui.getCore().getLibraryResourceBundle("sap.ui.fl");
|
|
108
|
+
}
|
|
74
109
|
if (!mPropertyBag.layer) {
|
|
75
110
|
return Promise.reject("No layer was provided");
|
|
76
111
|
}
|
|
@@ -80,14 +115,29 @@ sap.ui.define([
|
|
|
80
115
|
var sReference = getFlexReferenceForControl(mPropertyBag.control);
|
|
81
116
|
mPropertyBag.reference = sReference;
|
|
82
117
|
var sLayer = mPropertyBag.layer;
|
|
83
|
-
|
|
84
|
-
.
|
|
85
|
-
|
|
118
|
+
if (_mInstances && _mInstances[sReference] && _mInstances[sReference][sLayer]) {
|
|
119
|
+
return Promise.resolve(_mInstances[sReference][sLayer]);
|
|
120
|
+
}
|
|
121
|
+
var bContextBasedAdaptationsEnabled;
|
|
122
|
+
return FeaturesAPI.isContextBasedAdaptationAvailable(sLayer)
|
|
123
|
+
.then(function(bContextBasedAdaptationsEnabledResponse) {
|
|
124
|
+
bContextBasedAdaptationsEnabled = bContextBasedAdaptationsEnabledResponse;
|
|
86
125
|
var oAdaptationsPromise = bContextBasedAdaptationsEnabled ? ContextBasedAdaptationsAPI.load(mPropertyBag) : Promise.resolve({adaptations: []});
|
|
87
126
|
return oAdaptationsPromise;
|
|
88
127
|
})
|
|
89
128
|
.then(function(oAdaptations) {
|
|
90
|
-
|
|
129
|
+
// Determine displayed adaptation
|
|
130
|
+
// Flex Info Session returns currently shown one based on Flex Data response
|
|
131
|
+
// If no longer available switch to highest ranked one
|
|
132
|
+
var oFlexInfoSession = FlexInfoSession.get(mPropertyBag.control) || {};
|
|
133
|
+
var oDisplayedAdaptation = oAdaptations.adaptations[0];
|
|
134
|
+
if (oFlexInfoSession.adaptationId) {
|
|
135
|
+
oDisplayedAdaptation = oAdaptations.adaptations.find(function(oAdaptation) {
|
|
136
|
+
return oAdaptation.id === oFlexInfoSession.adaptationId;
|
|
137
|
+
}) || oDisplayedAdaptation;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return ContextBasedAdaptationsAPI.createModel(oAdaptations.adaptations, oDisplayedAdaptation, bContextBasedAdaptationsEnabled);
|
|
91
141
|
})
|
|
92
142
|
.then(function(oModel) {
|
|
93
143
|
_mInstances[sReference] = _mInstances[sReference] || {};
|
|
@@ -99,33 +149,101 @@ sap.ui.define([
|
|
|
99
149
|
|
|
100
150
|
/**
|
|
101
151
|
* Initializes and creates an new adaptation Model
|
|
102
|
-
* @param {
|
|
103
|
-
* @
|
|
152
|
+
* @param {object[]} aAdaptations - List of adaptations from backend
|
|
153
|
+
* @param {object} oDisplayedAdaptation - Adaptation to be set as displayedAdaptation
|
|
154
|
+
* @param {boolean} bContextBasedAdaptationsEnabled - Whether the feature is enabled
|
|
155
|
+
* @returns {sap.ui.model.json.JSONModel} Model of adaptations enhanced with additional properties
|
|
104
156
|
*/
|
|
105
|
-
ContextBasedAdaptationsAPI.createModel = function(aAdaptations) {
|
|
157
|
+
ContextBasedAdaptationsAPI.createModel = function(aAdaptations, oDisplayedAdaptation, bContextBasedAdaptationsEnabled) {
|
|
106
158
|
if (!Array.isArray(aAdaptations)) {
|
|
107
159
|
throw Error("Adaptations model can only be initialized with an array of adaptations");
|
|
108
160
|
}
|
|
161
|
+
if (bContextBasedAdaptationsEnabled && !oDisplayedAdaptation) {
|
|
162
|
+
throw Error("Invalid call, must pass displayed adaptation");
|
|
163
|
+
}
|
|
164
|
+
if (!bContextBasedAdaptationsEnabled && aAdaptations.length) {
|
|
165
|
+
throw Error("Invalid call, must not pass adaptations if feature is disabled");
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// TODO Extract class
|
|
109
169
|
var oModel = new JSONModel({
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
170
|
+
allAdaptations: [],
|
|
171
|
+
adaptations: [],
|
|
172
|
+
count: 0,
|
|
173
|
+
displayedAdaptation: {},
|
|
174
|
+
contextBasedAdaptationsEnabled: bContextBasedAdaptationsEnabled
|
|
113
175
|
});
|
|
114
176
|
oModel.updateAdaptations = function(aAdaptations) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
177
|
+
var aContextBasedAdaptations = aAdaptations.filter(function(oAdaptation, iIndex) {
|
|
178
|
+
oAdaptation.rank = iIndex + 1; // initialize ranks
|
|
179
|
+
return oAdaptation.type !== Adaptations.Type.Default;
|
|
180
|
+
});
|
|
181
|
+
oModel.setProperty("/adaptations", aContextBasedAdaptations);
|
|
182
|
+
oModel.setProperty("/allAdaptations", aAdaptations);
|
|
183
|
+
oModel.setProperty("/count", aContextBasedAdaptations.length);
|
|
184
|
+
|
|
185
|
+
// update displayed adaptation
|
|
186
|
+
var oDisplayedAdaptation = oModel.getProperty("/displayedAdaptation");
|
|
187
|
+
var oCorrespondingAdaptation = aAdaptations.find(function(oAdaptation) {
|
|
188
|
+
return !!oDisplayedAdaptation && oAdaptation.id === oDisplayedAdaptation.id;
|
|
189
|
+
});
|
|
190
|
+
if (oCorrespondingAdaptation) {
|
|
191
|
+
oDisplayedAdaptation = Object.assign({}, oCorrespondingAdaptation);
|
|
119
192
|
oModel.setProperty("/displayedAdaptation", oDisplayedAdaptation);
|
|
120
193
|
}
|
|
121
194
|
oModel.updateBindings(true);
|
|
122
195
|
};
|
|
123
196
|
oModel.insertAdaptation = function(oNewAdaptation) {
|
|
124
|
-
aAdaptations = oModel.getProperty("/
|
|
197
|
+
var aAdaptations = oModel.getProperty("/allAdaptations");
|
|
125
198
|
aAdaptations.splice(oNewAdaptation.priority, 0, oNewAdaptation);
|
|
126
199
|
delete oNewAdaptation.priority;
|
|
127
200
|
oModel.updateAdaptations(aAdaptations);
|
|
128
201
|
};
|
|
202
|
+
oModel.deleteAdaptation = function() {
|
|
203
|
+
var iIndex = oModel.getProperty("/displayedAdaptation").rank - 1;
|
|
204
|
+
var aAdaptations = oModel.getProperty("/adaptations");
|
|
205
|
+
var iModelCount = oModel.getProperty("/count");
|
|
206
|
+
var sToBeDisplayedAdaptationId;
|
|
207
|
+
if (iModelCount > 1) {
|
|
208
|
+
sToBeDisplayedAdaptationId = aAdaptations[iIndex + ((iIndex === iModelCount - 1) ? -1 : 1)].id;
|
|
209
|
+
}
|
|
210
|
+
aAdaptations.splice(iIndex, 1);
|
|
211
|
+
var oDefaultAdaptation = oModel.getProperty("/allAdaptations").pop();
|
|
212
|
+
aAdaptations.push(oDefaultAdaptation);
|
|
213
|
+
oModel.updateAdaptations(aAdaptations);
|
|
214
|
+
return sToBeDisplayedAdaptationId;
|
|
215
|
+
};
|
|
216
|
+
oModel.switchDisplayedAdaptation = function(sAdaptationId) {
|
|
217
|
+
var iIndex = oModel.getIndexByAdaptationId(sAdaptationId);
|
|
218
|
+
var oNewDisplayedAdaptation = iIndex ? oModel.getProperty("/allAdaptations")[iIndex] : oModel.getProperty("/allAdaptations")[0];
|
|
219
|
+
oModel.setProperty("/displayedAdaptation", oNewDisplayedAdaptation);
|
|
220
|
+
oModel.updateBindings(true);
|
|
221
|
+
};
|
|
222
|
+
oModel.updateAdaptationContent = function(oContextBasedAdaptation) {
|
|
223
|
+
var aAdaptations = oModel.getProperty("/allAdaptations");
|
|
224
|
+
var oAdaptationForUpdate = aAdaptations.find(function(oAdaptation) {
|
|
225
|
+
return oContextBasedAdaptation.adaptationId === oAdaptation.id;
|
|
226
|
+
});
|
|
227
|
+
oAdaptationForUpdate.title = oContextBasedAdaptation.title;
|
|
228
|
+
oAdaptationForUpdate.contexts = oContextBasedAdaptation.contexts;
|
|
229
|
+
var iIndex = oAdaptationForUpdate.rank - 1;
|
|
230
|
+
if (iIndex !== oContextBasedAdaptation.priority) {
|
|
231
|
+
var aDisplayedAdaptation = aAdaptations.splice(iIndex, 1);
|
|
232
|
+
aAdaptations.splice(oContextBasedAdaptation.priority, 0, aDisplayedAdaptation[0]);
|
|
233
|
+
}
|
|
234
|
+
oModel.updateAdaptations(aAdaptations);
|
|
235
|
+
};
|
|
236
|
+
oModel.getIndexByAdaptationId = function(sAdaptationId) {
|
|
237
|
+
var aAdaptations = oModel.getProperty("/allAdaptations");
|
|
238
|
+
var iAdaptationIndex = aAdaptations.findIndex(function(oAdaptation) {
|
|
239
|
+
return oAdaptation.id === sAdaptationId;
|
|
240
|
+
});
|
|
241
|
+
return (iAdaptationIndex > -1) ? iAdaptationIndex : undefined;
|
|
242
|
+
};
|
|
243
|
+
if (aAdaptations.length > 0) {
|
|
244
|
+
oModel.updateAdaptations(aAdaptations);
|
|
245
|
+
oModel.setProperty("/displayedAdaptation", oDisplayedAdaptation);
|
|
246
|
+
}
|
|
129
247
|
return oModel;
|
|
130
248
|
};
|
|
131
249
|
|
|
@@ -134,7 +252,7 @@ sap.ui.define([
|
|
|
134
252
|
* @param {object} mPropertyBag - Object with parameters as properties
|
|
135
253
|
* @param {sap.ui.core.Control} mPropertyBag.control - Control for which the request is done
|
|
136
254
|
* @param {string} mPropertyBag.layer - Layer
|
|
137
|
-
* @returns {sap.ui.model.json.JSONModel}
|
|
255
|
+
* @returns {sap.ui.model.json.JSONModel} Model of adaptations enhanced with additional properties
|
|
138
256
|
*/
|
|
139
257
|
ContextBasedAdaptationsAPI.getAdaptationsModel = function(mPropertyBag) {
|
|
140
258
|
if (!mPropertyBag.layer) {
|
|
@@ -152,6 +270,18 @@ sap.ui.define([
|
|
|
152
270
|
return _mInstances[sReference][sLayer];
|
|
153
271
|
};
|
|
154
272
|
|
|
273
|
+
/**
|
|
274
|
+
* Returns displayed adaptation id given layer and control for setting the adaptationId in changes etc.
|
|
275
|
+
* @param {object} mPropertyBag - Object with parameters as properties
|
|
276
|
+
* @param {sap.ui.core.Control} mPropertyBag.control - Control for which the request is done
|
|
277
|
+
* @param {string} mPropertyBag.layer - Layer
|
|
278
|
+
* @returns {string} - Displayed adaptation id, undefined for DEFAULT adaptation
|
|
279
|
+
*/
|
|
280
|
+
ContextBasedAdaptationsAPI.getDisplayedAdaptationId = function(mPropertyBag) {
|
|
281
|
+
var adaptationId = this.getAdaptationsModel(mPropertyBag).getProperty("/displayedAdaptation/id");
|
|
282
|
+
return adaptationId !== Adaptations.Type.Default ? adaptationId : undefined;
|
|
283
|
+
};
|
|
284
|
+
|
|
155
285
|
/**
|
|
156
286
|
* Checks if adaptations model for a given reference and layer exists.
|
|
157
287
|
* @param {object} mPropertyBag - Object with parameters as properties
|
|
@@ -165,10 +295,562 @@ sap.ui.define([
|
|
|
165
295
|
return _mInstances[sReference] && _mInstances[sReference][sLayer];
|
|
166
296
|
};
|
|
167
297
|
|
|
298
|
+
/**
|
|
299
|
+
* Checks if an adaptation for a given reference and layer exists.
|
|
300
|
+
* @param {object} mPropertyBag - Object with parameters as properties
|
|
301
|
+
* @param {string} mPropertyBag.reference - ID of the application for which the versions are requested
|
|
302
|
+
* @param {string} mPropertyBag.layer - Layer
|
|
303
|
+
* @returns {boolean} checks if at least one adaptation exists for this reference and layer
|
|
304
|
+
*/
|
|
305
|
+
ContextBasedAdaptationsAPI.adaptationExists = function(mPropertyBag) {
|
|
306
|
+
var sReference = mPropertyBag.reference;
|
|
307
|
+
var sLayer = mPropertyBag.layer;
|
|
308
|
+
return this.hasAdaptationsModel({reference: sReference, layer: sLayer}) && _mInstances[sReference][sLayer].getProperty("/count") > 0;
|
|
309
|
+
};
|
|
310
|
+
|
|
168
311
|
ContextBasedAdaptationsAPI.clearInstances = function() {
|
|
169
312
|
_mInstances = {};
|
|
170
313
|
};
|
|
171
314
|
|
|
315
|
+
/**
|
|
316
|
+
* Discards the model, initializes it again and returns the displayed adaptation.
|
|
317
|
+
* @param {object} mPropertyBag - Object with parameters as properties
|
|
318
|
+
* @param {sap.ui.core.Control} mPropertyBag.control - Control for which the request is done
|
|
319
|
+
* @param {string} mPropertyBag.layer - Layer
|
|
320
|
+
* @returns {string} Displayed adaptation id of the refreshed model
|
|
321
|
+
*/
|
|
322
|
+
ContextBasedAdaptationsAPI.refreshAdaptationModel = function(mPropertyBag) {
|
|
323
|
+
this.clearInstances();
|
|
324
|
+
return this.initialize(mPropertyBag)
|
|
325
|
+
.then(function(oModel) {
|
|
326
|
+
return oModel.getProperty("/displayedAdaptation/id");
|
|
327
|
+
});
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
function getNewVariantId(mFileNames, sOldVariantId) {
|
|
331
|
+
return mFileNames.get(sOldVariantId) || sOldVariantId;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Creates a new context-based adaptation
|
|
336
|
+
* @param {object} mPropertyBag - Object with parameters as properties
|
|
337
|
+
* @param {string} mPropertyBag.layer - Target layer
|
|
338
|
+
* @param {string} mPropertyBag.appId - Reference of the application
|
|
339
|
+
* @param {object} mPropertyBag.control - Control to fetch app reference
|
|
340
|
+
* @param {object} oContextBasedAdaptation - Parameters for new adaptation
|
|
341
|
+
* @param {object} oContextBasedAdaptation.id - ID of new context-based adaptation
|
|
342
|
+
* @param {object} oContextBasedAdaptation.title - Title of new context-based adaptation
|
|
343
|
+
* @param {object} oContextBasedAdaptation.contexts - Contexts of new context-based adaptation
|
|
344
|
+
* @param {object} oContextBasedAdaptation.priority - Priority of new context-based adaptation
|
|
345
|
+
* @returns {Promise<void>} Resolves when done
|
|
346
|
+
*/
|
|
347
|
+
function createContextBasedAdaptation(mPropertyBag, oContextBasedAdaptation) {
|
|
348
|
+
return Storage.contextBasedAdaptation.create({
|
|
349
|
+
layer: mPropertyBag.layer,
|
|
350
|
+
flexObject: oContextBasedAdaptation,
|
|
351
|
+
appId: mPropertyBag.appId,
|
|
352
|
+
parentVersion: getParentVersion(mPropertyBag)
|
|
353
|
+
}).then(function(oResponse) {
|
|
354
|
+
var oModel = this.getAdaptationsModel(mPropertyBag);
|
|
355
|
+
oModel.insertAdaptation(oContextBasedAdaptation);
|
|
356
|
+
return handleResponseForVersioning(oResponse, mPropertyBag);
|
|
357
|
+
}.bind(this));
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Write changes to backend
|
|
362
|
+
* @param {object} mPropertyBag - Object with parameters as properties
|
|
363
|
+
* @param {string} mPropertyBag.parentVersion - Indicates if changes should be written as a draft and on which version the changes should be based on
|
|
364
|
+
* @param {string} mPropertyBag.layer - Target Layer
|
|
365
|
+
* @param {sap.ui.fl.apply._internal.flexObjects.FlexObject[]} aFlexObjects - Array containing FlexObjects
|
|
366
|
+
* @returns {Promise} Returns a promise that resolves as soon as the writing was completed or rejects in case of an error
|
|
367
|
+
*/
|
|
368
|
+
function writeChangesToBackend(mPropertyBag, aFlexObjects) {
|
|
369
|
+
return Storage.write({
|
|
370
|
+
layer: mPropertyBag.layer,
|
|
371
|
+
flexObjects: aFlexObjects,
|
|
372
|
+
transport: "",
|
|
373
|
+
isLegacyVariant: false,
|
|
374
|
+
parentVersion: getParentVersion(mPropertyBag)
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* CompVariant FlexObjects are already in final state with changes applied, but Fl vars are not and we have to fetch it
|
|
380
|
+
* @param {object[]} aFlVariantsFinalState FlVariant final states from Variant Management
|
|
381
|
+
* @param {object[]} aFlexObjects All Flex Objects
|
|
382
|
+
* @param {object} oVariant Comp or Fl Variant
|
|
383
|
+
* @returns {object} Comp variant or Fl variant from final states
|
|
384
|
+
*/
|
|
385
|
+
function getFinalState(aFlVariantsFinalState, aFlexObjects, oVariant) {
|
|
386
|
+
if (oVariant.isA("sap.ui.fl.apply._internal.flexObjects.CompVariant")) {
|
|
387
|
+
var aVariantChanges = aFlexObjects.filter(function(oFlexObject) {
|
|
388
|
+
return oFlexObject.getChangeType() === "updateVariant" && oFlexObject.getSelector().variantId === oVariant.getId();
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
// Clone it, to avoid that we modify the original and that modifying the original affects the state
|
|
392
|
+
var oClone = oVariant = oVariant.clone();
|
|
393
|
+
aVariantChanges.forEach(CompVariantMerger.applyChangeOnVariant.bind(CompVariantMerger, oClone));
|
|
394
|
+
// Avoid garbage
|
|
395
|
+
oClone.removeAllChanges();
|
|
396
|
+
oClone.destroy();
|
|
397
|
+
return oClone.mProperties;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// Also clone to avoid changes on it
|
|
401
|
+
var oFinalStateClone = aFlVariantsFinalState.find(function(oFlVariant) {
|
|
402
|
+
return oFlVariant.getId() === oVariant.getId();
|
|
403
|
+
}).clone();
|
|
404
|
+
oFinalStateClone.destroy();
|
|
405
|
+
return oFinalStateClone.mProperties;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Builds a map containing unique contextKeys (as key) with their respective variants and variants changes and a list of unrestricted views.
|
|
410
|
+
* @param {sap.ui.fl.apply._internal.flexObjects.Variant[]} aVariants - Variants object
|
|
411
|
+
* @param {object[]} oFinalStates - Final states of variants
|
|
412
|
+
* @returns {object} An object with both results
|
|
413
|
+
*/
|
|
414
|
+
function groupVariantsByContextEntry(aVariants, oFinalStates) {
|
|
415
|
+
var mUniqueContexts = {};
|
|
416
|
+
var aUnrestrictedViews = [];
|
|
417
|
+
aVariants.forEach(function(oVariant) {
|
|
418
|
+
var oFinalState = oFinalStates[oVariant.getId()];
|
|
419
|
+
// We do not need to copy invisible variants
|
|
420
|
+
if (oFinalState.visible) {
|
|
421
|
+
var bUnrestricted = true;
|
|
422
|
+
// TODO Needs to be enhanced if there can be multiple context types in parallel
|
|
423
|
+
var aContextKeys = Object.keys(oFinalState.contexts);
|
|
424
|
+
aContextKeys.forEach(function(sKey) {
|
|
425
|
+
var aContexts = Array.from(oFinalState.contexts[sKey]);
|
|
426
|
+
|
|
427
|
+
aContexts.forEach(function(sContext) {
|
|
428
|
+
bUnrestricted = false;
|
|
429
|
+
if (mUniqueContexts[sContext]) {
|
|
430
|
+
mUniqueContexts[sContext].variants.push(oVariant);
|
|
431
|
+
} else {
|
|
432
|
+
mUniqueContexts[sContext] = {
|
|
433
|
+
contextBasedAdaptationId: FlexUtils.createDefaultFileName(),
|
|
434
|
+
variants: [oVariant]
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
if (bUnrestricted) {
|
|
440
|
+
aUnrestrictedViews.push(oVariant);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
return {uniqueContexts: mUniqueContexts, unrestrictedViews: aUnrestrictedViews};
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Creates set visible false changes for restricted variants from layers below Customer.
|
|
449
|
+
* @param {sap.ui.fl.apply._internal.flexObjects.Variant} oVariant - Variant flex object
|
|
450
|
+
* @param {object} mPropertyBag - Object with parameters as properties
|
|
451
|
+
* @param {string} mPropertyBag.appId - App reference
|
|
452
|
+
* @param {string} mPropertyBag.layer - Working layer
|
|
453
|
+
* @param {sap.ui.core.Control} mPropertyBag.control - Control for which the request is done
|
|
454
|
+
* @param {string} [contextBasedAdaptationId] - ID of the context-based adaption
|
|
455
|
+
* @returns {object} Returns the change as JSON object
|
|
456
|
+
*/
|
|
457
|
+
function createChangeSetVisibleFalseToRestrictedVariant(oVariant, mPropertyBag, contextBasedAdaptationId) {
|
|
458
|
+
if (oVariant.isA("sap.ui.fl.apply._internal.flexObjects.CompVariant")) {
|
|
459
|
+
var sPersistencyKey = oVariant.getPersistencyKey();
|
|
460
|
+
oVariant = CompVariantState.updateVariant({
|
|
461
|
+
reference: mPropertyBag.appId,
|
|
462
|
+
persistencyKey: sPersistencyKey,
|
|
463
|
+
id: oVariant.getId(),
|
|
464
|
+
layer: mPropertyBag.layer,
|
|
465
|
+
visible: false,
|
|
466
|
+
adaptationId: contextBasedAdaptationId,
|
|
467
|
+
forceCreate: true
|
|
468
|
+
});
|
|
469
|
+
return oVariant.getChanges().reverse()[0].convertToFileContent();
|
|
470
|
+
}
|
|
471
|
+
// Fl variant
|
|
472
|
+
var oAppComponent = FlexUtils.getAppComponentForControl(mPropertyBag.control);
|
|
473
|
+
var oModel = oAppComponent.getModel(ControlVariantApplyAPI.getVariantModelName());
|
|
474
|
+
var oChange = oModel.createVariantChange(
|
|
475
|
+
oVariant.getVariantManagementReference(),
|
|
476
|
+
{
|
|
477
|
+
changeType: "setVisible",
|
|
478
|
+
visible: false,
|
|
479
|
+
variantReference: oVariant.getId(),
|
|
480
|
+
layer: mPropertyBag.layer,
|
|
481
|
+
appComponent: oAppComponent,
|
|
482
|
+
adaptationId: contextBasedAdaptationId
|
|
483
|
+
}
|
|
484
|
+
);
|
|
485
|
+
return oChange.convertToFileContent();
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
function getObjectsByLayerAndType(aFlexObjects, sChangesLayer, bVariants) {
|
|
489
|
+
var aVariants = aFlexObjects.filter(function(oFlexObject) {
|
|
490
|
+
return (bVariants === oFlexObject.isA("sap.ui.fl.apply._internal.flexObjects.Variant")) && oFlexObject.getLayer() === sChangesLayer;
|
|
491
|
+
});
|
|
492
|
+
return aVariants;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
function getVariantReference(oChange) {
|
|
496
|
+
var sFileType = oChange.getFileType();
|
|
497
|
+
if (sFileType === "change") {
|
|
498
|
+
if (oChange.getSelector().variantId) {
|
|
499
|
+
// selector of a change links to a CompVariant
|
|
500
|
+
return oChange.getSelector().variantId;
|
|
501
|
+
}
|
|
502
|
+
// references to a FLVariant (variant dependent change)
|
|
503
|
+
if (oChange.getVariantReference()) {
|
|
504
|
+
return oChange.getVariantReference();
|
|
505
|
+
}
|
|
506
|
+
} else if (sFileType === "ctrl_variant_change" && oChange.getSelector().id) {
|
|
507
|
+
return oChange.getSelector().id;
|
|
508
|
+
}
|
|
509
|
+
return undefined;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
function isSetContextChange(oChange) {
|
|
513
|
+
if (oChange.getFileType() === "ctrl_variant_change" && oChange.getChangeType() === "setContexts") {
|
|
514
|
+
return true;
|
|
515
|
+
}
|
|
516
|
+
return false;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Filter all changes that are relevant to be copied for an adaptation during migration.
|
|
521
|
+
* All non variant changes are taken over. Variant dependent changes are filtered depending on the variant
|
|
522
|
+
* Changes for variants that will not be taken over into this adaptation will be removed
|
|
523
|
+
* Also removes setContext changes for FLVariants
|
|
524
|
+
* @param {array<string>} aIgnoredVariantIds - IDs of variants that are out of scope
|
|
525
|
+
* @param {sap.ui.fl.apply._internal.flexObjects.FlexObject[]} aChanges - Array of flex objects
|
|
526
|
+
* @returns {sap.ui.fl.apply._internal.flexObjects.FlexObject[]} A list of changes that are relevant
|
|
527
|
+
*/
|
|
528
|
+
function filterChangesForAdaptation(aIgnoredVariantIds, aChanges) {
|
|
529
|
+
return aChanges.filter(function(oChange) {
|
|
530
|
+
var sVariantId = getVariantReference(oChange);
|
|
531
|
+
if (isSetContextChange(oChange)) {
|
|
532
|
+
return false;
|
|
533
|
+
}
|
|
534
|
+
// Either independent or related to variant in scope
|
|
535
|
+
return (!sVariantId || aIgnoredVariantIds.indexOf(sVariantId) < 0);
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Copies existing changes.
|
|
541
|
+
* @param {sap.ui.fl.apply._internal.flexObjects.FlexObject[]} aFlexObjects - Array of flex objects changes and variants
|
|
542
|
+
* @param {string} sContextBasedAdaptationId - ID of the adaptation to be created
|
|
543
|
+
* @returns {object[]} Returns a list of copied changes and variant as JSON object
|
|
544
|
+
*/
|
|
545
|
+
function copyVariantsAndChanges(aFlexObjects, sContextBasedAdaptationId) {
|
|
546
|
+
var aVariants = [];
|
|
547
|
+
var aChanges = [];
|
|
548
|
+
var mFileNames = new Map();
|
|
549
|
+
aFlexObjects.forEach(function(oFlexObject) {
|
|
550
|
+
if (oFlexObject.isA("sap.ui.fl.apply._internal.flexObjects.Variant")) {
|
|
551
|
+
aVariants.push(oFlexObject);
|
|
552
|
+
} else {
|
|
553
|
+
aChanges.push(oFlexObject);
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
var aCopiedVariants = copyVariants(aVariants, mFileNames, sContextBasedAdaptationId);
|
|
557
|
+
var aCopiedChanges = copyChanges(aChanges, mFileNames, sContextBasedAdaptationId);
|
|
558
|
+
return aCopiedVariants.concat(aCopiedChanges).map(function(oFlexObject) {
|
|
559
|
+
return oFlexObject.convertToFileContent();
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Copies CompVariants and FLVariants and sets adaptationId.
|
|
565
|
+
* @param {sap.ui.fl.apply._internal.flexObjects.Variant[]} aVariants - Variants to be copied
|
|
566
|
+
* @param {map} mFileNames - Mapping from old variants ID to new variants ID for changes
|
|
567
|
+
* @param {string} sContextBasedAdaptationId - Context-based adaptation ID
|
|
568
|
+
* @returns {sap.ui.fl.apply._internal.flexObjects.FlexObject[]} Returns an array of copied variants as FlexObject
|
|
569
|
+
*/
|
|
570
|
+
function copyVariants(aVariants, mFileNames, sContextBasedAdaptationId) {
|
|
571
|
+
var aCopiedFlexObjects = [];
|
|
572
|
+
aVariants.forEach(function(oVariant) {
|
|
573
|
+
var oCopiedVariant = FlexObjectFactory.createFromFileContent(oVariant.cloneFileContentWithNewId());
|
|
574
|
+
oCopiedVariant.setAdaptationId(sContextBasedAdaptationId);
|
|
575
|
+
oCopiedVariant.setContexts();
|
|
576
|
+
// Remember mapping of original variant ID to ID of copy
|
|
577
|
+
mFileNames.set(oVariant.getId(), oCopiedVariant.getId());
|
|
578
|
+
aCopiedFlexObjects.push(oCopiedVariant);
|
|
579
|
+
});
|
|
580
|
+
return aCopiedFlexObjects;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Copies changes and sets adaptationId.
|
|
585
|
+
* Variant references are updated where needed in case the variant has been copied.
|
|
586
|
+
* @param {sap.ui.fl.apply._internal.flexObjects.FlexObject[]} aChanges - Changes to be copied
|
|
587
|
+
* @param {map} mFileNames - Mapping from variants ID to new variants ID
|
|
588
|
+
* @param {string} sContextBasedAdaptationId - Context-based adaptation ID
|
|
589
|
+
* @returns {sap.ui.fl.apply._internal.flexObjects.FlexObject[]} Returns an array of copied FlexObjects
|
|
590
|
+
*/
|
|
591
|
+
function copyChanges(aChanges, mFileNames, sContextBasedAdaptationId) {
|
|
592
|
+
var aCopiedFlexObjects = [];
|
|
593
|
+
aChanges.forEach(function(oChange) {
|
|
594
|
+
var oCopiedChange = FlexObjectFactory.createFromFileContent(oChange.cloneFileContentWithNewId());
|
|
595
|
+
var oCopiedChangeContent = oCopiedChange.getContent();
|
|
596
|
+
var oCopiedChangeSelector = oCopiedChange.getSelector();
|
|
597
|
+
if (oChange.getFileType() === "change") {
|
|
598
|
+
if (oChange.getSelector().variantId) {
|
|
599
|
+
// selector of a change links to a CompVariant
|
|
600
|
+
oCopiedChangeSelector.variantId = getNewVariantId(mFileNames, oCopiedChange.getSelector().variantId);
|
|
601
|
+
oCopiedChange.setSelector(oCopiedChangeSelector);
|
|
602
|
+
} else if (oChange.getContent().defaultVariantName) {
|
|
603
|
+
// change references to a defaultVariant
|
|
604
|
+
oCopiedChangeContent.defaultVariantName = getNewVariantId(mFileNames, oCopiedChange.getContent().defaultVariantName);
|
|
605
|
+
oCopiedChange.setContent(oCopiedChangeContent);
|
|
606
|
+
}
|
|
607
|
+
// references to a FLVariant (variant dependent change)
|
|
608
|
+
if (oChange.getVariantReference()) {
|
|
609
|
+
oCopiedChange.setVariantReference(getNewVariantId(mFileNames, oCopiedChange.getVariantReference()));
|
|
610
|
+
}
|
|
611
|
+
// Avoid adding a context for Comp again
|
|
612
|
+
if (oChange.getChangeType() === "updateVariant") {
|
|
613
|
+
delete oCopiedChange.getContent().contexts;
|
|
614
|
+
if (!Object.keys(oCopiedChange.getContent()).length) {
|
|
615
|
+
// Change got empty, not needed anymore
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
} else if (oChange.getFileType() === "ctrl_variant_change" && oChange.getSelector().id) {
|
|
620
|
+
oCopiedChangeSelector.id = getNewVariantId(mFileNames, oCopiedChange.getSelector().id);
|
|
621
|
+
oCopiedChange.setSelector(oCopiedChangeSelector);
|
|
622
|
+
} else if (oChange.getFileType() === "ctrl_variant_management_change" && oChange.getContent().defaultVariant) {
|
|
623
|
+
oCopiedChangeContent.defaultVariant = getNewVariantId(mFileNames, oCopiedChange.getContent().defaultVariant);
|
|
624
|
+
oCopiedChange.setContent(oCopiedChangeContent);
|
|
625
|
+
}
|
|
626
|
+
oCopiedChange.setAdaptationId(sContextBasedAdaptationId);
|
|
627
|
+
aCopiedFlexObjects.push(oCopiedChange);
|
|
628
|
+
});
|
|
629
|
+
return aCopiedFlexObjects;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* Get the parent version
|
|
634
|
+
* @param {object} mPropertyBag - Object with parameters as properties
|
|
635
|
+
* @param {string} mPropertyBag.appId - Reference app ID
|
|
636
|
+
* @param {string} mPropertyBag.layer - Layer
|
|
637
|
+
* @returns {string} Returns the currently displayed version id
|
|
638
|
+
*/
|
|
639
|
+
function getParentVersion(mPropertyBag) {
|
|
640
|
+
return Versions.getVersionsModel({ layer: mPropertyBag.layer, reference: mPropertyBag.appId }).getProperty("/persistedVersion");
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Prepares data for migration of variants. Context-based adaptations don't support context-dependent
|
|
645
|
+
* variants. Therefore, a migration must be done. During the migration process, variants and changes are copied for each unique context,
|
|
646
|
+
* and added to a context-based adaptation. These context-based adaptations have one context.
|
|
647
|
+
* @param {sap.ui.fl.apply._internal.flexObjects.Variant[]} aVariants - Variants from all layers that are relevant to be copied
|
|
648
|
+
* @param {object[]} aFlVariantsFinalState - FL Variants from VariantManagementState holding final state
|
|
649
|
+
* @param {sap.ui.fl.apply._internal.flexObjects.FlexObject[]} aChanges - Changes from customer layer that need to be copied
|
|
650
|
+
* @param {object} mPropertyBag - Object with parameters as properties
|
|
651
|
+
* @param {string} mPropertyBag.appId - App reference
|
|
652
|
+
* @param {string} mPropertyBag.layer - Working layer
|
|
653
|
+
* @param {sap.ui.core.Control} mPropertyBag.control - Control for which the request is done
|
|
654
|
+
* @returns {object} Returns a object containing context-based adaptations and changes/variants as FlexObjects that must be migrated
|
|
655
|
+
*/
|
|
656
|
+
function prepareMigrationData(aVariants, aFlVariantsFinalState, aChanges, mPropertyBag) {
|
|
657
|
+
var oMigrationData = {
|
|
658
|
+
contextBasedAdaptations: [],
|
|
659
|
+
flexObjects: []
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
// Calculate final states for all variants by merging all changes and cache it
|
|
663
|
+
var oFinalStates = {};
|
|
664
|
+
aVariants.forEach(function(oVariant) {
|
|
665
|
+
oFinalStates[oVariant.getId()] = getFinalState(aFlVariantsFinalState, aChanges, oVariant);
|
|
666
|
+
});
|
|
667
|
+
|
|
668
|
+
// Group variants by their corresponding unique context for all layers {key: context, value: variants}
|
|
669
|
+
var oGrouped = groupVariantsByContextEntry(aVariants, oFinalStates);
|
|
670
|
+
var mUniqueContexts = oGrouped.uniqueContexts;
|
|
671
|
+
var aUnrestrictedViews = oGrouped.unrestrictedViews;
|
|
672
|
+
|
|
673
|
+
// Iterate over each unique context to copy context related variants and changes (for both: customer layer only), as well as to create context based adaptation
|
|
674
|
+
Object.entries(mUniqueContexts).forEach(function (aEntry) {
|
|
675
|
+
var sContext = aEntry[0];
|
|
676
|
+
var oUniqueContext = aEntry[1];
|
|
677
|
+
// add unrestricted variants
|
|
678
|
+
oUniqueContext.variants = oUniqueContext.variants.concat(aUnrestrictedViews);
|
|
679
|
+
|
|
680
|
+
// Prepare adaptation
|
|
681
|
+
var sContextBasedAdaptationId = oUniqueContext.contextBasedAdaptationId;
|
|
682
|
+
var oContextBasedAdaptation = {
|
|
683
|
+
id: sContextBasedAdaptationId,
|
|
684
|
+
title: _oResourceBundle.getText("CBA_MIGRATED_ADAPTATION_TITLE", sContext),
|
|
685
|
+
contexts: {
|
|
686
|
+
role: [sContext]
|
|
687
|
+
},
|
|
688
|
+
priority: 0
|
|
689
|
+
};
|
|
690
|
+
oMigrationData.contextBasedAdaptations.push(oContextBasedAdaptation);
|
|
691
|
+
|
|
692
|
+
// Filter variants for customer layer. Only customer layer variants must be copied
|
|
693
|
+
var aCustomerLayerVariants = oUniqueContext.variants.filter(function (oVariant) {
|
|
694
|
+
return oVariant.getLayer() === Layer.CUSTOMER;
|
|
695
|
+
});
|
|
696
|
+
var mFileNames = new Map();
|
|
697
|
+
var aCopiedVariants = copyVariants(aCustomerLayerVariants, mFileNames, sContextBasedAdaptationId);
|
|
698
|
+
// Add copied variants to migration data
|
|
699
|
+
aCopiedVariants.forEach(function (oContextRelevantVariant) {
|
|
700
|
+
oMigrationData.flexObjects.push(oContextRelevantVariant.convertToFileContent());
|
|
701
|
+
});
|
|
702
|
+
|
|
703
|
+
// Find variant relevant changes
|
|
704
|
+
var aUniqueContextVariantIds = oUniqueContext.variants.map(function (oVariant) {
|
|
705
|
+
return oVariant.getId();
|
|
706
|
+
});
|
|
707
|
+
var aVariantIdsNotInUniqueContext = aVariants.map(function(oVariant) {
|
|
708
|
+
return oVariant.getId();
|
|
709
|
+
}).filter(function(sVariantId) {
|
|
710
|
+
return aUniqueContextVariantIds.indexOf(sVariantId) < 0;
|
|
711
|
+
});
|
|
712
|
+
var aChangesToCopy = filterChangesForAdaptation(aVariantIdsNotInUniqueContext, aChanges);
|
|
713
|
+
var aCopiedChanges = copyChanges(aChangesToCopy, mFileNames, sContextBasedAdaptationId);
|
|
714
|
+
aCopiedChanges.forEach(function (oCopiedChange) {
|
|
715
|
+
oMigrationData.flexObjects.push(oCopiedChange.convertToFileContent());
|
|
716
|
+
});
|
|
717
|
+
|
|
718
|
+
// Hide variants from lower layers if not in scope
|
|
719
|
+
aVariants.forEach(function (oVariant) {
|
|
720
|
+
if (oVariant.getLayer() !== Layer.CUSTOMER && aUniqueContextVariantIds.indexOf(oVariant.getId()) < 0) {
|
|
721
|
+
oMigrationData.flexObjects.push(
|
|
722
|
+
createChangeSetVisibleFalseToRestrictedVariant(oVariant, mPropertyBag, sContextBasedAdaptationId)
|
|
723
|
+
);
|
|
724
|
+
}
|
|
725
|
+
});
|
|
726
|
+
});
|
|
727
|
+
|
|
728
|
+
// Hide all variants restricted in default adaptation if not already hidden
|
|
729
|
+
aVariants.forEach(function (oVariant) {
|
|
730
|
+
var oFinalState = oFinalStates[oVariant.getId()];
|
|
731
|
+
var bRestricted = aUnrestrictedViews.indexOf(oVariant) < 0;
|
|
732
|
+
if (oFinalState.visible === true && bRestricted) {
|
|
733
|
+
oMigrationData.flexObjects.push(
|
|
734
|
+
createChangeSetVisibleFalseToRestrictedVariant(oVariant, mPropertyBag, undefined)
|
|
735
|
+
);
|
|
736
|
+
}
|
|
737
|
+
});
|
|
738
|
+
|
|
739
|
+
return oMigrationData;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* Migrate variants to use context-based adaptations by creating context-based adaptations for single unique context.
|
|
744
|
+
* This is done by retrieving unique contexts, and grouping variants by unique contexts.
|
|
745
|
+
* For each unique context a new context-based adaptation is created that contains one unique context.
|
|
746
|
+
* Hereby, we can restrict context-based adaptations in the same way as variants used to be.
|
|
747
|
+
* @param {object} mPropertyBag - Object with parameters as properties
|
|
748
|
+
* @param {sap.ui.core.Control} mPropertyBag.control - Control for which the request is done
|
|
749
|
+
* @param {string} mPropertyBag.layer - Layer
|
|
750
|
+
* @returns {Promise} Promise that resolves with the context-based adaptation
|
|
751
|
+
*/
|
|
752
|
+
ContextBasedAdaptationsAPI.migrate = function(mPropertyBag) {
|
|
753
|
+
mPropertyBag.appId = getFlexReferenceForControl(mPropertyBag.control);
|
|
754
|
+
var sParentVersion = getParentVersion(mPropertyBag);
|
|
755
|
+
mPropertyBag.parentVersion = sParentVersion;
|
|
756
|
+
|
|
757
|
+
var aFlexObjectsData = [];
|
|
758
|
+
|
|
759
|
+
// Old way which has been refactored after 1.115
|
|
760
|
+
var oVariantsMap = FlexState.getVariantsState(ManifestUtils.getFlexReferenceForControl(mPropertyBag.control));
|
|
761
|
+
var aFlVariantsFinalState = Object.keys(oVariantsMap).reduce(function(aPrev, sCurr) {
|
|
762
|
+
return aPrev.concat(oVariantsMap[sCurr].variants);
|
|
763
|
+
}, [])
|
|
764
|
+
.map(function(oEntry) {
|
|
765
|
+
return oEntry.instance;
|
|
766
|
+
});
|
|
767
|
+
|
|
768
|
+
var oMigrationData = {
|
|
769
|
+
contextBasedAdaptation: [],
|
|
770
|
+
flexObjects: []
|
|
771
|
+
};
|
|
772
|
+
|
|
773
|
+
return FlexObjectState.getFlexObjects({
|
|
774
|
+
selector: mPropertyBag.control,
|
|
775
|
+
invalidateCache: false,
|
|
776
|
+
includeCtrlVariants: true,
|
|
777
|
+
includeDirtyChanges: true
|
|
778
|
+
})
|
|
779
|
+
.then(function(aFlexObjects) {
|
|
780
|
+
aMigrationLayers.forEach(function(sLayer) {
|
|
781
|
+
aFlexObjectsData.push(getObjectsByLayerAndType(aFlexObjects, sLayer, /*bVariants*/true));
|
|
782
|
+
});
|
|
783
|
+
aFlexObjectsData.push(getObjectsByLayerAndType(aFlexObjects, Layer.CUSTOMER, /*bVariants*/false));
|
|
784
|
+
|
|
785
|
+
return Promise.all(aFlexObjectsData);
|
|
786
|
+
})
|
|
787
|
+
.then(function(aFlexObjects) {
|
|
788
|
+
var aChanges = aFlexObjects.pop();
|
|
789
|
+
var aVariants = aFlexObjects.flat();
|
|
790
|
+
oMigrationData = prepareMigrationData(aVariants, aFlVariantsFinalState, aChanges, mPropertyBag);
|
|
791
|
+
|
|
792
|
+
// Create adaptations sequentially because backend does not support parallel calls
|
|
793
|
+
var oPromise = Promise.resolve();
|
|
794
|
+
oMigrationData.contextBasedAdaptations.forEach(function (contextBasedAdaptation) {
|
|
795
|
+
oPromise = oPromise.then(createContextBasedAdaptation.bind(this, mPropertyBag, contextBasedAdaptation));
|
|
796
|
+
}.bind(this));
|
|
797
|
+
return oPromise;
|
|
798
|
+
}.bind(this))
|
|
799
|
+
.then(function () {
|
|
800
|
+
if (oMigrationData.flexObjects.length > 0) {
|
|
801
|
+
return writeChangesToBackend(mPropertyBag, oMigrationData.flexObjects);
|
|
802
|
+
}
|
|
803
|
+
return Promise.resolve();
|
|
804
|
+
})
|
|
805
|
+
.then(function() {
|
|
806
|
+
return this.refreshAdaptationModel({control: mPropertyBag.control, layer: mPropertyBag.layer});
|
|
807
|
+
}.bind(this));
|
|
808
|
+
};
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* Check whether a migration of context-related variants can be performed. A migration must only be
|
|
812
|
+
* enabled if no context-based adaptations and at least one context-related variant exists.
|
|
813
|
+
* @param {object} mPropertyBag - Object with parameters as properties
|
|
814
|
+
* @param {sap.ui.core.Control} mPropertyBag.control - Control for which the request is done
|
|
815
|
+
* @param {string} mPropertyBag.layer - Layer
|
|
816
|
+
* @returns {Promise<boolean>} Returns a Promise that resolves with true if variants can be migrated.
|
|
817
|
+
*/
|
|
818
|
+
ContextBasedAdaptationsAPI.canMigrate = function(mPropertyBag) {
|
|
819
|
+
var oContextBasedAdaptationModel = ContextBasedAdaptationsAPI.getAdaptationsModel(mPropertyBag);
|
|
820
|
+
if (oContextBasedAdaptationModel.getProperty("/count") !== 0) {
|
|
821
|
+
return Promise.resolve(false);
|
|
822
|
+
}
|
|
823
|
+
return FlexObjectState.getFlexObjects({
|
|
824
|
+
selector: mPropertyBag.control,
|
|
825
|
+
invalidateCache: false,
|
|
826
|
+
includeCtrlVariants: true,
|
|
827
|
+
includeDirtyChanges: true
|
|
828
|
+
})
|
|
829
|
+
.then(function (aFlexObjects) {
|
|
830
|
+
// Filter FlexObjects for migration relevant objects
|
|
831
|
+
var aFilteredFlexObjects = [];
|
|
832
|
+
aMigrationLayers.forEach(function(sLayer) {
|
|
833
|
+
aFilteredFlexObjects.push(getObjectsByLayerAndType(aFlexObjects, sLayer, true));
|
|
834
|
+
});
|
|
835
|
+
aFilteredFlexObjects = aFilteredFlexObjects.flat();
|
|
836
|
+
// Old way which has been refactored after 1.115
|
|
837
|
+
var oVariantsMap = FlexState.getVariantsState(ManifestUtils.getFlexReferenceForControl(mPropertyBag.control));
|
|
838
|
+
var aFlVariantsFinalState = Object.keys(oVariantsMap).reduce(function(aPrev, sCurr) {
|
|
839
|
+
return aPrev.concat(oVariantsMap[sCurr].variants);
|
|
840
|
+
}, [])
|
|
841
|
+
.map(function(oEntry) {
|
|
842
|
+
return oEntry.instance;
|
|
843
|
+
});
|
|
844
|
+
return aFilteredFlexObjects.some(function(oFlexObject) {
|
|
845
|
+
var oFinalState = getFinalState(aFlVariantsFinalState, aFlexObjects, oFlexObject);
|
|
846
|
+
|
|
847
|
+
return oFinalState.visible === true && Object.keys(oFinalState.contexts).some(function(sKey) {
|
|
848
|
+
return oFinalState.contexts[sKey].length !== 0;
|
|
849
|
+
});
|
|
850
|
+
});
|
|
851
|
+
});
|
|
852
|
+
};
|
|
853
|
+
|
|
172
854
|
/**
|
|
173
855
|
* Create new context-based adaptation and saves it in the backend
|
|
174
856
|
* @param {object} mPropertyBag - Object with parameters as properties
|
|
@@ -178,10 +860,9 @@ sap.ui.define([
|
|
|
178
860
|
* @param {string} mPropertyBag.contextBasedAdaptation.title - Title of the new adaptation
|
|
179
861
|
* @param {object} mPropertyBag.contextBasedAdaptation.contexts - Contexts of the new adaptation, for example roles for which the adaptation is created
|
|
180
862
|
* @param {object} mPropertyBag.contextBasedAdaptation.priority - Priority of the new adaptation
|
|
181
|
-
* @param {object} mPropertyBag.contextBasedAdaptation.priority - ID of the new adaptation
|
|
182
863
|
* @returns {Promise} Promise that resolves with the context-based adaptation
|
|
183
864
|
*/
|
|
184
|
-
ContextBasedAdaptationsAPI.create = function
|
|
865
|
+
ContextBasedAdaptationsAPI.create = function(mPropertyBag) {
|
|
185
866
|
if (!mPropertyBag.layer) {
|
|
186
867
|
return Promise.reject("No layer was provided");
|
|
187
868
|
}
|
|
@@ -192,17 +873,60 @@ sap.ui.define([
|
|
|
192
873
|
return Promise.reject("No contextBasedAdaptation was provided");
|
|
193
874
|
}
|
|
194
875
|
mPropertyBag.contextBasedAdaptation.id = FlexUtils.createDefaultFileName();
|
|
195
|
-
mPropertyBag.
|
|
196
|
-
|
|
876
|
+
mPropertyBag.appId = getFlexReferenceForControl(mPropertyBag.control);
|
|
877
|
+
|
|
878
|
+
return createContextBasedAdaptation.call(this, mPropertyBag, mPropertyBag.contextBasedAdaptation)
|
|
879
|
+
.then(function() {
|
|
880
|
+
return FlexObjectState.getFlexObjects({
|
|
881
|
+
selector: mPropertyBag.control,
|
|
882
|
+
invalidateCache: false,
|
|
883
|
+
includeCtrlVariants: true,
|
|
884
|
+
includeDirtyChanges: true,
|
|
885
|
+
currentLayer: Layer.CUSTOMER
|
|
886
|
+
});
|
|
887
|
+
}).then(function(aFlexObjects) {
|
|
888
|
+
//currently getFlexObjects contains also VENDOR layer ctrl variant changes which need to be removed before copy
|
|
889
|
+
//TODO refactor when FlexObjectState.getFlexObjects will be refactored
|
|
890
|
+
var aCustomerFlexObjects = LayerUtils.filterChangeOrChangeDefinitionsByCurrentLayer(aFlexObjects, Layer.CUSTOMER);
|
|
891
|
+
var aCopiedChanges = copyVariantsAndChanges(aCustomerFlexObjects, mPropertyBag.contextBasedAdaptation.id);
|
|
892
|
+
return writeChangesToBackend(mPropertyBag, aCopiedChanges);
|
|
893
|
+
});
|
|
894
|
+
};
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* Updates existing context-based adaptation and saves it in the backend
|
|
898
|
+
* @param {object} mPropertyBag - Object with parameters as properties
|
|
899
|
+
* @param {sap.ui.core.Control} mPropertyBag.control - Control for which the request is done
|
|
900
|
+
* @param {string} mPropertyBag.layer - Layer
|
|
901
|
+
* @param {object} mPropertyBag.contextBasedAdaptation - Parameters
|
|
902
|
+
* @param {string} mPropertyBag.contextBasedAdaptation.title - Title of the updated adaptation
|
|
903
|
+
* @param {object} mPropertyBag.contextBasedAdaptation.contexts - Contexts of the updated adaptation, for example roles for which the adaptation is created
|
|
904
|
+
* @param {object} mPropertyBag.contextBasedAdaptation.priority - Priority of the updated adaptation
|
|
905
|
+
* @returns {Promise} Promise that resolves with the context-based adaptation
|
|
906
|
+
*/
|
|
907
|
+
ContextBasedAdaptationsAPI.update = function(mPropertyBag) {
|
|
908
|
+
if (!mPropertyBag.layer) {
|
|
909
|
+
return Promise.reject("No layer was provided");
|
|
910
|
+
}
|
|
911
|
+
if (!mPropertyBag.control) {
|
|
912
|
+
return Promise.reject("No control was provided");
|
|
913
|
+
}
|
|
914
|
+
if (!mPropertyBag.contextBasedAdaptation) {
|
|
915
|
+
return Promise.reject("No contextBasedAdaptation was provided");
|
|
916
|
+
}
|
|
917
|
+
if (!mPropertyBag.adaptationId) {
|
|
918
|
+
return Promise.reject("No adaptationId was provided");
|
|
919
|
+
}
|
|
920
|
+
mPropertyBag.appId = getFlexReferenceForControl(mPropertyBag.control);
|
|
921
|
+
return Storage.contextBasedAdaptation.update({
|
|
197
922
|
layer: mPropertyBag.layer,
|
|
198
923
|
flexObject: mPropertyBag.contextBasedAdaptation,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}.bind(this));
|
|
924
|
+
appId: mPropertyBag.appId,
|
|
925
|
+
adaptationId: mPropertyBag.adaptationId,
|
|
926
|
+
parentVersion: getParentVersion(mPropertyBag)
|
|
927
|
+
}).then(function(oResponse) {
|
|
928
|
+
return handleResponseForVersioning(oResponse, mPropertyBag);
|
|
929
|
+
});
|
|
206
930
|
};
|
|
207
931
|
|
|
208
932
|
/**
|
|
@@ -214,7 +938,7 @@ sap.ui.define([
|
|
|
214
938
|
* @param {string[]} mPropertyBag.parameters.priorities - Priority list
|
|
215
939
|
* @returns {Promise} Promise that resolves with the context-based adaptation
|
|
216
940
|
*/
|
|
217
|
-
ContextBasedAdaptationsAPI.reorder = function
|
|
941
|
+
ContextBasedAdaptationsAPI.reorder = function(mPropertyBag) {
|
|
218
942
|
if (!mPropertyBag.layer) {
|
|
219
943
|
return Promise.reject("No layer was provided");
|
|
220
944
|
}
|
|
@@ -224,43 +948,72 @@ sap.ui.define([
|
|
|
224
948
|
if (!mPropertyBag.parameters || !mPropertyBag.parameters.priorities) {
|
|
225
949
|
return Promise.reject("No valid priority list was provided");
|
|
226
950
|
}
|
|
227
|
-
mPropertyBag.
|
|
951
|
+
mPropertyBag.appId = getFlexReferenceForControl(mPropertyBag.control);
|
|
228
952
|
return Storage.contextBasedAdaptation.reorder({
|
|
229
953
|
layer: mPropertyBag.layer,
|
|
230
954
|
flexObjects: mPropertyBag.parameters,
|
|
231
|
-
|
|
232
|
-
parentVersion:
|
|
233
|
-
}).then(function
|
|
234
|
-
return handleResponseForVersioning(oResponse,
|
|
955
|
+
appId: mPropertyBag.appId,
|
|
956
|
+
parentVersion: getParentVersion(mPropertyBag)
|
|
957
|
+
}).then(function(oResponse) {
|
|
958
|
+
return handleResponseForVersioning(oResponse, mPropertyBag);
|
|
235
959
|
});
|
|
236
960
|
};
|
|
237
961
|
|
|
238
962
|
/**
|
|
239
|
-
* Load list of context-based
|
|
963
|
+
* Load list of context-based adaptations with priority
|
|
240
964
|
* @param {object} mPropertyBag - Object with parameters as properties
|
|
241
965
|
* @param {sap.ui.core.Control} mPropertyBag.control - Control for which the request is done
|
|
242
966
|
* @param {string} mPropertyBag.layer - Layer
|
|
243
967
|
* @returns {Promise<object>} Promise that resolves with the list of context-based adaptations
|
|
244
968
|
*/
|
|
245
|
-
ContextBasedAdaptationsAPI.load = function
|
|
969
|
+
ContextBasedAdaptationsAPI.load = function(mPropertyBag) {
|
|
246
970
|
if (!mPropertyBag.layer) {
|
|
247
971
|
return Promise.reject("No layer was provided");
|
|
248
972
|
}
|
|
249
973
|
if (!mPropertyBag.control) {
|
|
250
974
|
return Promise.reject("No control was provided");
|
|
251
975
|
}
|
|
252
|
-
mPropertyBag.
|
|
976
|
+
mPropertyBag.appId = getFlexReferenceForControl(mPropertyBag.control);
|
|
253
977
|
return Storage.contextBasedAdaptation.load({
|
|
254
978
|
layer: mPropertyBag.layer,
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}).then(function (oAdaptations) {
|
|
979
|
+
appId: mPropertyBag.appId,
|
|
980
|
+
version: getParentVersion(mPropertyBag)
|
|
981
|
+
}).then(function(oAdaptations) {
|
|
259
982
|
if (!oAdaptations) {
|
|
260
983
|
oAdaptations = { adaptations: [] };
|
|
261
984
|
}
|
|
262
985
|
return oAdaptations;
|
|
263
986
|
});
|
|
264
987
|
};
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* Deletes existing context-based adaptation
|
|
991
|
+
* @param {object} mPropertyBag - Object with parameters as properties
|
|
992
|
+
* @param {sap.ui.core.Control} mPropertyBag.control - Control for which the request is done
|
|
993
|
+
* @param {string} mPropertyBag.layer - Layer
|
|
994
|
+
* @param {string} mPropertyBag.appId - Reference of the application
|
|
995
|
+
* @returns {Promise} Promise that resolves with the context-based adaptation
|
|
996
|
+
*/
|
|
997
|
+
ContextBasedAdaptationsAPI.remove = function(mPropertyBag) {
|
|
998
|
+
if (!mPropertyBag.layer) {
|
|
999
|
+
return Promise.reject("No layer was provided");
|
|
1000
|
+
}
|
|
1001
|
+
if (!mPropertyBag.control) {
|
|
1002
|
+
return Promise.reject("No control was provided");
|
|
1003
|
+
}
|
|
1004
|
+
if (!mPropertyBag.adaptationId) {
|
|
1005
|
+
return Promise.reject("No adaptationId was provided");
|
|
1006
|
+
}
|
|
1007
|
+
mPropertyBag.appId = getFlexReferenceForControl(mPropertyBag.control);
|
|
1008
|
+
return Storage.contextBasedAdaptation.remove({
|
|
1009
|
+
layer: mPropertyBag.layer,
|
|
1010
|
+
appId: mPropertyBag.appId,
|
|
1011
|
+
adaptationId: mPropertyBag.adaptationId,
|
|
1012
|
+
parentVersion: getParentVersion(mPropertyBag)
|
|
1013
|
+
}).then(function(oResponse) {
|
|
1014
|
+
return handleResponseForVersioning(oResponse, mPropertyBag, true);
|
|
1015
|
+
});
|
|
1016
|
+
};
|
|
1017
|
+
|
|
265
1018
|
return ContextBasedAdaptationsAPI;
|
|
266
1019
|
});
|