@openui5/sap.ui.mdc 1.111.2 → 1.112.2

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 (167) hide show
  1. package/package.json +4 -4
  2. package/src/sap/ui/mdc/.library +1 -1
  3. package/src/sap/ui/mdc/ActionToolbar.js +1 -1
  4. package/src/sap/ui/mdc/Chart.js +21 -23
  5. package/src/sap/ui/mdc/ChartDelegate.js +1 -1
  6. package/src/sap/ui/mdc/ChartRenderer.js +0 -2
  7. package/src/sap/ui/mdc/Control.js +1 -1
  8. package/src/sap/ui/mdc/Element.js +1 -1
  9. package/src/sap/ui/mdc/Field.js +6 -6
  10. package/src/sap/ui/mdc/FilterBar.js +1 -1
  11. package/src/sap/ui/mdc/FilterBarDelegate.js +0 -37
  12. package/src/sap/ui/mdc/FilterField.js +4 -4
  13. package/src/sap/ui/mdc/Link.js +1 -1
  14. package/src/sap/ui/mdc/MultiValueField.js +1 -1
  15. package/src/sap/ui/mdc/Table.js +3 -11
  16. package/src/sap/ui/mdc/TableDelegate.js +5 -3
  17. package/src/sap/ui/mdc/ValueHelp.js +28 -15
  18. package/src/sap/ui/mdc/actiontoolbar/ActionToolbarAction.js +1 -1
  19. package/src/sap/ui/mdc/chart/ChartImplementationContainer.js +1 -1
  20. package/src/sap/ui/mdc/chart/ChartImplementationContainerRenderer.js +0 -2
  21. package/src/sap/ui/mdc/chart/ChartSelectionDetails.js +1 -1
  22. package/src/sap/ui/mdc/chart/ChartToolbar.js +2 -2
  23. package/src/sap/ui/mdc/chart/ChartTypeButton.js +2 -2
  24. package/src/sap/ui/mdc/chart/PropertyHelper.js +35 -2
  25. package/src/sap/ui/mdc/condition/Condition.js +1 -1
  26. package/src/sap/ui/mdc/condition/ConditionConverter.js +1 -1
  27. package/src/sap/ui/mdc/condition/ConditionModel.js +1 -1
  28. package/src/sap/ui/mdc/condition/FilterConverter.js +1 -1
  29. package/src/sap/ui/mdc/condition/FilterOperatorUtil.js +43 -1
  30. package/src/sap/ui/mdc/condition/Operator.js +1 -1
  31. package/src/sap/ui/mdc/condition/OperatorDynamicDateOption.js +10 -17
  32. package/src/sap/ui/mdc/condition/RangeOperator.js +7 -8
  33. package/src/sap/ui/mdc/field/ConditionType.js +1 -1
  34. package/src/sap/ui/mdc/field/ConditionsType.js +1 -1
  35. package/src/sap/ui/mdc/field/CustomFieldInfo.js +1 -1
  36. package/src/sap/ui/mdc/field/DefineConditionPanel.js +6 -6
  37. package/src/sap/ui/mdc/field/DynamicDateRangeConditionsType.js +49 -62
  38. package/src/sap/ui/mdc/field/FieldBase.js +93 -33
  39. package/src/sap/ui/mdc/field/FieldInfoBase.js +1 -1
  40. package/src/sap/ui/mdc/field/FieldInput.js +1 -1
  41. package/src/sap/ui/mdc/field/FieldInputRenderUtil.js +1 -1
  42. package/src/sap/ui/mdc/field/FieldMultiInput.js +1 -1
  43. package/src/sap/ui/mdc/field/ListFieldHelpItem.js +1 -1
  44. package/src/sap/ui/mdc/field/MultiValueFieldItem.js +1 -1
  45. package/src/sap/ui/mdc/field/TokenDisplay.js +1 -1
  46. package/src/sap/ui/mdc/field/TokenizerDisplay.js +1 -1
  47. package/src/sap/ui/mdc/field/content/DateContent.js +1 -2
  48. package/src/sap/ui/mdc/filterbar/FilterBarBase.js +4 -4
  49. package/src/sap/ui/mdc/filterbar/FilterBarBaseRenderer.js +3 -0
  50. package/src/sap/ui/mdc/filterbar/PropertyHelper.js +1 -1
  51. package/src/sap/ui/mdc/filterbar/p13n/AdaptationFilterBar.js +29 -2
  52. package/src/sap/ui/mdc/filterbar/vh/FilterBar.js +1 -1
  53. package/src/sap/ui/mdc/flexibility/Chart.flexibility.js +1 -1
  54. package/src/sap/ui/mdc/flexibility/FilterBar.flexibility.js +1 -1
  55. package/src/sap/ui/mdc/flexibility/FilterItemFlex.js +1 -1
  56. package/src/sap/ui/mdc/flexibility/GroupFlex.js +56 -9
  57. package/src/sap/ui/mdc/flexibility/SortFlex.js +56 -9
  58. package/src/sap/ui/mdc/flexibility/Util.js +7 -1
  59. package/src/sap/ui/mdc/library.js +108 -2
  60. package/src/sap/ui/mdc/link/ContactDetails.js +1 -1
  61. package/src/sap/ui/mdc/link/ContactDetailsAddressItem.js +1 -1
  62. package/src/sap/ui/mdc/link/ContactDetailsEmailItem.js +1 -1
  63. package/src/sap/ui/mdc/link/ContactDetailsItem.js +1 -1
  64. package/src/sap/ui/mdc/link/ContactDetailsPhoneItem.js +1 -1
  65. package/src/sap/ui/mdc/link/Factory.js +1 -1
  66. package/src/sap/ui/mdc/link/FakeFlpConnector.js +1 -1
  67. package/src/sap/ui/mdc/link/LinkItem.js +1 -1
  68. package/src/sap/ui/mdc/link/Panel.js +1 -1
  69. package/src/sap/ui/mdc/link/PanelItem.js +1 -1
  70. package/src/sap/ui/mdc/link/SemanticObjectMapping.js +1 -1
  71. package/src/sap/ui/mdc/link/SemanticObjectMappingItem.js +1 -1
  72. package/src/sap/ui/mdc/link/SemanticObjectUnavailableAction.js +1 -1
  73. package/src/sap/ui/mdc/messagebundle.properties +15 -0
  74. package/src/sap/ui/mdc/messagebundle_ar.properties +11 -1
  75. package/src/sap/ui/mdc/messagebundle_bg.properties +10 -0
  76. package/src/sap/ui/mdc/messagebundle_ca.properties +10 -0
  77. package/src/sap/ui/mdc/messagebundle_cs.properties +10 -0
  78. package/src/sap/ui/mdc/messagebundle_cy.properties +10 -0
  79. package/src/sap/ui/mdc/messagebundle_da.properties +10 -0
  80. package/src/sap/ui/mdc/messagebundle_de.properties +10 -0
  81. package/src/sap/ui/mdc/messagebundle_el.properties +13 -3
  82. package/src/sap/ui/mdc/messagebundle_en.properties +10 -0
  83. package/src/sap/ui/mdc/messagebundle_en_GB.properties +10 -0
  84. package/src/sap/ui/mdc/messagebundle_en_US_sappsd.properties +10 -0
  85. package/src/sap/ui/mdc/messagebundle_en_US_saprigi.properties +2 -0
  86. package/src/sap/ui/mdc/messagebundle_en_US_saptrc.properties +10 -0
  87. package/src/sap/ui/mdc/messagebundle_es.properties +10 -0
  88. package/src/sap/ui/mdc/messagebundle_es_MX.properties +10 -0
  89. package/src/sap/ui/mdc/messagebundle_et.properties +10 -0
  90. package/src/sap/ui/mdc/messagebundle_fi.properties +10 -0
  91. package/src/sap/ui/mdc/messagebundle_fr.properties +10 -0
  92. package/src/sap/ui/mdc/messagebundle_fr_CA.properties +10 -0
  93. package/src/sap/ui/mdc/messagebundle_hi.properties +10 -0
  94. package/src/sap/ui/mdc/messagebundle_hr.properties +10 -0
  95. package/src/sap/ui/mdc/messagebundle_hu.properties +10 -0
  96. package/src/sap/ui/mdc/messagebundle_id.properties +10 -0
  97. package/src/sap/ui/mdc/messagebundle_it.properties +10 -0
  98. package/src/sap/ui/mdc/messagebundle_iw.properties +10 -0
  99. package/src/sap/ui/mdc/messagebundle_ja.properties +11 -1
  100. package/src/sap/ui/mdc/messagebundle_kk.properties +10 -0
  101. package/src/sap/ui/mdc/messagebundle_ko.properties +10 -0
  102. package/src/sap/ui/mdc/messagebundle_lt.properties +10 -0
  103. package/src/sap/ui/mdc/messagebundle_lv.properties +10 -0
  104. package/src/sap/ui/mdc/messagebundle_ms.properties +10 -0
  105. package/src/sap/ui/mdc/messagebundle_nl.properties +10 -0
  106. package/src/sap/ui/mdc/messagebundle_no.properties +10 -0
  107. package/src/sap/ui/mdc/messagebundle_pl.properties +10 -0
  108. package/src/sap/ui/mdc/messagebundle_pt.properties +10 -0
  109. package/src/sap/ui/mdc/messagebundle_pt_PT.properties +10 -0
  110. package/src/sap/ui/mdc/messagebundle_ro.properties +10 -0
  111. package/src/sap/ui/mdc/messagebundle_ru.properties +10 -0
  112. package/src/sap/ui/mdc/messagebundle_sh.properties +10 -0
  113. package/src/sap/ui/mdc/messagebundle_sk.properties +10 -0
  114. package/src/sap/ui/mdc/messagebundle_sl.properties +10 -0
  115. package/src/sap/ui/mdc/messagebundle_sv.properties +10 -0
  116. package/src/sap/ui/mdc/messagebundle_th.properties +10 -0
  117. package/src/sap/ui/mdc/messagebundle_tr.properties +10 -0
  118. package/src/sap/ui/mdc/messagebundle_uk.properties +15 -5
  119. package/src/sap/ui/mdc/messagebundle_vi.properties +10 -0
  120. package/src/sap/ui/mdc/messagebundle_zh_CN.properties +10 -0
  121. package/src/sap/ui/mdc/messagebundle_zh_TW.properties +10 -0
  122. package/src/sap/ui/mdc/mixin/AdaptationMixin.js +1 -1
  123. package/src/sap/ui/mdc/mixin/DelegateMixin.js +1 -1
  124. package/src/sap/ui/mdc/mixin/FilterIntegrationMixin.js +4 -3
  125. package/src/sap/ui/mdc/mixin/PromiseMixin.js +1 -1
  126. package/src/sap/ui/mdc/mixin/PropertyHelperMixin.js +1 -71
  127. package/src/sap/ui/mdc/odata/v4/TableDelegate.js +7 -0
  128. package/src/sap/ui/mdc/p13n/P13nBuilder.js +382 -376
  129. package/src/sap/ui/mdc/p13n/PropertyHelper.js +1 -1
  130. package/src/sap/ui/mdc/p13n/UIManager.js +1 -1
  131. package/src/sap/ui/mdc/p13n/panels/FilterPanel.js +1 -1
  132. package/src/sap/ui/mdc/p13n/subcontroller/AdaptFiltersController.js +5 -3
  133. package/src/sap/ui/mdc/p13n/subcontroller/ColumnWidthController.js +1 -1
  134. package/src/sap/ui/mdc/p13n/subcontroller/FilterController.js +158 -11
  135. package/src/sap/ui/mdc/p13n/subcontroller/LinkPanelController.js +7 -7
  136. package/src/sap/ui/mdc/p13n/subcontroller/SelectionController.js +1 -1
  137. package/src/sap/ui/mdc/table/ColumnSettings.js +1 -1
  138. package/src/sap/ui/mdc/table/CreationRow.js +1 -1
  139. package/src/sap/ui/mdc/table/GridTableType.js +19 -0
  140. package/src/sap/ui/mdc/table/PropertyHelper.js +1 -1
  141. package/src/sap/ui/mdc/table/ResponsiveColumnSettings.js +1 -1
  142. package/src/sap/ui/mdc/table/RowActionItem.js +1 -1
  143. package/src/sap/ui/mdc/table/RowSettings.js +1 -1
  144. package/src/sap/ui/mdc/table/V4AnalyticsPropertyHelper.js +1 -1
  145. package/src/sap/ui/mdc/table/menu/Item.js +6 -0
  146. package/src/sap/ui/mdc/themes/base/Chart.less +1 -1
  147. package/src/sap/ui/mdc/themes/base/ValueHelpDialog.less +5 -1
  148. package/src/sap/ui/mdc/util/DateUtil.js +84 -95
  149. package/src/sap/ui/mdc/util/InfoBar.js +88 -60
  150. package/src/sap/ui/mdc/util/PromiseCache.js +1 -1
  151. package/src/sap/ui/mdc/util/PropertyHelper.js +5 -1
  152. package/src/sap/ui/mdc/util/TypeUtil.js +6 -3
  153. package/src/sap/ui/mdc/valuehelp/Dialog.js +67 -58
  154. package/src/sap/ui/mdc/valuehelp/Popover.js +19 -1
  155. package/src/sap/ui/mdc/valuehelp/base/Container.js +12 -1
  156. package/src/sap/ui/mdc/valuehelp/base/Content.js +1 -1
  157. package/src/sap/ui/mdc/valuehelp/base/DialogTab.js +1 -1
  158. package/src/sap/ui/mdc/valuehelp/base/FilterableListContent.js +1 -1
  159. package/src/sap/ui/mdc/valuehelp/base/ListContent.js +1 -1
  160. package/src/sap/ui/mdc/valuehelp/content/Bool.js +1 -1
  161. package/src/sap/ui/mdc/valuehelp/content/Conditions.js +1 -1
  162. package/src/sap/ui/mdc/valuehelp/content/FixedList.js +1 -1
  163. package/src/sap/ui/mdc/valuehelp/content/MDCTable.js +1 -1
  164. package/src/sap/ui/mdc/valuehelp/content/MTable.js +6 -8
  165. package/src/sap/ui/mdc/p13n/Engine.js +0 -1200
  166. package/src/sap/ui/mdc/p13n/FlexUtil.js +0 -276
  167. package/src/sap/ui/mdc/p13n/subcontroller/BaseController.js +0 -438
@@ -1,1200 +0,0 @@
1
- /*!
2
- * OpenUI5
3
- * (c) Copyright 2009-2023 SAP SE or an SAP affiliate company.
4
- * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
- */
6
-
7
- sap.ui.define([
8
- "sap/ui/mdc/p13n/AdaptationProvider",
9
- "sap/base/util/merge",
10
- "sap/base/Log",
11
- "sap/ui/mdc/util/PropertyHelper",
12
- "sap/ui/mdc/p13n/modification/FlexModificationHandler",
13
- "sap/m/MessageStrip",
14
- "sap/ui/core/library",
15
- "sap/ui/core/Element",
16
- "sap/ui/mdc/p13n/modules/DefaultProviderRegistry",
17
- "sap/ui/mdc/p13n/UIManager",
18
- "sap/ui/mdc/p13n/modules/StateHandlerRegistry",
19
- "sap/ui/mdc/p13n/modules/xConfigAPI",
20
- "sap/base/util/UriParameters",
21
- "sap/ui/mdc/enum/ProcessingStrategy"
22
- ], function (AdaptationProvider, merge, Log, PropertyHelper, FlexModificationHandler, MessageStrip, coreLibrary, Element, DefaultProviderRegistry, UIManager, StateHandlerRegistry, xConfigAPI, SAPUriParameters, ProcessingStrategy) {
23
- "use strict";
24
-
25
- var ERROR_INSTANCING = "Engine: This class is a singleton. Please use the getInstance() method instead.";
26
-
27
- //Shortcut to 'MessageType'
28
- var MessageType = coreLibrary.MessageType;
29
-
30
- /*global WeakMap */
31
- var _mRegistry = new WeakMap();
32
-
33
- //Singleton storage
34
- var oEngine;
35
-
36
- /**
37
- * Constructor for a new Engine.
38
- *
39
- * The Engine should always be accessed via 'getInstance' and not by creating a new instance of it.
40
- * The class should only be used to create derivations.
41
- *
42
- * @class
43
- * @extends sap.ui.mdc.p13n.AdaptationProvider
44
- *
45
- * @author SAP SE
46
- * @version 1.111.2
47
- *
48
- * @private
49
- * @ui5-restricted sap.ui.mdc
50
- * @experimental
51
- * @since 1.87
52
- * @alias sap.ui.mdc.p13n.Engine
53
- */
54
- var Engine = AdaptationProvider.extend("sap.ui.mdc.p13n.Engine", {
55
- constructor: function() {
56
- AdaptationProvider.call(this);
57
-
58
- if (oEngine) {
59
- throw Error(ERROR_INSTANCING);
60
- }
61
-
62
- this._bDebugMode = new SAPUriParameters(window.location.search).getAll("sap-ui-xx-debugP13n")[0] === "true";
63
-
64
- this._aRegistry = [];
65
- this._aStateHandlers = [];
66
-
67
- //Default Provider Registry to be used for internal PersistenceProvider functionality access
68
- this.defaultProviderRegistry = DefaultProviderRegistry.getInstance(this);
69
-
70
- //UIManager to be used for p13n UI creation
71
- this.uimanager = UIManager.getInstance(this);
72
-
73
- //Default state Handler Registry to be used for state event handling
74
- this.stateHandlerRegistry = StateHandlerRegistry.getInstance();
75
- }
76
- });
77
-
78
- /**
79
- * This method should only be called once per instance to register provided
80
- * classes of <code>sap.ui.mdc.p13n.Controller</code> for the control instance
81
- * @private
82
- * @ui5-restricted sap.ui.mdc
83
- *
84
- * @param {sap.ui.mdc.Control} oControl The control insance to be registered for adaptation
85
- * @param {Object} oConfig The config object providing key value pairs of keys and
86
- * <code>sap.ui.mdc.p13n.Controller</code> classes.
87
- *
88
- * @example
89
- * {
90
- * controller: {
91
- * Item: ColumnController,
92
- * Sort: SortController,
93
- * Filter: FilterController
94
- * }
95
- * }
96
- */
97
- Engine.prototype.registerAdaptation = function(oControl, oConfig) {
98
-
99
- if (!oConfig.hasOwnProperty("controller")) {
100
- throw new Error("Please provide atleast a configuration 'controller' containing a map of key-value pairs (key + Controller class) in order to register adaptation.");
101
- }
102
-
103
- if (this._getRegistryEntry(oControl)){
104
- this.deregisterAdaptation(oControl);
105
- }
106
-
107
- var aControllerKeys = Object.keys(oConfig.controller);
108
-
109
- aControllerKeys.forEach(function(sKey){
110
-
111
- var SubController = oConfig.controller[sKey];
112
-
113
- if (!this.getController(oControl, sKey)) {
114
- if (this._aRegistry.indexOf(oControl.getId()) < 0){
115
- this._aRegistry.push(oControl.getId());
116
- }
117
- var oController = new SubController(oControl);
118
-
119
- this.addController(oController, sKey);
120
- }
121
-
122
- }.bind(this));
123
-
124
- };
125
-
126
- /**
127
- * Deregister a registered control. By deregistering a control the control will
128
- * be removed from the <code>Engine</code> registry and all instance specific sub
129
- * modules such as the registered controllers are going to be destroyed.
130
- *
131
- * @param {sap.ui.mdc.Control} oControl
132
- */
133
- Engine.prototype.deregisterAdaptation = function(oControl) {
134
- var oRegistryEntry = this._getRegistryEntry(oControl);
135
-
136
- //destroy subcontroller
137
- Object.keys(oRegistryEntry.controller).forEach(function(sKey){
138
- var oController = oRegistryEntry.controller[sKey];
139
- oController.destroy();
140
-
141
- delete oRegistryEntry.controller[sKey];
142
- });
143
-
144
- //Remove the control from the weakmap housekeeping
145
- _mRegistry.delete(oControl);
146
-
147
- //Remove the control from the array to maintain debugging
148
- var iControlIndex = this._aRegistry.indexOf(oControl.getId());
149
- this._aRegistry.splice(iControlIndex, 1);
150
- };
151
-
152
- /**
153
- * This method can be used to set the modification handling for a control instance.
154
- * @private
155
- *
156
- * @param {sap.ui.mdc.Control} vControl The registered control instance
157
- * @param {sap.ui.mdc.p13n.modification.ModificationHandler} ModificationHandler The modification handler singleton instance
158
- */
159
- Engine.prototype._setModificationHandler = function(vControl, oModificationHandler) {
160
- if (!oModificationHandler.isA("sap.ui.mdc.p13n.modification.ModificationHandler")) {
161
- throw new Error("Only sap.ui.mdc.p13n.modification.ModificationHandler derivations are allowed for modification");
162
- }
163
- var oModificationSetting = this._determineModification(vControl); //check and calculate modification basics
164
- oModificationSetting.handler = oModificationHandler;
165
- this._getRegistryEntry(vControl).modification = oModificationSetting;
166
- };
167
-
168
- Engine.prototype._addToQueue = function(oControl, fTask) {
169
- var oRegistryEntry = this._getRegistryEntry(oControl);
170
-
171
- var fCleanupPromiseQueue = function(pOriginalPromise) {
172
- if (oRegistryEntry.pendingModification === pOriginalPromise){
173
- oRegistryEntry.pendingModification = null;
174
- }
175
- };
176
-
177
- oRegistryEntry.pendingModification = oRegistryEntry.pendingModification instanceof Promise ? oRegistryEntry.pendingModification.then(fTask) : fTask();
178
- oRegistryEntry.pendingModification.then(fCleanupPromiseQueue.bind(null, oRegistryEntry.pendingModification));
179
-
180
- return oRegistryEntry.pendingModification;
181
- };
182
-
183
- /**
184
- * <code>Engine#createChanges</code> can be used to programmatically trigger the creation
185
- * of a set of changes based on the current control state and the provided state.
186
- * @private
187
- * @ui5-restricted sap.ui.mdc
188
- *
189
- * @param {object} mDiffParameters A map defining the configuration to create the changes.
190
- * @param {sap.ui.mdc.Control} mDiffParameters.control The control instance tht should be adapted.
191
- * @param {string} mDiffParameters.key The key used to retrieve the corresponding Controller.
192
- * @param {object[]|Promise<object[]>} mDiffParameters.state The state which should be applied on the provided control instance
193
- * @param {sap.ui.mdc.p13n.ProcessingStrategy} [mDiffParameters.applyAbsolute] Decides about the diff mode to compare two states
194
- * @param {boolean} [mDiffParameters.stateBefore] In case the state should be diffed manually
195
- * for example if "A" is existing in the control state, but not mentioned in the new state provided in the
196
- * mDiffParameters.state then the absolute appliance decides whether to remove "A" or to keep it.
197
- * @param {boolean} [mDiffParameters.suppressAppliance] Decides whether the change should be applied directly.
198
- * Controller
199
- *
200
- * @returns {Promise} A Promise resolving in the according delta changes.
201
- */
202
- Engine.prototype.createChanges = function(mDiffParameters) {
203
-
204
- var oControl = Engine.getControlInstance(mDiffParameters.control);
205
- var sKey = mDiffParameters.key;
206
- var vNewState = mDiffParameters.state;
207
- var bSuppressCallback = !!mDiffParameters.suppressAppliance;
208
-
209
- if (!sKey || !mDiffParameters.control || !vNewState) {
210
- throw new Error("To create changes via Engine, atleast a 1)Control 2)Key and 3)State needs to be provided.");
211
- }
212
-
213
- var fDeltaHandling = function() {
214
- return this.initAdaptation(oControl, sKey).then(function(){
215
- return vNewState;
216
- })
217
- .then(function(aNewState){
218
- var oController = this.getController(oControl, sKey);
219
- var mChangeOperations = oController.getChangeOperations();
220
-
221
- var oRegistryEntry = this._getRegistryEntry(oControl);
222
- var oCurrentState = oController.getCurrentState();
223
- var oPriorState = merge(oCurrentState instanceof Array ? [] : {}, oCurrentState);
224
-
225
- var mDeltaConfig = {
226
- existingState: mDiffParameters.stateBefore || oPriorState,
227
- applyAbsolute: mDiffParameters.applyAbsolute,
228
- changedState: aNewState,
229
- control: oController.getAdaptationControl(),
230
- changeOperations: mChangeOperations,
231
- deltaAttributes: ["name"],
232
- propertyInfo: oRegistryEntry.helper.getProperties().map(function(a){return {name: a.name};})
233
- };
234
-
235
- //Only execute change calculation in case there is a difference (--> example: press 'Ok' without a difference)
236
- var aChanges = oController.getDelta(mDeltaConfig);
237
-
238
- if (!bSuppressCallback) {
239
- return this._processChanges(oControl, aChanges);
240
- }
241
-
242
- return aChanges || [];
243
- }.bind(this));
244
- }.bind(this);
245
-
246
- return this._addToQueue(oControl, fDeltaHandling);
247
- };
248
-
249
- /**
250
- * This method can be used to trigger a reset on the provided control instance.
251
- * @private
252
- * @ui5-restricted sap.ui.mdc
253
- *
254
- * @param {sap.ui.mdc.Control} oControl The according control instance.
255
- * @param {string} aKeys The key for the affected config.
256
- *
257
- * @returns {Promise} A Promise resolving once the reset is completed.
258
- */
259
- Engine.prototype.reset = function(oControl, aKeys) {
260
-
261
- aKeys = aKeys instanceof Array ? aKeys : [aKeys];
262
-
263
- var aSelectors = [];
264
-
265
- aKeys.forEach(function(sKey) {
266
- aSelectors = aSelectors.concat(this.getController(oControl, sKey).getSelectorForReset());
267
- }.bind(this));
268
-
269
- var oResetConfig = {
270
- selectors: aSelectors,
271
- selector: oControl
272
- };
273
-
274
- var oModificationSetting = this._determineModification(oControl);
275
- return oModificationSetting.handler.reset(oResetConfig, oModificationSetting.payload).then(function(){
276
- //trigger statehandlerregistry notification
277
- this.stateHandlerRegistry.fireChange(oControl);
278
-
279
- //Re-Init housekeeping after update
280
- return this.initAdaptation(oControl, aKeys).then(function(oPropertyHelper){
281
- aKeys.forEach(function(sKey){
282
- var oController = this.getController(oControl, sKey);
283
- oController.update(oPropertyHelper);
284
- }.bind(this));
285
- }.bind(this));
286
- }.bind(this));
287
- };
288
-
289
- /**
290
- * Returns a promise resolving after all currently pending modifications have been applied.
291
- * This method will wait in addition for <code>Engine</code> related promises (retrieving necessary modules, initializing the propertyhelper, etc.) to be fulfilled before resolving.
292
- *
293
- * @private
294
- * @param {sap.ui.mdc.Control} oControl The according control instance.
295
- * @returns {Promise} A Promise resolving after all pending modifications have been applied.
296
- */
297
- Engine.prototype.waitForChanges = function(oControl) {
298
- var oModificationSetting = this._determineModification(oControl);
299
- var oRegistryEntry = this._getRegistryEntry(oControl);
300
- return oRegistryEntry && oRegistryEntry.pendingModification ? oRegistryEntry.pendingModification : Promise.resolve()
301
- .then(function(){
302
- return oModificationSetting.handler.waitForChanges({
303
- element: oControl
304
- }, oModificationSetting.payload);
305
- });
306
- };
307
-
308
- /**
309
- * Determines whether the environment is suitable for the desired modification of the provided control instance.
310
- *
311
- * @private
312
- * @param {sap.ui.mdc.Control} oControl The according control instance.
313
- */
314
- Engine.prototype.isModificationSupported = function(oControl) {
315
- var oModificationSetting = this._determineModification(oControl);
316
- return oModificationSetting.handler.isModificationSupported({
317
- element: oControl
318
- }, oModificationSetting.payload);
319
- };
320
-
321
- /**
322
- * This method can be used to process an array of changes.
323
- * @private
324
- *
325
- * @param {sap.ui.mdc.Control} vControl The registered control instance
326
- * @returns {Promise} The change appliance promise.
327
- */
328
- Engine.prototype._processChanges = function(vControl, aChanges) {
329
- if (aChanges instanceof Array && aChanges.length > 0) {
330
- var oModificationSetting = this._determineModification(vControl);
331
- return oModificationSetting.handler.processChanges(aChanges, oModificationSetting.payload)
332
- .then(function(aChanges){
333
- var oControl = Engine.getControlInstance(vControl);
334
- this.stateHandlerRegistry.fireChange(oControl);
335
- return aChanges;
336
- }.bind(this));
337
- } else {
338
- return Promise.resolve([]);
339
- }
340
- };
341
-
342
- /**
343
- * This method can be used in the control's according designtime metadata
344
- * for keyuser personalization.
345
- * @private
346
- * @ui5-restricted sap.ui.mdc
347
- *
348
- * @param {sap.ui.mdc.Control} oControl The registered control instance.
349
- * @param {object} mPropertyBag The propertybag provided in the settings action.
350
- * @param {string} aKeys The keys to be used to display in the corresponding Controller
351
- *
352
- * @returns {Promise} A Promise resolving in the set of changes to be created during RTA.
353
- */
354
- Engine.prototype.getRTASettingsActionHandler = function (oControl, mPropertyBag, aKeys) {
355
-
356
- var fResolveRTA;
357
-
358
- //var aVMs = Engine.hasForReference(oControl, "sap.ui.fl.variants.VariantManagement");
359
- // TODO: clarify if we need this error handling / what to do with the Link if we want to keep it
360
- var aPVs = Engine.hasForReference(oControl, "sap.ui.mdc.p13n.PersistenceProvider");
361
-
362
- if (aPVs.length > 0 && !oControl.isA("sap.ui.mdc.link.Panel")) {
363
- return Promise.reject("Please do not use a PeristenceProvider in RTA.");
364
- }
365
-
366
- var oOriginalModifHandler = this.getModificationHandler(oControl);
367
- var oTemporaryRTAHandler = new FlexModificationHandler();
368
-
369
- var oRTAPromise = new Promise(function(resolve, reject){
370
- fResolveRTA = resolve;
371
- });
372
-
373
- oTemporaryRTAHandler.processChanges = function(aChanges) {
374
- fResolveRTA(aChanges);
375
- return Promise.resolve(aChanges);
376
- };
377
-
378
- this._setModificationHandler(oControl, oTemporaryRTAHandler);
379
-
380
- this.uimanager.show(oControl, aKeys).then(function(oContainer){
381
- var oCustomHeader = oContainer.getCustomHeader();
382
- if (oCustomHeader) {
383
- oCustomHeader.getContentRight()[0].setVisible(false);
384
- }
385
- oContainer.addStyleClass(mPropertyBag.styleClass);
386
- if (mPropertyBag.fnAfterClose instanceof Function) {
387
- oContainer.attachAfterClose(mPropertyBag.fnAfterClose);
388
- }
389
- });
390
-
391
- oRTAPromise.then(function(){
392
- this._setModificationHandler(oControl, oOriginalModifHandler);
393
- oTemporaryRTAHandler.destroy();
394
- }.bind(this));
395
-
396
- return oRTAPromise;
397
-
398
- };
399
-
400
- /**
401
- * Enhances the xConfig object by using the <code>ModificationHandler</code>
402
- *
403
- * @private
404
- * @ui5-restricted sap.ui.mdc
405
- *
406
- * @param {sap.ui.mdc.Control} vControl The registered control instance.
407
- * @param {object} mEnhanceConfig An object providing the information about the xConfig enhancement
408
- * @param {object} mEnhanceConfig.name The affected property name
409
- * @param {object} mEnhanceConfig.controlMeta Object describing which config is affected
410
- * @param {object} mEnhanceConfig.controlMeta.aggregation The affected aggregation name (such as <code>columns</code> or <code>filterItems</code>)
411
- * @param {object} mEnhanceConfig.controlMeta.property The affected property name (such as <code>width</code> or <code>lable</code>)
412
- * @param {object} mEnhanceConfig.value The value that should be written in the xConfig
413
- * @param {object} [mEnhanceConfig.propertyBag] Optional propertybag for the <code>ModificationHandler</code>
414
- * @returns {Promise} Promise resolving when the XConfig is successfully enhanced
415
- */
416
- Engine.prototype.enhanceXConfig = function(vControl, mEnhanceConfig) {
417
-
418
- var oControl = Engine.getControlInstance(vControl);
419
- var oRegistryEntry = this._getRegistryEntry(vControl);
420
-
421
- return Promise.resolve()
422
- .then(function() {
423
- return xConfigAPI.enhanceConfig(oControl, mEnhanceConfig)
424
- .then(function(oConfig){
425
- if (oRegistryEntry) {
426
- //to simplify debugging
427
- oRegistryEntry.xConfig = oConfig;
428
- }
429
- });
430
- });
431
- };
432
-
433
- /**
434
- * Returns a copy of the xConfig object
435
- *
436
- * @param {sap.ui.core.Element} vControl The according element which should be checked
437
- * @param {object} [mEnhanceConfig] An object providing a modification handler specific payload
438
- * @param {object} [mEnhanceConfig.propertyBag] Optional propertybag for different modification handler derivations
439
- *
440
- * @returns {Promise<object>|object}
441
- * A promise that resolves with the xConfig, the xConfig directly if it is already available, or <code>null</code> if there is no xConfig
442
- */
443
- Engine.prototype.readXConfig = function(vControl, mEnhanceConfig) {
444
-
445
- var oControl = Engine.getControlInstance(vControl);
446
- return xConfigAPI.readConfig(oControl, mEnhanceConfig) || {};
447
- };
448
-
449
- /**
450
- * The Engine is processing state via the internal key registry.
451
- * The external state representation might differ from the internal registration.
452
- * <b>Note:</b> This will only replace the keys to the external StateUtil representation, but not transform the state content itself.
453
- *
454
- * @private
455
- * @param {string|sap.ui.mdc.Control} vControl The registered control instance
456
- * @param {object} oInternalState The internal state
457
- * @returns {object} The externalized state
458
- */
459
- Engine.prototype.externalizeKeys = function(vControl, oInternalState) {
460
- var oExternalState = {};
461
- Object.keys(oInternalState).forEach(function(sInternalKey){
462
- var oController = this.getController(Engine.getControlInstance(vControl), sInternalKey);
463
- if (oController) {
464
- oExternalState[oController.getStateKey()] = oInternalState[sInternalKey];
465
- }
466
- }.bind(this));
467
- return oExternalState;
468
- };
469
-
470
- /**
471
- * The Engine is processing state via the internal key registry.
472
- * The external state representation might differ from the internal registration.
473
- * <b>Note:</b> This will only replace the keys to the internal Engine registry, but not transform the state content itself.
474
- *
475
- * @private
476
- * @param {string|sap.ui.mdc.Control} vControl The registered control instance
477
- * @param {object} oExternalState The external state
478
- * @returns {object} The internalized state
479
- */
480
- Engine.prototype.internalizeKeys = function (vControl, oExternalState) {
481
- var aControllerKeys = this.getRegisteredControllers(vControl), oInternalState = {};
482
- aControllerKeys.forEach(function(sInternalRegistryKey){
483
- var sExternalStateKey = this.getController(vControl, sInternalRegistryKey).getStateKey();
484
- if (oExternalState.hasOwnProperty(sExternalStateKey)) {
485
- oInternalState[sInternalRegistryKey] = oExternalState[sExternalStateKey];
486
- }
487
- }.bind(this));
488
- return oInternalState;
489
- };
490
-
491
- /**
492
- * Apply a State on a control by passing an object that contains the
493
- * registered controller key and an object matching the innter subcontroller housekeeping.
494
- *
495
- * @example {
496
- * ControllerKey: [{<someState>}, {...}]
497
- * }
498
- *
499
- * @param {sap.ui.mdc.Control} oControl The registered control instance
500
- * @param {object} oState The state object
501
- * @param {boolean} bApplyAbsolute Defines whether the state should be an additional delta on the current control state
502
- *
503
- * @returns {Promise} A Promise resolving after the state has been applied
504
- */
505
- Engine.prototype.applyState = function(oControl, oState, bApplyAbsolute) {
506
-
507
- //Call retrieve only to ensure that the control is initialized and enabled for modification
508
- return this.retrieveState(oControl).then(function(oCurrentState){
509
-
510
- var aStatePromise = [], aChanges = [], mInfoState = {};
511
-
512
- if (oControl.validateState instanceof Function) {
513
- mInfoState = oControl.validateState(this.externalizeKeys(oControl, oState));
514
- }
515
-
516
- if (mInfoState.validation === MessageType.Error){
517
- Log.error(mInfoState.message);
518
- }
519
-
520
- Object.keys(oState).forEach(function(sControllerKey){
521
-
522
- var oController = this.getController(oControl, sControllerKey);
523
-
524
- if (!oController){
525
- //TODO: p13nMode <> registerAdaptation <> StateUtil key alignment
526
- return;
527
- }
528
-
529
- var oStatePromise = this.createChanges({
530
- control: oControl,
531
- key: sControllerKey,
532
- state: oController.sanityCheck(oState[sControllerKey]),
533
- suppressAppliance: true,
534
- applyAbsolute: bApplyAbsolute
535
- });
536
-
537
- aStatePromise.push(oStatePromise);
538
- }.bind(this));
539
-
540
- return Promise.all(aStatePromise).then(function(aRawChanges){
541
- aRawChanges.forEach(function(aSpecificChanges){
542
- if (aSpecificChanges && aSpecificChanges.length > 0){
543
- aChanges = aChanges.concat(aSpecificChanges);
544
- }
545
- });
546
-
547
- if (this._bDebugMode) {
548
- Log.info("Engine state appliance for control: \n" + oControl.getId() + "\n\napplied state: \n" + JSON.stringify(oState, null, 2));
549
- }
550
-
551
- return this._processChanges(oControl, aChanges);
552
- }.bind(this));
553
-
554
- }.bind(this));
555
- };
556
-
557
- Engine.prototype.diffState = function(oControl, oOld, oNew) {
558
-
559
- var aDiffCreation = [], oDiffState = {};
560
- oOld = merge({}, oOld);
561
- oNew = merge({}, oNew);
562
-
563
- Object.keys(oNew).forEach(function(sKey){
564
- aDiffCreation.push(this.createChanges({
565
- control: oControl,
566
- stateBefore: oOld[sKey],
567
- state: oNew[sKey],
568
- applyAbsolute: ProcessingStrategy.FullReplace,
569
- key: sKey,
570
- suppressAppliance: true
571
- }));
572
- }.bind(this));
573
- return Promise.all(aDiffCreation)
574
- .then(function(aChanges){
575
- Object.keys(oNew).forEach(function(sKey, i){
576
-
577
- if (oNew[sKey]) {
578
- var aState = this.getController(oControl, sKey).changesToState(aChanges[i], oOld[sKey], oNew[sKey]);
579
- oDiffState[sKey] = aState;
580
- }
581
- }.bind(this));
582
-
583
- return oDiffState;
584
-
585
- }.bind(this));
586
- };
587
-
588
- /**
589
- * Retrieves the externalized state for a given control instance.
590
- * The retrieved state is equivalent to the "getCurrentState" API for the given Control,
591
- * after all necessary changes have been applied (e.g. variant appliance and P13n/StateUtil changes).
592
- * After the returned Promise has been resolved, the returned State is in sync with the according
593
- * state object of the MDC control (for example "filterConditions" for the FilterBar).
594
- *
595
- * @private
596
- * @ui5-restricted sap.ui.mdc
597
- *
598
- * @param {object} oControl The control instance implementing IxState to retrieve the externalized state
599
- *
600
- * @returns {Promise} a Promise resolving in the current control state.
601
- */
602
- Engine.prototype.retrieveState = function(oControl) {
603
-
604
- var bValidInterface = this.checkXStateInterface(oControl);
605
-
606
- if (!bValidInterface){
607
- throw new Error("The control needs to implement the interface IxState.");
608
- }
609
-
610
- //ensure that the control has been initialized
611
- return oControl.initialized().then(function() {
612
-
613
- //ensure that all changes have been applied
614
- return Engine.getInstance().waitForChanges(oControl).then(function() {
615
-
616
- var oRetrievedState = {};
617
- Engine.getInstance().getRegisteredControllers(oControl).forEach(function(sKey){
618
- oRetrievedState[sKey] = Engine.getInstance().getController(oControl, sKey).getCurrentState();
619
- });
620
-
621
- return merge({}, oRetrievedState);
622
-
623
- });
624
-
625
- });
626
-
627
- };
628
-
629
- /**
630
- * This method sanity checks a control for state appliance.
631
- * The according interface is <code>sap.ui.mdc.IxState</code>
632
- * @private
633
- *
634
- * @param {object} oControl The registered control instance
635
- *
636
- * @returns {boolean} Returns true/false depending on the sanity state.
637
- */
638
- Engine.prototype.checkXStateInterface = function(oControl) {
639
-
640
- //check if a control instance is available
641
- if (!oControl) {
642
- return false;
643
- }
644
-
645
- //check if flex is enabled
646
- if (!this.isModificationSupported(oControl)) {
647
- return false;
648
- }
649
-
650
- //check for IxState 'initialized'
651
- if (!oControl.isA("sap.ui.mdc.IxState")) {
652
- return false;
653
- }
654
-
655
- return true;
656
- };
657
-
658
- /**
659
- * This method can be used to initialize the Controller housekeeping.
660
- *
661
- * @private
662
- *
663
- * @param {sap.ui.mdc.Control} vControl The registered control instance
664
- * @param {string|string[]} aKeys The key for the according Controller
665
- * @param {Object[]} aCustomInfo A custom set of propertyinfos as base to create the UI
666
- *
667
- * @returns {Promise} A Promise resolving after the adaptation housekeeping has been initialized.
668
- */
669
- Engine.prototype.initAdaptation = function(vControl, aKeys, aCustomInfo) {
670
- this.verifyController(vControl, aKeys);
671
-
672
- //1) Init property helper
673
- return this._retrievePropertyHelper(vControl, aCustomInfo);
674
-
675
- };
676
-
677
- /**
678
- * This method should only be used to register a new Controller.
679
- *
680
- * @private
681
- *
682
- * @param {sap.ui.mdc.p13n.subcontroller.Controller} oController The controller instance.
683
- * @param {string} sKey The key that defines the later access to the controller instance.
684
- */
685
- Engine.prototype.addController = function(oController, sKey, oPreConfig) {
686
- var oRegistryEntry = this._createRegistryEntry(oController.getAdaptationControl(), oPreConfig);
687
- oRegistryEntry.controller[sKey] = oController;
688
- };
689
-
690
- /**
691
- * This method can be used to get a controller instance.
692
- *
693
- * @private
694
- *
695
- * @param {sap.ui.mdc.Control} vControl The registered Control instance.
696
- * @param {string} sKey The key for which the controller has been registered.
697
- */
698
- Engine.prototype.getController = function(vControl, sKey) {
699
- var oRegistryEntry = this._getRegistryEntry(vControl);
700
-
701
- if (oRegistryEntry && oRegistryEntry.controller.hasOwnProperty(sKey)) {
702
- return oRegistryEntry.controller[sKey];
703
- }
704
- };
705
-
706
- /**
707
- * Verifies the existence of a set of subcontrollers registered for a provided control instance.
708
- *
709
- * @param {sap.ui.mdc.Control} vControl The registered Control instance.
710
- * @param {string|array} vKey A key as string or an array of keys
711
- */
712
- Engine.prototype.verifyController = function(vControl, vKey) {
713
- var aKeys = vKey instanceof Array ? vKey : [vKey];
714
-
715
- aKeys.forEach(function(sKey){
716
- if (!this.getController(vControl, sKey)) {
717
- var oControl = Engine.getControlInstance(vControl);
718
- throw new Error("No controller registered yet for " + oControl.getId() + " and key: " + sKey);
719
- }
720
- }.bind(this));
721
-
722
- };
723
-
724
- /**
725
- * Retrieves the subcontroller UI settings for a provided control instance
726
- * and the set of provided registered keys.
727
- *
728
- * @param {sap.ui.mdc.Control} vControl The registered Control instance.
729
- * @param {string|array} vKeys A key as string or an array of keys
730
- *
731
- * @returns {object} The requested UI settings of the control instance and provided keys
732
- */
733
- Engine.prototype.getUISettings = function(vControl, vKeys) {
734
- var aKeys = Array.isArray(vKeys) ? vKeys : [vKeys];
735
- this.verifyController(vControl, aKeys);
736
- var oPropertyHelper = this._getRegistryEntry(vControl).helper;
737
- var mUiSettings = {};
738
-
739
- aKeys.forEach(function(sKey){
740
- var oController = this.getController(vControl, sKey);
741
- var pAdaptationUI = oController.getAdaptationUI(oPropertyHelper);
742
- //Check faceless controller implementations and skip them
743
-
744
- //TODO: error handling for non promises
745
- if (pAdaptationUI instanceof Promise){
746
- mUiSettings[sKey] = {};
747
- mUiSettings[sKey] = {
748
- resetEnabled: oController.getResetEnabled(),
749
- containerSettings: oController.getUISettings(),
750
- adaptationUI: pAdaptationUI
751
- };
752
- }
753
- }.bind(this));
754
-
755
- return mUiSettings;
756
- };
757
-
758
- /**
759
- * This method can be used to determine if modification settings for a control have already been created.
760
- *
761
- * @private
762
- *
763
- * @param {sap.ui.mdc.Control} vControl The registered Control instance
764
- * @returns {boolean} true if modification settings were already determined
765
- */
766
- Engine.prototype.isRegisteredForModification = function(vControl) {
767
- var oRegistryEntry = this._getRegistryEntry(vControl);
768
- return oRegistryEntry && !!oRegistryEntry.modification;
769
- };
770
-
771
- /**
772
- * Retruns an array of all registered controllers
773
- *
774
- * @param {sap.ui.mdc.Control} vControl The registered Control instance
775
- * @returns {array} An array of all registered controller instances
776
- */
777
- Engine.prototype.getRegisteredControllers = function(vControl){
778
- var oRegistryEntry = this._getRegistryEntry(vControl);
779
- return oRegistryEntry ? Object.keys(oRegistryEntry.controller) : [];
780
- };
781
-
782
- /**
783
- * This method can be used to get the registry entry for a control instance
784
- *
785
- * @private
786
- * @param {sap.ui.mdc.Control} vControl
787
- *
788
- * @returns {object} The according registry entry
789
- */
790
- Engine.prototype._getRegistryEntry = function(vControl) {
791
-
792
- var oControl = Engine.getControlInstance(vControl);
793
- return _mRegistry.get(oControl);
794
-
795
- };
796
-
797
- /**
798
- * This method can be used to get the modification handling for a control instance
799
- *
800
- * @private
801
- * @ui5-restricted sap.ui.mdc
802
- *
803
- * @param {sap.ui.mdc.Control} vControl
804
- *
805
- * @returns {object} The according ModificationHandler.
806
- */
807
- Engine.prototype.getModificationHandler = function(vControl) {
808
- var oModificationSetting = this._determineModification(vControl);
809
-
810
- //This method might also be retrieved by non-registered Controls (such as FilterBarBase) - the default should always be Flex.
811
- return oModificationSetting.handler;
812
-
813
- };
814
-
815
- /**
816
- * This method can be used to create the registry entry for a control instance
817
- *
818
- * @private
819
- * @param {sap.ui.mdc.Control} vControl
820
- *
821
- * @returns {object} The according registry entry
822
- */
823
- Engine.prototype._createRegistryEntry = function(vControl, oPreConfiguration) {
824
-
825
- var oControl = Engine.getControlInstance(vControl);
826
-
827
- if (!_mRegistry.has(oControl)) {
828
-
829
- _mRegistry.set(oControl, {
830
- modification: oPreConfiguration && oPreConfiguration.modification ? oPreConfiguration.modification : null,
831
- controller: {},
832
- activeP13n: null,
833
- helper: null,
834
- xConfig: null,
835
- pendingAppliance: {},
836
- pendingModification: null
837
- });
838
-
839
- }
840
-
841
- return _mRegistry.get(oControl);
842
- };
843
-
844
- Engine.prototype.trace = function(vControl, oChange) {
845
- var oRegistryEntry = this._getRegistryEntry(vControl);
846
- this.getRegisteredControllers(vControl).forEach(function(sKey){
847
- var oController = this.getController(vControl, sKey);
848
- var mChangeOperations = oController.getChangeOperations();
849
- Object.keys(mChangeOperations).forEach(function(sType){
850
- if (mChangeOperations[sType] === oChange.changeSpecificData.changeType) {
851
- oRegistryEntry.pendingAppliance[sKey] = [].concat(oRegistryEntry.pendingAppliance[sKey]).concat(oChange);
852
- }
853
- });
854
- }.bind(this));
855
- };
856
-
857
- Engine.prototype.getTrace = function(vControl, oChange) {
858
- var oRegistryEntry = this._getRegistryEntry(vControl);
859
- return Object.keys(oRegistryEntry.pendingAppliance);
860
- };
861
-
862
- Engine.prototype.clearTrace = function(vControl, oChange) {
863
- var oRegistryEntry = this._getRegistryEntry(vControl);
864
- oRegistryEntry.pendingAppliance = {};
865
- };
866
-
867
- /**
868
- * Determines and registeres the ModificationHandler per control instance
869
- *
870
- * @private
871
- * @param {sap.ui.mdc.Control} vControl
872
- * @returns {object} The according modification registry entry
873
- */
874
- Engine.prototype._determineModification = function (vControl) {
875
-
876
- var oRegistryEntry = this._getRegistryEntry(vControl);
877
-
878
- //Modification setting is only calculated once per control instance
879
- if (oRegistryEntry && oRegistryEntry.modification) {
880
- return oRegistryEntry.modification;
881
- }
882
-
883
- var aPPResults = Engine.hasForReference(vControl, "sap.ui.mdc.p13n.PersistenceProvider");
884
- var aVMResults = Engine.hasForReference(vControl, "sap.ui.fl.variants.VariantManagement");
885
-
886
- var aPersistenceProvider = aPPResults.length ? aPPResults : undefined;
887
- var sHandlerMode = aPersistenceProvider ? aPersistenceProvider[0].getMode() : "Standard";
888
-
889
- var mHandlerMode = {
890
- //During preprocessing, it might be necessary to calculate the modification handler instance
891
- //without an initialized control instance --> use flex as default
892
- undefined: FlexModificationHandler,
893
- Global: FlexModificationHandler,
894
- Transient: FlexModificationHandler,
895
- Standard: FlexModificationHandler,
896
- Auto: FlexModificationHandler
897
- };
898
-
899
- var ModificiationHandler = mHandlerMode[sHandlerMode];
900
-
901
- if (!ModificiationHandler) {
902
- throw new Error("Please provide a valid ModificationHandler! - valid Modification handlers are:" + Object.keys(mHandlerMode));
903
- }
904
-
905
- var oModificationSetting = {
906
- handler: ModificiationHandler.getInstance(),
907
- payload: {
908
- hasVM: aVMResults && aVMResults.length > 0,
909
- hasPP: aPPResults && aPPResults.length > 0,
910
- mode: sHandlerMode
911
- }
912
- };
913
-
914
- if (oRegistryEntry && !oRegistryEntry.modification) {
915
- oRegistryEntry.modification = oModificationSetting;
916
- }
917
-
918
- return oModificationSetting;
919
- };
920
-
921
- Engine.hasForReference = function(vControl, sControlType) {
922
- var sControlId = vControl && vControl.getId ? vControl.getId() : vControl;
923
- var aResults = Element.registry.filter(function (oElement) {
924
- if (!oElement.isA(sControlType)) {
925
- return false;
926
- }
927
- var aFor = oElement.getFor();
928
- for (var n = 0; n < aFor.length; n++) {
929
- if (aFor[n] === sControlId || Engine.hasControlAncestorWithId(sControlId, aFor[n])) {
930
- return true;
931
- }
932
- }
933
- return false;
934
- });
935
- return aResults;
936
- };
937
-
938
- /**
939
- * Determines and registeres the ModificationHandler per control instance
940
- *
941
- * @private
942
- * @param {string} sControlId The control id
943
- * @param {string} sAncestorControlId The control ancestor id
944
- *
945
- * @returns {boolean} Returns whether an according ancestor could be found.
946
- */
947
- Engine.hasControlAncestorWithId = function(sControlId, sAncestorControlId) {
948
- var oControl;
949
-
950
- if (sControlId === sAncestorControlId) {
951
- return true;
952
- }
953
-
954
- oControl = sap.ui.getCore().byId(sControlId);
955
- while (oControl) {
956
- if (oControl.getId() === sAncestorControlId) {
957
- return true;
958
- }
959
-
960
- if (typeof oControl.getParent === "function") {
961
- oControl = oControl.getParent();
962
- } else {
963
- return false;
964
- }
965
- }
966
-
967
- return false;
968
- };
969
-
970
-
971
- /**
972
- * This method can be used to get a control instance by passing either the control
973
- * or the Control's Id.
974
- *
975
- * @private
976
- *
977
- * @param {sap.ui.mdc.Control|string} vControl
978
- * @returns {sap.ui.core.Control} The control instance
979
- */
980
- Engine.getControlInstance = function(vControl) {
981
- return typeof vControl == "string" ? sap.ui.getCore().byId(vControl) : vControl;
982
- };
983
-
984
- /**
985
- * This method can be used to get the active p13n state of a registered Control.
986
- * E.g. the method will return the key of the Controller that is currently being
987
- * used to display a p13n UI.
988
- *
989
- * @private
990
- * @param {sap.ui.mdc.Control} vControl
991
- *
992
- * @returns {boolean} The according flag is the Control has an open P13n container
993
- */
994
- Engine.prototype.hasActiveP13n = function(vControl) {
995
- return !!this._getRegistryEntry(vControl).activeP13n;
996
- };
997
-
998
- /**
999
- * This method can be used to set the active p13n state of a registered Control.
1000
- * E.g. the method will return the key of the Controller that is currently being
1001
- * used to display a p13n UI.
1002
- *
1003
- * @private
1004
- *
1005
- * @param {sap.ui.mdc.Control} vControl The registered control instance.
1006
- * @param {string} sKey The registerd key to get the corresponding Controller.
1007
- */
1008
- Engine.prototype.setActiveP13n = function(vControl, sKey) {
1009
- this._getRegistryEntry(vControl).activeP13n = sKey;
1010
- };
1011
-
1012
- /**
1013
- * Triggers a validation for a certain controller - The method will create a
1014
- * MessageStrip and place it on the according oP13nUI. The BaseController needs
1015
- * to implement <code>BaseController#validateP13n</code>.
1016
- *
1017
- * @private
1018
- *
1019
- * @param {sap.ui.mdc.Control} vControl The registered control instance.
1020
- * @param {string} sKey The registerd key to get the corresponding Controller.
1021
- * @param {sap.ui.core.Control} oP13nUI The adaptation UI displayed in the container (e.g. BasePanel derivation).
1022
- *
1023
- * @returns {object} Object defining the state validation result
1024
- */
1025
- Engine.prototype.validateP13n = function(vControl, sKey, oP13nUI) {
1026
- var oController = this.getController(vControl, sKey);
1027
- var oControl = Engine.getControlInstance(vControl);
1028
-
1029
-
1030
- var mControllers = this._getRegistryEntry(vControl).controller;
1031
- var oTheoreticalState = {};
1032
-
1033
- Object.keys(mControllers).forEach(function(sControllerKey){
1034
- oTheoreticalState[sControllerKey] = mControllers[sControllerKey].getCurrentState();
1035
- });
1036
-
1037
- //Only execeute validation for controllers that support 'model2State'
1038
- if (oController && oController.model2State instanceof Function) {
1039
- oTheoreticalState[sKey] = oController.model2State();
1040
-
1041
- var mInfoState = oControl.validateState(this.externalizeKeys(oControl, oTheoreticalState), sKey);
1042
-
1043
- var oMessageStrip;
1044
-
1045
- if (mInfoState.validation !== MessageType.None) {
1046
- oMessageStrip = new MessageStrip({
1047
- type: mInfoState.validation,
1048
- text: mInfoState.message
1049
- });
1050
- }
1051
-
1052
- if (oP13nUI.setMessageStrip instanceof Function) {
1053
- oP13nUI.setMessageStrip(oMessageStrip);
1054
- } else {
1055
- Log.warning("message strip could not be provided - the adaptation UI needs to implement 'setMessageStrip'");
1056
- }
1057
- return mInfoState;
1058
- } else {
1059
- return undefined;
1060
- }
1061
-
1062
- };
1063
-
1064
- /**
1065
- * Reads the current state of the subcontrollers and triggers a state appliance
1066
- *
1067
- * @param {sap.ui.mdc.Control} oControl The registered Control instance.
1068
- * @param {array} aKeys An array of keys
1069
- * @returns {Promise} A Promise resolving after all p13n changes have been calculated and processed
1070
- */
1071
- Engine.prototype.handleP13n = function(oControl, aKeys) {
1072
-
1073
- var pChanges = [];
1074
-
1075
- aKeys.forEach(function(sControllerKey){
1076
-
1077
- var oController = this.getController(oControl, sControllerKey);
1078
-
1079
- var p = this.createChanges({
1080
- control: oControl,
1081
- key: sControllerKey,
1082
- state: oController.getP13nData(),
1083
- suppressAppliance: true,
1084
- applyAbsolute: ProcessingStrategy.PartialReplace
1085
- })
1086
- .then(function(aItemChanges){
1087
-
1088
- return oController.getBeforeApply().then(function(aChanges){
1089
-
1090
- var aComulatedChanges = aChanges ? aChanges.concat(aItemChanges) : aItemChanges;
1091
- return aComulatedChanges;
1092
-
1093
- });
1094
- });
1095
-
1096
- pChanges.push(p);
1097
- }.bind(this));
1098
-
1099
- return Promise.all(pChanges).then(function(aChangeMatrix){
1100
-
1101
- var aApplyChanges = [];
1102
-
1103
- aChangeMatrix.forEach(function(aTypeChanges){
1104
- aApplyChanges = aApplyChanges.concat(aTypeChanges);
1105
- });
1106
-
1107
- if (aApplyChanges.length > 0) {
1108
- Engine.getInstance()._processChanges(oControl, aApplyChanges);
1109
- }
1110
- });
1111
-
1112
- };
1113
-
1114
- /**
1115
- * This method can be used to retrieve the PropertyHelper for a registered Control.
1116
- *
1117
- * @private
1118
- *
1119
- * @param {sap.ui.mdc.Control} vControl The registered control instance.
1120
- * @param {object[]} [aCustomPropertyInfo] A custom set of propertyinfo.
1121
- *
1122
- */
1123
- Engine.prototype._retrievePropertyHelper = function (vControl, aCustomPropertyInfo) {
1124
-
1125
- var oRegistryEntry = this._getRegistryEntry(vControl);
1126
- var oControl = Engine.getControlInstance(vControl);
1127
-
1128
- if (aCustomPropertyInfo) {
1129
- if (oRegistryEntry.helper) {
1130
- oRegistryEntry.helper.destroy();
1131
- }
1132
- oRegistryEntry.helper = new PropertyHelper(aCustomPropertyInfo);
1133
- return Promise.resolve(oRegistryEntry.helper);
1134
- }
1135
-
1136
- if (oRegistryEntry.helper) {
1137
- return Promise.resolve(oRegistryEntry.helper);
1138
- }
1139
-
1140
- return oControl.initPropertyHelper().then(function (oPropertyHelper) {
1141
- oRegistryEntry.helper = oPropertyHelper;
1142
- return oPropertyHelper;
1143
- }, function (sHelperError) {
1144
- throw new Error(sHelperError);
1145
- });
1146
- };
1147
-
1148
- /**
1149
- * This method is the central point of access to the Engine Singleton.
1150
- *
1151
- * @private
1152
- * @ui5-restricted sap.ui.mdc
1153
- */
1154
- Engine.getInstance = function() {
1155
- if (!oEngine) {
1156
- oEngine = new Engine();
1157
- }
1158
- return oEngine;
1159
- };
1160
-
1161
- /**
1162
- * This method can be used for debugging to retrieve the complete registry.
1163
- *
1164
- * @private
1165
- */
1166
- Engine.prototype._getRegistry = function() {
1167
- var oRegistry = {
1168
- stateHandlerRegistry: this.stateHandlerRegistry,
1169
- defaultProviderRegistry: this.defaultProviderRegistry,
1170
- controlRegistry: {}
1171
- };
1172
-
1173
- this._aRegistry.forEach(function(sKey){
1174
- var oControl = sap.ui.getCore().byId(sKey);
1175
- oRegistry.controlRegistry[sKey] = _mRegistry.get(oControl);
1176
- });
1177
-
1178
- return oRegistry;
1179
- };
1180
-
1181
- /**
1182
- * @override
1183
- * @inheritDoc
1184
- */
1185
- Engine.prototype.destroy = function() {
1186
- AdaptationProvider.prototype.destroy.apply(this, arguments);
1187
- oEngine = null;
1188
- this._aRegistry = null;
1189
- _mRegistry.delete(this);
1190
- this.defaultProviderRegistry.destroy();
1191
- this.defaultProviderRegistry = null;
1192
- this.stateHandlerRegistry.destroy();
1193
- this.stateHandlerRegistry = null;
1194
- this._bDebugMode = null;
1195
- this.uimanager.destroy();
1196
- this.uimanager = null;
1197
- };
1198
-
1199
- return Engine;
1200
- });