@sapui5/sap.suite.ui.generic.template 1.136.14 → 1.136.16

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 (42) hide show
  1. package/package.json +1 -1
  2. package/src/sap/suite/ui/generic/template/.library +1 -1
  3. package/src/sap/suite/ui/generic/template/AnalyticalListPage/i18n/i18n_bg.properties +3 -3
  4. package/src/sap/suite/ui/generic/template/AnalyticalListPage/i18n/i18n_da.properties +3 -3
  5. package/src/sap/suite/ui/generic/template/AnalyticalListPage/i18n/i18n_it.properties +1 -1
  6. package/src/sap/suite/ui/generic/template/AnalyticalListPage/manifest.json +1 -1
  7. package/src/sap/suite/ui/generic/template/Canvas/manifest.json +1 -1
  8. package/src/sap/suite/ui/generic/template/ListReport/controller/ControllerImplementation.js +93 -12
  9. package/src/sap/suite/ui/generic/template/ListReport/controller/IappStateHandler.js +19 -8
  10. package/src/sap/suite/ui/generic/template/ListReport/manifest.json +1 -1
  11. package/src/sap/suite/ui/generic/template/ListReport/view/fragments/SmartChart.fragment.xml +2 -1
  12. package/src/sap/suite/ui/generic/template/ListReport/view/fragments/SmartTable.fragment.xml +3 -2
  13. package/src/sap/suite/ui/generic/template/ObjectPage/controller/ControllerImplementation.js +5 -2
  14. package/src/sap/suite/ui/generic/template/ObjectPage/controller/RelatedAppsHandler.js +19 -27
  15. package/src/sap/suite/ui/generic/template/ObjectPage/i18n/i18n_cnr.properties +1 -1
  16. package/src/sap/suite/ui/generic/template/ObjectPage/i18n/i18n_mk.properties +1 -1
  17. package/src/sap/suite/ui/generic/template/ObjectPage/i18n/i18n_sh.properties +1 -1
  18. package/src/sap/suite/ui/generic/template/ObjectPage/i18n/i18n_sl.properties +3 -3
  19. package/src/sap/suite/ui/generic/template/ObjectPage/i18n/i18n_sr.properties +1 -1
  20. package/src/sap/suite/ui/generic/template/ObjectPage/manifest.json +1 -1
  21. package/src/sap/suite/ui/generic/template/ObjectPage/view/fragments/SmartChart.fragment.xml +3 -2
  22. package/src/sap/suite/ui/generic/template/ObjectPage/view/fragments/SmartTable.fragment.xml +3 -2
  23. package/src/sap/suite/ui/generic/template/QuickCreate/manifest.json +1 -1
  24. package/src/sap/suite/ui/generic/template/QuickView/manifest.json +1 -1
  25. package/src/sap/suite/ui/generic/template/genericUtilities/ControlStateWrapperFactory.js +108 -67
  26. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/DynamicPageWrapper.js +19 -51
  27. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/ObjectPageLayoutWrapper.js +10 -32
  28. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/PreliminaryWrapper.js +151 -0
  29. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SearchFieldWrapper.js +8 -30
  30. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartFilterBarWrapper.js +49 -162
  31. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartTableChartCommon.js +99 -93
  32. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartTableWrapper.js +22 -3
  33. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartVariantManagementWrapper.js +90 -81
  34. package/src/sap/suite/ui/generic/template/lib/AppComponent.js +1 -1
  35. package/src/sap/suite/ui/generic/template/lib/ContextMenuHandler.js +9 -0
  36. package/src/sap/suite/ui/generic/template/lib/i18n/i18n_fi.properties +2 -2
  37. package/src/sap/suite/ui/generic/template/lib/i18n/i18n_fr.properties +2 -2
  38. package/src/sap/suite/ui/generic/template/lib/i18n/i18n_mk.properties +1 -1
  39. package/src/sap/suite/ui/generic/template/lib/i18n/i18n_nl.properties +1 -1
  40. package/src/sap/suite/ui/generic/template/lib/i18n/i18n_ru.properties +5 -5
  41. package/src/sap/suite/ui/generic/template/lib/navigation/NavigationController.js +1 -1
  42. 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,12 +76,17 @@ 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();
57
- if (!oUiState.getProperty("variantName")){
58
- oUiState.setPresentationVariant(oState.oUiState.oPresentationVariant);
59
- oUiState.setSelectionVariant(oState.oUiState.oSelectionVariant);
60
- oUiState.setTableSettings(oState.oUiState.oTableSettings);
61
- oControl.setUiState(oUiState);
79
+ var oControlUiState = oControl.getUiState();
80
+ if (!oControlUiState.getProperty("variantName")){
81
+ oControlUiState.setPresentationVariant(oState.oUiState.oPresentationVariant);
82
+ oControlUiState.setSelectionVariant(oState.oUiState.oSelectionVariant);
83
+
84
+ // Allow extension to set control-specific properties (e.g., tableSettings for SmartTable)
85
+ if (mExtensions && mExtensions.fnExtendSetUiState) {
86
+ mExtensions.fnExtendSetUiState(oState.oUiState, oControlUiState);
87
+ }
88
+
89
+ oControl.setUiState(oControlUiState);
62
90
  }
63
91
  bIsApplying = false;
64
92
  } else {
@@ -85,76 +113,58 @@ sap.ui.define([
85
113
  setState: fnSetState,
86
114
  getLocalId: fnGetLocalId,
87
115
  bVMConnection: oControl && oControl.getSmartVariant && !!oControl.getSmartVariant(),
88
- attachStateChanged: fnAttachStateChanged
116
+ attachStateChanged: fnAttachStateChanged,
117
+ onAfterVariantInitialise: oVariantManagementInitializedResolve
89
118
  };
90
119
  }
91
120
 
92
121
  function fnGetState() {
93
- if (bSmartControlInitialized) {
94
- if (oVariantManagementStateWrapper) {
95
- // oVariantManagementStateWrapper would be undefined only in cases SmartControl is not yet initialized
96
- // or VariantManagement is not enabled.
97
- return oVariantManagementStateWrapper.getState();
98
- }
99
-
100
- if (oSmartControlStateWrapper && !bVariantManagementActive) {
101
- // VariantManagement is not turned on & SmartControlStateWrapper instance
102
- return oSmartControlStateWrapper.getState();
103
- }
122
+ if (oVariantManagementStateWrapper) {
123
+ // Variant management is active
124
+ return oVariantManagementStateWrapper.getState();
104
125
  }
105
126
 
106
- // Control is not available and StateWrapper is not initialized
107
- return oPreliminaryState;
127
+ // No variant management - return control state directly
128
+ return oSmartControlStateWrapper.getState();
108
129
  }
109
130
 
110
131
  function fnSetState(oState) {
111
- oPreliminaryState = oState;
112
- oControlAssignedPromise.then(function () {
113
- // map legacy states - before separating VM state from state of managed control, inner state information
114
- // (presentation variant and selection variant) were put as oUiState on the same level as VM state
115
- // information (variant id and dirty indicator), now they are contained in map managedControlStates
116
- if (oState){
117
- if (oState.oUiState && !oState.managedControlStates) {
118
- oState.managedControlStates = Object.create(null);
119
- oState.managedControlStates[oSmartControlStateWrapper.getLocalId()] = {oUiState: oState.oUiState};
120
- }
121
- if (oState.bVariantModified !== undefined) {
122
- oState.modified = oState.bVariantModified;
123
- }
124
- if (oState.sVariantId !== undefined) {
125
- oState.variantId = oState.sVariantId;
126
- }
127
- }
128
-
132
+ if (!oState) {
133
+ // If no state provided, set standard variant on control
129
134
  if (bVariantManagementActive) {
130
- // In case VariantManagement is configured
131
- oVariantManagementStateWrapper.setState(oPreliminaryState);
132
- return;
135
+ oVariantManagementStateWrapper.setState(oState);
136
+ } else {
137
+ oSmartControlStateWrapper.setState(oState);
133
138
  }
134
-
135
- // SmartTable/Chart shall be used
136
- oSmartControlStateWrapper.setState(oPreliminaryState);
137
- });
138
- }
139
-
140
- function fnSetControl(oControl) {
141
- oSmartControl = oControl;
142
- oSmartControlStateWrapper = getControlWrapper(oSmartControl);
143
- if (!oSmartControl.isInitialised()) {
144
- // In case Smart Chart/Table is not yet initialized
145
- // listen to the initialize event & then resolve the control
146
- oSmartControl.attachEvent(sInitializationEvent, fnControlInitialized);
147
139
  return;
148
140
  }
149
141
 
150
- fnControlInitialized();
142
+ // Map legacy states - before separating VM state from state of managed control, inner state information
143
+ // (presentation variant and selection variant) were put as oUiState on the same level as VM state
144
+ // information (variant id and dirty indicator), now they are contained in map managedControlStates
145
+ if (oState.oUiState && !oState.managedControlStates) {
146
+ oState.managedControlStates = Object.create(null);
147
+ oState.managedControlStates[oSmartControlStateWrapper.getLocalId()] = {oUiState: oState.oUiState};
148
+ }
149
+ if (oState.bVariantModified !== undefined) {
150
+ oState.modified = oState.bVariantModified;
151
+ }
152
+ if (oState.sVariantId !== undefined) {
153
+ oState.variantId = oState.sVariantId;
154
+ }
155
+
156
+ if (bVariantManagementActive) {
157
+ // In case VariantManagement is configured
158
+ oVariantManagementStateWrapper.setState(oState);
159
+ } else {
160
+ // SmartTable/Chart shall be used
161
+ oSmartControlStateWrapper.setState(oState);
162
+ }
151
163
  }
152
164
 
153
165
  function fnControlInitialized() {
154
- bSmartControlInitialized = true;
155
-
156
166
  // deal with VM
157
- // 3 possibilties with respect to VM
167
+ // 3 possibilities with respect to VM
158
168
  // a) no VM (relevant for this control) at all
159
169
  // b) control managed as part of page wide variant management
160
170
  // c) control creates own VM
@@ -178,39 +188,35 @@ sap.ui.define([
178
188
  oVariantManagementStateWrapper = oFactory.getControlStateWrapper(oVariantManagementControl, {
179
189
  managedControlWrappers: [ oSmartControlStateWrapper ]
180
190
  });
181
- oControlAssignedResolve();
191
+ fnResolveReady();
182
192
  } else {
183
- // Resolve the ControlAssignedPromise only once the VariantManagement is
184
- // also initialized
193
+ // Wait for VariantManagement to be initialized
185
194
  oSmartControl.attachAfterVariantInitialise(fnControlInitialized);
186
195
  }
187
-
188
- return;
196
+ } else {
197
+ // No variant management or page-level variant management - ready immediately
198
+ fnResolveReady();
189
199
  }
190
- // There is no VariantManagement configured for this SmartChart/SmartTable
191
- oControlAssignedResolve(oSmartControl);
192
200
  }
193
201
 
194
202
  function fnAttachStateChanged(fnHandler) {
195
- oControlAssignedPromise.then(function () {
196
- if (bVariantManagementActive) {
197
- oVariantManagementStateWrapper.attachStateChanged(fnHandler);
198
- return;
199
- }
200
-
203
+ if (bVariantManagementActive) {
204
+ oVariantManagementStateWrapper.attachStateChanged(fnHandler);
205
+ } else {
201
206
  oSmartControlStateWrapper.attachStateChanged(fnHandler);
202
-
203
- });
207
+ }
204
208
  }
205
209
 
206
210
  return {
207
211
  getState: fnGetState,
208
212
  setState: fnSetState,
209
- setControl: fnSetControl,
210
213
  attachStateChanged: fnAttachStateChanged,
211
- bVMConnection: oSmartControl && oSmartControl.getSmartVariant && !!oSmartControl.getSmartVariant()
214
+ bVMConnection: oSmartControl && oSmartControl.getSmartVariant && !!oSmartControl.getSmartVariant(),
215
+ oVariantManagementInitializedPromise: oVariantManagementInitializedPromise,
216
+ onAfterVariantInitialise: oVariantManagementInitializedResolve,
217
+ oReadyPromise: oReadyPromise
212
218
  };
213
219
  }
214
220
 
215
221
  return SmartTableChartCommon;
216
- });
222
+ });
@@ -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
+ });