@sapui5/sap.suite.ui.generic.template 1.145.0 → 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 (27) 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/manifest.json +1 -1
  5. package/src/sap/suite/ui/generic/template/ListReport/controller/ControllerImplementation.js +92 -9
  6. package/src/sap/suite/ui/generic/template/ListReport/controller/IappStateHandler.js +19 -8
  7. package/src/sap/suite/ui/generic/template/ListReport/manifest.json +1 -1
  8. package/src/sap/suite/ui/generic/template/ListReport/view/fragments/SmartChart.fragment.xml +3 -2
  9. package/src/sap/suite/ui/generic/template/ListReport/view/fragments/SmartTable.fragment.xml +5 -4
  10. package/src/sap/suite/ui/generic/template/ObjectPage/controller/ControllerImplementation.js +5 -2
  11. package/src/sap/suite/ui/generic/template/ObjectPage/manifest.json +1 -1
  12. package/src/sap/suite/ui/generic/template/ObjectPage/view/fragments/SmartChart.fragment.xml +3 -2
  13. package/src/sap/suite/ui/generic/template/ObjectPage/view/fragments/SmartTable.fragment.xml +3 -2
  14. package/src/sap/suite/ui/generic/template/QuickCreate/manifest.json +1 -1
  15. package/src/sap/suite/ui/generic/template/QuickView/manifest.json +1 -1
  16. package/src/sap/suite/ui/generic/template/genericUtilities/ControlStateWrapperFactory.js +108 -67
  17. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/DynamicPageWrapper.js +19 -51
  18. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/ObjectPageLayoutWrapper.js +10 -32
  19. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/PreliminaryWrapper.js +151 -0
  20. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SearchFieldWrapper.js +8 -30
  21. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartFilterBarWrapper.js +49 -162
  22. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartTableChartCommon.js +100 -94
  23. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartTableWrapper.js +22 -3
  24. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartVariantManagementWrapper.js +90 -81
  25. package/src/sap/suite/ui/generic/template/lib/AppComponent.js +1 -1
  26. package/src/sap/suite/ui/generic/template/lib/navigation/NavigationController.js +1 -1
  27. 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
  aBasicFilters = oSmartFilterBar.getAllFilterItems(true);
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
@@ -224,43 +138,40 @@ sap.ui.define([
224
138
  }
225
139
 
226
140
  bIsApplying = true;
227
- oPreliminaryState = oState;
228
-
229
- oControlAssignedPromise.then(function() {
230
- // SFB expects a UIState object - not serializable, but a managed object, actually containing also information not belonging to SFBs state
231
- // => get current UIState object from SFB, replace only relevant information, and set it again
232
- var oUiState = oSmartFilterBar.getUiState(),
233
- oSmartVariant = oSmartFilterBar.getSmartVariant(),
234
- bIsCurrentVariantModifiedBeforeSetState = oSmartVariant.currentVariantGetModified();
235
-
236
- oUiState.getSelectionVariant().SelectOptions = oPreliminaryState && oPreliminaryState.selectOptions;
237
- oUiState.getSelectionVariant().Parameters = oPreliminaryState && oPreliminaryState.parameters;
238
- oUiState.setSemanticDates(oPreliminaryState && oPreliminaryState.semanticDates);
239
- // setState is meant to set the state absolutely, no merge needed => replace and strictMode can be set to true.
240
- // (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
241
- // 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
242
- // same control))
243
- oSmartFilterBar.setUiState(oUiState, {replace: true, strictMode: true});
244
-
245
- mParams.oCustomFiltersWrapper.setState(oPreliminaryState && oPreliminaryState.customFilters);
246
141
 
247
- // set visibility
248
- // TODO:
249
- // - How to deal with old states (not containing all information about visibility) -> legacy state handler?
250
- // - restoring from old state when annotation has changed (new selection fields)?
251
- oSmartFilterBar.getAllFilterItems().forEach(function(oFilterItem){
252
- if (oPreliminaryState && oPreliminaryState.addedFilterItems && oPreliminaryState.addedFilterItems.includes(oFilterItem.getName())){
253
- oFilterItem.setVisibleInFilterBar();
254
- }
255
- if (oPreliminaryState && oPreliminaryState.removedFilterItems && oPreliminaryState.removedFilterItems.includes(oFilterItem.getName())){
256
- oFilterItem.setVisibleInFilterBar(false);
257
- }
258
- });
259
-
260
- // Retaining the old value of "modified" flag in the smart variant
261
- oSmartVariant.currentVariantSetModified(bIsCurrentVariantModifiedBeforeSetState);
142
+ // SFB expects a UIState object - not serializable, but a managed object, actually containing also information not belonging to SFBs state
143
+ // => get current UIState object from SFB, replace only relevant information, and set it again
144
+ var oUiState = oSmartFilterBar.getUiState(),
145
+ oSmartVariant = oSmartFilterBar.getSmartVariant(),
146
+ bIsCurrentVariantModifiedBeforeSetState = oSmartVariant.currentVariantGetModified();
147
+
148
+ oUiState.getSelectionVariant().SelectOptions = oState && oState.selectOptions;
149
+ oUiState.getSelectionVariant().Parameters = oState && oState.parameters;
150
+ oUiState.setSemanticDates(oState && oState.semanticDates);
151
+ // setState is meant to set the state absolutely, no merge needed => replace and strictMode can be set to true.
152
+ // (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
153
+ // 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
154
+ // same control))
155
+ oSmartFilterBar.setUiState(oUiState, {replace: true, strictMode: true});
156
+
157
+ mParams.oCustomFiltersWrapper.setState(oState && oState.customFilters);
158
+
159
+ // set visibility
160
+ // TODO:
161
+ // - How to deal with old states (not containing all information about visibility) -> legacy state handler?
162
+ // - restoring from old state when annotation has changed (new selection fields)?
163
+ oSmartFilterBar.getAllFilterItems().forEach(function(oFilterItem){
164
+ if (oState && oState.addedFilterItems && oState.addedFilterItems.includes(oFilterItem.getName())){
165
+ oFilterItem.setVisibleInFilterBar();
166
+ }
167
+ if (oState && oState.removedFilterItems && oState.removedFilterItems.includes(oFilterItem.getName())){
168
+ oFilterItem.setVisibleInFilterBar(false);
169
+ }
262
170
  });
263
171
 
172
+ // Retaining the old value of "modified" flag in the smart variant
173
+ oSmartVariant.currentVariantSetModified(bIsCurrentVariantModifiedBeforeSetState);
174
+
264
175
  // Apparently, SFB does not always correctly adapt the adapt filters count automatically. The following method has been provided espacially to trigger the same.
265
176
  // 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.
266
177
  oSmartFilterBar.refreshFiltersCount();
@@ -275,25 +186,11 @@ sap.ui.define([
275
186
  }
276
187
  }
277
188
 
278
- oControlAssignedPromise.then(function () {
279
- oSmartFilterBar.attachFilterChange(function () {
280
- // Don't forward filter change event while dialog is open - changes should only be registered when dialog is closed
281
- if (!oSmartFilterBar.isDialogOpen()) {
282
- handleStateChanged();
283
- }
284
- });
285
- // unclear, whether this is needed, or filterChange event is anyway raised again (after dialog is closed)
286
- oSmartFilterBar.attachFiltersDialogClosed(handleStateChanged);
287
-
288
- // do we need to provide and handle change events from custom filters?
289
- // contra:
290
- // - SFB raises filteChange event also for custom filters
291
- // - maybe also needed to be suppressed while dialog is open
292
- // pro:
293
- // - cleaner from architectural perspective
294
- // - SFB cannot deal correctly with unknown custom controls
295
- // - existing method in extensionAPI (onCustomAppStateChange)
296
- mParams.oCustomFiltersWrapper.attachStateChanged(handleStateChanged);
189
+ oSmartFilterBar.attachFilterChange(function () {
190
+ // Don't forward filter change event while dialog is open - changes should only be registered when dialog is closed
191
+ if (!oSmartFilterBar.isDialogOpen()) {
192
+ handleStateChanged();
193
+ }
297
194
  });
298
195
  // unclear, whether this is needed, or filterChange event is anyway raised again (after dialog is closed)
299
196
  oSmartFilterBar.attachFiltersDialogClosed(handleStateChanged);
@@ -321,15 +218,6 @@ sap.ui.define([
321
218
  });
322
219
  }
323
220
 
324
- function fnSetControl(oControl) {
325
- oSmartFilterBar = oControl;
326
- oControlAssignedResolve(oSmartFilterBar);
327
- }
328
-
329
- function fnGetMissingNavProperties() {
330
- return aMissingNavFilters;
331
- }
332
-
333
221
  // check waiting for initialization (like in SmartTableWrapper/SmartChartWrapper)
334
222
  // currently, whole appState restoring is waiting for initialized event from sfb - but probably it would be enough to wait for it here
335
223
  fnInitialize();
@@ -338,15 +226,14 @@ sap.ui.define([
338
226
  // generic properties (provided by all state wrappers)
339
227
  getState: fnGetState,
340
228
  setState: fnSetState,
341
- setControl: fnSetControl,
342
229
  attachStateChanged: fnAttachStateChanged,
343
230
  // specific properties (needed to workaround direct connection between SFB and SVM)
344
231
  setSVMWrapperCallbacks: setSVMWrapperCallbacks,
345
232
  bVMConnection: oSmartFilterBar.getSmartVariant(),
346
233
  suppressSelection: oSmartFilterBar.setSuppressSelection.bind(oSmartFilterBar), // if multiple reasons for suppressing overlap, a counter (to avoid to early resume) could be implemented here
347
- getMissingNavProperties: fnGetMissingNavProperties
234
+ oVariantManagementInitializedPromise: oVariantManagementInitializedPromise
348
235
  };
349
236
  }
350
237
 
351
238
  return SmartFilterBarWrapper;
352
- });
239
+ });
@@ -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
+ });