@sapui5/sap.suite.ui.generic.template 1.144.1 → 1.145.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) 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/manifest.json +1 -1
  4. package/src/sap/suite/ui/generic/template/Canvas/behaviour.js +11 -0
  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 +92 -9
  7. package/src/sap/suite/ui/generic/template/ListReport/controller/IappStateHandler.js +19 -8
  8. package/src/sap/suite/ui/generic/template/ListReport/manifest.json +1 -1
  9. package/src/sap/suite/ui/generic/template/ListReport/view/fragments/SmartChart.fragment.xml +3 -2
  10. package/src/sap/suite/ui/generic/template/ListReport/view/fragments/SmartTable.fragment.xml +5 -4
  11. package/src/sap/suite/ui/generic/template/ObjectPage/controller/ControllerImplementation.js +5 -2
  12. package/src/sap/suite/ui/generic/template/ObjectPage/extensionAPI/ExtensionAPI.js +2 -2
  13. package/src/sap/suite/ui/generic/template/ObjectPage/manifest.json +1 -1
  14. package/src/sap/suite/ui/generic/template/ObjectPage/view/fragments/SmartChart.fragment.xml +3 -2
  15. package/src/sap/suite/ui/generic/template/ObjectPage/view/fragments/SmartTable.fragment.xml +3 -2
  16. package/src/sap/suite/ui/generic/template/QuickCreate/manifest.json +1 -1
  17. package/src/sap/suite/ui/generic/template/QuickView/manifest.json +1 -1
  18. package/src/sap/suite/ui/generic/template/designtime/floorplans/ObjectPage.designtime.js +6 -1
  19. package/src/sap/suite/ui/generic/template/designtime/utils/designtimeUtils.js +10 -3
  20. package/src/sap/suite/ui/generic/template/fragments/QuickViewSmartForm.fragment.xml +4 -3
  21. package/src/sap/suite/ui/generic/template/genericUtilities/ControlStateWrapperFactory.js +108 -67
  22. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/DynamicPageWrapper.js +19 -51
  23. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/ObjectPageLayoutWrapper.js +10 -32
  24. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/PreliminaryWrapper.js +151 -0
  25. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SearchFieldWrapper.js +8 -30
  26. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartFilterBarWrapper.js +49 -162
  27. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartTableChartCommon.js +100 -94
  28. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartTableWrapper.js +22 -3
  29. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartVariantManagementWrapper.js +90 -81
  30. package/src/sap/suite/ui/generic/template/lib/AppComponent.js +1 -1
  31. package/src/sap/suite/ui/generic/template/lib/PageLeaveHandler.js +36 -8
  32. package/src/sap/suite/ui/generic/template/lib/i18n/i18n.properties +3 -0
  33. package/src/sap/suite/ui/generic/template/lib/i18n/i18n_en_US_saprigi.properties +2 -0
  34. package/src/sap/suite/ui/generic/template/lib/navigation/NavigationController.js +10 -25
  35. package/src/sap/suite/ui/generic/template/lib/presentationControl/SmartTableHandler.js +1 -1
  36. 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,66 @@ 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 type and control.
97
+ * This function is injected into PreliminaryWrapper and not exposed in the factory's public API.
98
+ * Parameters are ordered to allow using .bind() for partial application.
99
+ *
100
+ * @param {string} sType - The type of control (e.g., "SmartTable", "SmartChart")
101
+ * @param {object} [mParams] - Additional parameters passed to constructor of wrapper
102
+ * @param {sap.ui.core.Control} oControl - The control instance (last to enable .bind())
103
+ * @return {object} The real wrapper object for the control with helper methods attached
104
+ */
105
+ function fnCreateRealWrapper(sType, mParams, oControl) {
106
+ var oWrapper;
107
+ switch (sType) {
108
+ case "SmartFilterBar":
109
+ oWrapper = new SmartFilterBarWrapper(oControl, oFactory, mParams);
110
+ break;
111
+ case "SmartTable":
112
+ oWrapper = new SmartTableWrapper(oControl, oController, oFactory);
113
+ break;
114
+ case "SmartChart":
115
+ oWrapper = new SmartChartWrapper(oControl, oController, oFactory);
116
+ break;
117
+ case "DynamicPage":
118
+ oWrapper = new DynamicPageWrapper(oControl);
119
+ break;
120
+ case "SmartVariantManagement":
121
+ oWrapper = new SmartVariantManagementWrapper(oControl, oController, oFactory, mParams);
122
+ break;
123
+ case "ObjectPageLayout":
124
+ oWrapper = new ObjectPageLayoutWrapper(oControl);
125
+ break;
126
+ case "SearchField":
127
+ oWrapper = new SearchFieldWrapper(oControl);
128
+ break;
129
+ default:
130
+ // control not carrying a state or no wrapper built yet
131
+ oWrapper = oDummyWrapper;
132
+ }
133
+
134
+ // Add helper methods to the real wrapper
135
+ var sId = oController.getView().getLocalId(oControl.getId());
136
+ oWrapper.getLocalId = function() { return sId; };
137
+ oWrapper.isCurrentState = oWrapper.isCurrentState || function (oState) {
138
+ return JSON.stringify(oState) === JSON.stringify(oWrapper.getState());
139
+ };
140
+
141
+ return oWrapper;
142
+ }
143
+
94
144
  var oFactory = {
95
145
  getSuppressChangeEventWhenApplyingWrapper: getSuppressChangeEventWhenApplyingWrapper,
146
+
96
147
  /**
97
- * Factory function to generate control wrapper object based on control type
98
- *
148
+ * Factory function to generate control wrapper object based on control type.
149
+ * Always returns a PreliminaryWrapper, which delegates to the real wrapper internally.
150
+ *
99
151
  * @param {sap.ui.core.Control} oControl - control a wrapper should be provided for
100
152
  * @param {object} [mParams] - map with any additional parameters passed to constructor of wrapper
101
- * @return {object} wrapper object for the control
153
+ * @return {object} wrapper object for the control (always a PreliminaryWrapper)
102
154
  */
103
155
  getControlStateWrapper: function (oControl, mParams) {
104
156
  // checking for control here (instead of at all callers) allows simple use for optional controls
@@ -107,52 +159,66 @@ sap.ui.define([
107
159
  // no need to add the dummy to the map
108
160
  return oDummyWrapper;
109
161
  }
110
- var sId = oController.getView().getLocalId(oControl.getId());
162
+ var sId = oController.getView().getLocalId(oControl.getId());
163
+
111
164
  if (!mWrappers[sId]) {
112
- var oWrapper;
165
+ // Determine control type
166
+ var sType;
113
167
  switch (true) {
114
168
  case controlHelper.isSmartFilterBar(oControl):
115
- oWrapper = new SmartFilterBarWrapper(oControl, oFactory, mParams);
169
+ sType = "SmartFilterBar";
116
170
  break;
117
171
  case controlHelper.isSmartTable(oControl):
118
- oWrapper = new SmartTableWrapper(oControl, oController, oFactory);
172
+ sType = "SmartTable";
119
173
  break;
120
174
  case controlHelper.isSmartChart(oControl):
121
- oWrapper = new SmartChartWrapper(oControl, oController, oFactory);
175
+ sType = "SmartChart";
122
176
  break;
123
177
  case controlHelper.isDynamicPage(oControl):
124
- oWrapper = new DynamicPageWrapper(oControl);
178
+ sType = "DynamicPage";
125
179
  break;
126
180
  case controlHelper.isSmartVariantManagement(oControl):
127
- oWrapper = new SmartVariantManagementWrapper(oControl, oController, oFactory, mParams);
181
+ sType = "SmartVariantManagement";
128
182
  break;
129
183
  case controlHelper.isObjectObjectPageLayout(oControl):
130
- oWrapper = new ObjectPageLayoutWrapper(oControl);
184
+ sType = "ObjectPageLayout";
131
185
  break;
132
186
  case controlHelper.isSearchField(oControl):
133
- oWrapper = new SearchFieldWrapper(oControl);
187
+ sType = "SearchField";
134
188
  break;
135
189
  default:
136
- // control not carrying a state or no wrapper build yet
137
- oWrapper = oDummyWrapper;
190
+ // control not carrying a state or no wrapper built yet
191
+ return oDummyWrapper;
138
192
  }
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;
193
+
194
+ // Create bound function with type and params, leaving oControl to be provided later
195
+ var fnBoundCreator = fnCreateRealWrapper.bind(null, sType, mParams);
196
+
197
+ // Always create a PreliminaryWrapper
198
+ var oPreliminaryWrapper = new PreliminaryWrapper(sId, fnBoundCreator);
199
+
200
+ // Since control is available, immediately set it
201
+ oPreliminaryWrapper.setControl(oControl);
202
+
203
+ // Store the PreliminaryWrapper in map (not the real wrapper)
204
+ mWrappers[sId] = oPreliminaryWrapper;
205
+ } else if (mWrappers[sId].setControl) {
206
+ // PreliminaryWrapper already exists but control wasn't set yet - set it now
207
+ mWrappers[sId].setControl(oControl);
145
208
  }
209
+
146
210
  return mWrappers[sId];
147
211
  },
148
212
 
149
213
  /**
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
214
+ * Factory function to generate control wrapper object based on control ID and type.
215
+ * Creates a PreliminaryWrapper when the control doesn't exist yet (e.g., lazy loading).
216
+ * Always returns a PreliminaryWrapper, which delegates to the real wrapper internally.
217
+ *
218
+ * @param {string} sControlId - ID of the control for which wrapper needs to be initiated
153
219
  * @param {string} sControlType - Type of the control for which wrapper needs to be initiated
154
220
  * @param {object} [mParams] - map with any additional parameters passed to constructor of wrapper
155
- * @return {object} wrapper object for the control
221
+ * @return {object} wrapper object for the control (always a PreliminaryWrapper)
156
222
  */
157
223
  getControlStateWrapperById: function (sControlId, sControlType, mParams) {
158
224
  // checking for control here (instead of at all callers) allows simple use for optional controls
@@ -161,40 +227,15 @@ sap.ui.define([
161
227
  // no need to add the dummy to the map
162
228
  return oDummyWrapper;
163
229
  }
164
- var sId = oController.getView().getLocalId(sControlId);
230
+ var sId = oController.getView().getLocalId(sControlId);
165
231
  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;
232
+ // Create bound function with type and params, leaving oControl to be provided later
233
+ var fnBoundCreator = fnCreateRealWrapper.bind(null, sControlType, mParams);
234
+
235
+ // Create a PreliminaryWrapper (control will be set later)
236
+ var oPreliminaryWrapper = new PreliminaryWrapper(sId, fnBoundCreator);
237
+
238
+ mWrappers[sId] = oPreliminaryWrapper;
198
239
  }
199
240
  return mWrappers[sId];
200
241
  }
@@ -207,4 +248,4 @@ sap.ui.define([
207
248
  extend(this, getMethods(oController));
208
249
  }
209
250
  });
210
- });
251
+ });
@@ -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,151 @@
1
+ sap.ui.define([
2
+ "sap/base/util/extend"
3
+ ], function(extend) {
4
+ "use strict";
5
+
6
+ /**
7
+ * PreliminaryWrapper - Acts as a proxy wrapper before the real control is available.
8
+ *
9
+ * This wrapper is created when a control state wrapper is requested by ID and type,
10
+ * but the actual control instance doesn't exist yet (e.g., due to lazy loading on ObjectPage).
11
+ * It stores state operations and event handler registrations, then transfers them to the
12
+ * real wrapper once the control is assigned via setControl().
13
+ *
14
+ * @param {string} sId - The local ID of the control
15
+ * @param {function} fnCreateRealWrapper - Function to create the real wrapper, bound with type and params
16
+ * @returns {object} Preliminary wrapper object that will delegate to real wrapper once control is set
17
+ */
18
+ function PreliminaryWrapper(sId, fnCreateRealWrapper) {
19
+ var oLatestState;
20
+ var oRealWrapper;
21
+ var fnResolveRealWrapperReady;
22
+ var oRealWrapperReadyPromise = new Promise(function(resolve) {
23
+ fnResolveRealWrapperReady = resolve;
24
+ });
25
+
26
+ var oPublicInterface = {
27
+ /**
28
+ * Get the current state. Returns stored state before control is set,
29
+ * delegates to real wrapper afterwards.
30
+ * @returns {object} The current state
31
+ */
32
+ getState: function() {
33
+ return oRealWrapper ? oRealWrapper.getState() : oLatestState;
34
+ },
35
+
36
+ /**
37
+ * Set the state. Stores state before control is set,
38
+ * delegates to real wrapper afterwards.
39
+ * @param {object} oState - The state to set
40
+ */
41
+ setState: function(oState) {
42
+ if (oRealWrapper) {
43
+ oRealWrapper.setState(oState);
44
+ } else {
45
+ oLatestState = oState;
46
+ }
47
+ },
48
+
49
+ /**
50
+ * Assign the actual control and create the real wrapper.
51
+ * This triggers the creation of the real wrapper, applies any stored state,
52
+ * extends the preliminary wrapper with all methods from the real wrapper,
53
+ * and resolves the promise that queues event handler attachments.
54
+ * @param {sap.ui.core.Control} oControl - The control instance
55
+ */
56
+ setControl: function(oControl) {
57
+ // Create the real wrapper using bound function (already has type and params bound)
58
+ var oCreatedWrapper = fnCreateRealWrapper(oControl);
59
+
60
+ // Check if wrapper needs time to initialize
61
+ var oWrapperReadyPromise = oCreatedWrapper.oReadyPromise || Promise.resolve();
62
+
63
+ // Wait for wrapper to be ready before setting oRealWrapper
64
+ oWrapperReadyPromise.then(function() {
65
+ oRealWrapper = oCreatedWrapper;
66
+
67
+ // Apply stored state if any
68
+ if (oLatestState !== undefined) {
69
+ oRealWrapper.setState(oLatestState);
70
+ }
71
+
72
+ // Extend the preliminary wrapper with all properties from the real wrapper
73
+ // This makes any additional methods (like setSVMWrapperCallbacks) available
74
+ // The nested extend ensures we keep our proxy methods (getState, setState, etc.)
75
+ // while adding new methods from the real wrapper
76
+ extend(oPublicInterface, extend({}, oRealWrapper, oPublicInterface));
77
+
78
+ // Resolve the promise - this triggers all queued attachStateChanged calls
79
+ fnResolveRealWrapperReady(oRealWrapper);
80
+ });
81
+ },
82
+
83
+ /**
84
+ * Attach a state change handler. Uses promise to queue attachment
85
+ * until the real wrapper is available and ready.
86
+ * @param {function} fnHandler - The event handler function
87
+ */
88
+ attachStateChanged: function(fnHandler) {
89
+ // Use promise to defer attachment until real wrapper is available and ready
90
+ oRealWrapperReadyPromise.then(function(oWrapper) {
91
+ oWrapper.attachStateChanged(fnHandler);
92
+ });
93
+ },
94
+
95
+ /**
96
+ * Detach a state change handler. Forwards to real wrapper once available and ready.
97
+ * @param {function} fnHandler - The event handler function to detach
98
+ */
99
+ detachStateChanged: function(fnHandler) {
100
+ // Forward to real wrapper once available and ready
101
+ oRealWrapperReadyPromise.then(function(oWrapper) {
102
+ oWrapper.detachStateChanged(fnHandler);
103
+ });
104
+ },
105
+
106
+ /**
107
+ * Get the local ID of the control.
108
+ * @returns {string} The local ID
109
+ */
110
+ getLocalId: function() {
111
+ return sId;
112
+ },
113
+
114
+ /**
115
+ * Check if the provided state matches the current state.
116
+ * @param {object} oState - The state to compare
117
+ * @returns {boolean} True if states match
118
+ */
119
+ isCurrentState: function(oState) {
120
+ return oRealWrapper ? oRealWrapper.isCurrentState(oState) :
121
+ JSON.stringify(oState) === JSON.stringify(oLatestState);
122
+ },
123
+
124
+ /**
125
+ * Called after variant is initialized (for SmartTable/SmartChart wrappers).
126
+ * Delegates to real wrapper once control is set and ready.
127
+ * Note: When this is called, the control always exists (event fired by control),
128
+ * so the promise will already be resolved.
129
+ */
130
+ onAfterVariantInitialise: function() {
131
+ oRealWrapperReadyPromise.then(function(oWrapper) {
132
+ if (oWrapper.onAfterVariantInitialise) {
133
+ oWrapper.onAfterVariantInitialise();
134
+ }
135
+ });
136
+ },
137
+
138
+ /**
139
+ * Promise that resolves to the bVMConnection flag value once the real wrapper is ready.
140
+ * This indicates whether the control is connected to page-wide variant management.
141
+ */
142
+ oVMConnectionPromise: oRealWrapperReadyPromise.then(function(oWrapper) {
143
+ return oWrapper.bVMConnection;
144
+ })
145
+ };
146
+
147
+ return oPublicInterface;
148
+ }
149
+
150
+ return PreliminaryWrapper;
151
+ });
@@ -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
+ });