@sapui5/sap.suite.ui.generic.template 1.142.5 → 1.142.7

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 (29) 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/controller/ControllerImplementation.js +6 -9
  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 +94 -11
  7. package/src/sap/suite/ui/generic/template/ListReport/controller/IappStateHandler.js +19 -9
  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 +2 -1
  10. package/src/sap/suite/ui/generic/template/ListReport/view/fragments/SmartTable.fragment.xml +3 -2
  11. package/src/sap/suite/ui/generic/template/ObjectPage/controller/ControllerImplementation.js +5 -2
  12. package/src/sap/suite/ui/generic/template/ObjectPage/manifest.json +1 -1
  13. package/src/sap/suite/ui/generic/template/ObjectPage/view/fragments/SmartChart.fragment.xml +3 -2
  14. package/src/sap/suite/ui/generic/template/ObjectPage/view/fragments/SmartTable.fragment.xml +3 -2
  15. package/src/sap/suite/ui/generic/template/QuickCreate/manifest.json +1 -1
  16. package/src/sap/suite/ui/generic/template/QuickView/manifest.json +1 -1
  17. package/src/sap/suite/ui/generic/template/genericUtilities/ControlStateWrapperFactory.js +101 -67
  18. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/DynamicPageWrapper.js +19 -51
  19. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/ObjectPageLayoutWrapper.js +10 -32
  20. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/PreliminaryWrapper.js +144 -0
  21. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SearchFieldWrapper.js +8 -30
  22. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartFilterBarWrapper.js +49 -162
  23. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartTableChartCommon.js +100 -94
  24. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartTableWrapper.js +22 -3
  25. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartVariantManagementWrapper.js +82 -75
  26. package/src/sap/suite/ui/generic/template/lib/AppComponent.js +1 -1
  27. package/src/sap/suite/ui/generic/template/lib/ai/EasyFilterBarHandler.js +21 -8
  28. package/src/sap/suite/ui/generic/template/lib/navigation/NavigationController.js +1 -1
  29. package/src/sap/suite/ui/generic/template/library.js +1 -1
@@ -1,6 +1,5 @@
1
1
  sap.ui.define([
2
- "sap/ui/model/FilterOperator"
3
- ], function (FilterOperator) {
2
+ ], function () {
4
3
  "use strict";
5
4
 
6
5
 
@@ -23,29 +22,24 @@ sap.ui.define([
23
22
  * @returns {object}
24
23
  * @alias sap.suite.ui.generic.template.genericUtilities.controlStateWrapperFactory.SmartFilterBarWrapper
25
24
  */
26
- function SmartFilterBarWrapper(vTarget, oFactory, mParams) {
25
+ function SmartFilterBarWrapper(oControl, oFactory, mParams) {
27
26
  var bIsApplying = false;
28
27
  var aBasicFilters = [];
29
- var aMissingNavFilters = [];
30
- var oSmartFilterBar, oControlAssignedResolve, oPreliminaryState;
31
- var oControlAssignedPromise = new Promise(function (resolve) {
32
- oControlAssignedResolve = resolve;
33
- });
28
+ var oSmartFilterBar = oControl;
34
29
 
35
- function fnInitialize() {
36
- if (typeof vTarget !== "string") {
37
- fnSetControl(vTarget);
38
- }
30
+ var oVariantManagementInitializedPromise;
39
31
 
32
+ function fnInitialize() {
40
33
  // Filters visible initially (after initialization). Stored here to be
41
34
  // able to compare with currently visible ones to identify added and
42
35
  // removed ones without need to instantiate all possible filter items
43
36
  // (which would harm performance). Can only be retrieved in initialized event.
44
- oControlAssignedPromise.then(function () {
45
- oSmartFilterBar.getInitializedPromise().then(function () {
46
- aBasicFilters = oSmartFilterBar.getAllFilterItems(true);
47
- });
37
+ oSmartFilterBar.getInitializedPromise().then(function () {
38
+ aBasicFilters = oSmartFilterBar.getAllFilterItems(true);
48
39
  });
40
+
41
+ // Initialize variant management promise
42
+ oVariantManagementInitializedPromise = oSmartFilterBar.getInitializedPromise();
49
43
  }
50
44
 
51
45
  // Attach to variantFetch and variantLoad events to be able to store and restore also custom filters and state of other controls (in case of page VM) with variant.
@@ -69,7 +63,7 @@ sap.ui.define([
69
63
  // in SFB instead of SVM where it would make more sense.
70
64
  // Here the event is afterVariantLoad, as the variant content known to SVM/SFB has first to be applied to the SFB, which will also pass the custom data accordingly. Only
71
65
  // after this has happened, we can get the custom data from SFB.
72
- oSmartFilterBar.attachAfterVariantLoad(function(oEvent){
66
+ oSmartFilterBar.attachAfterVariantLoad(function(){
73
67
  var oCustomData = oSmartFilterBar.getCustomFilterData();
74
68
  // variant stored with 1.103 or later: all customFilter data stored in property customFilters
75
69
  // legacy variant stored with 1.102 or earlier: customFilters (from storing point of view) separated according to their origin
@@ -81,91 +75,11 @@ sap.ui.define([
81
75
 
82
76
  mParams.oCustomFiltersWrapper.setState(oCustomFiltersState);
83
77
  oSVMWrapperCallbacks.setManagedControlStates(oCustomData[dataPropertyNameGeneric]);
84
- /* SFB header state of a variant (standard or custom) gets determined by the Apply Automatically checkbox's value of the corresponding
85
- variant i.e. if the checkbox is checked, then the header should be collapsed and vice versa. */
86
- oSVMWrapperCallbacks.setHeaderState(!oEvent.getParameter("executeOnSelect"));
87
- aMissingNavFilters = fnGetNavigationProperties();
88
78
  });
89
79
 
90
80
  }
91
81
 
92
- function fnGetNavigationProperties() {
93
- //Fetch the navigation properties
94
- const oMetaModel = oSmartFilterBar.getModel().getMetaModel(),
95
- sEntitySet = oSmartFilterBar.getEntitySet(),
96
- oDataEntitySet = oMetaModel.getODataEntitySet(sEntitySet),
97
- oDataEntityType = oMetaModel.getODataEntityType(oDataEntitySet.entityType),
98
- aNavigationProperties = oDataEntityType['navigationProperty'];
99
- //Fetch the added filters in the current variant
100
- const sCurrentVariantID = oSmartFilterBar.getVariantManagement().getCurrentVariantId(),
101
- oCurrentVariant = oSmartFilterBar.getVariantManagement().getAllVariants().find(function(variant) {
102
- return variant.getId() === sCurrentVariantID;
103
- });
104
- if (!oCurrentVariant
105
- || !oCurrentVariant.getContent()
106
- || !oCurrentVariant.getContent().searchListReportVariant
107
- || !oCurrentVariant.getContent().searchListReportVariant.filterBarVariant
108
- || !aNavigationProperties
109
- || !aNavigationProperties.length
110
- ) {
111
- return [];
112
- }
113
- const oManifestNavigationProperties = oSmartFilterBar.getNavigationProperties() ?
114
- oSmartFilterBar.getNavigationProperties().split(",").reduce(function(accumulator, currentValue){
115
- accumulator[currentValue] = true;
116
- return accumulator;
117
- }, {}) : {},
118
- oNavigationProperties = aNavigationProperties.reduce(function(accumulator, currentValue){
119
- accumulator[currentValue.name] = true;
120
- return accumulator;
121
- }, {}),
122
- oSmartFilterBarVariant = JSON.parse(oCurrentVariant.getContent().searchListReportVariant.filterBarVariant),
123
- aMissing = [];
124
- delete oSmartFilterBarVariant["_CUSTOM"];
125
-
126
- // Compare the filter source and navigation properties
127
- // Take into account if parameter is already specified in page setting in manifest.json - settings->filterSettings->navigationProperties
128
- // If parameter exist in navigationProperties -> SFB will handle specific parameter and code ignore it
129
- for (const sFilterKey in oSmartFilterBarVariant) {
130
- const sParamName = sFilterKey.split(".")[0]; // take first part from navigation parameter. Example: to_Currency.Currency_Code -> to_Currency
131
- if (!oNavigationProperties[sParamName] || oManifestNavigationProperties[sParamName]
132
- ) {
133
- // Parameter is
134
- // 1) not navigation property -> we don't process it
135
- // 2) is defined in manifest.json - settings->filterSettings->navigationProperties -> value will be handled by SFB
136
- continue;
137
- }
138
- if (oSmartFilterBarVariant[sFilterKey].items && oSmartFilterBarVariant[sFilterKey].items.length) {
139
- aMissing.push(oSmartFilterBarVariant[sFilterKey].items.map(function(entry) {
140
- return {
141
- exclude: false,
142
- field: sFilterKey,
143
- operation: FilterOperator.EQ,
144
- value1: entry.key
145
- };
146
- }));
147
- continue;
148
- }
149
- if (oSmartFilterBarVariant[sFilterKey].ranges && oSmartFilterBarVariant[sFilterKey].ranges.length) {
150
- aMissing.push(oSmartFilterBarVariant[sFilterKey].ranges.map(function(entry) {
151
- return {
152
- exclude: entry.exclude,
153
- field: entry.keyField,
154
- operation: entry.operation,
155
- value1: entry.value1,
156
- value2: entry.value2
157
- };
158
- }));
159
- }
160
- }
161
- return aMissing;
162
- }
163
-
164
82
  function fnGetState() {
165
- if (!oSmartFilterBar) {
166
- return oPreliminaryState;
167
- }
168
-
169
83
  var oUiState = oSmartFilterBar.getUiState();
170
84
  // UiState is not Serializable, but a managed object, containing information only partly relevant
171
85
  // relevant information are
@@ -217,43 +131,40 @@ sap.ui.define([
217
131
  }
218
132
 
219
133
  bIsApplying = true;
220
- oPreliminaryState = oState;
221
134
 
222
- oControlAssignedPromise.then(function() {
223
- // SFB expects a UIState object - not serializable, but a managed object, actually containing also information not belonging to SFBs state
224
- // => get current UIState object from SFB, replace only relevant information, and set it again
225
- var oUiState = oSmartFilterBar.getUiState(),
226
- oSmartVariant = oSmartFilterBar.getSmartVariant(),
227
- bIsCurrentVariantModifiedBeforeSetState = oSmartVariant.currentVariantGetModified();
228
-
229
- oUiState.getSelectionVariant().SelectOptions = oPreliminaryState && oPreliminaryState.selectOptions;
230
- oUiState.getSelectionVariant().Parameters = oPreliminaryState && oPreliminaryState.parameters;
231
- oUiState.setSemanticDates(oPreliminaryState && oPreliminaryState.semanticDates);
232
- // setState is meant to set the state absolutely, no merge needed => replace and strictMode can be set to true.
233
- // (replace=false can be used to set additional selectOptions but keeping the existing ones. strictMode=false is used to map filters to parameters. Both might make sense in navigation
234
- // scenarios (navigation parameter to be merged with defaults, property used in source app as filter but in target as parameter), but not when just restoring to a state (provided from the
235
- // same control))
236
- oSmartFilterBar.setUiState(oUiState, {replace: true, strictMode: true});
237
-
238
- mParams.oCustomFiltersWrapper.setState(oPreliminaryState && oPreliminaryState.customFilters);
239
-
240
- // set visibility
241
- // TODO:
242
- // - How to deal with old states (not containing all information about visibility) -> legacy state handler?
243
- // - restoring from old state when annotation has changed (new selection fields)?
244
- oSmartFilterBar.getAllFilterItems().forEach(function(oFilterItem){
245
- if (oPreliminaryState && oPreliminaryState.addedFilterItems && oPreliminaryState.addedFilterItems.includes(oFilterItem.getName())){
246
- oFilterItem.setVisibleInFilterBar();
247
- }
248
- if (oPreliminaryState && oPreliminaryState.removedFilterItems && oPreliminaryState.removedFilterItems.includes(oFilterItem.getName())){
249
- oFilterItem.setVisibleInFilterBar(false);
250
- }
251
- });
252
-
253
- // Retaining the old value of "modified" flag in the smart variant
254
- oSmartVariant.currentVariantSetModified(bIsCurrentVariantModifiedBeforeSetState);
135
+ // SFB expects a UIState object - not serializable, but a managed object, actually containing also information not belonging to SFBs state
136
+ // => get current UIState object from SFB, replace only relevant information, and set it again
137
+ var oUiState = oSmartFilterBar.getUiState(),
138
+ oSmartVariant = oSmartFilterBar.getSmartVariant(),
139
+ bIsCurrentVariantModifiedBeforeSetState = oSmartVariant.currentVariantGetModified();
140
+
141
+ oUiState.getSelectionVariant().SelectOptions = oState && oState.selectOptions;
142
+ oUiState.getSelectionVariant().Parameters = oState && oState.parameters;
143
+ oUiState.setSemanticDates(oState && oState.semanticDates);
144
+ // setState is meant to set the state absolutely, no merge needed => replace and strictMode can be set to true.
145
+ // (replace=false can be used to set additional selectOptions but keeping the existing ones. strictMode=false is used to map filters to parameters. Both might make sense in navigation
146
+ // scenarios (navigation parameter to be merged with defaults, property used in source app as filter but in target as parameter), but not when just restoring to a state (provided from the
147
+ // same control))
148
+ oSmartFilterBar.setUiState(oUiState, {replace: true, strictMode: true});
149
+
150
+ mParams.oCustomFiltersWrapper.setState(oState && oState.customFilters);
151
+
152
+ // set visibility
153
+ // TODO:
154
+ // - How to deal with old states (not containing all information about visibility) -> legacy state handler?
155
+ // - restoring from old state when annotation has changed (new selection fields)?
156
+ oSmartFilterBar.getAllFilterItems().forEach(function(oFilterItem){
157
+ if (oState && oState.addedFilterItems && oState.addedFilterItems.includes(oFilterItem.getName())){
158
+ oFilterItem.setVisibleInFilterBar();
159
+ }
160
+ if (oState && oState.removedFilterItems && oState.removedFilterItems.includes(oFilterItem.getName())){
161
+ oFilterItem.setVisibleInFilterBar(false);
162
+ }
255
163
  });
256
164
 
165
+ // Retaining the old value of "modified" flag in the smart variant
166
+ oSmartVariant.currentVariantSetModified(bIsCurrentVariantModifiedBeforeSetState);
167
+
257
168
  // Apparently, SFB does not always correctly adapt the adapt filters count automatically. The following method has been provided espacially to trigger the same.
258
169
  // TODO: Verify, whether this is really needed (or was rather an artifact of old structure) - if yes, this API should be made public, if no, we should remove the call.
259
170
  oSmartFilterBar.refreshFiltersCount();
@@ -268,25 +179,11 @@ sap.ui.define([
268
179
  }
269
180
  }
270
181
 
271
- oControlAssignedPromise.then(function () {
272
- oSmartFilterBar.attachFilterChange(function () {
273
- // Don't forward filter change event while dialog is open - changes should only be registered when dialog is closed
274
- if (!oSmartFilterBar.isDialogOpen()) {
275
- handleStateChanged();
276
- }
277
- });
278
- // unclear, whether this is needed, or filterChange event is anyway raised again (after dialog is closed)
279
- oSmartFilterBar.attachFiltersDialogClosed(handleStateChanged);
280
-
281
- // do we need to provide and handle change events from custom filters?
282
- // contra:
283
- // - SFB raises filteChange event also for custom filters
284
- // - maybe also needed to be suppressed while dialog is open
285
- // pro:
286
- // - cleaner from architectural perspective
287
- // - SFB cannot deal correctly with unknown custom controls
288
- // - existing method in extensionAPI (onCustomAppStateChange)
289
- mParams.oCustomFiltersWrapper.attachStateChanged(handleStateChanged);
182
+ oSmartFilterBar.attachFilterChange(function () {
183
+ // Don't forward filter change event while dialog is open - changes should only be registered when dialog is closed
184
+ if (!oSmartFilterBar.isDialogOpen()) {
185
+ handleStateChanged();
186
+ }
290
187
  });
291
188
  // unclear, whether this is needed, or filterChange event is anyway raised again (after dialog is closed)
292
189
  oSmartFilterBar.attachFiltersDialogClosed(handleStateChanged);
@@ -314,15 +211,6 @@ sap.ui.define([
314
211
  });
315
212
  }
316
213
 
317
- function fnSetControl(oControl) {
318
- oSmartFilterBar = oControl;
319
- oControlAssignedResolve(oSmartFilterBar);
320
- }
321
-
322
- function fnGetMissingNavProperties() {
323
- return aMissingNavFilters;
324
- }
325
-
326
214
  // check waiting for initialization (like in SmartTableWrapper/SmartChartWrapper)
327
215
  // currently, whole appState restoring is waiting for initialized event from sfb - but probably it would be enough to wait for it here
328
216
  fnInitialize();
@@ -331,15 +219,14 @@ sap.ui.define([
331
219
  // generic properties (provided by all state wrappers)
332
220
  getState: fnGetState,
333
221
  setState: fnSetState,
334
- setControl: fnSetControl,
335
222
  attachStateChanged: fnAttachStateChanged,
336
223
  // specific properties (needed to workaround direct connection between SFB and SVM)
337
224
  setSVMWrapperCallbacks: setSVMWrapperCallbacks,
338
225
  bVMConnection: oSmartFilterBar.getSmartVariant(),
339
226
  suppressSelection: oSmartFilterBar.setSuppressSelection.bind(oSmartFilterBar), // if multiple reasons for suppressing overlap, a counter (to avoid to early resume) could be implemented here
340
- getMissingNavProperties: fnGetMissingNavProperties
227
+ oVariantManagementInitializedPromise: oVariantManagementInitializedPromise
341
228
  };
342
229
  }
343
230
 
344
231
  return SmartFilterBarWrapper;
345
- });
232
+ });
@@ -4,41 +4,64 @@ sap.ui.define([
4
4
 
5
5
  /**
6
6
  * Constructor for SmartTableChartCommon
7
- * ...
8
- * @param {object} mParams
9
- * @param mParams.oCustomFiltersWrapper - wrapper for custom filters (from SFB point of view)
10
- * (currently containing: generic (currently only editState), app extension, and adaptation extension - but this is knowledge of LR, i.e. of iAppStateHandler, not of SFB)
7
+ * @param {sap.ui.core.Control} oControl - The SmartTable or SmartChart control
8
+ * @param {object} oController - The controller instance
9
+ * @param {object} oFactory - The ControlStateWrapperFactory instance
10
+ * @param {string} sInitializationEvent - The initialization event name (e.g., "initialise")
11
+ * @param {object} [mExtensions] - Optional extension functions for control-specific state handling
12
+ * @param {function} [mExtensions.fnExtendGetUiState] - Function to extend UiState during getState
13
+ * Called with (oStateUiState, oControlUiState) where modifications to oStateUiState add to the state
14
+ * @param {function} [mExtensions.fnExtendSetUiState] - Function to extend UiState during setState
15
+ * Called with (oStateUiState, oControlUiState) where oStateUiState contains the state to apply
11
16
  * @returns {object}
12
17
  */
13
18
 
14
19
  // deals with state of SFB itself, without SVM (see SmartVariantManagementWrapper) and go-button
15
20
  // (does not contain a state from SFB point of view - however, we remember whether it was pressed once
16
21
  // to restore data - this information is not considered being part of SFB)
17
- function SmartTableChartCommon(vTarget, oController, oFactory, sInitializationEvent) {
18
- var oSmartControl, oVariantManagementControl, bVariantManagementActive;
19
- var oControlAssignedResolve, oPreliminaryState, bSmartControlInitialized;
22
+ function SmartTableChartCommon(oControl, oController, oFactory, sInitializationEvent, mExtensions) {
23
+ var oSmartControl = oControl;
24
+ var oVariantManagementControl, bVariantManagementActive;
20
25
  var oSmartControlStateWrapper;
21
26
  var oVariantManagementStateWrapper;
27
+ var oVariantManagementInitializedResolve;
28
+ var fnResolveReady;
22
29
 
23
- var oControlAssignedPromise = new Promise(function (resolve) {
24
- oControlAssignedResolve = resolve;
30
+ var oVariantManagementInitializedPromise = new Promise(function(resolve){
31
+ oVariantManagementInitializedResolve = resolve;
25
32
  });
26
33
 
27
- if (typeof vTarget !== "string") {
28
- fnSetControl(vTarget);
34
+ var oReadyPromise = new Promise(function(resolve) {
35
+ fnResolveReady = resolve;
36
+ });
37
+
38
+ // Initialize control state wrapper and check if control is already initialized
39
+ oSmartControlStateWrapper = getControlWrapper(oSmartControl);
40
+ if (!oSmartControl.isInitialised()) {
41
+ // In case Smart Chart/Table is not yet initialized
42
+ // listen to the initialize event & then initialize the wrapper
43
+ oSmartControl.attachEvent(sInitializationEvent, fnControlInitialized);
44
+ } else {
45
+ fnControlInitialized();
29
46
  }
30
47
 
31
48
  // creates a simple wrapper for a SmartTable or SmartChart (a control using UIState) (ignoring initialization and vm)
32
49
  function getControlWrapper(oControl) {
33
50
  var bIsApplying = false; // avoid forwarding change event when caused by us applying a state
34
51
  function fnGetState() {
35
- var oUiState = oControl.getUiState(); // unfortunately not serializable, but a managed object
52
+ var oControlUiState = oControl.getUiState(); // unfortunately not serializable, but a managed object
53
+ var oStateUiState = {
54
+ oPresentationVariant: oControlUiState.getPresentationVariant(),
55
+ oSelectionVariant: oControlUiState.getSelectionVariant()
56
+ };
57
+
58
+ // Allow extension to add control-specific properties (e.g., tableSettings for SmartTable)
59
+ if (mExtensions && mExtensions.fnExtendGetUiState) {
60
+ mExtensions.fnExtendGetUiState(oStateUiState, oControlUiState);
61
+ }
62
+
36
63
  return {
37
- oUiState: {
38
- oPresentationVariant: oUiState.getPresentationVariant(),
39
- oSelectionVariant: oUiState.getSelectionVariant(),
40
- oTableSettings: oUiState.getTableSettings()
41
- }
64
+ oUiState: oStateUiState
42
65
  };
43
66
  }
44
67
 
@@ -53,15 +76,20 @@ sap.ui.define([
53
76
  bIsApplying = true;
54
77
  // don't create UiState (managed object) from scratch, but fetch it from control and only apply known properties from state - thus, if any other properties would be added, we don't
55
78
  // interfere with them
56
- var oUiState = oControl.getUiState();
79
+ var oControlUiState = oControl.getUiState();
57
80
  if (
58
- oUiState.getProperty("variantName") === "" ||
59
- oControl.getVariantManagement().getModified() && oControl.getVariantManagement().getStandardVariantKey() === oUiState.getProperty("variantName")
81
+ oControlUiState.getProperty("variantName") === "" ||
82
+ oControl.getVariantManagement().getModified() && oControl.getVariantManagement().getStandardVariantKey() === oControlUiState.getProperty("variantName")
60
83
  ){
61
- oUiState.setPresentationVariant(oState.oUiState.oPresentationVariant);
62
- oUiState.setSelectionVariant(oState.oUiState.oSelectionVariant);
63
- oUiState.setTableSettings(oState.oUiState.oTableSettings);
64
- oControl.setUiState(oUiState);
84
+ oControlUiState.setPresentationVariant(oState.oUiState.oPresentationVariant);
85
+ oControlUiState.setSelectionVariant(oState.oUiState.oSelectionVariant);
86
+
87
+ // Allow extension to set control-specific properties (e.g., tableSettings for SmartTable)
88
+ if (mExtensions && mExtensions.fnExtendSetUiState) {
89
+ mExtensions.fnExtendSetUiState(oState.oUiState, oControlUiState);
90
+ }
91
+
92
+ oControl.setUiState(oControlUiState);
65
93
  }
66
94
  bIsApplying = false;
67
95
  } else {
@@ -88,76 +116,58 @@ sap.ui.define([
88
116
  setState: fnSetState,
89
117
  getLocalId: fnGetLocalId,
90
118
  bVMConnection: oControl && oControl.getSmartVariant && !!oControl.getSmartVariant(),
91
- attachStateChanged: fnAttachStateChanged
119
+ attachStateChanged: fnAttachStateChanged,
120
+ onAfterVariantInitialise: oVariantManagementInitializedResolve
92
121
  };
93
122
  }
94
123
 
95
124
  function fnGetState() {
96
- if (bSmartControlInitialized) {
97
- if (oVariantManagementStateWrapper) {
98
- // oVariantManagementStateWrapper would be undefined only in cases SmartControl is not yet initialized
99
- // or VariantManagement is not enabled.
100
- return oVariantManagementStateWrapper.getState();
101
- }
102
-
103
- if (oSmartControlStateWrapper && !bVariantManagementActive) {
104
- // VariantManagement is not turned on & SmartControlStateWrapper instance
105
- return oSmartControlStateWrapper.getState();
106
- }
125
+ if (oVariantManagementStateWrapper) {
126
+ // Variant management is active
127
+ return oVariantManagementStateWrapper.getState();
107
128
  }
108
129
 
109
- // Control is not available and StateWrapper is not initialized
110
- return oPreliminaryState;
130
+ // No variant management - return control state directly
131
+ return oSmartControlStateWrapper.getState();
111
132
  }
112
133
 
113
134
  function fnSetState(oState) {
114
- oPreliminaryState = oState;
115
- oControlAssignedPromise.then(function () {
116
- // map legacy states - before separating VM state from state of managed control, inner state information
117
- // (presentation variant and selection variant) were put as oUiState on the same level as VM state
118
- // information (variant id and dirty indicator), now they are contained in map managedControlStates
119
- if (oState){
120
- if (oState.oUiState && !oState.managedControlStates) {
121
- oState.managedControlStates = Object.create(null);
122
- oState.managedControlStates[oSmartControlStateWrapper.getLocalId()] = {oUiState: oState.oUiState};
123
- }
124
- if (oState.bVariantModified !== undefined) {
125
- oState.modified = oState.bVariantModified;
126
- }
127
- if (oState.sVariantId !== undefined) {
128
- oState.variantId = oState.sVariantId;
129
- }
130
- }
131
-
135
+ if (!oState) {
136
+ // If no state provided, set standard variant on control
132
137
  if (bVariantManagementActive) {
133
- // In case VariantManagement is configured
134
- oVariantManagementStateWrapper.setState(oPreliminaryState);
135
- return;
138
+ oVariantManagementStateWrapper.setState(oState);
139
+ } else {
140
+ oSmartControlStateWrapper.setState(oState);
136
141
  }
137
-
138
- // SmartTable/Chart shall be used
139
- oSmartControlStateWrapper.setState(oPreliminaryState);
140
- });
141
- }
142
-
143
- function fnSetControl(oControl) {
144
- oSmartControl = oControl;
145
- oSmartControlStateWrapper = getControlWrapper(oSmartControl);
146
- if (!oSmartControl.isInitialised()) {
147
- // In case Smart Chart/Table is not yet initialized
148
- // listen to the initialize event & then resolve the control
149
- oSmartControl.attachEvent(sInitializationEvent, fnControlInitialized);
150
142
  return;
151
143
  }
152
144
 
153
- fnControlInitialized();
145
+ // Map legacy states - before separating VM state from state of managed control, inner state information
146
+ // (presentation variant and selection variant) were put as oUiState on the same level as VM state
147
+ // information (variant id and dirty indicator), now they are contained in map managedControlStates
148
+ if (oState.oUiState && !oState.managedControlStates) {
149
+ oState.managedControlStates = Object.create(null);
150
+ oState.managedControlStates[oSmartControlStateWrapper.getLocalId()] = {oUiState: oState.oUiState};
151
+ }
152
+ if (oState.bVariantModified !== undefined) {
153
+ oState.modified = oState.bVariantModified;
154
+ }
155
+ if (oState.sVariantId !== undefined) {
156
+ oState.variantId = oState.sVariantId;
157
+ }
158
+
159
+ if (bVariantManagementActive) {
160
+ // In case VariantManagement is configured
161
+ oVariantManagementStateWrapper.setState(oState);
162
+ } else {
163
+ // SmartTable/Chart shall be used
164
+ oSmartControlStateWrapper.setState(oState);
165
+ }
154
166
  }
155
167
 
156
168
  function fnControlInitialized() {
157
- bSmartControlInitialized = true;
158
-
159
169
  // deal with VM
160
- // 3 possibilties with respect to VM
170
+ // 3 possibilities with respect to VM
161
171
  // a) no VM (relevant for this control) at all
162
172
  // b) control managed as part of page wide variant management
163
173
  // c) control creates own VM
@@ -181,39 +191,35 @@ sap.ui.define([
181
191
  oVariantManagementStateWrapper = oFactory.getControlStateWrapper(oVariantManagementControl, {
182
192
  managedControlWrappers: [ oSmartControlStateWrapper ]
183
193
  });
184
- oControlAssignedResolve();
194
+ fnResolveReady();
185
195
  } else {
186
- // Resolve the ControlAssignedPromise only once the VariantManagement is
187
- // also initialized
196
+ // Wait for VariantManagement to be initialized
188
197
  oSmartControl.attachAfterVariantInitialise(fnControlInitialized);
189
198
  }
190
-
191
- return;
199
+ } else {
200
+ // No variant management or page-level variant management - ready immediately
201
+ fnResolveReady();
192
202
  }
193
- // There is no VariantManagement configured for this SmartChart/SmartTable
194
- oControlAssignedResolve(oSmartControl);
195
203
  }
196
204
 
197
205
  function fnAttachStateChanged(fnHandler) {
198
- oControlAssignedPromise.then(function () {
199
- if (bVariantManagementActive) {
200
- oVariantManagementStateWrapper.attachStateChanged(fnHandler);
201
- return;
202
- }
203
-
206
+ if (bVariantManagementActive) {
207
+ oVariantManagementStateWrapper.attachStateChanged(fnHandler);
208
+ } else {
204
209
  oSmartControlStateWrapper.attachStateChanged(fnHandler);
205
-
206
- });
210
+ }
207
211
  }
208
212
 
209
213
  return {
210
214
  getState: fnGetState,
211
215
  setState: fnSetState,
212
- setControl: fnSetControl,
213
216
  attachStateChanged: fnAttachStateChanged,
214
- bVMConnection: oSmartControl && oSmartControl.getSmartVariant && !!oSmartControl.getSmartVariant()
217
+ bVMConnection: oSmartControl && oSmartControl.getSmartVariant && !!oSmartControl.getSmartVariant(),
218
+ oVariantManagementInitializedPromise: oVariantManagementInitializedPromise,
219
+ onAfterVariantInitialise: oVariantManagementInitializedResolve,
220
+ oReadyPromise: oReadyPromise
215
221
  };
216
222
  }
217
223
 
218
224
  return SmartTableChartCommon;
219
- });
225
+ });
@@ -2,10 +2,29 @@ sap.ui.define([
2
2
  "sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartTableChartCommon"
3
3
  ], function(SmartTableChartCommon) {
4
4
  "use strict";
5
-
5
+
6
+ /**
7
+ * Constructor for SmartTableWrapper
8
+ * @param {sap.ui.comp.smarttable.SmartTable} oSmartTable - The SmartTable control
9
+ * @param {object} oController - The controller instance
10
+ * @param {object} oFactory - The ControlStateWrapperFactory instance
11
+ * @returns {object} Wrapper object for SmartTable
12
+ */
6
13
  function SmartTableWrapper(oSmartTable, oController, oFactory){
7
- return new SmartTableChartCommon(oSmartTable, oController, oFactory, "initialise");
14
+ // SmartTable extends SmartTableChartCommon with tableSettings support
15
+ return new SmartTableChartCommon(oSmartTable, oController, oFactory, "initialise", {
16
+ // Extension to add tableSettings to the state
17
+ fnExtendGetUiState: function(oStateUiState, oControlUiState) {
18
+ oStateUiState.oTableSettings = oControlUiState.getTableSettings();
19
+ },
20
+ // Extension to apply tableSettings from the state
21
+ fnExtendSetUiState: function(oStateUiState, oControlUiState) {
22
+ if (oStateUiState.oTableSettings) {
23
+ oControlUiState.setTableSettings(oStateUiState.oTableSettings);
24
+ }
25
+ }
26
+ });
8
27
  }
9
28
 
10
29
  return SmartTableWrapper;
11
- });
30
+ });