@sapui5/sap.suite.ui.generic.template 1.120.41 → 1.120.42

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 (38) hide show
  1. package/package.json +1 -1
  2. package/src/sap/suite/ui/generic/template/.library +1 -1
  3. package/src/sap/suite/ui/generic/template/AnalyticalListPage/i18n/i18n_it.properties +2 -2
  4. package/src/sap/suite/ui/generic/template/AnalyticalListPage/manifest.json +1 -1
  5. package/src/sap/suite/ui/generic/template/Canvas/manifest.json +1 -1
  6. package/src/sap/suite/ui/generic/template/ListReport/controller/ControllerImplementation.js +4 -2
  7. package/src/sap/suite/ui/generic/template/ListReport/controller/IappStateHandler.js +18 -8
  8. package/src/sap/suite/ui/generic/template/ListReport/manifest.json +1 -1
  9. package/src/sap/suite/ui/generic/template/ListReport/view/fragments/SmartChart.fragment.xml +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 +12 -2
  12. package/src/sap/suite/ui/generic/template/ObjectPage/controller/RelatedAppsHandler.js +27 -32
  13. package/src/sap/suite/ui/generic/template/ObjectPage/i18n/i18n_cnr.properties +1 -1
  14. package/src/sap/suite/ui/generic/template/ObjectPage/i18n/i18n_mk.properties +1 -1
  15. package/src/sap/suite/ui/generic/template/ObjectPage/i18n/i18n_sh.properties +1 -1
  16. package/src/sap/suite/ui/generic/template/ObjectPage/i18n/i18n_sl.properties +3 -3
  17. package/src/sap/suite/ui/generic/template/ObjectPage/i18n/i18n_sr.properties +1 -1
  18. package/src/sap/suite/ui/generic/template/ObjectPage/manifest.json +1 -1
  19. package/src/sap/suite/ui/generic/template/ObjectPage/view/fragments/SmartChart.fragment.xml +1 -0
  20. package/src/sap/suite/ui/generic/template/ObjectPage/view/fragments/SmartTable.fragment.xml +1 -0
  21. package/src/sap/suite/ui/generic/template/QuickCreate/manifest.json +1 -1
  22. package/src/sap/suite/ui/generic/template/QuickView/manifest.json +1 -1
  23. package/src/sap/suite/ui/generic/template/genericUtilities/ControlStateWrapperFactory.js +109 -68
  24. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/DynamicPageWrapper.js +19 -51
  25. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/ObjectPageLayoutWrapper.js +10 -32
  26. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/PreliminaryWrapper.js +151 -0
  27. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SearchFieldWrapper.js +8 -30
  28. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartFilterBarWrapper.js +76 -99
  29. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartTableChartCommon.js +100 -92
  30. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartTableWrapper.js +10 -2
  31. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartVariantManagementWrapper.js +90 -81
  32. package/src/sap/suite/ui/generic/template/lib/AppComponent.js +1 -1
  33. package/src/sap/suite/ui/generic/template/lib/i18n/i18n_fi.properties +2 -2
  34. package/src/sap/suite/ui/generic/template/lib/i18n/i18n_fr.properties +2 -2
  35. package/src/sap/suite/ui/generic/template/lib/i18n/i18n_nl.properties +1 -1
  36. package/src/sap/suite/ui/generic/template/lib/i18n/i18n_ru.properties +5 -5
  37. package/src/sap/suite/ui/generic/template/lib/navigation/NavigationController.js +1 -1
  38. package/src/sap/suite/ui/generic/template/library.js +1 -1
@@ -4,12 +4,12 @@ sap.ui.define([
4
4
 
5
5
  /**
6
6
  * Constructor for SmartFilterBarWrapper
7
- * @param {sap.ui.comp.smartfilterbar.SmartFilterBar} vTarget - The SmartFilterBar control
7
+ * @param {sap.ui.comp.smartfilterbar.SmartFilterBar} vTarget - The SmartFilterBar control
8
8
  * or the Id of control for which this wrapper is created
9
9
  * @param {object} oFactory - the controlStateWrapperFactory
10
- * @param {object} mParams
10
+ * @param {object} mParams
11
11
  * @param mParams.oCustomFiltersWrapper - wrapper for custom filters (from SFB point of view)
12
- * (currently containing: generic (currently only editState), app extension, and adaptation extension - but this is knowledge of LR, i.e. of iAppStateHandler, not of SFB)
12
+ * (currently containing: generic (currently only editState), app extension, and adaptation extension - but this is knowledge of LR, i.e. of iAppStateHandler, not of SFB)
13
13
  * @returns
14
14
  */
15
15
 
@@ -20,29 +20,36 @@ sap.ui.define([
20
20
  var dataPropertyNameCustom = "sap.suite.ui.generic.template.customData",
21
21
  dataPropertyNameExtension = "sap.suite.ui.generic.template.extensionData",
22
22
  dataPropertyNameGeneric = "sap.suite.ui.generic.template.genericData";
23
-
24
- function SmartFilterBarWrapper(vTarget, oFactory, mParams) {
23
+
24
+ /**
25
+ * Constructor for SmartFilterBarWrapper
26
+ * @param {sap.ui.comp.smartfilterbar.SmartFilterBar} vTarget - The SmartFilterBar control
27
+ * or the Id of control for which this wrapper is created
28
+ * @param {object} oFactory - the controlStateWrapperFactory
29
+ * @param {object} mParams
30
+ * @param {Object} mParams.oCustomFiltersWrapper - wrapper for custom filters (from SFB point of view)
31
+ * (currently containing: generic (currently only editState), app extension, and adaptation extension - but this is knowledge of LR, i.e. of iAppStateHandler, not of SFB)
32
+ * @returns {object}
33
+ * @alias sap.suite.ui.generic.template.genericUtilities.controlStateWrapperFactory.SmartFilterBarWrapper
34
+ */
35
+ function SmartFilterBarWrapper(oControl, oFactory, mParams) {
25
36
  var bIsApplying = false;
26
37
  var aBasicFilters = [];
27
- var oSmartFilterBar, oControlAssignedResolve, oPreliminaryState;
28
- var oControlAssignedPromise = new Promise(function (resolve) {
29
- oControlAssignedResolve = resolve;
30
- });
38
+ var oSmartFilterBar = oControl;
39
+
40
+ var oVariantManagementInitializedPromise;
31
41
 
32
42
  function fnInitialize() {
33
- if (typeof vTarget !== "string") {
34
- fnSetControl(vTarget);
35
- }
36
-
37
- // Filters visible initially (after initialization). Stored here to be
38
- // able to compare with currently visible ones to identify added and
39
- // removed ones without need to instantiate all possible filter items
43
+ // Filters visible initially (after initialization). Stored here to be
44
+ // able to compare with currently visible ones to identify added and
45
+ // removed ones without need to instantiate all possible filter items
40
46
  // (which would harm performance). Can only be retrieved in initialized event.
41
- oControlAssignedPromise.then(function () {
42
- oSmartFilterBar.getInitializedPromise().then(function () {
43
- aBasicFilters = oSmartFilterBar.getAllFilterItems(true);
44
- });
47
+ oSmartFilterBar.getInitializedPromise().then(function () {
48
+ aBasicFilters = oSmartFilterBar.getAllFilterItems(true);
45
49
  });
50
+
51
+ // Initialize variant management promise
52
+ oVariantManagementInitializedPromise = oSmartFilterBar.getInitializedPromise();
46
53
  }
47
54
 
48
55
  // 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.
@@ -53,7 +60,7 @@ sap.ui.define([
53
60
  function setSVMWrapperCallbacks(oSVMWrapperCallbacks){
54
61
  // Before saving the current state as a new variant, we need to provide all state data of controls controlled by VM, but not known to it with setCustomFilterData. From a
55
62
  // logical point of view, the event (beforeVariantFetch) as well as the method to store the extension data (setCustomFilterData) belong to SVM, but both are implemented
56
- // in SFB. Additionally, beforeVariantSave would actually be the name more logical to the consumer, however that name had been used earlier and was deprecated and
63
+ // in SFB. Additionally, beforeVariantSave would actually be the name more logical to the consumer, however that name had been used earlier and was deprecated and
57
64
  // replaced by the given one. Fetch actually does not mean to fetch variant content from the place variants are stored, but to get the current state from the controls!
58
65
  oSmartFilterBar.attachBeforeVariantFetch(function(){
59
66
  var oCustomData = Object.create(null);
@@ -61,14 +68,14 @@ sap.ui.define([
61
68
  oCustomData[dataPropertyNameGeneric].customFilters = mParams.oCustomFiltersWrapper.getState();
62
69
  oSmartFilterBar.setCustomFilterData(oCustomData);
63
70
  });
64
-
71
+
65
72
  // When a variant is loaded, correspondingly we have to get the customData and apply the states to the controls not known to SVM. Again, event and method are implemented
66
73
  // in SFB instead of SVM where it would make more sense.
67
74
  // 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
68
- // after this has happened, we can get the custom data from SFB.
69
- oSmartFilterBar.attachAfterVariantLoad(function(oEvent){
75
+ // after this has happened, we can get the custom data from SFB.
76
+ oSmartFilterBar.attachAfterVariantLoad(function(){
70
77
  var oCustomData = oSmartFilterBar.getCustomFilterData();
71
- // variant stored with 1.103 or later: all customFilter data stored in property customFilters
78
+ // variant stored with 1.103 or later: all customFilter data stored in property customFilters
72
79
  // legacy variant stored with 1.102 or earlier: customFilters (from storing point of view) separated according to their origin
73
80
  var oCustomFiltersState = oCustomData[dataPropertyNameGeneric].customFilters || {
74
81
  editState: oCustomData[dataPropertyNameGeneric].editStateFilter,
@@ -78,18 +85,10 @@ sap.ui.define([
78
85
  aBasicFilters = oSmartFilterBar.getAllFilterItems(true);
79
86
  mParams.oCustomFiltersWrapper.setState(oCustomFiltersState);
80
87
  oSVMWrapperCallbacks.setManagedControlStates(oCustomData[dataPropertyNameGeneric]);
81
- /* SFB header state of a variant (standard or custom) gets determined by the Apply Automatically checkbox's value of the corresponding
82
- variant i.e. if the checkbox is checked, then the header should be collapsed and vice versa. */
83
- oSVMWrapperCallbacks.setHeaderState(!oEvent.getParameter("executeOnSelect"));
84
88
  });
85
89
 
86
90
  }
87
-
88
91
  function fnGetState() {
89
- if (!oSmartFilterBar) {
90
- return oPreliminaryState;
91
- }
92
-
93
92
  var oUiState = oSmartFilterBar.getUiState();
94
93
  // UiState is not Serializable, but a managed object, containing information only partly relevant
95
94
  // relevant information are
@@ -100,14 +99,14 @@ sap.ui.define([
100
99
  // added/removedFilterItems: selectOptions only contains values/ranges, not the information, whether the filter should be shown directly ("visibleInFilterBar"). SFB just assumes any items to
101
100
  // be shown that contain values (plus those shown per default), which is wrong in two directions: items made visible but without a value are missed, items with a value, but not shown are
102
101
  // added additionally
103
- // Remark:
102
+ // Remark:
104
103
  // - When saving as variant, the information seems to be passed to VM directly - but for appState, it would still be missing
105
104
  // - Storing added (not in BASIC group but made visible by user) and removed (the other way round) separately to not disconnect the user (using e.g. a saved tile) from future changes
106
105
  // in the application (e.g. adding a new property to selection fields)
107
106
  // (Remark: old logic (see iAppStateHandler.getByDefaultNonVisibleCustomFilterNames) seems to provide this data only for custom fields. Assumption: Even in VM it was only available for
108
107
  // standard fields some time back - now, this seems to be solved from SFB/SVM, but still it's missing for appState)
109
108
  var oSelectOptions = oUiState.getSelectionVariant().SelectOptions; // again, data contained in SelectionVaraint is only partly relevant
110
- // In beforeVariantFetch we need to provide the custom (from SVMs point of view) control's state data to the SFB. However, SFB also tries to interpret this data as
109
+ // In beforeVariantFetch we need to provide the custom (from SVMs point of view) control's state data to the SFB. However, SFB also tries to interpret this data as
111
110
  // name-value pairs (implicitly stringifying them and assuming name to be a name of a filter), thus whenever the beforeVariantFetch has occured before getting the state
112
111
  // here, the selectionVariant contains a superfluous select option for the property sap.suite.ui.generic.template.genericData (filtering for the value [object Object]).
113
112
  // Note: beforeVariantFetch is even called on initial startup, i.e. without explicetly removing it, the superfluous select option would always be there.
@@ -154,49 +153,46 @@ sap.ui.define([
154
153
 
155
154
  function fnSetState(oState) {
156
155
  // Don't cause side effects (filter change event), if setting state is no real change.
157
- // If this comparison fails for state that actually are identically, maybe it needs to be enhanced (e.g. ignoring order in some arrays might be needed)
156
+ // If this comparison fails for state that actually are identically, maybe it needs to be enhanced (e.g. ignoring order in some arrays might be needed)
158
157
  if (JSON.stringify(oState) === JSON.stringify(fnGetState())){
159
158
  return;
160
159
  }
161
-
160
+
162
161
  bIsApplying = true;
163
- oPreliminaryState = oState;
164
162
 
165
- oControlAssignedPromise.then(function() {
166
- // SFB expects a UIState object - not serializable, but a managed object, actually containing also information not belonging to SFBs state
167
- // => get current UIState object from SFB, replace only relevant information, and set it again
168
- var oUiState = oSmartFilterBar.getUiState(),
169
- oSmartVariant = oSmartFilterBar.getSmartVariant(),
170
- bIsCurrentVariantModifiedBeforeSetState = oSmartVariant.currentVariantGetModified();
163
+ // SFB expects a UIState object - not serializable, but a managed object, actually containing also information not belonging to SFBs state
164
+ // => get current UIState object from SFB, replace only relevant information, and set it again
165
+ var oUiState = oSmartFilterBar.getUiState(),
166
+ oSmartVariant = oSmartFilterBar.getSmartVariant(),
167
+ bIsCurrentVariantModifiedBeforeSetState = oSmartVariant.currentVariantGetModified();
171
168
 
172
- oUiState.getSelectionVariant().SelectOptions = oPreliminaryState && oPreliminaryState.selectOptions;
173
- oUiState.getSelectionVariant().Parameters = oPreliminaryState && oPreliminaryState.parameters;
174
- oUiState.setSemanticDates(oPreliminaryState && oPreliminaryState.semanticDates);
175
- // setState is meant to set the state absolutely, no merge needed => replace and strictMode can be set to true.
176
- // (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
177
- // 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
178
- // same control))
179
- oSmartFilterBar.setUiState(oUiState, {replace: true, strictMode: true});
169
+ oUiState.getSelectionVariant().SelectOptions = oState && oState.selectOptions;
170
+ oUiState.getSelectionVariant().Parameters = oState && oState.parameters;
171
+ oUiState.setSemanticDates(oState && oState.semanticDates);
172
+ // setState is meant to set the state absolutely, no merge needed => replace and strictMode can be set to true.
173
+ // (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
174
+ // 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
175
+ // same control))
176
+ oSmartFilterBar.setUiState(oUiState, {replace: true, strictMode: true});
180
177
 
181
- mParams.oCustomFiltersWrapper.setState(oPreliminaryState && oPreliminaryState.customFilters);
182
-
183
- // set visibility
184
- // TODO:
185
- // - How to deal with old states (not containing all information about visibility) -> legacy state handler?
186
- // - restoring from old state when annotation has changed (new selection fields)?
187
- oSmartFilterBar.getAllFilterItems().forEach(function(oFilterItem){
188
- if (oPreliminaryState && oPreliminaryState.addedFilterItems && oPreliminaryState.addedFilterItems.includes(oFilterItem.getName())){
189
- oFilterItem.setVisibleInFilterBar();
190
- }
191
- if (oPreliminaryState && oPreliminaryState.removedFilterItems && oPreliminaryState.removedFilterItems.includes(oFilterItem.getName())){
192
- oFilterItem.setVisibleInFilterBar(false);
193
- }
194
- });
178
+ mParams.oCustomFiltersWrapper.setState(oState && oState.customFilters);
195
179
 
196
- // Retaining the old value of "modified" flag in the smart variant
197
- oSmartVariant.currentVariantSetModified(bIsCurrentVariantModifiedBeforeSetState);
180
+ // set visibility
181
+ // TODO:
182
+ // - How to deal with old states (not containing all information about visibility) -> legacy state handler?
183
+ // - restoring from old state when annotation has changed (new selection fields)?
184
+ oSmartFilterBar.getAllFilterItems().forEach(function(oFilterItem){
185
+ if (oState && oState.addedFilterItems && oState.addedFilterItems.includes(oFilterItem.getName())){
186
+ oFilterItem.setVisibleInFilterBar();
187
+ }
188
+ if (oState && oState.removedFilterItems && oState.removedFilterItems.includes(oFilterItem.getName())){
189
+ oFilterItem.setVisibleInFilterBar(false);
190
+ }
198
191
  });
199
192
 
193
+ // Retaining the old value of "modified" flag in the smart variant
194
+ oSmartVariant.currentVariantSetModified(bIsCurrentVariantModifiedBeforeSetState);
195
+
200
196
  // Apparently, SFB does not always correctly adapt the adapt filters count automatically. The following method has been provided espacially to trigger the same.
201
197
  // 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.
202
198
  oSmartFilterBar.refreshFiltersCount();
@@ -211,29 +207,15 @@ sap.ui.define([
211
207
  }
212
208
  }
213
209
 
214
- oControlAssignedPromise.then(function () {
215
- oSmartFilterBar.attachFilterChange(function () {
216
- // Don't forward filter change event while dialog is open - changes should only be registered when dialog is closed
217
- if (!oSmartFilterBar.isDialogOpen()) {
218
- handleStateChanged();
219
- }
220
- });
221
- // unclear, whether this is needed, or filterChange event is anyway raised again (after dialog is closed)
222
- oSmartFilterBar.attachFiltersDialogClosed(handleStateChanged);
223
-
224
- // do we need to provide and handle change events from custom filters?
225
- // contra:
226
- // - SFB raises filteChange event also for custom filters
227
- // - maybe also needed to be suppressed while dialog is open
228
- // pro:
229
- // - cleaner from architectural perspective
230
- // - SFB cannot deal correctly with unknown custom controls
231
- // - existing method in extensionAPI (onCustomAppStateChange)
232
- mParams.oCustomFiltersWrapper.attachStateChanged(handleStateChanged);
210
+ oSmartFilterBar.attachFilterChange(function () {
211
+ // Don't forward filter change event while dialog is open - changes should only be registered when dialog is closed
212
+ if (!oSmartFilterBar.isDialogOpen()) {
213
+ handleStateChanged();
214
+ }
233
215
  });
234
216
  // unclear, whether this is needed, or filterChange event is anyway raised again (after dialog is closed)
235
217
  oSmartFilterBar.attachFiltersDialogClosed(handleStateChanged);
236
-
218
+
237
219
  // do we need to provide and handle change events from custom filters?
238
220
  // contra:
239
221
  // - SFB raises filteChange event also for custom filters
@@ -244,7 +226,7 @@ sap.ui.define([
244
226
  // - existing method in extensionAPI (onCustomAppStateChange)
245
227
  mParams.oCustomFiltersWrapper.attachStateChanged(function(){
246
228
  handleStateChanged();
247
- // When a custom filter value is changed by the user, not only the appState changes, but also the variant needs to be marked as dirty. For some known controls, this is
229
+ // When a custom filter value is changed by the user, not only the appState changes, but also the variant needs to be marked as dirty. For some known controls, this is
248
230
  // handled from the SFB (which informs the SVM directly). This logic is broken from architectural point of view, as it does not allow to use arbitrary own controls for
249
231
  // extension filters (which is the general idea of an extension).
250
232
  // However, when user selects a variant, custom filters also have to be restored, but that must not mark the selected variant as dirty. Ideally, this should be handled
@@ -257,27 +239,22 @@ sap.ui.define([
257
239
  });
258
240
  }
259
241
 
260
- function fnSetControl(oControl) {
261
- oSmartFilterBar = oControl;
262
- oControlAssignedResolve(oSmartFilterBar);
263
- }
264
-
265
242
  // check waiting for initialization (like in SmartTableWrapper/SmartChartWrapper)
266
243
  // currently, whole appState restoring is waiting for initialized event from sfb - but probably it would be enough to wait for it here
267
244
  fnInitialize();
268
-
245
+
269
246
  return {
270
- // generic properties (provided by all state wrappers)
247
+ // generic properties (provided by all state wrappers)
271
248
  getState: fnGetState,
272
249
  setState: fnSetState,
273
- setControl: fnSetControl,
274
250
  attachStateChanged: fnAttachStateChanged,
275
251
  // specific properties (needed to workaround direct connection between SFB and SVM)
276
252
  setSVMWrapperCallbacks: setSVMWrapperCallbacks,
277
253
  bVMConnection: oSmartFilterBar.getSmartVariant(),
278
- suppressSelection: oSmartFilterBar.setSuppressSelection.bind(oSmartFilterBar) // if multiple reasons for suppressing overlap, a counter (to avoid to early resume) could be implemented here
254
+ suppressSelection: oSmartFilterBar.setSuppressSelection.bind(oSmartFilterBar), // if multiple reasons for suppressing overlap, a counter (to avoid to early resume) could be implemented here
255
+ oVariantManagementInitializedPromise: oVariantManagementInitializedPromise
279
256
  };
280
257
  }
281
258
 
282
259
  return SmartFilterBarWrapper;
283
- });
260
+ });
@@ -4,40 +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
- }
64
+ oUiState: oStateUiState
41
65
  };
42
66
  }
43
67
 
@@ -52,11 +76,17 @@ sap.ui.define([
52
76
  bIsApplying = true;
53
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
54
78
  // interfere with them
55
- var oUiState = oControl.getUiState();
56
- if (!oUiState.getProperty("variantName")){
57
- oUiState.setPresentationVariant(oState.oUiState.oPresentationVariant);
58
- oUiState.setSelectionVariant(oState.oUiState.oSelectionVariant);
59
- 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);
60
90
  }
61
91
  bIsApplying = false;
62
92
  } else {
@@ -82,77 +112,59 @@ sap.ui.define([
82
112
  getState: fnGetState,
83
113
  setState: fnSetState,
84
114
  getLocalId: fnGetLocalId,
85
- bVMConnection: false,
86
- attachStateChanged: fnAttachStateChanged
115
+ bVMConnection: oControl && oControl.getSmartVariant && !!oControl.getSmartVariant(),
116
+ attachStateChanged: fnAttachStateChanged,
117
+ onAfterVariantInitialise: oVariantManagementInitializedResolve
87
118
  };
88
119
  }
89
120
 
90
121
  function fnGetState() {
91
- if (bSmartControlInitialized) {
92
- if (oVariantManagementStateWrapper) {
93
- // oVariantManagementStateWrapper would be undefined only in cases SmartControl is not yet initialized
94
- // or VariantManagement is not enabled.
95
- return oVariantManagementStateWrapper.getState();
96
- }
97
-
98
- if (oSmartControlStateWrapper && !bVariantManagementActive) {
99
- // VariantManagement is not turned on & SmartControlStateWrapper instance
100
- return oSmartControlStateWrapper.getState();
101
- }
122
+ if (oVariantManagementStateWrapper) {
123
+ // Variant management is active
124
+ return oVariantManagementStateWrapper.getState();
102
125
  }
103
126
 
104
- // Control is not available and StateWrapper is not initialized
105
- return oPreliminaryState;
127
+ // No variant management - return control state directly
128
+ return oSmartControlStateWrapper.getState();
106
129
  }
107
130
 
108
131
  function fnSetState(oState) {
109
- oPreliminaryState = oState;
110
- oControlAssignedPromise.then(function () {
111
- // map legacy states - before separating VM state from state of managed control, inner state information
112
- // (presentation variant and selection variant) were put as oUiState on the same level as VM state
113
- // information (variant id and dirty indicator), now they are contained in map managedControlStates
114
- if (oState){
115
- if (oState.oUiState && !oState.managedControlStates) {
116
- oState.managedControlStates = Object.create(null);
117
- oState.managedControlStates[oSmartControlStateWrapper.getLocalId()] = {oUiState: oState.oUiState};
118
- }
119
- if (oState.bVariantModified !== undefined) {
120
- oState.modified = oState.bVariantModified;
121
- }
122
- if (oState.sVariantId !== undefined) {
123
- oState.variantId = oState.sVariantId;
124
- }
125
- }
126
-
132
+ if (!oState) {
133
+ // If no state provided, set standard variant on control
127
134
  if (bVariantManagementActive) {
128
- // In case VariantManagement is configured
129
- oVariantManagementStateWrapper.setState(oPreliminaryState);
130
- return;
135
+ oVariantManagementStateWrapper.setState(oState);
136
+ } else {
137
+ oSmartControlStateWrapper.setState(oState);
131
138
  }
132
-
133
- // SmartTable/Chart shall be used
134
- oSmartControlStateWrapper.setState(oPreliminaryState);
135
- });
136
- }
137
-
138
- function fnSetControl(oControl) {
139
- oSmartControl = oControl;
140
- oSmartControlStateWrapper = getControlWrapper(oSmartControl);
141
- if (!oSmartControl.isInitialised()) {
142
- // In case Smart Chart/Table is not yet initialized
143
- // listen to the initialize event & then resolve the control
144
- oSmartControl.attachEvent(sInitializationEvent, fnControlInitialized);
145
139
  return;
146
140
  }
147
141
 
148
- 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
+ }
149
163
  }
150
164
 
151
165
  function fnControlInitialized() {
152
- bSmartControlInitialized = true;
153
-
154
166
  // deal with VM
155
- // 3 possibilties with respect to VM
167
+ // 3 possibilities with respect to VM
156
168
  // a) no VM (relevant for this control) at all
157
169
  // b) control managed as part of page wide variant management
158
170
  // c) control creates own VM
@@ -176,39 +188,35 @@ sap.ui.define([
176
188
  oVariantManagementStateWrapper = oFactory.getControlStateWrapper(oVariantManagementControl, {
177
189
  managedControlWrappers: [ oSmartControlStateWrapper ]
178
190
  });
179
- oControlAssignedResolve();
191
+ fnResolveReady();
180
192
  } else {
181
- // Resolve the ControlAssignedPromise only once the VariantManagement is
182
- // also initialized
193
+ // Wait for VariantManagement to be initialized
183
194
  oSmartControl.attachAfterVariantInitialise(fnControlInitialized);
184
195
  }
185
-
186
- return;
196
+ } else {
197
+ // No variant management or page-level variant management - ready immediately
198
+ fnResolveReady();
187
199
  }
188
- // There is no VariantManagement configured for this SmartChart/SmartTable
189
- oControlAssignedResolve(oSmartControl);
190
200
  }
191
201
 
192
202
  function fnAttachStateChanged(fnHandler) {
193
- oControlAssignedPromise.then(function () {
194
- if (bVariantManagementActive) {
195
- oVariantManagementStateWrapper.attachStateChanged(fnHandler);
196
- return;
197
- }
198
-
203
+ if (bVariantManagementActive) {
204
+ oVariantManagementStateWrapper.attachStateChanged(fnHandler);
205
+ } else {
199
206
  oSmartControlStateWrapper.attachStateChanged(fnHandler);
200
-
201
- });
207
+ }
202
208
  }
203
209
 
204
210
  return {
205
211
  getState: fnGetState,
206
212
  setState: fnSetState,
207
- setControl: fnSetControl,
208
213
  attachStateChanged: fnAttachStateChanged,
209
- bVMConnection: oSmartControl && oSmartControl.getSmartVariant && !!oSmartControl.getSmartVariant()
214
+ bVMConnection: oSmartControl && oSmartControl.getSmartVariant && !!oSmartControl.getSmartVariant(),
215
+ oVariantManagementInitializedPromise: oVariantManagementInitializedPromise,
216
+ onAfterVariantInitialise: oVariantManagementInitializedResolve,
217
+ oReadyPromise: oReadyPromise
210
218
  };
211
219
  }
212
220
 
213
221
  return SmartTableChartCommon;
214
- });
222
+ });
@@ -2,10 +2,18 @@ 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){
14
+ // SmartTable extends SmartTableChartCommon with tableSettings support
7
15
  return new SmartTableChartCommon(oSmartTable, oController, oFactory, "initialise");
8
16
  }
9
17
 
10
18
  return SmartTableWrapper;
11
- });
19
+ });