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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/package.json +1 -1
  2. package/src/sap/suite/ui/generic/template/.library +1 -1
  3. package/src/sap/suite/ui/generic/template/AnalyticalListPage/controller/ControllerImplementation.js +6 -9
  4. package/src/sap/suite/ui/generic/template/AnalyticalListPage/manifest.json +1 -1
  5. package/src/sap/suite/ui/generic/template/Canvas/manifest.json +1 -1
  6. package/src/sap/suite/ui/generic/template/ListReport/controller/ControllerImplementation.js +94 -11
  7. package/src/sap/suite/ui/generic/template/ListReport/controller/IappStateHandler.js +19 -9
  8. package/src/sap/suite/ui/generic/template/ListReport/manifest.json +1 -1
  9. package/src/sap/suite/ui/generic/template/ListReport/view/fragments/SmartChart.fragment.xml +2 -1
  10. package/src/sap/suite/ui/generic/template/ListReport/view/fragments/SmartTable.fragment.xml +3 -2
  11. package/src/sap/suite/ui/generic/template/ObjectPage/controller/ControllerImplementation.js +5 -2
  12. package/src/sap/suite/ui/generic/template/ObjectPage/manifest.json +1 -1
  13. package/src/sap/suite/ui/generic/template/ObjectPage/view/fragments/SmartChart.fragment.xml +3 -2
  14. package/src/sap/suite/ui/generic/template/ObjectPage/view/fragments/SmartTable.fragment.xml +3 -2
  15. package/src/sap/suite/ui/generic/template/QuickCreate/manifest.json +1 -1
  16. package/src/sap/suite/ui/generic/template/QuickView/manifest.json +1 -1
  17. package/src/sap/suite/ui/generic/template/genericUtilities/ControlStateWrapperFactory.js +101 -67
  18. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/DynamicPageWrapper.js +19 -51
  19. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/ObjectPageLayoutWrapper.js +10 -32
  20. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/PreliminaryWrapper.js +144 -0
  21. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SearchFieldWrapper.js +8 -30
  22. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartFilterBarWrapper.js +49 -162
  23. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartTableChartCommon.js +100 -94
  24. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartTableWrapper.js +22 -3
  25. package/src/sap/suite/ui/generic/template/genericUtilities/controlStateWrapperFactory/SmartVariantManagementWrapper.js +82 -75
  26. package/src/sap/suite/ui/generic/template/lib/AppComponent.js +1 -1
  27. package/src/sap/suite/ui/generic/template/lib/ai/EasyFilterBarHandler.js +21 -8
  28. package/src/sap/suite/ui/generic/template/lib/navigation/NavigationController.js +1 -1
  29. package/src/sap/suite/ui/generic/template/library.js +1 -1
@@ -4,18 +4,16 @@ sap.ui.define([
4
4
 
5
5
  /**
6
6
  * Constructor for SmartVariantManagementWrapper
7
- * @param {sap.ui.comp.smartvariants.SmartVariantManagement} vTarget - The SmartVariantManagement control
8
- * or the Id of control for which this wrapper is created
7
+ * @param {sap.ui.comp.smartvariants.SmartVariantManagement} oControl - The SmartVariantManagement control
9
8
  * @param {object} oController - the controller of the current component
10
9
  * @param {object} oFactory - the controlStateWrapperFactory
11
10
  * @param {object} mParams
12
11
  * @param {array} mParams.managedControlWrappers - array of controlStateWrappers for controls handled by the SVM
13
12
  * (currently also including SFB wrapper - to be removed)
14
- * @param {Object} mParams.dynamicPageWrapper - dynamicPageWrapper instance handled by SVM
15
13
  * @returns {object}
16
14
  */
17
15
 
18
- function SmartVariantManagementWrapper(vTarget, oController, oFactory, mParams) {
16
+ function SmartVariantManagementWrapper(oControl, oController, oFactory, mParams) {
19
17
  // Special handling of SmartFilterBarWrapper for several reasons:
20
18
  // - Suppress selection when restoring a variant. Selection is solely triggered according to information in appState. Otherwise, erroneous selection could be triggered in
21
19
  // a few situations:
@@ -26,14 +24,10 @@ sap.ui.define([
26
24
  // - Store and restore extension state (extension implemented in SFB instead of SVM, which would be more appropriate from architectural point of view)
27
25
  // flag to control whether we are currently in the process of applying a state to suppress the event to inform about a new state´
28
26
  // only needed when setting the variant itself - for managed controls, their wrappers should avoid firing the event themselves
29
- var oSmartVariantManagement, fnResolveControlAssigned, oPreliminaryState;
30
- var oControlAssignedPromise = new Promise(function (resolve) {
31
- fnResolveControlAssigned = resolve;
32
- });
33
-
34
- if (typeof vTarget !== "string") {
35
- fnSetControl(vTarget);
36
- }
27
+ var oSmartVariantManagement = oControl;
28
+ var oPreliminaryState;
29
+ var bIsApplyingVariant = false;
30
+ var bAllControlsInitialized = false;
37
31
 
38
32
  // Handles the state of the variant management itself (i.e. which variant is selected and whether it's dirty), including the state of the managed controls.
39
33
  // Is responsible esp. to restore this state with correct dependency resp. in correct order
@@ -50,69 +44,72 @@ sap.ui.define([
50
44
  // For these controls, a real user changes are already handled by the direct connection. On the other hand, these controls also fire their change events, if their state is
51
45
  // changed from SVM (by the same connection) - setting variant dirty here would be wrong.
52
46
  mParams.managedControlWrappers.forEach(function(oWrapper){
53
- if (!oWrapper.bVMConnection){
54
- oWrapper.attachStateChanged(function(){
55
- oSmartVariantManagement.currentVariantSetModified(true);
56
- });
57
- }
47
+ (oWrapper.oVMConnectionPromise || Promise.resolve(oWrapper.bVMConnection)).then(function(bVMConnection) {
48
+ if (!bVMConnection) {
49
+ oWrapper.attachStateChanged(function(){
50
+ oSmartVariantManagement.currentVariantSetModified(true);
51
+ });
52
+ }
53
+ });
58
54
  });
59
55
 
60
56
 
61
57
 
62
- function fnSetControl(oControl) {
63
- oSmartVariantManagement = oControl;
64
- fnResolveControlAssigned(oSmartVariantManagement);
65
- }
66
-
67
58
  var oSmartFilterBarWrapper = mParams.managedControlWrappers.find(function(oWrapper){
68
59
  return oWrapper.setSVMWrapperCallbacks;
69
60
  });
70
61
 
71
- // provide callbacks needed for SFB wrapper to store/restore extnesion state with variant
62
+ // provide callbacks needed for SFB wrapper to store/restore extension state with variant
72
63
  if (oSmartFilterBarWrapper){
73
- oSmartFilterBarWrapper.setSVMWrapperCallbacks({
74
- getManagedControlStates: function(){
75
- var mManagedControlStates = Object.create(null);
76
- mParams.managedControlWrappers.forEach(function(oWrapper){
77
- if (!oWrapper.bVMConnection){
78
- mManagedControlStates[oWrapper.getLocalId()] = oWrapper.getState();
79
- }
80
- });
81
- return mManagedControlStates;
82
- },
83
- setManagedControlStates: function(oState){
84
- mParams.managedControlWrappers.forEach(function(oWrapper){
85
- if (!oWrapper.bVMConnection){
86
- oWrapper.setState(oState[oWrapper.getLocalId()]);
87
- }
88
- });
89
- },
90
- setHeaderState: function(bHeaderToBeExpanded) {
91
- mParams.dynamicPageWrapper.setHeaderState(oController, bHeaderToBeExpanded);
92
- }
64
+ // Build array with wrapper + bVMConnection info once all wrappers are ready
65
+ Promise.all(mParams.managedControlWrappers.map(function(oWrapper){
66
+ return (oWrapper.oVMConnectionPromise || Promise.resolve(oWrapper.bVMConnection)).then(function(bVMConnection){
67
+ return {
68
+ wrapper: oWrapper,
69
+ bVMConnection: bVMConnection
70
+ };
71
+ });
72
+ })).then(function(aWrapperInfo) {
73
+ oSmartFilterBarWrapper.setSVMWrapperCallbacks({
74
+ getManagedControlStates: function(){
75
+ var mManagedControlStates = Object.create(null);
76
+ aWrapperInfo.forEach(function(oInfo){
77
+ if (!oInfo.bVMConnection) {
78
+ mManagedControlStates[oInfo.wrapper.getLocalId()] = oInfo.wrapper.getState();
79
+ }
80
+ });
81
+ return mManagedControlStates;
82
+ },
83
+ setManagedControlStates: function(oState){
84
+ aWrapperInfo.forEach(function(oInfo){
85
+ if (!oInfo.bVMConnection) {
86
+ oInfo.wrapper.setState(oState[oInfo.wrapper.getLocalId()]);
87
+ }
88
+ });
89
+ }
90
+ });
93
91
  });
94
92
  }
95
93
 
94
+ // Create promise that resolves when all managed controls' variant management is ready
95
+ // This ensures getState() can query controls even if setState() is never called (e.g., app starts from scratch)
96
+ var oAllControlsInitializedPromise = Promise.all(
97
+ mParams.managedControlWrappers.map(function(oWrapper){
98
+ return oWrapper.oVariantManagementInitializedPromise || Promise.resolve();
99
+ })
100
+ );
101
+
102
+ // Set flag when all controls are initialized
103
+ oAllControlsInitializedPromise.then(function() {
104
+ bAllControlsInitialized = true;
105
+ });
106
+
96
107
  // Wrapper is intended to set a state to the ui, but not to trigger a selection (which should happen only after all (relevant) parts of ui state is set to the correct state
97
108
  // are set correct. Therefore, setting variant from here should never trigger a selection.
98
109
  function fnSetVariant(sVariantId){
99
110
  if (oSmartFilterBarWrapper){
100
111
  oSmartFilterBarWrapper.suppressSelection(true);
101
112
  }
102
- var sId = mParams.managedControlWrappers[0].getLocalId();
103
- var oControl = oController.getView().byId(sId);
104
- if (oControl && oControl.isA("sap.ui.comp.smarttable.SmartTable")) {
105
- oControl.attachAfterVariantInitialise(function() {
106
- //set currentVariantId only when sVariantId is not standard (as it might be overriding existing
107
- //different currentVariantId) or smartTable's (oControl) currentVariantId is not equal to sVariantId.
108
- if (sVariantId !== '*standard*' && sVariantId !== '') {
109
- if (oControl.getCurrentVariantId && oControl.getCurrentVariantId() !== sVariantId) {
110
- oControl.setCurrentVariantId(sVariantId);
111
- }
112
- oSmartVariantManagement.setModified(false);
113
- }
114
- });
115
- }
116
113
  oSmartVariantManagement.setCurrentVariantId(sVariantId);
117
114
  if (oSmartFilterBarWrapper){
118
115
  oSmartFilterBarWrapper.suppressSelection(false);
@@ -133,7 +130,11 @@ sap.ui.define([
133
130
  }
134
131
 
135
132
  function getState() {
136
- if (!oSmartVariantManagement) {
133
+ // Return preliminary state if managed controls not fully initialized
134
+ // Note: If early getState() calls become an issue (controls not initialized yet), we could enhance this to:
135
+ // - Store only SVM-specific data (variantId, modified) in oPreliminaryState
136
+ // - Always query managed control wrappers directly (they handle their own preliminary state via PreliminaryWrapper)
137
+ if (!bAllControlsInitialized) {
137
138
  return oPreliminaryState;
138
139
  }
139
140
 
@@ -150,22 +151,23 @@ sap.ui.define([
150
151
 
151
152
  function setState(oState) {
152
153
  oPreliminaryState = oState;
153
- oControlAssignedPromise.then(function() {
154
+
155
+ // Wait for all managed controls to be initialized before applying state
156
+ oAllControlsInitializedPromise.then(function() {
157
+ bIsApplyingVariant = true;
154
158
  if (!oPreliminaryState) {
155
159
  // if no state is provided set default variant (not modified)
156
160
  // use cases:
157
161
  // - LR: if appStateKey in the URL that cannot be read
158
162
  // - OP: if switching to different object instance (in discovery mode always, in persistency mode when page was not shown)
159
163
  fnSetVariant(oSmartVariantManagement.getDefaultVariantId());
160
- return;
161
- }
162
- if (oPreliminaryState.modified) {
164
+ } else if (oPreliminaryState.modified) {
163
165
  // Special logic according to UX: If variant was modified anyway, there's no benefit for the user to see the name (but it could be confusing), so standard variant (not default!) should be
164
166
  // set (which is achieved by empty string)
165
167
  fnSetVariant("");
168
+ oSmartVariantManagement.currentVariantSetModified(true);
166
169
  // Usually restoring the state of any of the managed controls should mark the variant as dirty, but there might be edge cases (state from an old release not containing information for any
167
170
  // managed control now relevant), so to be on the safe side, we set modified=true explicitly.
168
- oSmartVariantManagement.currentVariantSetModified(true);
169
171
  fnSetManagedControlStates(oPreliminaryState);
170
172
  } else {
171
173
  fnSetVariant(oPreliminaryState.variantId);
@@ -183,6 +185,7 @@ sap.ui.define([
183
185
  }
184
186
  }
185
187
  }
188
+ bIsApplyingVariant = false;
186
189
  });
187
190
  }
188
191
 
@@ -190,26 +193,30 @@ sap.ui.define([
190
193
  // state of variant management itself can be changed directly (user selects a different variant or stores current state as (new) variant), or indirectly (user changes some
191
194
  // data of a control managed by VM, e.g. some filter values in SFB)
192
195
 
193
- oControlAssignedPromise.then(function() {
194
- // state change when user selects a different variant
195
- oSmartVariantManagement.attachSelect(fnHandler);
196
+ // Wrap the handler to suppress events when applying a variant
197
+ var fnSuppressibleHandler = function() {
198
+ if (!bIsApplyingVariant) {
199
+ fnHandler();
200
+ }
201
+ };
202
+
203
+ // state change when user selects a different variant
204
+ oSmartVariantManagement.attachSelect(fnSuppressibleHandler);
196
205
 
197
- // when user saves current state as a new variant, this is also a state change (as the variant id is part of the state)
198
- // note: Even if new (SFB) variant is marked as execute on select, and currently no data is selected, no need to select data here (and thus also not to collapse header).
199
- // This is one of the possible ways to get into a state with a clean variant with execute on select, but no data loaded - see also comment to identify SFB wrapper.
200
- oSmartVariantManagement.attachAfterSave(fnHandler);
206
+ // when user saves current state as a new variant, this is also a state change (as the variant id is part of the state)
207
+ // note: Even if new (SFB) variant is marked as execute on select, and currently no data is selected, no need to select data here (and thus also not to collapse header).
208
+ // This is one of the possible ways to get into a state with a clean variant with execute on select, but no data loaded - see also comment to identify SFB wrapper.
209
+ oSmartVariantManagement.attachAfterSave(fnSuppressibleHandler);
201
210
 
202
- // any change of a managed control is state change
203
- mParams.managedControlWrappers.forEach(function(oWrapper){
204
- oWrapper.attachStateChanged(fnHandler);
205
- });
211
+ // any change of a managed control is state change
212
+ mParams.managedControlWrappers.forEach(function(oWrapper){
213
+ oWrapper.attachStateChanged(fnSuppressibleHandler);
206
214
  });
207
215
  }
208
216
 
209
217
  return {
210
218
  getState : getState,
211
219
  setState : setState,
212
- setControl: fnSetControl,
213
220
  attachStateChanged : attachStateChanged
214
221
  };
215
222
  }
@@ -959,7 +959,7 @@ sap.ui.define([
959
959
  * @public
960
960
  * @extends sap.ui.core.UIComponent
961
961
  * @author SAP SE
962
- * @version 1.142.5
962
+ * @version 1.142.7
963
963
  * @name sap.suite.ui.generic.template.lib.AppComponent
964
964
  */
965
965
  var oAppComponent = UIComponent.extend("sap.suite.ui.generic.template.lib.AppComponent", {
@@ -435,7 +435,7 @@ sap.ui.define([
435
435
  oTemplateUtils.oComponentUtils.getBusyHelper().setBusy(oQueryPromise);
436
436
  }
437
437
 
438
- function fnTokensChanged(oEvent) {
438
+ function fnTokensChanged(oEvent) {
439
439
  var oSmartFilterbar = oState.oSmartFilterbar;
440
440
  var oFiltersFromAI = oEvent.getParameter("tokens");
441
441
  var sSmartFilterBarId = oSmartFilterbar.getId();
@@ -456,19 +456,32 @@ sap.ui.define([
456
456
  oSmartFilterBarVariant.customFilters.editState = oVariantDataFromAI.oEditStateFilter;
457
457
  }
458
458
 
459
- if (oSmartFilterBarVariant.semanticDates) {
460
- var { Low: value1, High: value2 } = oVariantDataFromAI.aSelectOptions[0].Ranges[0];
461
- var dateData = oSmartFilterBarVariant.semanticDates.Dates[0].Data;
462
- dateData.operation = "DATERANGE";
463
- dateData.value1 = value1;
464
- dateData.value2 = value2 || value1;
459
+ //checking if the variant of SFB has previous semantic dates and if there are new filter values from easy filter then update the SFB variant
460
+ if (oSmartFilterBarVariant.semanticDates?.Dates) {
461
+ oSmartFilterBarVariant.semanticDates.Dates.forEach(function (semanticDate) {
462
+ var propertyName = semanticDate.PropertyName;
463
+
464
+ // Find matching property in aSelectOptions
465
+ var matchingSelectOption = oVariantDataFromAI.aSelectOptions.find(function (selectOption) {
466
+ return selectOption.PropertyName === propertyName;
467
+ });
468
+
469
+ // If matching property found and has ranges
470
+ if (matchingSelectOption?.Ranges?.length > 0) {
471
+ var { Low: value1 = null, High: value2 = null } = matchingSelectOption.Ranges[0];
472
+ // Update the semantic date data in the smart filter bar
473
+ var dateData = semanticDate.Data;
474
+ dateData.operation = "DATERANGE";
475
+ dateData.value1 = value1;
476
+ dateData.value2 = value2 || value1; // Use value1 if value2 is null/empty
477
+ }
478
+ });
465
479
  }
466
480
 
467
481
  oSmartFilterBarWrapper.setState(oSmartFilterBarVariant);
468
482
  oSmartFilterbar.getSmartVariant() && oSmartFilterbar.getSmartVariant().currentVariantSetModified(true);
469
483
  oSmartFilterbar.search();
470
484
  }
471
-
472
485
  /**
473
486
  * Event handler for the EasyFilter control's showValueHelp event.
474
487
  * Identifies the input field for which the value help is requested and triggers the value help opening from SFB.
@@ -3213,7 +3213,7 @@ sap.ui.define(["sap/ui/base/Object",
3213
3213
  * @param {sap.suite.ui.generic.template.lib.AppComponent} oAppComponent The AppComponent instance
3214
3214
  * @public
3215
3215
  * @extends sap.ui.base.Object
3216
- * @version 1.142.5
3216
+ * @version 1.142.7
3217
3217
  * @since 1.30.0
3218
3218
  * @alias sap.suite.ui.generic.template.lib.NavigationController
3219
3219
  */
@@ -66,7 +66,7 @@ sap.ui.define([
66
66
  interfaces: [],
67
67
  controls: [],
68
68
  elements: [],
69
- version: "1.142.5",
69
+ version: "1.142.7",
70
70
  extensions: {
71
71
  //Configuration used for rule loading of Support Assistant
72
72
  "sap.ui.support": {