@openui5/sap.ui.fl 1.108.0 → 1.109.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 (175) hide show
  1. package/THIRDPARTY.txt +1 -1
  2. package/package.json +3 -3
  3. package/src/sap/ui/fl/.library +1 -1
  4. package/src/sap/ui/fl/Cache.js +4 -4
  5. package/src/sap/ui/fl/ChangePersistence.js +39 -48
  6. package/src/sap/ui/fl/ChangePersistenceFactory.js +1 -1
  7. package/src/sap/ui/fl/FakeLrepConnectorLocalStorage.js +1 -1
  8. package/src/sap/ui/fl/FakeLrepConnectorSessionStorage.js +1 -1
  9. package/src/sap/ui/fl/FakeLrepLocalStorage.js +1 -1
  10. package/src/sap/ui/fl/FlexController.js +26 -26
  11. package/src/sap/ui/fl/FlexControllerFactory.js +6 -5
  12. package/src/sap/ui/fl/LayerUtils.js +3 -3
  13. package/src/sap/ui/fl/Utils.js +68 -274
  14. package/src/sap/ui/fl/apply/_internal/ChangesController.js +17 -2
  15. package/src/sap/ui/fl/apply/_internal/DelegateMediator.js +1 -1
  16. package/src/sap/ui/fl/apply/_internal/changes/Applier.js +2 -2
  17. package/src/sap/ui/fl/apply/_internal/changes/FlexCustomData.js +12 -12
  18. package/src/sap/ui/fl/apply/_internal/changes/Reverter.js +2 -2
  19. package/src/sap/ui/fl/apply/_internal/changes/Utils.js +4 -4
  20. package/src/sap/ui/fl/apply/_internal/changes/descriptor/Applier.js +10 -8
  21. package/src/sap/ui/fl/apply/_internal/changes/descriptor/Preprocessor.js +1 -1
  22. package/src/sap/ui/fl/apply/_internal/changes/descriptor/Registration.js +1 -1
  23. package/src/sap/ui/fl/apply/_internal/changes/descriptor/RegistrationBuild.js +1 -1
  24. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/AddAnnotationsToOData.js +1 -1
  25. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/ChangeDataSource.js +5 -4
  26. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/ChangeInbound.js +1 -1
  27. package/src/sap/ui/fl/apply/_internal/changes/descriptor/app/SetTitle.js +1 -1
  28. package/src/sap/ui/fl/apply/_internal/changes/descriptor/fiori/SetAbstract.js +1 -1
  29. package/src/sap/ui/fl/apply/_internal/changes/descriptor/fiori/SetRegistrationIds.js +1 -1
  30. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ovp/AddNewCard.js +1 -1
  31. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ovp/ChangeCard.js +1 -1
  32. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ovp/DeleteCard.js +1 -1
  33. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddComponentUsages.js +1 -1
  34. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddLibrary.js +1 -1
  35. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddNewModel.js +1 -1
  36. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddNewModelEnhanceWith.js +1 -1
  37. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/SetFlexExtensionPointEnabled.js +1 -1
  38. package/src/sap/ui/fl/apply/_internal/changes/descriptor/ui5/SetMinUI5Version.js +1 -1
  39. package/src/sap/ui/fl/apply/_internal/connectors/ObjectStorageUtils.js +1 -1
  40. package/src/sap/ui/fl/apply/_internal/controlVariants/URLHandler.js +2 -1
  41. package/src/sap/ui/fl/apply/_internal/extensionPoint/Processor.js +1 -1
  42. package/src/sap/ui/fl/apply/_internal/flexObjects/AppDescriptorChange.js +1 -2
  43. package/src/sap/ui/fl/apply/_internal/flexObjects/CompVariant.js +6 -6
  44. package/src/sap/ui/fl/apply/_internal/flexObjects/CompVariantRevertData.js +5 -2
  45. package/src/sap/ui/fl/apply/_internal/flexObjects/ControllerExtensionChange.js +1 -1
  46. package/src/sap/ui/fl/apply/_internal/flexObjects/FlVariant.js +1 -2
  47. package/src/sap/ui/fl/apply/_internal/flexObjects/FlexObject.js +11 -11
  48. package/src/sap/ui/fl/apply/_internal/flexObjects/FlexObjectFactory.js +24 -11
  49. package/src/sap/ui/fl/apply/_internal/flexObjects/RevertData.js +2 -1
  50. package/src/sap/ui/fl/apply/_internal/flexObjects/States.js +19 -4
  51. package/src/sap/ui/fl/apply/_internal/flexObjects/UIChange.js +462 -0
  52. package/src/sap/ui/fl/apply/_internal/flexObjects/UpdatableChange.js +16 -6
  53. package/src/sap/ui/fl/apply/_internal/flexObjects/Variant.js +2 -1
  54. package/src/sap/ui/fl/apply/_internal/flexState/FlexState.js +1 -1
  55. package/src/sap/ui/fl/apply/_internal/flexState/Loader.js +1 -1
  56. package/src/sap/ui/fl/apply/_internal/flexState/ManifestUtils.js +60 -29
  57. package/src/sap/ui/fl/apply/_internal/flexState/UI2Personalization/UI2PersonalizationState.js +1 -1
  58. package/src/sap/ui/fl/apply/_internal/flexState/appDescriptorChanges/prepareAppDescriptorMap.js +3 -3
  59. package/src/sap/ui/fl/apply/_internal/flexState/changes/DependencyHandler.js +7 -7
  60. package/src/sap/ui/fl/apply/_internal/flexState/changes/ExtensionPointState.js +5 -3
  61. package/src/sap/ui/fl/apply/_internal/flexState/changes/prepareChangesMap.js +1 -12
  62. package/src/sap/ui/fl/apply/_internal/flexState/compVariants/CompVariantMerger.js +2 -2
  63. package/src/sap/ui/fl/apply/_internal/flexState/compVariants/prepareCompVariantsMap.js +2 -2
  64. package/src/sap/ui/fl/apply/_internal/flexState/controlVariants/Switcher.js +1 -1
  65. package/src/sap/ui/fl/apply/_internal/flexState/controlVariants/VariantManagementState.js +9 -11
  66. package/src/sap/ui/fl/apply/_internal/flexState/controlVariants/prepareVariantsMap.js +27 -7
  67. package/src/sap/ui/fl/apply/_internal/preprocessors/ControllerExtension.js +1 -1
  68. package/src/sap/ui/fl/apply/_internal/preprocessors/EventHistory.js +1 -1
  69. package/src/sap/ui/fl/apply/_internal/preprocessors/RegistrationDelegator.js +1 -1
  70. package/src/sap/ui/fl/apply/_internal/preprocessors/XmlPreprocessor.js +1 -1
  71. package/src/sap/ui/fl/apply/api/ControlVariantApplyAPI.js +16 -8
  72. package/src/sap/ui/fl/apply/api/SmartVariantManagementApplyAPI.js +10 -46
  73. package/src/sap/ui/fl/changeHandler/AddIFrame.js +4 -4
  74. package/src/sap/ui/fl/changeHandler/AddXML.js +1 -1
  75. package/src/sap/ui/fl/changeHandler/AddXMLAtExtensionPoint.js +1 -1
  76. package/src/sap/ui/fl/changeHandler/Base.js +5 -4
  77. package/src/sap/ui/fl/changeHandler/BaseAddViaDelegate.js +6 -6
  78. package/src/sap/ui/fl/changeHandler/BaseAddXml.js +20 -18
  79. package/src/sap/ui/fl/changeHandler/BaseRename.js +6 -6
  80. package/src/sap/ui/fl/changeHandler/HideControl.js +5 -5
  81. package/src/sap/ui/fl/changeHandler/MoveControls.js +5 -5
  82. package/src/sap/ui/fl/changeHandler/MoveElements.js +2 -2
  83. package/src/sap/ui/fl/changeHandler/PropertyBindingChange.js +2 -2
  84. package/src/sap/ui/fl/changeHandler/PropertyChange.js +2 -2
  85. package/src/sap/ui/fl/changeHandler/StashControl.js +5 -5
  86. package/src/sap/ui/fl/changeHandler/UnhideControl.js +5 -5
  87. package/src/sap/ui/fl/changeHandler/UnstashControl.js +5 -5
  88. package/src/sap/ui/fl/changeHandler/UpdateIFrame.js +4 -4
  89. package/src/sap/ui/fl/changeHandler/common/createIFrame.js +1 -1
  90. package/src/sap/ui/fl/changeHandler/common/getTargetAggregationIndex.js +1 -1
  91. package/src/sap/ui/fl/descriptorRelated/api/DescriptorChangeFactory.js +4 -4
  92. package/src/sap/ui/fl/descriptorRelated/api/DescriptorInlineChangeFactory.js +1 -1
  93. package/src/sap/ui/fl/descriptorRelated/api/DescriptorVariantFactory.js +1 -1
  94. package/src/sap/ui/fl/designtime/variants/VariantManagement.designtime.js +4 -2
  95. package/src/sap/ui/fl/initial/_internal/Storage.js +1 -1
  96. package/src/sap/ui/fl/initial/_internal/StorageUtils.js +1 -14
  97. package/src/sap/ui/fl/initial/_internal/changeHandlers/ChangeHandlerRegistration.js +1 -1
  98. package/src/sap/ui/fl/initial/_internal/changeHandlers/ChangeHandlerStorage.js +2 -2
  99. package/src/sap/ui/fl/initial/_internal/changeHandlers/ChangeRegistryItem.js +1 -1
  100. package/src/sap/ui/fl/initial/_internal/connectors/Utils.js +3 -3
  101. package/src/sap/ui/fl/initial/_internal/storageResultDisassemble.js +3 -3
  102. package/src/sap/ui/fl/interfaces/BaseLoadConnector.js +1 -1
  103. package/src/sap/ui/fl/interfaces/Delegate.js +1 -1
  104. package/src/sap/ui/fl/library.js +43 -43
  105. package/src/sap/ui/fl/support/_internal/getChangeDependencies.js +1 -1
  106. package/src/sap/ui/fl/support/_internal/getFlexSettings.js +1 -1
  107. package/src/sap/ui/fl/support/api/SupportAPI.js +1 -1
  108. package/src/sap/ui/fl/support/apps/contentbrowser/controller/ContentDetails.controller.js +1 -1
  109. package/src/sap/ui/fl/support/apps/contentbrowser/controller/ContentDetailsEdit.controller.js +1 -1
  110. package/src/sap/ui/fl/support/apps/contentbrowser/controller/LayerContentMaster.controller.js +1 -1
  111. package/src/sap/ui/fl/support/apps/contentbrowser/controller/Layers.controller.js +1 -1
  112. package/src/sap/ui/fl/support/apps/contentbrowser/lrepConnector/LRepConnector.js +1 -1
  113. package/src/sap/ui/fl/support/apps/contentbrowser/utils/DataUtils.js +1 -1
  114. package/src/sap/ui/fl/support/apps/contentbrowser/utils/ErrorUtils.js +1 -1
  115. package/src/sap/ui/fl/themes/base/library.source.less +0 -2
  116. package/src/sap/ui/fl/transport/TransportSelection.js +1 -1
  117. package/src/sap/ui/fl/util/DescriptorChangeCheck.js +2 -2
  118. package/src/sap/ui/fl/util/IFrame.js +1 -1
  119. package/src/sap/ui/fl/util/ManagedObjectModel.js +1 -1
  120. package/src/sap/ui/fl/util/changePropertyValueByPath.js +1 -1
  121. package/src/sap/ui/fl/util/resolveBinding.js +1 -1
  122. package/src/sap/ui/fl/variants/VariantManagement.js +38 -7
  123. package/src/sap/ui/fl/variants/VariantModel.js +96 -47
  124. package/src/sap/ui/fl/variants/context/Component.js +0 -1
  125. package/src/sap/ui/fl/variants/context/controller/ContextVisibility.controller.js +1 -0
  126. package/src/sap/ui/fl/write/_internal/SaveAs.js +4 -2
  127. package/src/sap/ui/fl/write/_internal/Storage.js +11 -11
  128. package/src/sap/ui/fl/write/_internal/StorageFeaturesMerger.js +1 -1
  129. package/src/sap/ui/fl/write/_internal/Versions.js +1 -1
  130. package/src/sap/ui/fl/write/_internal/appVariant/AppVariant.js +1 -1
  131. package/src/sap/ui/fl/write/_internal/appVariant/AppVariantFactory.js +1 -1
  132. package/src/sap/ui/fl/write/_internal/appVariant/AppVariantInlineChange.js +1 -1
  133. package/src/sap/ui/fl/write/_internal/appVariant/AppVariantInlineChangeFactory.js +1 -1
  134. package/src/sap/ui/fl/write/_internal/condenser/Condenser.js +28 -26
  135. package/src/sap/ui/fl/write/_internal/condenser/UIReconstruction.js +9 -4
  136. package/src/sap/ui/fl/write/_internal/condenser/classifications/LastOneWins.js +1 -1
  137. package/src/sap/ui/fl/write/_internal/condenser/classifications/Reverse.js +2 -2
  138. package/src/sap/ui/fl/write/_internal/condenser/classifications/Update.js +1 -1
  139. package/src/sap/ui/fl/write/_internal/connectors/BackendConnector.js +1 -1
  140. package/src/sap/ui/fl/write/_internal/connectors/KeyUserConnector.js +4 -2
  141. package/src/sap/ui/fl/write/_internal/connectors/LrepConnector.js +11 -15
  142. package/src/sap/ui/fl/write/_internal/connectors/NeoLrepConnector.js +1 -1
  143. package/src/sap/ui/fl/write/_internal/connectors/ObjectPathConnector.js +1 -1
  144. package/src/sap/ui/fl/write/_internal/connectors/PersonalizationConnector.js +1 -1
  145. package/src/sap/ui/fl/write/_internal/connectors/Utils.js +1 -1
  146. package/src/sap/ui/fl/write/_internal/extensionPoint/Processor.js +1 -1
  147. package/src/sap/ui/fl/write/_internal/extensionPoint/Registry.js +1 -1
  148. package/src/sap/ui/fl/write/_internal/fieldExtensibility/ABAPAccess.js +1 -1
  149. package/src/sap/ui/fl/write/_internal/fieldExtensibility/ABAPExtensibilityVariant.js +1 -1
  150. package/src/sap/ui/fl/write/_internal/fieldExtensibility/ABAPExtensibilityVariantFactory.js +1 -1
  151. package/src/sap/ui/fl/write/_internal/fieldExtensibility/MultiTenantABAPExtensibilityVariant.js +1 -1
  152. package/src/sap/ui/fl/write/_internal/fieldExtensibility/ServiceValidation.js +1 -1
  153. package/src/sap/ui/fl/write/_internal/fieldExtensibility/SingleTenantABAPExtensibilityVariant.js +2 -2
  154. package/src/sap/ui/fl/write/_internal/fieldExtensibility/UriParser.js +1 -1
  155. package/src/sap/ui/fl/write/_internal/fieldExtensibility/Utils.js +1 -1
  156. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/CAPAccess.js +1 -1
  157. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/dialog/CustomFieldCAPDialog.js +1 -1
  158. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/editor/propertyEditor/booleanEditor/BooleanEditor.js +1 -1
  159. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/editor/propertyEditor/rangeEditor/RangeEditor.js +1 -1
  160. package/src/sap/ui/fl/write/_internal/fieldExtensibility/cap/editor/propertyEditor/timeEditor/TimeEditor.js +1 -1
  161. package/src/sap/ui/fl/write/_internal/flexState/FlexObjectState.js +32 -26
  162. package/src/sap/ui/fl/write/_internal/flexState/compVariants/CompVariantState.js +32 -36
  163. package/src/sap/ui/fl/write/_internal/transport/TransportSelection.js +18 -19
  164. package/src/sap/ui/fl/write/_internal/transport/Transports.js +1 -1
  165. package/src/sap/ui/fl/write/api/ChangesWriteAPI.js +6 -6
  166. package/src/sap/ui/fl/write/api/ControlPersonalizationWriteAPI.js +5 -3
  167. package/src/sap/ui/fl/write/api/FieldExtensibility.js +1 -1
  168. package/src/sap/ui/fl/write/api/LocalResetAPI.js +6 -6
  169. package/src/sap/ui/fl/write/api/PersistenceWriteAPI.js +8 -8
  170. package/src/sap/ui/fl/write/api/SmartBusinessWriteAPI.js +4 -4
  171. package/src/sap/ui/fl/write/api/SmartVariantManagementWriteAPI.js +1 -0
  172. package/ui5.yaml +4 -2
  173. package/src/sap/ui/fl/Change.js +0 -1092
  174. package/src/sap/ui/fl/codeExt/CodeExtManager.js +0 -122
  175. package/src/sap/ui/fl/themes/base/VariantManagement.less +0 -97
@@ -1,1092 +0,0 @@
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
-
7
- sap.ui.define([
8
- "sap/base/util/isPlainObject",
9
- "sap/ui/base/ManagedObject",
10
- "sap/ui/core/Core",
11
- "sap/ui/fl/Layer",
12
- "sap/ui/fl/Utils",
13
- "sap/ui/fl/LayerUtils",
14
- "sap/ui/fl/registry/Settings",
15
- "sap/base/Log",
16
- "sap/ui/fl/apply/_internal/appVariant/DescriptorChangeTypes",
17
- "sap/ui/fl/apply/_internal/flexObjects/States",
18
- "sap/base/util/includes",
19
- "sap/base/util/restricted/_isEqual"
20
- ], function (
21
- isPlainObject,
22
- ManagedObject,
23
- Core,
24
- Layer,
25
- Utils,
26
- LayerUtils,
27
- Settings,
28
- Log,
29
- DescriptorChangeTypes,
30
- States,
31
- includes,
32
- _isEqual
33
- ) {
34
- "use strict";
35
-
36
- /**
37
- * Flexibility change class. Stores change content and related information.
38
- *
39
- * @param {object} oFile - File content and admin data
40
- *
41
- * @class sap.ui.fl.Change
42
- * @extends sap.ui.base.ManagedObject
43
- * @private
44
- * @ui5-restricted
45
- * @experimental Since 1.25.0
46
- */
47
- var Change = ManagedObject.extend("sap.ui.fl.Change", /** @lends sap.ui.fl.Change.prototype */ {
48
- constructor: function(oFile) {
49
- ManagedObject.apply(this);
50
-
51
- if (!isPlainObject(oFile)) {
52
- Log.error("Constructor : sap.ui.fl.Change : oFile is not defined");
53
- }
54
-
55
- this._oDefinition = oFile;
56
- this._sRequest = '';
57
- this._bUserDependent = (oFile.layer === Layer.USER);
58
- this._vRevertData = null;
59
- this._aUndoOperations = null;
60
- this._oExtensionPointInfo = null;
61
- this.setState(Change.states.NEW);
62
- this._sPreviousState = null;
63
- this._oChangeProcessedPromise = null;
64
- this.setInitialApplyState();
65
- this._oChangeProcessingPromises = {};
66
- },
67
- metadata: {
68
- properties: {
69
- state: {
70
- type: "string"
71
- },
72
- /**
73
- * Describes the current state of the change regarding the application and reversion of changes.
74
- * To change or retrieve the state, use the getters and setters defined in this class.
75
- * Initially the state is <code>Change.applyState.INITIAL</code>.
76
- */
77
- applyState: {
78
- type: "int"
79
- }
80
- }
81
- }
82
- });
83
-
84
- Change.states = {
85
- NEW: States.NEW,
86
- PERSISTED: States.PERSISTED,
87
- DELETED: States.DELETED,
88
- DIRTY: States.DIRTY
89
- };
90
-
91
- Change.applyState = {
92
- INITIAL: 0,
93
- APPLYING: 1,
94
- APPLY_FINISHED: 2, // Deprecated
95
- REVERTING: 3,
96
- REVERT_FINISHED: 4,
97
- APPLY_SUCCESSFUL: 5,
98
- APPLY_FAILED: 6
99
- };
100
-
101
- Change.operations = {
102
- APPLY: 0,
103
- REVERT: 1
104
- };
105
-
106
- Change.prototype.setState = function(sState) {
107
- var sCurrentState = this.getState();
108
- if (sCurrentState !== sState && this._isValidState(sState)) {
109
- this._sPreviousState = sCurrentState;
110
- this.setProperty("state", sState);
111
- }
112
- return this;
113
- };
114
-
115
- Change.prototype.setQueuedForRevert = function() {
116
- if (this._aQueuedProcesses[this._aQueuedProcesses.length - 1] !== Change.operations.REVERT) {
117
- this._aQueuedProcesses.unshift(Change.operations.REVERT);
118
- }
119
- };
120
-
121
- Change.prototype.isQueuedForRevert = function() {
122
- return this._aQueuedProcesses.indexOf(Change.operations.REVERT) > -1;
123
- };
124
-
125
- Change.prototype.setQueuedForApply = function() {
126
- // Not optimized application code can result that the change applying call twice
127
- // So check if there was already APPLY operation to prevent permanent waitForChangeApplied issue
128
- // Same apply for setQueuedForRevert
129
- if (this._aQueuedProcesses[this._aQueuedProcesses.length - 1] !== Change.operations.APPLY) {
130
- this._aQueuedProcesses.unshift(Change.operations.APPLY);
131
- }
132
- };
133
-
134
- Change.prototype.isQueuedForApply = function() {
135
- return this._aQueuedProcesses.indexOf(Change.operations.APPLY) > -1;
136
- };
137
-
138
- Change.prototype.setInitialApplyState = function() {
139
- this._aQueuedProcesses = [];
140
- delete this._ignoreOnce;
141
- this.setApplyState(Change.applyState.INITIAL);
142
- this._oChangeProcessedPromise = {};
143
- this._oChangeProcessedPromise.promise = new Promise(function(resolve) {
144
- this._oChangeProcessedPromise.resolveFunction = {
145
- resolve: resolve
146
- };
147
- }.bind(this));
148
- };
149
-
150
- Change.prototype.isInInitialState = function() {
151
- return (this._aQueuedProcesses.length === 0) && (this.getApplyState() === Change.applyState.INITIAL);
152
- };
153
-
154
- Change.prototype.isValidForDependencyMap = function() {
155
- //Change without id in selector should be skipped from adding dependencies process
156
- return this.getSelector() && this.getSelector().id;
157
- };
158
-
159
- Change.prototype.startApplying = function() {
160
- this.setApplyState(Change.applyState.APPLYING);
161
- };
162
-
163
- // Deprecated, use markSuccessful or markFailed instead
164
- Change.prototype.markFinished = function(oResult, bApplySuccessful) {
165
- this._aQueuedProcesses.pop();
166
- this._resolveChangeProcessingPromiseWithError(Change.operations.APPLY, oResult);
167
- var sNewApplyState = bApplySuccessful !== false
168
- ? Change.applyState.APPLY_SUCCESSFUL
169
- : Change.applyState.APPLY_FAILED;
170
- this.setApplyState(sNewApplyState);
171
- };
172
-
173
- Change.prototype.markSuccessful = function(oResult) {
174
- this.markFinished(oResult, true);
175
- };
176
-
177
- Change.prototype.markFailed = function(oResult) {
178
- this.markFinished(oResult, false);
179
- };
180
-
181
- Change.prototype.startReverting = function() {
182
- this.setApplyState(Change.applyState.REVERTING);
183
- };
184
-
185
- Change.prototype.markRevertFinished = function(oResult) {
186
- this._aQueuedProcesses.pop();
187
- this._resolveChangeProcessingPromiseWithError(Change.operations.REVERT, oResult);
188
- this.setApplyState(Change.applyState.REVERT_FINISHED);
189
- };
190
-
191
- Change.prototype.hasApplyProcessStarted = function() {
192
- return this.getApplyState() === Change.applyState.APPLYING;
193
- };
194
-
195
- Change.prototype.isSuccessfullyApplied = function() {
196
- return this.getApplyState() === Change.applyState.APPLY_SUCCESSFUL;
197
- };
198
-
199
- Change.prototype.hasApplyProcessFailed = function() {
200
- return this.getApplyState() === Change.applyState.APPLY_FAILED;
201
- };
202
-
203
- Change.prototype.isApplyProcessFinished = function() {
204
- return this.isSuccessfullyApplied() || this.hasApplyProcessFailed();
205
- };
206
-
207
- Change.prototype.hasRevertProcessStarted = function() {
208
- return this.getApplyState() === Change.applyState.REVERTING;
209
- };
210
-
211
- Change.prototype.isRevertProcessFinished = function() {
212
- return this.getApplyState() === Change.applyState.REVERT_FINISHED;
213
- };
214
-
215
- Change.prototype.isCurrentProcessFinished = function() {
216
- return this._aQueuedProcesses.length === 0 && this.getApplyState() !== Change.applyState.INITIAL;
217
- };
218
-
219
- /**
220
- * Adds and returns a promise that resolves as soon as
221
- * <code>resolveChangeProcessingPromise</code> or <code>resolveChangeProcessingPromiseWithError</code> is called.
222
- * The promise will always resolve, either without a parameter or with an object and an <code>error</code> parameter inside.
223
- * At any time, there is only one object for 'apply' or 'revert'. If this function is called multiple times for the same key, only the current promise will be returned.
224
- *
225
- * _oChangeProcessingPromises: {
226
- * Change.operations.APPLY: {
227
- * promise: <Promise>,
228
- * resolveFunction: {}
229
- * },
230
- * Change.operations.REVERT: {
231
- * promise: <Promise>,
232
- * resolveFunction: {}
233
- * }
234
- * }
235
- *
236
- * @param {string} sKey - Current process, should be either <code>Change.operations.APPLY</code> or <code>Change.operations.REVERT</code>
237
- * @returns {Promise} Promise
238
- */
239
- Change.prototype.addChangeProcessingPromise = function(sKey) {
240
- if (!this._oChangeProcessingPromises[sKey]) {
241
- this._oChangeProcessingPromises[sKey] = {};
242
- this._oChangeProcessingPromises[sKey].promise = new Promise(function(resolve) {
243
- this._oChangeProcessingPromises[sKey].resolveFunction = {
244
- resolve: resolve
245
- };
246
- }.bind(this));
247
- }
248
- return this._oChangeProcessingPromises[sKey].promise;
249
- };
250
-
251
- /**
252
- * Calls <code>addChangeProcessingPromise</code> for all currently queued processes.
253
- *
254
- * @returns {Promise[]} Array with all promises for every process
255
- */
256
- Change.prototype.addChangeProcessingPromises = function() {
257
- var aReturn = [];
258
- if (this.getApplyState() === Change.applyState.INITIAL && this._oChangeProcessedPromise) {
259
- aReturn.push(this._oChangeProcessedPromise.promise);
260
- }
261
- this._aQueuedProcesses.forEach(function(sProcess) {
262
- aReturn.push(this.addChangeProcessingPromise(sProcess));
263
- }, this);
264
- return aReturn;
265
- };
266
-
267
- Change.prototype.addPromiseForApplyProcessing = function() {
268
- return this.addChangeProcessingPromise(Change.operations.APPLY);
269
- };
270
-
271
- Change.prototype._resolveChangeProcessingPromiseWithError = function(sKey, oResult) {
272
- if (this._oChangeProcessingPromises[sKey]) {
273
- this._oChangeProcessingPromises[sKey].resolveFunction.resolve(oResult);
274
- delete this._oChangeProcessingPromises[sKey];
275
- }
276
- if (this._oChangeProcessedPromise) {
277
- this._oChangeProcessedPromise.resolveFunction.resolve(oResult);
278
- this._oChangeProcessedPromise = null;
279
- }
280
- };
281
-
282
- /**
283
- * Validates if the new state of the change has a valid value.
284
- * The new state value has to be in the <code>Change.states</code> list.
285
- * Moving a state directly from <code>Change.states.NEW</code> to <code>Change.states.DIRTY</code> is not allowed.
286
- * @param {string} sState - Value of the target state
287
- * @returns {boolean} - <code>true</code> if the new state is valid
288
- * @private
289
- */
290
- Change.prototype._isValidState = function(sState) {
291
- //new state have to be in the Change.states value list
292
- var bStateFound = false;
293
- Object.keys(Change.states).some(function(sKey) {
294
- if (Change.states[sKey] === sState) {
295
- bStateFound = true;
296
- }
297
- return bStateFound;
298
- });
299
- if (!bStateFound) {
300
- return false;
301
- }
302
- //change' state can not move from NEW to DIRTY directly
303
- if ((this.getState() === Change.states.NEW) && (sState === Change.states.DIRTY)) {
304
- return false;
305
- }
306
- return true;
307
- };
308
-
309
- /**
310
- * Returns if the type of the change is <code>variant</code>.
311
- * @returns {boolean} <code>true</code> if the <code>fileType</code> of the change file is a variant
312
- *
313
- * @public
314
- */
315
- Change.prototype.isVariant = function () {
316
- return this.getFileType() === "variant";
317
- };
318
-
319
- /**
320
- * Returns the change type.
321
- *
322
- * @returns {string} Change type of the file, for example <code>LabelChange</code>
323
- * @public
324
- */
325
- Change.prototype.getChangeType = function () {
326
- return this.getDefinition().changeType;
327
- };
328
-
329
- /**
330
- * Returns the file name.
331
- *
332
- * @returns {string} <code>fileName</code> of the file
333
- * @public
334
- */
335
- Change.prototype.getFileName = function () {
336
- return this.getDefinition().fileName;
337
- };
338
-
339
- /**
340
- * Returns the file type.
341
- *
342
- * @returns {string} <code>fileType</code> of the file
343
- * @public
344
- */
345
- Change.prototype.getFileType = function () {
346
- return this.getDefinition().fileType;
347
- };
348
-
349
- /**
350
- * Returns the ABAP package name.
351
- * @returns {string} ABAP package that the change is assigned to
352
- *
353
- * @public
354
- */
355
- Change.prototype.getPackage = function () {
356
- return this.getDefinition().packageName;
357
- };
358
-
359
- /**
360
- * Sets the ABAP package name.
361
- *
362
- * @param {string} sPackage - Package name
363
- *
364
- * @public
365
- */
366
- Change.prototype.setPackage = function (sPackage) {
367
- if (typeof (sPackage) !== "string") {
368
- Log.error("sap.ui.fl.Change.setPackage : sPackage is not defined");
369
- }
370
- this._oDefinition.packageName = sPackage;
371
- };
372
-
373
- /**
374
- * Returns the namespace. The namespace of the change is also the namespace of the change file in the repository.
375
- *
376
- * @returns {string} Namespace of the change file
377
- *
378
- * @public
379
- */
380
- Change.prototype.getNamespace = function () {
381
- return this.getDefinition().namespace;
382
- };
383
-
384
- /**
385
- * Sets the namespace.
386
- *
387
- * @param {string} sNamespace - Namespace of the change file
388
- *
389
- * @public
390
- */
391
- Change.prototype.setNamespace = function (sNamespace) {
392
- this._oDefinition.namespace = sNamespace;
393
- };
394
-
395
- /**
396
- * Returns the name of module which this change refers to (XML or JS).
397
- *
398
- * @returns {string} Module name
399
- *
400
- * @public
401
- */
402
- Change.prototype.getModuleName = function () {
403
- return this.getDefinition().moduleName;
404
- };
405
-
406
- /**
407
- * Sets the module name.
408
- *
409
- * @param {string} sModuleName - Module name of the change file
410
- *
411
- * @public
412
- */
413
- Change.prototype.setModuleName = function (sModuleName) {
414
- this._oDefinition.moduleName = sModuleName;
415
- };
416
-
417
- /**
418
- * Returns the project ID of the change. There might be multiple projects adapting a base application. The project ID helps to see where the change is coming from. If no <code>projectIDid</code> is specified, it is the <code>sap.app/id</code>.
419
- *
420
- * @returns {string} Project ID of the change file
421
- *
422
- * @public
423
- */
424
- Change.prototype.getProjectId = function () {
425
- return this.getDefinition().projectId;
426
- };
427
-
428
- /**
429
- * Returns the ID of the change.
430
- * @returns {string} ID of the change file
431
- *
432
- * @public
433
- */
434
- Change.prototype.getId = function () {
435
- return this.getDefinition().fileName;
436
- };
437
-
438
- /**
439
- * Returns the content section of the change.
440
- * @returns {string} Content of the change file. The content structure can be any JSON.
441
- *
442
- * @public
443
- */
444
- Change.prototype.getContent = function () {
445
- return this.getDefinition().content;
446
- };
447
-
448
- /**
449
- * Sets the object of the content attribute.
450
- *
451
- * @param {object} oContent - Content of the change file. Can be any JSON object.
452
- *
453
- * @public
454
- */
455
- Change.prototype.setContent = function (oContent) {
456
- if (!_isEqual(this._oDefinition.content, oContent)) {
457
- this._oDefinition.content = oContent;
458
- this.setState(Change.states.DIRTY);
459
- }
460
- };
461
-
462
- /**
463
- * Returns the variant reference of the change.
464
- * @returns {string} Variant reference of the change.
465
- *
466
- * @public
467
- */
468
- Change.prototype.getVariantReference = function () {
469
- return this.getDefinition().variantReference || "";
470
- };
471
-
472
- /**
473
- * Sets the variant reference of the change.
474
- *
475
- * @param {object} sVariantReference - Variant reference of the change
476
- *
477
- * @public
478
- */
479
- Change.prototype.setVariantReference = function (sVariantReference) {
480
- this._oDefinition.variantReference = sVariantReference;
481
- this.setState(Change.states.DIRTY);
482
- };
483
-
484
- /**
485
- * Returns the selector from the file content.
486
- * @returns {object} Selector in the following format <code>selectorPropertyName:selectorPropertyValue</code>
487
- *
488
- * @public
489
- */
490
- Change.prototype.getSelector = function () {
491
- return this.getDefinition().selector;
492
- };
493
-
494
- Change.prototype.setSelector = function (oSelector) {
495
- this._oDefinition.selector = oSelector;
496
- };
497
-
498
- /**
499
- * Returns the text in the current language for a given ID.
500
- *
501
- * @param {string} sTextId - Text ID which was used as part of the <code>oTexts</code> object
502
- * @returns {string} The text for the given text ID
503
- *
504
- * @function
505
- */
506
- Change.prototype.getText = function (sTextId) {
507
- if (typeof (sTextId) !== "string") {
508
- Log.error("sap.ui.fl.Change.getTexts : sTextId is not defined");
509
- }
510
- if (this.getDefinition().texts) {
511
- if (this.getDefinition().texts[sTextId]) {
512
- return this.getDefinition().texts[sTextId].value;
513
- }
514
- }
515
- return "";
516
- };
517
-
518
- /**
519
- * Returns all texts.
520
- *
521
- * @returns {object} All texts
522
- *
523
- * @function
524
- */
525
- Change.prototype.getTexts = function () {
526
- if (isPlainObject(this.getDefinition().texts)) {
527
- return Object.assign({}, this.getDefinition().texts);
528
- }
529
- return this.getDefinition().texts;
530
- };
531
-
532
- /**
533
- * Sets the new text for the given text ID or creates new text with the given ID.
534
- *
535
- * @param {string} sTextId - Text ID which was used as part of the <code>oTexts</code> object
536
- * @param {string} sNewText - New text for the given text ID
537
- * @param {string} sType - Translation text type
538
- *
539
- * @public
540
- */
541
- Change.prototype.setText = function (sTextId, sNewText, sType) {
542
- if (typeof (sTextId) !== "string") {
543
- Log.error("sap.ui.fl.Change.setTexts : sTextId is not defined");
544
- return;
545
- }
546
- this._oDefinition.texts = this.getDefinition().texts || {};
547
- if (this._oDefinition.texts) {
548
- if (this._oDefinition.texts[sTextId]) {
549
- this._oDefinition.texts[sTextId].value = sNewText;
550
- } else {
551
- this._oDefinition.texts[sTextId] = {
552
- value: sNewText,
553
- type: sType
554
- };
555
- }
556
- this.setState(Change.states.DIRTY);
557
- }
558
- };
559
-
560
- /**
561
- * Returns the OData Information of the change.
562
- * oDataInformation.propertyName - Name of the OData property
563
- * oDataInformation.entityType - Name of the OData entity type that the property belongs to
564
- * oDataInformation.oDataServiceUri - URI of the OData service
565
- * @returns {object} OData Information of the change - propertyName, entityType and oDataServiceUri
566
- *
567
- * @function
568
- */
569
- Change.prototype.getODataInformation = function () {
570
- return this.getDefinition().oDataInformation;
571
- };
572
-
573
- /**
574
- * Checks if change is read only because of its source system.
575
- * @returns {boolean} <code>true</code> if the change is from another system
576
- *
577
- * @public
578
- */
579
- Change.prototype.isChangeFromOtherSystem = function () {
580
- var sSourceSystem = this._oDefinition.sourceSystem;
581
- var sSourceClient = this._oDefinition.sourceClient;
582
- if (!sSourceSystem || !sSourceClient) {
583
- return false;
584
- }
585
- var oSettings = Settings.getInstanceOrUndef();
586
- if (!oSettings) {
587
- return true; // without settings the right to edit or delete a change cannot be determined
588
- }
589
- var sSystem = oSettings.getSystem();
590
- var sClient = oSettings.getClient();
591
- if (!sSystem || !sClient) {
592
- return false;
593
- }
594
- return (sSourceSystem !== sSystem || sSourceClient !== sClient);
595
- };
596
-
597
-
598
- /**
599
- * Marks the current change to be deleted persistently.
600
- *
601
- * @public
602
- */
603
- Change.prototype.markForDeletion = function () {
604
- this.setState(Change.states.DELETED);
605
- };
606
-
607
- Change.prototype.restorePreviousState = function () {
608
- if (this._sPreviousState) {
609
- this.setState(this._sPreviousState);
610
- delete this._sPreviousState;
611
- }
612
- };
613
-
614
- /**
615
- * Sets the transport request.
616
- *
617
- * @param {string} sRequest - Transport request
618
- *
619
- * @public
620
- */
621
- Change.prototype.setRequest = function (sRequest) {
622
- if (typeof (sRequest) !== "string") {
623
- Log.error("sap.ui.fl.Change.setRequest : sRequest is not defined");
624
- }
625
- this._sRequest = sRequest;
626
- };
627
-
628
- /**
629
- * Gets the transport request.
630
- * @returns {string} Transport request
631
- *
632
- * @public
633
- */
634
- Change.prototype.getRequest = function () {
635
- return this._sRequest;
636
- };
637
-
638
- /**
639
- * Gets the layer type for the change.
640
- * @returns {string} Layer of the change file
641
- *
642
- * @public
643
- */
644
- Change.prototype.getLayer = function () {
645
- return this.getDefinition().layer;
646
- };
647
-
648
- /**
649
- * Gets the component for the change.
650
- * @returns {string} SAPUI5 component that this change is assigned to
651
- *
652
- * @public
653
- */
654
- Change.prototype.getComponent = function () {
655
- return this.getDefinition().reference;
656
- };
657
-
658
- /**
659
- * Sets the component.
660
- *
661
- * @param {string} sComponent - ID of the app or app variant
662
- *
663
- * @public
664
- */
665
- Change.prototype.setComponent = function (sComponent) {
666
- this._oDefinition.reference = sComponent;
667
- };
668
-
669
- /**
670
- * Gets the creation timestamp.
671
- *
672
- * @returns {string} Creation timestamp
673
- *
674
- * @public
675
- */
676
- Change.prototype.getCreation = function () {
677
- return this.getDefinition().creation;
678
- };
679
-
680
- /**
681
- * Sets the creation timestamp.
682
- *
683
- * @param {string} sCreation creation timestamp
684
- *
685
- * @public
686
- */
687
- Change.prototype.setCreation = function (sCreation) {
688
- this._oDefinition.creation = sCreation;
689
- };
690
-
691
- /**
692
- * Returns <code>true</code> if the change is user dependent
693
- * @returns {boolean} <code>true</code> if the change is only relevant for the current user
694
- *
695
- * @public
696
- */
697
- Change.prototype.isUserDependent = function () {
698
- return (this._bUserDependent);
699
- };
700
-
701
- /**
702
- * Gets the JSON definition of the change.
703
- * @returns {object} Content of the change file
704
- *
705
- * @public
706
- */
707
- Change.prototype.getDefinition = function () {
708
- return this._oDefinition;
709
- };
710
-
711
- // temporary function
712
- Change.prototype.convertToFileContent = function() {
713
- return this.getDefinition();
714
- };
715
-
716
- /**
717
- * Sets the response from the back end after the change is saved.
718
- * @param {object} oResponse - Content of the change file
719
- *
720
- * @public
721
- */
722
- Change.prototype.setResponse = function (oResponse) {
723
- var sResponse = JSON.stringify(oResponse);
724
- if (sResponse) {
725
- this._oDefinition = JSON.parse(sResponse);
726
- this.setState(Change.states.PERSISTED);
727
- }
728
- };
729
-
730
- /**
731
- * Adds the selector to the dependent selector list.
732
- *
733
- * @param {(string|sap.ui.core.Control|string[]|sap.ui.core.Control[])} vControl - SAPUI5 control, or ID string, or array of SAPUI5 controls, for which the selector should be determined
734
- * @param {string} sAlias - Alias under which the dependent object is saved
735
- * @param {object} mPropertyBag - Property bag
736
- * @param {sap.ui.core.util.reflection.BaseTreeModifier} mPropertyBag.modifier - Modifier for the controls
737
- * @param {sap.ui.core.Component} [mPropertyBag.appComponent] - Application component; only needed if <code>vControl</code> is a string or an XML node
738
- * @param {object} [mAdditionalSelectorInformation] - Additional mapped data which is added to the selector
739
- *
740
- * @throws {Exception} oException If <code>sAlias</code> already exists
741
- * @public
742
- */
743
- Change.prototype.addDependentControl = function (vControl, sAlias, mPropertyBag, mAdditionalSelectorInformation) {
744
- if (!vControl) {
745
- throw new Error("Parameter vControl is mandatory");
746
- }
747
- if (!sAlias) {
748
- throw new Error("Parameter sAlias is mandatory");
749
- }
750
- if (!mPropertyBag) {
751
- throw new Error("Parameter mPropertyBag is mandatory");
752
- }
753
-
754
- if (!this._oDefinition.dependentSelector) {
755
- this._oDefinition.dependentSelector = {};
756
- }
757
-
758
- if (this._oDefinition.dependentSelector[sAlias]) {
759
- throw new Error("Alias '" + sAlias + "' already exists in the change.");
760
- }
761
-
762
- var oModifier = mPropertyBag.modifier;
763
- var oAppComponent = mPropertyBag.appComponent;
764
-
765
- if (Array.isArray(vControl)) {
766
- var aSelector = [];
767
- vControl.forEach(function (oControl) {
768
- aSelector.push(oModifier.getSelector(oControl, oAppComponent, mAdditionalSelectorInformation));
769
- });
770
- this._oDefinition.dependentSelector[sAlias] = aSelector;
771
- } else {
772
- this._oDefinition.dependentSelector[sAlias] = oModifier.getSelector(vControl, oAppComponent, mAdditionalSelectorInformation);
773
- }
774
-
775
- //remove dependency list so that it will be created again in method getDependentSelectorList
776
- delete this._aDependentSelectorList;
777
- };
778
-
779
- /**
780
- * Returns the control or array of controls saved under the passed alias.
781
- *
782
- * @param {string} sAlias - Retrieves the selectors that have been saved under this alias
783
- * @param {object} mPropertyBag - Property bag
784
- * @param {sap.ui.core.util.reflection.BaseTreeModifier} mPropertyBag.modifier - Modifier for the controls
785
- * @param {sap.ui.core.Component} mPropertyBag.appComponent - Application component needed to retrieve the control from the selector
786
- * @param {Node} mPropertyBag.view - For XML processing: XML node of the view
787
- *
788
- * @returns {array|object} Dependent selector list in <code>selectorPropertyName:selectorPropertyValue</code> format, or the selector saved under the alias
789
- *
790
- * @public
791
- */
792
- Change.prototype.getDependentControl = function (sAlias, mPropertyBag) {
793
- var aDependentControls = [];
794
- var oDependentSelector;
795
- if (!sAlias) {
796
- throw new Error("Parameter sAlias is mandatory");
797
- }
798
- if (!mPropertyBag) {
799
- throw new Error("Parameter mPropertyBag is mandatory");
800
- }
801
-
802
- var oModifier = mPropertyBag.modifier;
803
- var oAppComponent = mPropertyBag.appComponent;
804
-
805
- if (!this._oDefinition.dependentSelector) {
806
- return undefined;
807
- }
808
-
809
- oDependentSelector = this._oDefinition.dependentSelector[sAlias];
810
- if (Array.isArray(oDependentSelector)) {
811
- oDependentSelector.forEach(function (oSelector) {
812
- aDependentControls.push(oModifier.bySelector(oSelector, oAppComponent, mPropertyBag.view));
813
- });
814
- return aDependentControls;
815
- }
816
-
817
- return oModifier.bySelector(oDependentSelector, oAppComponent, mPropertyBag.view);
818
- };
819
-
820
- /**
821
- * Returns the 'originalSelector' from the dependent selectors. This is only set in case of changes on a template.
822
- *
823
- * @returns {sap.ui.fl.selector} the original selector if available
824
- */
825
- Change.prototype.getOriginalSelector = function() {
826
- return this.getDefinition().dependentSelector && this.getDefinition().dependentSelector.originalSelector;
827
- };
828
-
829
- /**
830
- * Gets the dependent selector.
831
- *
832
- * @returns {object|undefined} Dependent selector object if available
833
- */
834
- Change.prototype.getDependentSelector = function() {
835
- return this.getDefinition().dependentSelector;
836
- };
837
-
838
- /**
839
- * Sets the dependent selector.
840
- *
841
- * @param {object} oDependentSelector Dependent selector
842
- */
843
- Change.prototype.setDependentSelector = function(oDependentSelector) {
844
- this._oDefinition.dependentSelector = oDependentSelector;
845
- };
846
-
847
- /**
848
- * Returns all dependent selectors, including the selector from the selector of the change.
849
- *
850
- * @returns {array} Dependent selector list
851
- * @public
852
- */
853
- Change.prototype.getDependentSelectorList = function () {
854
- var that = this;
855
- var aDependentSelectors = [this.getSelector()];
856
-
857
- if (!this._aDependentSelectorList) {
858
- if (this.getDefinition().dependentSelector) {
859
- Object.keys(this.getDefinition().dependentSelector).some(function(sAlias) {
860
- // if there is an 'originalSelector' as dependent the change is made inside a template; this means that the
861
- // dependent selectors point to the specific clones of the template; those clones don't go through the
862
- // propagation listener and will never be cleaned up from the dependencies, thus blocking the JS Change Applying
863
- // therefore all the dependents have to be ignored and the dependents reset to the initial state (only selector)
864
- if (sAlias === "originalSelector") {
865
- aDependentSelectors = [this.getSelector()];
866
- return true;
867
- }
868
- var aCurrentSelector = that.getDefinition().dependentSelector[sAlias];
869
- if (!Array.isArray(aCurrentSelector)) {
870
- aCurrentSelector = [aCurrentSelector];
871
- }
872
-
873
- aCurrentSelector.forEach(function(oCurrentSelector) {
874
- if (oCurrentSelector && Utils.indexOfObject(aDependentSelectors, oCurrentSelector) === -1) {
875
- aDependentSelectors.push(oCurrentSelector);
876
- }
877
- });
878
- }.bind(this));
879
- }
880
- this._aDependentSelectorList = aDependentSelectors;
881
- }
882
-
883
- return this._aDependentSelectorList;
884
- };
885
-
886
- /**
887
- * Returns a list of selectors of the controls that the change depends on, excluding the selector of the change.
888
- *
889
- * @returns {array} List of selectors that the change depends on
890
- * @public
891
- */
892
- Change.prototype.getDependentControlSelectorList = function () {
893
- var aDependentSelectors = this.getDependentSelectorList().concat();
894
-
895
- if (aDependentSelectors.length > 0) {
896
- var oSelector = this.getSelector();
897
- var iIndex = Utils.indexOfObject(aDependentSelectors, oSelector);
898
- if (iIndex > -1) {
899
- aDependentSelectors.splice(iIndex, 1);
900
- }
901
- }
902
-
903
- return aDependentSelectors;
904
- };
905
-
906
- /**
907
- * Returns the revert-specific data.
908
- *
909
- * @returns {*} Revert-specific data
910
- * @public
911
- */
912
- Change.prototype.getRevertData = function() {
913
- if (isPlainObject(this._vRevertData)) {
914
- return Object.assign({}, this._vRevertData);
915
- }
916
- return this._vRevertData;
917
- };
918
-
919
- /**
920
- * Checks if the change has revert data and returns a boolean;
921
- * For falsy revert data also true is returned.
922
- *
923
- * @returns {boolean} Returns wheather the change has revert data
924
- */
925
- Change.prototype.hasRevertData = function() {
926
- return this._vRevertData !== null;
927
- };
928
-
929
- /**
930
- * Sets the revert-specific data.
931
- *
932
- * @param {*} vData - Revert-specific data
933
- * @public
934
- */
935
- Change.prototype.setRevertData = function(vData) {
936
- if (vData === undefined) {
937
- throw new Error("Change cannot be applied in XML as revert data is not available yet. Retrying in JS.");
938
- }
939
- this._vRevertData = vData;
940
- };
941
-
942
- /**
943
- * Resets the revert-specific data.
944
- * @public
945
- */
946
- Change.prototype.resetRevertData = function() {
947
- this.setRevertData(null);
948
- };
949
-
950
-
951
- /**
952
- * Gets the extension point information.
953
- * @returns {*} Extension point information
954
- */
955
- Change.prototype.getExtensionPointInfo = function() {
956
- if (isPlainObject(this._oExtensionPointInfo)) {
957
- return Object.assign({}, this._oExtensionPointInfo);
958
- }
959
- return this._oExtensionPointInfo;
960
- };
961
-
962
- /**
963
- * Sets the extension point information.
964
- * @param {*} oExtensionPointInfo Extension point information
965
- */
966
- Change.prototype.setExtensionPointInfo = function(oExtensionPointInfo) {
967
- this._oExtensionPointInfo = oExtensionPointInfo;
968
- };
969
-
970
- /**
971
- * Gets the support information.
972
- * @returns {object} Support information
973
- */
974
- Change.prototype.getSupportInformation = function() {
975
- return Object.assign({}, this._oDefinition.support);
976
- };
977
-
978
- /**
979
- * Sets the support information.
980
- * @param {object} oChangeSupportInformation Support information
981
- */
982
- Change.prototype.setSupportInformation = function(oChangeSupportInformation) {
983
- this._oDefinition.support = oChangeSupportInformation;
984
- };
985
-
986
- /**
987
- * Gets the JSOnly property.
988
- * @returns {boolean} True if the change is JSOnly
989
- */
990
- Change.prototype.getJsOnly = function() {
991
- return this.getDefinition().jsOnly;
992
- };
993
-
994
- /**
995
- * Sets the JSOnly property.
996
- * @param {boolean} bJsOnly Value to be set
997
- */
998
- Change.prototype.setJsOnly = function(bJsOnly) {
999
- this._oDefinition.jsOnly = bJsOnly;
1000
- };
1001
-
1002
- /**
1003
- * Returns the appDescriptorChange flag.
1004
- * @returns {boolean} True if the change is an appDescriptor change
1005
- */
1006
- Change.prototype.isAppDescriptorChange = function() {
1007
- return this.getDefinition().appDescriptorChange;
1008
- };
1009
-
1010
- /**
1011
- * Creates and returns an instance of a change instance.
1012
- *
1013
- * @param {object} [oPropertyBag] - Property bag
1014
- * @param {string} [oPropertyBag.service] - Name of the OData service
1015
- * @param {string} [oPropertyBag.changeType] - Type of the change
1016
- * @param {object} [oPropertyBag.texts] - Map object with all referenced texts within the file; these texts will be connected to the translation process
1017
- * @param {object} [oPropertyBag.content] - Content of the new change
1018
- * @param {boolean} [oPropertyBag.isVariant] - Indicates whether the change is a variant
1019
- * @param {string} [oPropertyBag.packageName] - ABAP package name
1020
- * @param {object} [oPropertyBag.selector] - Name-value pair of the attribute and value
1021
- * @param {string} [oPropertyBag.id] - Name/ID of the file; if it's not set, it's created implicitly
1022
- * @param {boolean} [oPropertyBag.isVariant] - Name of the component
1023
- * @param {boolean} [oPropertyBag.isUserDependent] - <code>true</code> in case of end user changes
1024
- * @param {object} [oPropertyBag.dependentSelector] - List of selectors saved under an alias for creating the dependencies between changes
1025
- * @param {string} [oPropertyBag.reference] - Application component name
1026
- * @param {string} [oPropertyBag.namespace] - Namespace of the change file
1027
- * @param {string} [oPropertyBag.projectId] - Project ID of the change file
1028
- * @param {string} [oPropertyBag.moduleName] - Name of the module which this changes refers to (XML or JS)
1029
- * @param {string} [oPropertyBag.generator] - Tool that is used to generate the change file
1030
- * @param {boolean} [oPropertyBag.jsOnly] - Indicates that the change can only be applied with the JS modifier
1031
- * @param {object} [oPropertyBag.oDataInformation] - Object with information about the oData service
1032
- * @param {string} [oPropertyBag.oDataInformation.propertyName] - Name of the OData property
1033
- * @param {string} [oPropertyBag.oDataInformation.entityType] - Name of the OData entity type that the property belongs to
1034
- * @param {string} [oPropertyBag.oDataInformation.oDataServiceUri] - URI of the OData service
1035
- * @param {string} [oPropertyBag.variantReference] - Variant reference of a change belonging to a variant
1036
- * @param {string} [oPropertyBag.support.sourceChangeFileName] - File name of the source change in case of a copied change
1037
- * @param {string} [oPropertyBag.support.compositeCommand] - Unique ID that defines which changes belong together in a composite command
1038
- *
1039
- * @returns {object} Content of the change file
1040
- *
1041
- * @public
1042
- */
1043
- Change.createInitialFileContent = function (oPropertyBag) {
1044
- if (!oPropertyBag) {
1045
- oPropertyBag = {};
1046
- }
1047
-
1048
- var sFileType;
1049
- if (oPropertyBag.fileType) {
1050
- sFileType = oPropertyBag.fileType;
1051
- } else {
1052
- sFileType = oPropertyBag.isVariant ? "variant" : "change";
1053
- }
1054
-
1055
- var oNewFile = {
1056
- fileName: oPropertyBag.id || Utils.createDefaultFileName(oPropertyBag.changeType),
1057
- fileType: sFileType,
1058
- changeType: oPropertyBag.changeType || "",
1059
- moduleName: oPropertyBag.moduleName || "",
1060
- reference: oPropertyBag.reference || "",
1061
- packageName: oPropertyBag.packageName || "",
1062
- content: oPropertyBag.content || {},
1063
- // TODO: Is an empty selector allowed?
1064
- selector: oPropertyBag.selector || { id: "" },
1065
- layer: oPropertyBag.layer || (oPropertyBag.isUserDependent ? Layer.USER : LayerUtils.getCurrentLayer()),
1066
- texts: oPropertyBag.texts || {},
1067
- namespace: oPropertyBag.namespace || Utils.createNamespace(oPropertyBag, sFileType), //TODO: we need to think of a better way to create namespaces from Adaptation projects.
1068
- projectId: oPropertyBag.projectId || (oPropertyBag.reference && oPropertyBag.reference.replace(".Component", "")) || "",
1069
- creation: "",
1070
- originalLanguage: Utils.getCurrentLanguage() || "",
1071
- support: {
1072
- generator: oPropertyBag.generator || "Change.createInitialFileContent",
1073
- service: oPropertyBag.service || "",
1074
- user: "",
1075
- sapui5Version: Core.getConfiguration().getVersion().toString(),
1076
- sourceChangeFileName: oPropertyBag.support && oPropertyBag.support.sourceChangeFileName || "",
1077
- compositeCommand: oPropertyBag.support && oPropertyBag.support.compositeCommand || "",
1078
- command: oPropertyBag.command || oPropertyBag.support && oPropertyBag.support.command || ""
1079
- },
1080
- oDataInformation: oPropertyBag.oDataInformation || {},
1081
- dependentSelector: oPropertyBag.dependentSelector || {},
1082
- jsOnly: oPropertyBag.jsOnly || false,
1083
- variantReference: oPropertyBag.variantReference || "",
1084
- // since not all storage implementations know about all app descriptor change types, we store a flag if this change type changes a descriptor
1085
- appDescriptorChange: includes(DescriptorChangeTypes.getChangeTypes(), oPropertyBag.changeType)
1086
- };
1087
-
1088
- return oNewFile;
1089
- };
1090
-
1091
- return Change;
1092
- }, true);