@sapui5/sap.suite.ui.generic.template 1.136.13 → 1.136.15

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 (44) hide show
  1. package/package.json +1 -1
  2. package/src/sap/suite/ui/generic/template/.library +1 -1
  3. package/src/sap/suite/ui/generic/template/AnalyticalListPage/i18n/i18n_it.properties +2 -2
  4. package/src/sap/suite/ui/generic/template/AnalyticalListPage/manifest.json +1 -1
  5. package/src/sap/suite/ui/generic/template/Canvas/manifest.json +1 -1
  6. package/src/sap/suite/ui/generic/template/ListReport/controller/ControllerImplementation.js +93 -12
  7. package/src/sap/suite/ui/generic/template/ListReport/controller/IappStateHandler.js +19 -9
  8. package/src/sap/suite/ui/generic/template/ListReport/i18n/i18n_it.properties +1 -1
  9. package/src/sap/suite/ui/generic/template/ListReport/manifest.json +1 -1
  10. package/src/sap/suite/ui/generic/template/ListReport/view/fragments/SmartChart.fragment.xml +2 -1
  11. package/src/sap/suite/ui/generic/template/ListReport/view/fragments/SmartTable.fragment.xml +3 -2
  12. package/src/sap/suite/ui/generic/template/ObjectPage/controller/ControllerImplementation.js +5 -2
  13. package/src/sap/suite/ui/generic/template/ObjectPage/controller/RelatedAppsHandler.js +19 -27
  14. package/src/sap/suite/ui/generic/template/ObjectPage/i18n/i18n_cnr.properties +1 -1
  15. package/src/sap/suite/ui/generic/template/ObjectPage/i18n/i18n_mk.properties +1 -1
  16. package/src/sap/suite/ui/generic/template/ObjectPage/i18n/i18n_pt.properties +1 -1
  17. package/src/sap/suite/ui/generic/template/ObjectPage/i18n/i18n_sh.properties +1 -1
  18. package/src/sap/suite/ui/generic/template/ObjectPage/i18n/i18n_sr.properties +1 -1
  19. package/src/sap/suite/ui/generic/template/ObjectPage/manifest.json +1 -1
  20. package/src/sap/suite/ui/generic/template/ObjectPage/view/fragments/SmartChart.fragment.xml +3 -2
  21. package/src/sap/suite/ui/generic/template/ObjectPage/view/fragments/SmartTable.fragment.xml +3 -2
  22. package/src/sap/suite/ui/generic/template/QuickCreate/manifest.json +1 -1
  23. package/src/sap/suite/ui/generic/template/QuickView/manifest.json +1 -1
  24. package/src/sap/suite/ui/generic/template/designtime/floorplans/ObjectPage.designtime.js +6 -1
  25. package/src/sap/suite/ui/generic/template/genericUtilities/ControlStateWrapperFactory.js +101 -67
  26. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/DynamicPageWrapper.js +19 -51
  27. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/ObjectPageLayoutWrapper.js +10 -32
  28. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/PreliminaryWrapper.js +144 -0
  29. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SearchFieldWrapper.js +8 -30
  30. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartFilterBarWrapper.js +49 -162
  31. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartTableChartCommon.js +99 -93
  32. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartTableWrapper.js +22 -3
  33. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartVariantManagementWrapper.js +82 -75
  34. package/src/sap/suite/ui/generic/template/lib/AppComponent.js +1 -1
  35. package/src/sap/suite/ui/generic/template/lib/ContextMenuHandler.js +9 -0
  36. package/src/sap/suite/ui/generic/template/lib/PageLeaveHandler.js +36 -8
  37. package/src/sap/suite/ui/generic/template/lib/i18n/i18n_fi.properties +2 -2
  38. package/src/sap/suite/ui/generic/template/lib/i18n/i18n_id.properties +1 -1
  39. package/src/sap/suite/ui/generic/template/lib/i18n/i18n_it.properties +1 -1
  40. package/src/sap/suite/ui/generic/template/lib/i18n/i18n_nl.properties +1 -1
  41. package/src/sap/suite/ui/generic/template/lib/i18n/i18n_uk.properties +1 -1
  42. package/src/sap/suite/ui/generic/template/lib/i18n/i18n_zh_CN.properties +1 -1
  43. package/src/sap/suite/ui/generic/template/lib/navigation/NavigationController.js +10 -25
  44. package/src/sap/suite/ui/generic/template/library.js +1 -1
@@ -8,18 +8,19 @@ sap.ui.define([
8
8
  "sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/DynamicPageWrapper",
9
9
  "sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartVariantManagementWrapper",
10
10
  "sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/ObjectPageLayoutWrapper",
11
- "sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SearchFieldWrapper"
11
+ "sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SearchFieldWrapper",
12
+ "sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/PreliminaryWrapper"
12
13
  ], function (BaseObject, extend, controlHelper, SmartFilterBarWrapper, SmartTableWrapper, SmartChartWrapper,
13
- DynamicPageWrapper, SmartVariantManagementWrapper, ObjectPageLayoutWrapper, SearchFieldWrapper) {
14
+ DynamicPageWrapper, SmartVariantManagementWrapper, ObjectPageLayoutWrapper, SearchFieldWrapper, PreliminaryWrapper) {
14
15
  "use strict";
15
-
16
+
16
17
  /**
17
18
  * Dummy wrapper for not existing or not (yet) supported controls (either not carrying a state or to be added in future). Also used as interface description for wrapper classes.
18
19
  */
19
20
  var oDummyWrapper = {
20
21
  /**
21
22
  * Retrieve the current state of the control
22
- *
23
+ *
23
24
  * @return {object} serializable json object describing the current state of the control. Will be provided to setState exactly the same when restoring the state. Note: Structure of this object
24
25
  * is up to the wrapper, no one outside will rely on it - with one exception: legacyStateHandler translates legacy states (without clear separation per control) to this format. Open:
25
26
  * Should legacyStateHandler be responsible for providing most current version, or only first control specific version (i.e. first version using wrapper), and wrapper should be
@@ -28,7 +29,7 @@ sap.ui.define([
28
29
  getState: Function.prototype,
29
30
  /**
30
31
  * Restore the control to the given state
31
- *
32
+ *
32
33
  * @param {object} oState json object describing the state as provided by getState. Note: can also be undefined, if an old state is restored (from a release where the state of this control was
33
34
  * not stored), if a state is provided in the URL that cannot be read (anymore), or on OP in discovery mode, if the user navigates to a new object instance - in these cases, the
34
35
  * control has to be brought (back) into its initial state. Currently, expectation is the state to be restored synchronously. Planned:
@@ -40,13 +41,13 @@ sap.ui.define([
40
41
  * wrapper must provide an event to indicate a state change. Must be called whenever a user interacts with the control to change its state, but not when state is changed programmatically (e.g.
41
42
  * from setState, or when user interacts with a different control causing also this one to change (in that case, the event from the other control should be called) Function to register for that
42
43
  * event
43
- *
44
+ *
44
45
  * @param {function} fnHandler event handler function being attached
45
46
  */
46
47
  attachStateChanged: Function.prototype,
47
48
  /**
48
49
  * Function to deregister from event. Currently not used, but should be provided for symmetry reasons.
49
- *
50
+ *
50
51
  * @param {function} fnHandler event handler function being attached. Should only be deregistered, if provided exactly like in registration
51
52
  */
52
53
  detachStateChanged: Function.prototype,
@@ -57,7 +58,7 @@ sap.ui.define([
57
58
 
58
59
  /**
59
60
  * Returns true if the state provided as argument is same as the state applied.
60
- * @param {Object} oState State object which needs to be checked against the current
61
+ * @param {Object} oState State object which needs to be checked against the current
61
62
  * state of the wrapper.
62
63
  * @returns {boolean} True in case State object passed as argument match with current state else false.
63
64
  */
@@ -90,15 +91,65 @@ sap.ui.define([
90
91
  };
91
92
  return extend({}, oWrapper, oOverride);
92
93
  }
93
-
94
+
95
+ /**
96
+ * Private helper function to create the real wrapper based on control and type.
97
+ * This function is injected into PreliminaryWrapper and not exposed in the factory's public API.
98
+ *
99
+ * @param {sap.ui.core.Control} oControl - The control instance
100
+ * @param {string} sType - The type of control (e.g., "SmartTable", "SmartChart")
101
+ * @param {object} [mParams] - Additional parameters passed to constructor of wrapper
102
+ * @return {object} The real wrapper object for the control with helper methods attached
103
+ */
104
+ function fnCreateRealWrapper(oControl, sType, mParams) {
105
+ var oWrapper;
106
+ switch (sType) {
107
+ case "SmartFilterBar":
108
+ oWrapper = new SmartFilterBarWrapper(oControl, oFactory, mParams);
109
+ break;
110
+ case "SmartTable":
111
+ oWrapper = new SmartTableWrapper(oControl, oController, oFactory);
112
+ break;
113
+ case "SmartChart":
114
+ oWrapper = new SmartChartWrapper(oControl, oController, oFactory);
115
+ break;
116
+ case "DynamicPage":
117
+ oWrapper = new DynamicPageWrapper(oControl);
118
+ break;
119
+ case "SmartVariantManagement":
120
+ oWrapper = new SmartVariantManagementWrapper(oControl, oController, oFactory, mParams);
121
+ break;
122
+ case "ObjectPageLayout":
123
+ oWrapper = new ObjectPageLayoutWrapper(oControl);
124
+ break;
125
+ case "SearchField":
126
+ oWrapper = new SearchFieldWrapper(oControl);
127
+ break;
128
+ default:
129
+ // control not carrying a state or no wrapper built yet
130
+ oWrapper = oDummyWrapper;
131
+ }
132
+
133
+ // Add helper methods to the real wrapper
134
+ var sId = oController.getView().getLocalId(oControl.getId());
135
+ oWrapper.getLocalId = function() { return sId; };
136
+ oWrapper.isCurrentState = oWrapper.isCurrentState || function (oState) {
137
+ return JSON.stringify(oState) === JSON.stringify(oWrapper.getState());
138
+ };
139
+
140
+ return oWrapper;
141
+ }
142
+
94
143
  var oFactory = {
95
144
  getSuppressChangeEventWhenApplyingWrapper: getSuppressChangeEventWhenApplyingWrapper,
145
+
96
146
  /**
97
- * Factory function to generate control wrapper object based on control type
98
- *
147
+ * Factory function to generate control wrapper object based on control type.
148
+ * Always returns a PreliminaryWrapper, which delegates to the real wrapper internally.
149
+ *
99
150
  * @param {sap.ui.core.Control} oControl - control a wrapper should be provided for
100
151
  * @param {object} [mParams] - map with any additional parameters passed to constructor of wrapper
101
- * @return {object} wrapper object for the control
152
+ * @return {object} wrapper object for the control (always a PreliminaryWrapper)
102
153
  */
103
154
  getControlStateWrapper: function (oControl, mParams) {
104
155
  // checking for control here (instead of at all callers) allows simple use for optional controls
@@ -107,52 +158,63 @@ sap.ui.define([
107
158
  // no need to add the dummy to the map
108
159
  return oDummyWrapper;
109
160
  }
110
- var sId = oController.getView().getLocalId(oControl.getId());
161
+ var sId = oController.getView().getLocalId(oControl.getId());
162
+
111
163
  if (!mWrappers[sId]) {
112
- var oWrapper;
164
+ // Determine control type
165
+ var sType;
113
166
  switch (true) {
114
167
  case controlHelper.isSmartFilterBar(oControl):
115
- oWrapper = new SmartFilterBarWrapper(oControl, oFactory, mParams);
168
+ sType = "SmartFilterBar";
116
169
  break;
117
170
  case controlHelper.isSmartTable(oControl):
118
- oWrapper = new SmartTableWrapper(oControl, oController, oFactory);
171
+ sType = "SmartTable";
119
172
  break;
120
173
  case controlHelper.isSmartChart(oControl):
121
- oWrapper = new SmartChartWrapper(oControl, oController, oFactory);
174
+ sType = "SmartChart";
122
175
  break;
123
176
  case controlHelper.isDynamicPage(oControl):
124
- oWrapper = new DynamicPageWrapper(oControl);
177
+ sType = "DynamicPage";
125
178
  break;
126
179
  case controlHelper.isSmartVariantManagement(oControl):
127
- oWrapper = new SmartVariantManagementWrapper(oControl, oController, oFactory, mParams);
180
+ sType = "SmartVariantManagement";
128
181
  break;
129
182
  case controlHelper.isObjectObjectPageLayout(oControl):
130
- oWrapper = new ObjectPageLayoutWrapper(oControl);
183
+ sType = "ObjectPageLayout";
131
184
  break;
132
185
  case controlHelper.isSearchField(oControl):
133
- oWrapper = new SearchFieldWrapper(oControl);
186
+ sType = "SearchField";
134
187
  break;
135
188
  default:
136
- // control not carrying a state or no wrapper build yet
137
- oWrapper = oDummyWrapper;
189
+ // control not carrying a state or no wrapper built yet
190
+ return oDummyWrapper;
138
191
  }
139
- oWrapper.getLocalId = function() { return sId; };
140
- oWrapper.isCurrentState = oWrapper.isCurrentState || function (oState) {
141
- return JSON.stringify(oState) === JSON.stringify(oWrapper.getState());
142
- };
143
-
144
- mWrappers[sId] = oWrapper;
192
+
193
+ // Always create a PreliminaryWrapper
194
+ var oPreliminaryWrapper = new PreliminaryWrapper(sId, sType, fnCreateRealWrapper, oController, mParams);
195
+
196
+ // Since control is available, immediately set it
197
+ oPreliminaryWrapper.setControl(oControl);
198
+
199
+ // Store the PreliminaryWrapper in map (not the real wrapper)
200
+ mWrappers[sId] = oPreliminaryWrapper;
201
+ } else if (mWrappers[sId].setControl) {
202
+ // PreliminaryWrapper already exists but control wasn't set yet - set it now
203
+ mWrappers[sId].setControl(oControl);
145
204
  }
205
+
146
206
  return mWrappers[sId];
147
207
  },
148
208
 
149
209
  /**
150
- * Factory function to generate control wrapper object based on control type
151
- *
152
- * @param {string} sId - Id of the control for which wrapper needs to be initiated
210
+ * Factory function to generate control wrapper object based on control ID and type.
211
+ * Creates a PreliminaryWrapper when the control doesn't exist yet (e.g., lazy loading).
212
+ * Always returns a PreliminaryWrapper, which delegates to the real wrapper internally.
213
+ *
214
+ * @param {string} sControlId - ID of the control for which wrapper needs to be initiated
153
215
  * @param {string} sControlType - Type of the control for which wrapper needs to be initiated
154
216
  * @param {object} [mParams] - map with any additional parameters passed to constructor of wrapper
155
- * @return {object} wrapper object for the control
217
+ * @return {object} wrapper object for the control (always a PreliminaryWrapper)
156
218
  */
157
219
  getControlStateWrapperById: function (sControlId, sControlType, mParams) {
158
220
  // checking for control here (instead of at all callers) allows simple use for optional controls
@@ -161,40 +223,12 @@ sap.ui.define([
161
223
  // no need to add the dummy to the map
162
224
  return oDummyWrapper;
163
225
  }
164
- var sId = oController.getView().getLocalId(sControlId);
226
+ var sId = oController.getView().getLocalId(sControlId);
165
227
  if (!mWrappers[sId]) {
166
- var oWrapper;
167
- switch (sControlType) {
168
- case "SmartFilterBar":
169
- oWrapper = new SmartFilterBarWrapper(sControlId, oFactory, mParams);
170
- break;
171
- case "SmartTable":
172
- oWrapper = new SmartTableWrapper(sControlId, oController, oFactory);
173
- break;
174
- case "SmartChart":
175
- oWrapper = new SmartChartWrapper(sControlId, oController, oFactory);
176
- break;
177
- case "DynamicPage":
178
- oWrapper = new DynamicPageWrapper();
179
- break;
180
- case "SmartVariantManagement":
181
- oWrapper = new SmartVariantManagementWrapper(sControlId, oController, oFactory, mParams);
182
- break;
183
- case "ObjectPageLayout":
184
- oWrapper = new ObjectPageLayoutWrapper(sControlId);
185
- break;
186
- case "SearchField":
187
- oWrapper = new SearchFieldWrapper(sControlId);
188
- break;
189
- default:
190
- // control not carrying a state or no wrapper build yet
191
- oWrapper = oDummyWrapper;
192
- }
193
- oWrapper.getLocalId = function() { return sId; };
194
- oWrapper.isCurrentState = oWrapper.isCurrentState || function (oState) {
195
- return JSON.stringify(oState) === JSON.stringify(oWrapper.getState());
196
- };
197
- mWrappers[sId] = oWrapper;
228
+ // Create a PreliminaryWrapper (control will be set later)
229
+ var oPreliminaryWrapper = new PreliminaryWrapper(sId, sControlType, fnCreateRealWrapper, oController, mParams);
230
+
231
+ mWrappers[sId] = oPreliminaryWrapper;
198
232
  }
199
233
  return mWrappers[sId];
200
234
  }
@@ -207,4 +241,4 @@ sap.ui.define([
207
241
  extend(this, getMethods(oController));
208
242
  }
209
243
  });
210
- });
244
+ });
@@ -2,67 +2,35 @@ sap.ui.define([
2
2
  ], function() {
3
3
  "use strict";
4
4
 
5
- function DynamicPageWrapper(vTarget) {
6
- var oDynamicPage;
7
- var oPreliminaryState;
8
- var oControlAssignedResolve;
9
- var oControlAssignedPromise = new Promise(function(resolve) {
10
- oControlAssignedResolve = resolve;
11
- });
12
-
13
- if (typeof vTarget !== "string") {
14
- fnSetControl(vTarget);
15
- }
16
-
5
+ function DynamicPageWrapper(oDynamicPage) {
17
6
  // Returns the state of the dynamic page
18
- // Right now we only consider the pinned status of the dynamic page header
7
+ // Right now we only consider the pinned status of the dynamic page header
19
8
  function fnGetState() {
20
- if (oDynamicPage) {
21
- var oControlState = {};
22
- oControlState.headerPinned = oDynamicPage.getHeaderPinned();
23
- return oControlState;
24
- }
25
-
26
- return oPreliminaryState;
9
+ var oControlState = {};
10
+ oControlState.headerPinned = oDynamicPage.getHeaderPinned();
11
+ return oControlState;
27
12
  }
28
13
 
29
14
  function fnSetState(oState) {
30
- // Store the state till the control is initialized
31
- oPreliminaryState = oState;
32
- oControlAssignedPromise.then(function() {
33
- if (oPreliminaryState && oPreliminaryState.headerPinned) {
34
- // There is a possibility that the header is collapsed at this point. Make sure it is expanded if we know the header is to be pinned.
35
- oDynamicPage.setHeaderExpanded(true);
36
- oDynamicPage.setHeaderPinned(true);
37
- } else {
38
- oDynamicPage.setHeaderPinned(false);
39
- }
40
- });
15
+ if (oState && oState.headerPinned) {
16
+ // There is a possibility that the header is collapsed at this point. Make sure it is expanded if we know the header is to be pinned.
17
+ oDynamicPage.setHeaderExpanded(true);
18
+ oDynamicPage.setHeaderPinned(true);
19
+ } else {
20
+ oDynamicPage.setHeaderPinned(false);
21
+ }
41
22
  }
42
23
 
43
24
  function fnAttachStateChanged(fnHandler) {
44
- oControlAssignedPromise.then(function() {
45
- oDynamicPage.attachPinnedStateChange(fnHandler);
46
- });
47
- }
48
-
49
- function fnSetControl(oControl) {
50
- oDynamicPage = oControl;
51
- oControlAssignedResolve(oDynamicPage);
52
- }
53
-
54
- function fnSetHeaderState(oController, bHeaderToBeExpanded) {
55
- oController.getOwnerComponent().getModel("_templPriv").setProperty("/listReport/isHeaderExpanded", bHeaderToBeExpanded);
25
+ oDynamicPage.attachPinnedStateChange(fnHandler);
56
26
  }
57
27
 
58
- return {
59
- getState: fnGetState,
60
- setState: fnSetState,
61
- setControl: fnSetControl,
62
- attachStateChanged: fnAttachStateChanged,
63
- setHeaderState: fnSetHeaderState
64
- };
28
+ return {
29
+ getState: fnGetState,
30
+ setState: fnSetState,
31
+ attachStateChanged: fnAttachStateChanged
32
+ };
65
33
  }
66
34
 
67
35
  return DynamicPageWrapper;
68
- });
36
+ });
@@ -2,57 +2,35 @@ sap.ui.define([
2
2
  ], function() {
3
3
  "use strict";
4
4
 
5
- function ObjectPageLayoutWrapper(vTarget) {
6
- var oObjectPageLayout, oControlAssignedResolve, oPreliminaryState;
7
- var oControlAssignedPromise = new Promise(function(resolve) {
8
- oControlAssignedResolve = resolve;
9
- });
10
-
11
- if (typeof vTarget !== "string") {
12
- fnSetControl(vTarget);
13
- }
5
+ function ObjectPageLayoutWrapper(oControl) {
6
+ var oObjectPageLayout = oControl;
14
7
 
15
8
  // Returns the state of the ObjectPageLayout
16
- // Right now we only consider the pinned status of the ObjectPageLayout
9
+ // Right now we only consider the pinned status of the ObjectPageLayout
17
10
  function fnGetObjectPageLayoutState() {
18
- if (!oObjectPageLayout) {
19
- return oPreliminaryState;
20
- }
21
-
22
11
  var oControlState = {};
23
12
  oControlState.headerPinned = oObjectPageLayout.getHeaderContentPinned();
24
13
  return oControlState;
25
14
  }
26
15
 
27
16
  function fnSetObjectPageLayoutState(oState) {
28
- oPreliminaryState = oState;
29
- oControlAssignedPromise.then(function() {
30
- if (oPreliminaryState && oPreliminaryState.headerPinned) {
31
- oObjectPageLayout.setHeaderContentPinned(true);
32
- } else {
33
- oObjectPageLayout.setHeaderContentPinned(false);
34
- }
35
- });
17
+ if (oState && oState.headerPinned) {
18
+ oObjectPageLayout.setHeaderContentPinned(true);
19
+ } else {
20
+ oObjectPageLayout.setHeaderContentPinned(false);
21
+ }
36
22
  }
37
23
 
38
24
  function fnAttachStateChanged(fnHandler) {
39
- oControlAssignedPromise.then(function() {
40
- oObjectPageLayout.attachHeaderContentPinnedStateChange(fnHandler);
41
- });
42
- }
43
-
44
- function fnSetControl(oControl) {
45
- oObjectPageLayout = oControl;
46
- oControlAssignedResolve(oObjectPageLayout);
25
+ oObjectPageLayout.attachHeaderContentPinnedStateChange(fnHandler);
47
26
  }
48
27
 
49
28
  return {
50
29
  getState: fnGetObjectPageLayoutState,
51
30
  setState: fnSetObjectPageLayoutState,
52
- setControl: fnSetControl,
53
31
  attachStateChanged: fnAttachStateChanged
54
32
  };
55
33
  }
56
34
 
57
35
  return ObjectPageLayoutWrapper;
58
- });
36
+ });
@@ -0,0 +1,144 @@
1
+ sap.ui.define([
2
+ ], function() {
3
+ "use strict";
4
+
5
+ /**
6
+ * PreliminaryWrapper - Acts as a proxy wrapper before the real control is available.
7
+ *
8
+ * This wrapper is created when a control state wrapper is requested by ID and type,
9
+ * but the actual control instance doesn't exist yet (e.g., due to lazy loading on ObjectPage).
10
+ * It stores state operations and event handler registrations, then transfers them to the
11
+ * real wrapper once the control is assigned via setControl().
12
+ *
13
+ * @param {string} sId - The local ID of the control
14
+ * @param {string} sType - The type of the control (e.g., "SmartTable", "SmartChart")
15
+ * @param {function} fnCreateRealWrapper - Function to create the real wrapper, injected by factory
16
+ * @param {object} oController - The controller instance
17
+ * @param {object} mParams - Additional parameters to pass to the real wrapper constructor
18
+ * @returns {object} Preliminary wrapper object that will delegate to real wrapper once control is set
19
+ */
20
+ function PreliminaryWrapper(sId, sType, fnCreateRealWrapper, oController, mParams) {
21
+ var oLatestState;
22
+ var oRealWrapper;
23
+ var fnResolveRealWrapperReady;
24
+ var oRealWrapperReadyPromise = new Promise(function(resolve) {
25
+ fnResolveRealWrapperReady = resolve;
26
+ });
27
+
28
+ return {
29
+ /**
30
+ * Get the current state. Returns stored state before control is set,
31
+ * delegates to real wrapper afterwards.
32
+ * @returns {object} The current state
33
+ */
34
+ getState: function() {
35
+ return oRealWrapper ? oRealWrapper.getState() : oLatestState;
36
+ },
37
+
38
+ /**
39
+ * Set the state. Stores state before control is set,
40
+ * delegates to real wrapper afterwards.
41
+ * @param {object} oState - The state to set
42
+ */
43
+ setState: function(oState) {
44
+ if (oRealWrapper) {
45
+ oRealWrapper.setState(oState);
46
+ } else {
47
+ oLatestState = oState;
48
+ }
49
+ },
50
+
51
+ /**
52
+ * Assign the actual control and create the real wrapper.
53
+ * This triggers the creation of the real wrapper, applies any stored state,
54
+ * and resolves the promise that queues event handler attachments.
55
+ * @param {sap.ui.core.Control} oControl - The control instance
56
+ */
57
+ setControl: function(oControl) {
58
+ // Create the real wrapper using injected function
59
+ var oCreatedWrapper = fnCreateRealWrapper(oControl, sType, mParams);
60
+
61
+ // Check if wrapper needs time to initialize
62
+ var oWrapperReadyPromise = oCreatedWrapper.oReadyPromise || Promise.resolve();
63
+
64
+ // Wait for wrapper to be ready before setting oRealWrapper
65
+ oWrapperReadyPromise.then(function() {
66
+ oRealWrapper = oCreatedWrapper;
67
+
68
+ // Apply stored state if any
69
+ if (oLatestState !== undefined) {
70
+ oRealWrapper.setState(oLatestState);
71
+ }
72
+
73
+ // Resolve the promise - this triggers all queued attachStateChanged calls
74
+ fnResolveRealWrapperReady(oRealWrapper);
75
+ });
76
+ },
77
+
78
+ /**
79
+ * Attach a state change handler. Uses promise to queue attachment
80
+ * until the real wrapper is available and ready.
81
+ * @param {function} fnHandler - The event handler function
82
+ */
83
+ attachStateChanged: function(fnHandler) {
84
+ // Use promise to defer attachment until real wrapper is available and ready
85
+ oRealWrapperReadyPromise.then(function(oWrapper) {
86
+ oWrapper.attachStateChanged(fnHandler);
87
+ });
88
+ },
89
+
90
+ /**
91
+ * Detach a state change handler. Forwards to real wrapper once available and ready.
92
+ * @param {function} fnHandler - The event handler function to detach
93
+ */
94
+ detachStateChanged: function(fnHandler) {
95
+ // Forward to real wrapper once available and ready
96
+ oRealWrapperReadyPromise.then(function(oWrapper) {
97
+ oWrapper.detachStateChanged(fnHandler);
98
+ });
99
+ },
100
+
101
+ /**
102
+ * Get the local ID of the control.
103
+ * @returns {string} The local ID
104
+ */
105
+ getLocalId: function() {
106
+ return sId;
107
+ },
108
+
109
+ /**
110
+ * Check if the provided state matches the current state.
111
+ * @param {object} oState - The state to compare
112
+ * @returns {boolean} True if states match
113
+ */
114
+ isCurrentState: function(oState) {
115
+ return oRealWrapper ? oRealWrapper.isCurrentState(oState) :
116
+ JSON.stringify(oState) === JSON.stringify(oLatestState);
117
+ },
118
+
119
+ /**
120
+ * Called after variant is initialized (for SmartTable/SmartChart wrappers).
121
+ * Delegates to real wrapper once control is set and ready.
122
+ * Note: When this is called, the control always exists (event fired by control),
123
+ * so the promise will already be resolved.
124
+ */
125
+ onAfterVariantInitialise: function() {
126
+ oRealWrapperReadyPromise.then(function(oWrapper) {
127
+ if (oWrapper.onAfterVariantInitialise) {
128
+ oWrapper.onAfterVariantInitialise();
129
+ }
130
+ });
131
+ },
132
+
133
+ /**
134
+ * Promise that resolves to the bVMConnection flag value once the real wrapper is ready.
135
+ * This indicates whether the control is connected to page-wide variant management.
136
+ */
137
+ oVMConnectionPromise: oRealWrapperReadyPromise.then(function(oWrapper) {
138
+ return oWrapper.bVMConnection;
139
+ })
140
+ };
141
+ }
142
+
143
+ return PreliminaryWrapper;
144
+ });
@@ -2,54 +2,32 @@ sap.ui.define([
2
2
  ], function() {
3
3
  "use strict";
4
4
 
5
- function SearchFieldWrapper(vTarget) {
6
- var oSearchField, oControlAssignedResolve, oPreliminaryState;
7
- var oControlAssignedPromise = new Promise(function(resolve) {
8
- oControlAssignedResolve = resolve;
9
- });
10
-
11
- if (typeof vTarget !== "string") {
12
- fnSetControl(vTarget);
13
- }
5
+ function SearchFieldWrapper(oControl) {
6
+ var oSearchField = oControl;
14
7
 
15
8
  function fnGetState() {
16
- if (!oSearchField) {
17
- return oPreliminaryState;
18
- }
19
-
20
9
  return {
21
10
  searchString: oSearchField.getValue()
22
11
  };
23
12
  }
24
13
 
25
14
  function fnSetState(oState) {
26
- oPreliminaryState = oState;
27
- oControlAssignedPromise.then(function() {
28
- oSearchField.setValue(oState.searchString);
29
- // original implementation also called fireSearch. Seems to be superfluous (would fire the search event, on which worklisthandler is registered and finally calls rebindTable
30
- // when restoring from an appState of a worklist, always data should be shown at time of saving the state and thus automatically search would be triggered again
31
- // oSearchField.fireSearch();
32
- });
15
+ oSearchField.setValue(oState.searchString);
16
+ // original implementation also called fireSearch. Seems to be superfluous (would fire the search event, on which worklisthandler is registered and finally calls rebindTable
17
+ // when restoring from an appState of a worklist, always data should be shown at time of saving the state and thus automatically search would be triggered again
18
+ // oSearchField.fireSearch();
33
19
  }
34
20
 
35
21
  function fnAttachStateChanged(fnHandler) {
36
- oControlAssignedPromise.then(function() {
37
- oSearchField.attachLiveChange(fnHandler);
38
- });
22
+ oSearchField.attachLiveChange(fnHandler);
39
23
  }
40
24
 
41
- function fnSetControl(oControl) {
42
- oSearchField = oControl;
43
- oControlAssignedResolve(oSearchField);
44
- }
45
-
46
25
  return {
47
26
  getState: fnGetState,
48
27
  setState: fnSetState,
49
- setControl: fnSetControl,
50
28
  attachStateChanged: fnAttachStateChanged
51
29
  };
52
30
  }
53
31
 
54
32
  return SearchFieldWrapper;
55
- });
33
+ });