@sapui5/sap.fe.templates 1.100.0 → 1.102.0

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 (150) hide show
  1. package/package.json +4 -5
  2. package/src/sap/fe/templates/.library +1 -2
  3. package/src/sap/fe/templates/AnalyticalListPage/Component.js +24 -12
  4. package/src/sap/fe/templates/AnalyticalListPage/Component.ts +6 -0
  5. package/src/sap/fe/templates/AnalyticalListPage/chart/FEChartDelegate.js +30 -32
  6. package/src/sap/fe/templates/AnalyticalListPage/chart/FEChartDelegate.ts +25 -0
  7. package/src/sap/fe/templates/Feedback.js +80 -0
  8. package/src/sap/fe/templates/Feedback.ts +67 -0
  9. package/src/sap/fe/templates/ListComponent.js +156 -118
  10. package/src/sap/fe/templates/ListComponent.ts +105 -0
  11. package/src/sap/fe/templates/ListReport/Component.js +82 -53
  12. package/src/sap/fe/templates/ListReport/Component.ts +39 -0
  13. package/src/sap/fe/templates/ListReport/ExtensionAPI.js +126 -112
  14. package/src/sap/fe/templates/ListReport/ExtensionAPI.ts +106 -0
  15. package/src/sap/fe/templates/ListReport/ListReport.view.xml +106 -58
  16. package/src/sap/fe/templates/ListReport/ListReportController.controller.js +1196 -1081
  17. package/src/sap/fe/templates/ListReport/ListReportController.controller.ts +1088 -0
  18. package/src/sap/fe/templates/ListReport/ListReportTemplating.js +45 -0
  19. package/src/sap/fe/templates/ListReport/ListReportTemplating.ts +30 -0
  20. package/src/sap/fe/templates/ListReport/overrides/IntentBasedNavigation.js +54 -53
  21. package/src/sap/fe/templates/ListReport/overrides/IntentBasedNavigation.ts +55 -0
  22. package/src/sap/fe/templates/ListReport/overrides/Share.js +137 -137
  23. package/src/sap/fe/templates/ListReport/overrides/Share.ts +135 -0
  24. package/src/sap/fe/templates/ListReport/overrides/ViewState.js +451 -428
  25. package/src/sap/fe/templates/ListReport/overrides/ViewState.ts +419 -0
  26. package/src/sap/fe/templates/ListReport/view/fragments/CollectionVisualization.fragment.xml +25 -25
  27. package/src/sap/fe/templates/ListReport/view/fragments/MultipleMode.fragment.js +72 -0
  28. package/src/sap/fe/templates/ListReport/view/fragments/MultipleMode.fragment.ts +62 -0
  29. package/src/sap/fe/templates/ListReport/view/fragments/{MultipleMode.fragment.xml → MultipleModeOld.fragment.xml} +24 -23
  30. package/src/sap/fe/templates/ObjectPage/Component.js +169 -138
  31. package/src/sap/fe/templates/ObjectPage/Component.ts +131 -0
  32. package/src/sap/fe/templates/ObjectPage/ExtensionAPI.js +140 -142
  33. package/src/sap/fe/templates/ObjectPage/ExtensionAPI.ts +116 -0
  34. package/src/sap/fe/templates/ObjectPage/ObjectPage.view.xml +162 -22
  35. package/src/sap/fe/templates/ObjectPage/ObjectPageController.controller.js +1534 -1447
  36. package/src/sap/fe/templates/ObjectPage/ObjectPageController.controller.ts +1454 -0
  37. package/src/sap/fe/templates/ObjectPage/ObjectPageTemplating.js +872 -0
  38. package/src/sap/fe/templates/ObjectPage/ObjectPageTemplating.ts +837 -0
  39. package/src/sap/fe/templates/ObjectPage/controls/StashableHBox.js +136 -101
  40. package/src/sap/fe/templates/ObjectPage/controls/StashableHBox.ts +84 -0
  41. package/src/sap/fe/templates/ObjectPage/controls/StashableVBox.js +24 -21
  42. package/src/sap/fe/templates/ObjectPage/controls/StashableVBox.ts +10 -0
  43. package/src/sap/fe/templates/ObjectPage/controls/SubSectionBlock.js +98 -53
  44. package/src/sap/fe/templates/ObjectPage/controls/SubSectionBlock.ts +50 -0
  45. package/src/sap/fe/templates/ObjectPage/designtime/FlexBox.designtime.js +20 -19
  46. package/src/sap/fe/templates/ObjectPage/designtime/FlexBox.designtime.ts +15 -0
  47. package/src/sap/fe/templates/ObjectPage/designtime/StashableHBox.designtime.js +50 -47
  48. package/src/sap/fe/templates/ObjectPage/designtime/StashableHBox.designtime.ts +47 -0
  49. package/src/sap/fe/templates/ObjectPage/designtime/StashableVBox.designtime.js +34 -34
  50. package/src/sap/fe/templates/ObjectPage/designtime/StashableVBox.designtime.ts +34 -0
  51. package/src/sap/fe/templates/ObjectPage/flexibility/StashableHBox.flexibility.js +15 -15
  52. package/src/sap/fe/templates/ObjectPage/flexibility/StashableHBox.flexibility.ts +13 -0
  53. package/src/sap/fe/templates/ObjectPage/flexibility/StashableVBox.flexibility.js +11 -11
  54. package/src/sap/fe/templates/ObjectPage/flexibility/StashableVBox.flexibility.ts +7 -0
  55. package/src/sap/fe/templates/ObjectPage/overrides/IntentBasedNavigation.js +55 -52
  56. package/src/sap/fe/templates/ObjectPage/overrides/IntentBasedNavigation.ts +57 -0
  57. package/src/sap/fe/templates/ObjectPage/overrides/InternalRouting.js +15 -17
  58. package/src/sap/fe/templates/ObjectPage/overrides/InternalRouting.ts +13 -0
  59. package/src/sap/fe/templates/ObjectPage/overrides/MessageHandler.js +13 -17
  60. package/src/sap/fe/templates/ObjectPage/overrides/MessageHandler.ts +14 -0
  61. package/src/sap/fe/templates/ObjectPage/overrides/Paginator.js +23 -21
  62. package/src/sap/fe/templates/ObjectPage/overrides/Paginator.ts +21 -0
  63. package/src/sap/fe/templates/ObjectPage/overrides/Share.js +310 -317
  64. package/src/sap/fe/templates/ObjectPage/overrides/Share.ts +316 -0
  65. package/src/sap/fe/templates/ObjectPage/overrides/ViewState.js +66 -57
  66. package/src/sap/fe/templates/ObjectPage/overrides/ViewState.ts +65 -0
  67. package/src/sap/fe/templates/ObjectPage/view/fragments/Actions.fragment.xml +26 -33
  68. package/src/sap/fe/templates/ObjectPage/view/fragments/CollaborationDraft.fragment.xml +11 -10
  69. package/src/sap/fe/templates/ObjectPage/view/fragments/EditableHeaderFacet.fragment.xml +15 -15
  70. package/src/sap/fe/templates/ObjectPage/view/fragments/FooterContent.fragment.xml +31 -27
  71. package/src/sap/fe/templates/ObjectPage/view/fragments/FormActionButtons.fragment.xml +15 -16
  72. package/src/sap/fe/templates/ObjectPage/view/fragments/FormActions.fragment.xml +1 -5
  73. package/src/sap/fe/templates/ObjectPage/view/fragments/HeaderDataPoint.fragment.xml +1 -2
  74. package/src/sap/fe/templates/ObjectPage/view/fragments/HeaderDataPointTitle.fragment.xml +1 -3
  75. package/src/sap/fe/templates/ObjectPage/view/fragments/HeaderFacet.fragment.xml +3 -4
  76. package/src/sap/fe/templates/ObjectPage/view/fragments/Heading.fragment.xml +16 -17
  77. package/src/sap/fe/templates/ObjectPage/view/fragments/HeadingTitle.fragment.xml +3 -3
  78. package/src/sap/fe/templates/ObjectPage/view/fragments/ObjectPageHeaderForm.fragment.xml +3 -3
  79. package/src/sap/fe/templates/ObjectPage/view/fragments/RelatedApps.fragment.xml +7 -4
  80. package/src/sap/fe/templates/ObjectPage/view/fragments/Section.fragment.xml +71 -6
  81. package/src/sap/fe/templates/ObjectPage/view/fragments/SectionContent.fragment.xml +114 -94
  82. package/src/sap/fe/templates/ObjectPage/view/fragments/SectionContentLazyLoader.fragment.xml +127 -107
  83. package/src/sap/fe/templates/ObjectPage/view/fragments/SwitchDraftAndActiveObjectPopOver.fragment.xml +27 -0
  84. package/src/sap/fe/templates/RootContainer/controller/Fcl.controller.js +899 -817
  85. package/src/sap/fe/templates/RootContainer/controller/Fcl.controller.ts +833 -0
  86. package/src/sap/fe/templates/RootContainer/controller/NavContainer.controller.js +205 -189
  87. package/src/sap/fe/templates/RootContainer/controller/NavContainer.controller.ts +178 -0
  88. package/src/sap/fe/templates/RootContainer/controller/RootContainerBaseController.js +484 -459
  89. package/src/sap/fe/templates/RootContainer/controller/RootContainerBaseController.ts +438 -0
  90. package/src/sap/fe/templates/RootContainer/overrides/EditFlow.js +16 -14
  91. package/src/sap/fe/templates/RootContainer/overrides/EditFlow.ts +20 -0
  92. package/src/sap/fe/templates/TableScroller.js +45 -53
  93. package/src/sap/fe/templates/TableScroller.ts +48 -0
  94. package/src/sap/fe/templates/controls/Chart.fragment.xml +18 -17
  95. package/src/sap/fe/templates/controls/MacroChart.fragment.xml +23 -0
  96. package/src/sap/fe/templates/controls/Table.fragment.xml +3 -4
  97. package/src/sap/fe/templates/library.js +49 -63
  98. package/src/sap/fe/templates/library.ts +57 -0
  99. package/src/sap/fe/templates/messagebundle.properties +19 -7
  100. package/src/sap/fe/templates/messagebundle_ar.properties +12 -4
  101. package/src/sap/fe/templates/messagebundle_bg.properties +12 -4
  102. package/src/sap/fe/templates/messagebundle_ca.properties +12 -4
  103. package/src/sap/fe/templates/messagebundle_cs.properties +12 -4
  104. package/src/sap/fe/templates/messagebundle_cy.properties +12 -4
  105. package/src/sap/fe/templates/messagebundle_da.properties +12 -4
  106. package/src/sap/fe/templates/messagebundle_de.properties +12 -4
  107. package/src/sap/fe/templates/messagebundle_el.properties +12 -4
  108. package/src/sap/fe/templates/messagebundle_en.properties +12 -4
  109. package/src/sap/fe/templates/messagebundle_en_GB.properties +12 -4
  110. package/src/sap/fe/templates/messagebundle_en_US_sappsd.properties +13 -5
  111. package/src/sap/fe/templates/messagebundle_en_US_saprigi.properties +13 -5
  112. package/src/sap/fe/templates/messagebundle_en_US_saptrc.properties +13 -5
  113. package/src/sap/fe/templates/messagebundle_es.properties +12 -4
  114. package/src/sap/fe/templates/messagebundle_es_MX.properties +12 -4
  115. package/src/sap/fe/templates/messagebundle_et.properties +12 -4
  116. package/src/sap/fe/templates/messagebundle_fi.properties +12 -4
  117. package/src/sap/fe/templates/messagebundle_fr.properties +12 -4
  118. package/src/sap/fe/templates/messagebundle_fr_CA.properties +12 -4
  119. package/src/sap/fe/templates/messagebundle_hi.properties +12 -4
  120. package/src/sap/fe/templates/messagebundle_hr.properties +12 -4
  121. package/src/sap/fe/templates/messagebundle_hu.properties +12 -4
  122. package/src/sap/fe/templates/messagebundle_id.properties +12 -4
  123. package/src/sap/fe/templates/messagebundle_it.properties +12 -4
  124. package/src/sap/fe/templates/messagebundle_iw.properties +12 -4
  125. package/src/sap/fe/templates/messagebundle_ja.properties +12 -4
  126. package/src/sap/fe/templates/messagebundle_kk.properties +12 -4
  127. package/src/sap/fe/templates/messagebundle_ko.properties +12 -4
  128. package/src/sap/fe/templates/messagebundle_lt.properties +12 -4
  129. package/src/sap/fe/templates/messagebundle_lv.properties +12 -4
  130. package/src/sap/fe/templates/messagebundle_ms.properties +12 -4
  131. package/src/sap/fe/templates/messagebundle_nl.properties +12 -4
  132. package/src/sap/fe/templates/messagebundle_no.properties +12 -4
  133. package/src/sap/fe/templates/messagebundle_pl.properties +12 -4
  134. package/src/sap/fe/templates/messagebundle_pt.properties +13 -5
  135. package/src/sap/fe/templates/messagebundle_pt_PT.properties +12 -4
  136. package/src/sap/fe/templates/messagebundle_ro.properties +12 -4
  137. package/src/sap/fe/templates/messagebundle_ru.properties +12 -4
  138. package/src/sap/fe/templates/messagebundle_sh.properties +12 -4
  139. package/src/sap/fe/templates/messagebundle_sk.properties +12 -4
  140. package/src/sap/fe/templates/messagebundle_sl.properties +12 -4
  141. package/src/sap/fe/templates/messagebundle_sv.properties +12 -4
  142. package/src/sap/fe/templates/messagebundle_th.properties +12 -4
  143. package/src/sap/fe/templates/messagebundle_tr.properties +12 -4
  144. package/src/sap/fe/templates/messagebundle_uk.properties +12 -4
  145. package/src/sap/fe/templates/messagebundle_vi.properties +12 -4
  146. package/src/sap/fe/templates/messagebundle_zh_CN.properties +12 -4
  147. package/src/sap/fe/templates/messagebundle_zh_TW.properties +12 -4
  148. package/src/sap/fe/templates/ObjectPage/AnnotationHelper.js +0 -518
  149. package/src/sap/fe/templates/ObjectPage/templating/ObjectPageTemplating.js +0 -120
  150. package/src/sap/fe/templates/ObjectPage/templating/ObjectPageTemplating.ts +0 -138
@@ -0,0 +1,1088 @@
1
+ import ResourceBundle from "sap/base/i18n/ResourceBundle";
2
+ import Log from "sap/base/Log";
3
+ import ObjectPath from "sap/base/util/ObjectPath";
4
+ import DynamicPage from "sap/f/DynamicPage";
5
+ import CommonUtils from "sap/fe/core/CommonUtils";
6
+ import EditFlow from "sap/fe/core/controllerextensions/EditFlow";
7
+ import IntentBasedNavigation from "sap/fe/core/controllerextensions/IntentBasedNavigation";
8
+ import InternalIntentBasedNavigation from "sap/fe/core/controllerextensions/InternalIntentBasedNavigation";
9
+ import InternalRouting from "sap/fe/core/controllerextensions/InternalRouting";
10
+ import KPIManagement from "sap/fe/core/controllerextensions/KPIManagement";
11
+ import MassEdit from "sap/fe/core/controllerextensions/MassEdit";
12
+ import Placeholder from "sap/fe/core/controllerextensions/Placeholder";
13
+ import Share from "sap/fe/core/controllerextensions/Share";
14
+ import SideEffects from "sap/fe/core/controllerextensions/SideEffects";
15
+ import ViewState from "sap/fe/core/controllerextensions/ViewState";
16
+ import FilterBar from "sap/fe/core/controls/FilterBar";
17
+ import {
18
+ defineUI5Class,
19
+ extensible,
20
+ finalExtension,
21
+ privateExtension,
22
+ publicExtension,
23
+ usingExtension
24
+ } from "sap/fe/core/helpers/ClassSupport";
25
+ import EditState from "sap/fe/core/helpers/EditState";
26
+ import { InternalModelContext } from "sap/fe/core/helpers/ModelHelper";
27
+ import CoreLibrary from "sap/fe/core/library";
28
+ import PageController from "sap/fe/core/PageController";
29
+ import ChartRuntime from "sap/fe/macros/chart/ChartRuntime";
30
+ import ChartUtils from "sap/fe/macros/chart/ChartUtils";
31
+ import CommonHelper from "sap/fe/macros/CommonHelper";
32
+ import DelegateUtil from "sap/fe/macros/DelegateUtil";
33
+ import FilterUtils from "sap/fe/macros/filter/FilterUtils";
34
+ import TableUtils from "sap/fe/macros/table/Utils";
35
+ import ExtensionAPI from "sap/fe/templates/ListReport/ExtensionAPI";
36
+ import EditFlowOverrides from "sap/fe/templates/RootContainer/overrides/EditFlow";
37
+ import TableScroller from "sap/fe/templates/TableScroller";
38
+ import IconTabBar from "sap/m/IconTabBar";
39
+ import SegmentedButton from "sap/m/SegmentedButton";
40
+ import Control from "sap/ui/core/Control";
41
+ import Core from "sap/ui/core/Core";
42
+ import OverrideExecution from "sap/ui/core/mvc/OverrideExecution";
43
+ import { system } from "sap/ui/Device";
44
+ import ControlPersonalizationWriteAPI from "sap/ui/fl/write/api/ControlPersonalizationWriteAPI";
45
+ import StateUtil from "sap/ui/mdc/p13n/StateUtil";
46
+ import Table from "sap/ui/mdc/Table";
47
+ import JSONModel from "sap/ui/model/json/JSONModel";
48
+ import ResourceModel from "sap/ui/model/resource/ResourceModel";
49
+ import hasher from "sap/ui/thirdparty/hasher";
50
+ import IntentBasedNavigationOverride from "./overrides/IntentBasedNavigation";
51
+ import ShareOverrides from "./overrides/Share";
52
+ import ViewStateOverrides from "./overrides/ViewState";
53
+
54
+ const TemplateContentView = CoreLibrary.TemplateContentView,
55
+ InitialLoadMode = CoreLibrary.InitialLoadMode;
56
+
57
+ @defineUI5Class("sap.fe.templates.ListReport.ListReportController")
58
+ class ListReportController extends PageController {
59
+ @usingExtension(
60
+ InternalRouting.override({
61
+ onAfterBinding: function (this: InternalRouting) {
62
+ (this.getView().getController() as ListReportController)._onAfterBinding();
63
+ }
64
+ })
65
+ )
66
+ _routing!: InternalRouting;
67
+ @usingExtension(
68
+ InternalIntentBasedNavigation.override({
69
+ getEntitySet: function (this: InternalIntentBasedNavigation) {
70
+ return (this.base as ListReportController).getCurrentEntitySet();
71
+ }
72
+ })
73
+ )
74
+ _intentBasedNavigation!: InternalIntentBasedNavigation;
75
+ @usingExtension(SideEffects)
76
+ sideEffects!: SideEffects;
77
+
78
+ @usingExtension(IntentBasedNavigation.override(IntentBasedNavigationOverride))
79
+ intentBasedNavigation!: IntentBasedNavigation;
80
+
81
+ @usingExtension(Share.override(ShareOverrides))
82
+ share!: Share;
83
+
84
+ @usingExtension(EditFlow.override(EditFlowOverrides))
85
+ editFlow!: EditFlow;
86
+
87
+ @usingExtension(ViewState.override(ViewStateOverrides))
88
+ viewState!: ViewState;
89
+
90
+ @usingExtension(KPIManagement)
91
+ kpiManagement!: KPIManagement;
92
+ @usingExtension(Placeholder)
93
+ placeholder!: Placeholder;
94
+ @usingExtension(MassEdit)
95
+ massEdit!: MassEdit;
96
+ private extensionAPI?: ExtensionAPI;
97
+ private _oListReportControl?: Control;
98
+ private filterBarConditions?: any;
99
+ private _bMultiMode?: boolean;
100
+ private sUpdateTimer?: any;
101
+ private oResourceBundle?: ResourceBundle;
102
+ private _sEntitySet?: string;
103
+ private hasPendingChartChanges?: boolean;
104
+ private hasPendingTableChanges?: boolean;
105
+
106
+ @publicExtension()
107
+ @finalExtension()
108
+ getExtensionAPI(): ExtensionAPI {
109
+ if (!this.extensionAPI) {
110
+ this.extensionAPI = new ExtensionAPI(this);
111
+ }
112
+ return this.extensionAPI;
113
+ }
114
+
115
+ onInit() {
116
+ PageController.prototype.onInit.apply(this);
117
+ const aControls = this._getControls();
118
+ const oInternalModelContext = this.getView().getBindingContext("internal") as InternalModelContext;
119
+ if (this._isMultiMode()) {
120
+ const oMultiModeTab = this._getMultiModeControl();
121
+ oInternalModelContext.setProperty("tabs", {
122
+ selected: oMultiModeTab.getSelectedKey() || (oMultiModeTab.getItems()[0] as any).getKey()
123
+ });
124
+ aControls.forEach((oControl: any) => {
125
+ const oUpdateCounts = () => {
126
+ this._updateCounts();
127
+ };
128
+ CommonUtils.addEventToBindingInfo(oControl, "dataRequested", oUpdateCounts);
129
+ });
130
+ }
131
+ //TODO: This is only a temporary approach and will be removed once app state behaviour is finalized.
132
+
133
+ oInternalModelContext.setProperty("hasPendingFilters", true);
134
+ oInternalModelContext.setProperty("appliedFilters", "");
135
+ oInternalModelContext.setProperty("hideDraftInfo", false);
136
+ oInternalModelContext.setProperty("uom", {});
137
+ oInternalModelContext.setProperty("scalefactor", {});
138
+ oInternalModelContext.setProperty("scalefactorNumber", {});
139
+ oInternalModelContext.setProperty("currency", {});
140
+
141
+ if (this._hasMultiVisualizations()) {
142
+ let alpContentView = this._getDefaultPath();
143
+ if (!system.desktop && alpContentView === TemplateContentView.Hybrid) {
144
+ alpContentView = TemplateContentView.Chart;
145
+ }
146
+ oInternalModelContext.setProperty("alpContentView", alpContentView);
147
+ }
148
+
149
+ // Store conditions from filter bar
150
+ // this is later used before navigation to get conditions applied on the filter bar
151
+ this.filterBarConditions = {};
152
+
153
+ // As AppStateHandler.applyAppState triggers a navigation we want to make sure it will
154
+ // happen after the routeMatch event has been processed (otherwise the router gets broken)
155
+ this.getAppComponent().getRouterProxy().waitForRouteMatchBeforeNavigation();
156
+
157
+ this._isMultiMode() && this._updateMultiControlHiddenStatus();
158
+
159
+ // Configure the initial load settings
160
+ this._setInitLoad();
161
+ }
162
+
163
+ onExit() {
164
+ delete this.filterBarConditions;
165
+ delete this._oListReportControl;
166
+ this.extensionAPI && this.extensionAPI.destroy();
167
+ delete this.extensionAPI;
168
+ }
169
+
170
+ _onAfterBinding() {
171
+ const aTables = this._getControls("table");
172
+ if (EditState.isEditStateDirty()) {
173
+ const oTableBinding = this._getTableBinding();
174
+ if (oTableBinding) {
175
+ if (CommonUtils.getAppComponent(this.getView())._isFclEnabled()) {
176
+ // there is an issue if we use a timeout with a kept alive context used on another page
177
+ oTableBinding.refresh();
178
+ } else {
179
+ if (!this.sUpdateTimer) {
180
+ this.sUpdateTimer = setTimeout(() => {
181
+ oTableBinding.refresh();
182
+ if (this._isMultiMode()) {
183
+ this._setCountsOutDated();
184
+ this._updateCounts();
185
+ }
186
+ delete this.sUpdateTimer;
187
+ }, 0);
188
+ }
189
+
190
+ // Update action enablement and visibility upon table data update.
191
+ const fnUpdateTableActions = () => {
192
+ this._updateTableActions(aTables);
193
+ oTableBinding.detachDataReceived(fnUpdateTableActions);
194
+ };
195
+ oTableBinding.attachDataReceived(fnUpdateTableActions);
196
+ }
197
+ }
198
+ EditState.setEditStateProcessed();
199
+ }
200
+
201
+ if (!this.sUpdateTimer) {
202
+ this._updateTableActions(aTables);
203
+ }
204
+
205
+ this.pageReady.waitFor(this.getAppComponent().getAppStateHandler().applyAppState());
206
+ }
207
+
208
+ onBeforeRendering() {
209
+ PageController.prototype.onBeforeRendering.apply(this);
210
+ }
211
+
212
+ onAfterRendering() {
213
+ ((this.getView().getModel("sap.fe.i18n") as ResourceModel).getResourceBundle() as Promise<ResourceBundle>)
214
+ .then((response: any) => {
215
+ this.oResourceBundle = response;
216
+ const aControls = this._getControls();
217
+ const sEntitySet = (this.getView().getViewData() as any).entitySet;
218
+ const sText = CommonUtils.getTranslatedText(
219
+ "T_TABLE_AND_CHART_NO_DATA_TEXT",
220
+ this.oResourceBundle as ResourceBundle,
221
+ undefined,
222
+ sEntitySet
223
+ );
224
+ aControls.forEach(function (oControl: any) {
225
+ oControl.setNoDataText(sText);
226
+ });
227
+ })
228
+ .catch(function (oError: any) {
229
+ Log.error("Error while retrieving the resource bundle", oError);
230
+ });
231
+ }
232
+
233
+ @privateExtension()
234
+ @extensible(OverrideExecution.After)
235
+ onPageReady(mParameters: any) {
236
+ // Enabling mandatory filter fields message dialog and focusing on them
237
+ if (mParameters.forceFocus) {
238
+ const oFilterBar = this._getFilterBarControl();
239
+
240
+ if (oFilterBar && !oFilterBar.getShowMessages()) {
241
+ oFilterBar.setShowMessages(true);
242
+ (oFilterBar as any).setFocusOnFirstErroneousField();
243
+ }
244
+ }
245
+
246
+ // Remove the handler on back navigation that displays Draft confirmation
247
+ this.getAppComponent().getShellServices().setBackNavigation(undefined);
248
+ }
249
+
250
+ /**
251
+ * Method called when the content of a list report view needs to be refreshed.
252
+ * This happens either when there is a change on the FilterBar and the search is triggered,
253
+ * or when a tab with custom content is selected.
254
+ * This method can be overwritten by the controller extension in case of customization.
255
+ *
256
+ * @param {map} mParameters Map containing the filter conditions of the FilterBar, the currentTabID
257
+ * and the view refresh cause (tabChanged or search).
258
+ * The map looks like this:
259
+ * <code><pre>
260
+ * {
261
+ * filterConditions: {
262
+ * Country: [
263
+ * {
264
+ * operator: "EQ"
265
+ * validated: "NotValidated"
266
+ * values: ["Germany", ...]
267
+ * },
268
+ * ...
269
+ * ]
270
+ * ...
271
+ * },
272
+ * currentTabId: "fe::CustomTab::tab1",
273
+ * refreshCause: "tabChanged" | "search"
274
+ * }
275
+ * </pre></code>
276
+ *
277
+ * @public
278
+ */
279
+ @publicExtension()
280
+ @extensible(OverrideExecution.After)
281
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
282
+ onViewNeedsRefresh(mParameters: any) {
283
+ /* To be overriden */
284
+ }
285
+
286
+ /**
287
+ * Method called when a filter or search value has been changed in the FilterBar,
288
+ * but has not been validated yet by the end user (with the 'Go' or 'Search' button).
289
+ * Typically, the content of the current tab is greyed out until the filters are validated.
290
+ * This method can be overwritten by the controller extension in case of customization.
291
+ *
292
+ * @public
293
+ */
294
+ @publicExtension()
295
+ @extensible(OverrideExecution.After)
296
+ onPendingFilters() {
297
+ /* To be overriden */
298
+ }
299
+
300
+ getCurrentEntitySet() {
301
+ if (!this._sEntitySet) {
302
+ const oDisplayedControl = (this._isMultiMode() && this._getCurrentControl()) || this._getTable();
303
+ this._sEntitySet = oDisplayedControl?.data("targetCollectionPath").slice(1);
304
+ }
305
+ return this._sEntitySet;
306
+ }
307
+
308
+ /**
309
+ * This method initiates the update of the enabled state of the DataFieldForAction and the visible state of the DataFieldForIBN buttons.
310
+ * @param aTables Array of tables in the list report
311
+ * @private
312
+ */
313
+ _updateTableActions(aTables: any) {
314
+ let aIBNActions: any[] = [];
315
+ aTables.forEach(function (oTable: any) {
316
+ aIBNActions = CommonUtils.getIBNActions(oTable, aIBNActions);
317
+ // Update 'enabled' property of DataFieldForAction buttons on table toolbar
318
+ // The same is also performed on Table selectionChange event
319
+ const oInternalModelContext = oTable.getBindingContext("internal"),
320
+ oActionOperationAvailableMap = JSON.parse(
321
+ CommonHelper.parseCustomData(DelegateUtil.getCustomData(oTable, "operationAvailableMap")) as any
322
+ ),
323
+ aSelectedContexts = oTable.getSelectedContexts();
324
+
325
+ CommonUtils.setActionEnablement(oInternalModelContext, oActionOperationAvailableMap, aSelectedContexts);
326
+ });
327
+ CommonUtils.updateDataFieldForIBNButtonsVisibility(aIBNActions, this.getView());
328
+ }
329
+
330
+ /**
331
+ * This method scrolls to a specific row on all the available tables.
332
+ *
333
+ * @function
334
+ * @name sap.fe.templates.ListReport.ListReportController.controller#_scrollTablesToRow
335
+ * @param {string} sRowPath The path of the table row context to be scrolled to
336
+ */
337
+ _scrollTablesToRow(sRowPath: string) {
338
+ this._getControls("table").forEach(function (oTable: any) {
339
+ TableScroller.scrollTableToRow(oTable, sRowPath);
340
+ });
341
+ }
342
+
343
+ _getPageTitleInformation() {
344
+ const oTitleInfo = { title: "", subtitle: "", intent: "", icon: "" };
345
+ oTitleInfo.title = this.getView().getContent()[0].data().ListReportTitle;
346
+ oTitleInfo.subtitle = this.getView().getContent()[0].data().ListReportSubtitle;
347
+ return oTitleInfo;
348
+ }
349
+
350
+ _getPageOrFilterBarVariantManagement() {
351
+ return (
352
+ this.getView().byId("fe::PageVariantManagement") || this.getView().byId(this._getFilterBarControlId() + "::VariantManagement")
353
+ );
354
+ }
355
+
356
+ _getFilterBarControl() {
357
+ return this.getView().byId(this._getFilterBarControlId()) as FilterBar;
358
+ }
359
+
360
+ _getAdaptationFilterBarControl() {
361
+ // If the adaptation filter bar is part of the DOM tree, the "Adapt Filter" dialog is open,
362
+ // and we return the adaptation filter bar as an active control (visible for the user)
363
+ const adaptationFilterBar = (this._getFilterBarControl() as any).getInbuiltFilter();
364
+ return adaptationFilterBar?.getParent() ? adaptationFilterBar : undefined;
365
+ }
366
+
367
+ _getSegmentedButton(sControl: any) {
368
+ return this.getView().byId(this._getSegmentedButtonId(sControl));
369
+ }
370
+
371
+ _getSegmentedButtonId(sControl: any) {
372
+ if (sControl === "Chart") {
373
+ return this._getChart().data("segmentedButtonId");
374
+ } else {
375
+ return this._getTable()?.data("segmentedButtonId");
376
+ }
377
+ }
378
+
379
+ _getFilterBarControlId() {
380
+ return this.getView().getContent()[0].data("filterBarId");
381
+ }
382
+
383
+ _getChartControlId() {
384
+ return this.getView().getContent()[0].data("singleChartId");
385
+ }
386
+
387
+ getChartControl() {
388
+ return this.getView().byId(this._getChartControlId());
389
+ }
390
+
391
+ _getVisualFilterBarControl() {
392
+ return this.getView().byId(this._getVisualFilterBarControlId());
393
+ }
394
+
395
+ _getVisualFilterBarControlId() {
396
+ return this.getView().getContent()[0].data("visualFilterBarId");
397
+ }
398
+
399
+ _getMultiModeControl() {
400
+ return this.getView().byId("fe::TabMultipleMode") as IconTabBar;
401
+ }
402
+
403
+ _getTableControlId() {
404
+ return this.getView().getContent()[0].data("singleTableId");
405
+ }
406
+
407
+ _getCurrentControl(): Control {
408
+ if (!this._oListReportControl) {
409
+ const oMultiModeTab = this._getMultiModeControl();
410
+ this._oListReportControl = this.getView().byId(
411
+ oMultiModeTab.getSelectedKey() || (oMultiModeTab.getItems()[0] as any).getKey()
412
+ ) as Control;
413
+ }
414
+ return this._oListReportControl as Control;
415
+ }
416
+
417
+ _getTable(): Table | undefined {
418
+ if (this._isMultiMode()) {
419
+ const oControl = this._getCurrentControl();
420
+ return oControl && oControl.isA("sap.ui.mdc.Table") ? (oControl as Table) : undefined;
421
+ }
422
+ return this.getView().byId(this._getTableControlId()) as Table;
423
+ }
424
+
425
+ _getChart() {
426
+ return this.getView().byId(this._getChartControlId());
427
+ }
428
+
429
+ _getTableBinding(sTableId?: any) {
430
+ const oTableControl = sTableId ? this.getView().byId(sTableId) : this._getTable();
431
+ const oBinding = oTableControl && (oTableControl as any)._getRowBinding();
432
+
433
+ return oBinding;
434
+ }
435
+
436
+ _getControls(sKey?: any) {
437
+ if (this._isMultiMode()) {
438
+ const aControls: any[] = [];
439
+ const oTabMultiMode = this._getMultiModeControl();
440
+ oTabMultiMode.getItems().forEach((oItem: any) => {
441
+ const oControl = this.getView().byId(oItem.getKey());
442
+ if (sKey) {
443
+ if (oItem.getKey().indexOf("fe::" + sKey) > -1) {
444
+ oControl && aControls.push(oControl);
445
+ }
446
+ } else {
447
+ oControl && aControls.push(oControl);
448
+ }
449
+ });
450
+ return aControls;
451
+ } else if (sKey === "Chart") {
452
+ const oChart = this._getChart();
453
+ return oChart ? [oChart] : [];
454
+ } else {
455
+ const oTable = this._getTable();
456
+ return oTable ? [oTable] : [];
457
+ }
458
+ }
459
+
460
+ _getDefaultPath() {
461
+ const defaultPath = this.getView().getContent()[0].data("defaultPath");
462
+ switch (defaultPath) {
463
+ case "primary":
464
+ return TemplateContentView.Chart;
465
+ case "secondary":
466
+ return TemplateContentView.Table;
467
+ case "both":
468
+ default:
469
+ return TemplateContentView.Hybrid;
470
+ }
471
+ }
472
+
473
+ /**
474
+ * Method to know if ListReport is configured with Multiple Table mode.
475
+ *
476
+ * @function
477
+ * @name _isMultiMode
478
+ * @returns {boolean} Is Multiple Table mode set?
479
+ */
480
+ _isMultiMode() {
481
+ if (!this._oListReportControl) {
482
+ this._bMultiMode = !!this._getMultiModeControl();
483
+ }
484
+ return this._bMultiMode;
485
+ }
486
+
487
+ /**
488
+ * Method to know if ListReport is configured to load data at start up.
489
+ *
490
+ * @function
491
+ * @name _isInitLoadDisabled
492
+ * @returns {boolean} Is InitLoad enabled?
493
+ */
494
+ _isInitLoadEnabled() {
495
+ const initLoadMode = (this.getView().getViewData() as any).initialLoad;
496
+ return initLoadMode === InitialLoadMode.Enabled;
497
+ }
498
+
499
+ /**
500
+ * Method to know if ListReport is configured with Multiple EntitySets.
501
+ *
502
+ * @function
503
+ * @name _isMultiEntitySets
504
+ * @returns {boolean} Is Multiple EntitySets configuration?
505
+ */
506
+ _isMultiEntitySets() {
507
+ return this.getView().getContent()[0].data("isMultiEntitySets") === "true";
508
+ }
509
+
510
+ _hasMultiVisualizations() {
511
+ return this.getView().getContent()[0].data("hasMultiVisualizations") === "true";
512
+ }
513
+
514
+ /**
515
+ * Method to suspend search on the filter bar. The initial loading of data is disabled based on the manifest configuration InitLoad - Disabled/Auto.
516
+ * It is enabled later when the view state is set, when it is possible to realize if there are default filters.
517
+ */
518
+ _disableInitLoad() {
519
+ const filterBar = this._getFilterBarControl();
520
+ // check for filter bar hidden
521
+ if (filterBar) {
522
+ filterBar.setSuspendSelection(true);
523
+ }
524
+ }
525
+
526
+ /**
527
+ * Method called by flex to determine if the applyAutomatically setting on the variant is valid.
528
+ * Called only for Standard Variant and only when there is display text set for applyAutomatically (FE only sets it for Auto).
529
+ *
530
+ * @returns Boolean true if data should be loaded automatically, false otherwise
531
+ */
532
+ _applyAutomaticallyOnStandardVariant() {
533
+ // We always return false and take care of it when view state is set
534
+ return false;
535
+ }
536
+
537
+ /**
538
+ * Configure the settings for initial load based on
539
+ * - manifest setting initLoad - Enabled/Disabled/Auto
540
+ * - user's setting of applyAutomatically on variant
541
+ * - if there are default filters
542
+ * We disable the filter bar search at the beginning and enable it when view state is set.
543
+ */
544
+ _setInitLoad() {
545
+ // if initLoad is Disabled or Auto, switch off filter bar search temporarily at start
546
+ if (!this._isInitLoadEnabled()) {
547
+ this._disableInitLoad();
548
+ }
549
+ // set hook for flex for when standard variant is set (at start or by user at runtime)
550
+ // required to override the user setting 'apply automatically' behaviour if there are no filters
551
+ const variantManagement: any = this._getPageOrFilterBarVariantManagement();
552
+ if (variantManagement) {
553
+ variantManagement.registerApplyAutomaticallyOnStandardVariant(this._applyAutomaticallyOnStandardVariant.bind(this));
554
+ }
555
+ }
556
+
557
+ _setShareModel() {
558
+ // TODO: deactivated for now - currently there is no _templPriv anymore, to be discussed
559
+ // this method is currently not called anymore from the init method
560
+
561
+ const fnGetUser = ObjectPath.get("sap.ushell.Container.getUser");
562
+ //var oManifest = this.getOwnerComponent().getAppComponent().getMetadata().getManifestEntry("sap.ui");
563
+ //var sBookmarkIcon = (oManifest && oManifest.icons && oManifest.icons.icon) || "";
564
+
565
+ //shareModel: Holds all the sharing relevant information and info used in XML view
566
+ const oShareInfo = {
567
+ bookmarkTitle: document.title, //To name the bookmark according to the app title.
568
+ bookmarkCustomUrl: function () {
569
+ const sHash = hasher.getHash();
570
+ return sHash ? "#" + sHash : window.location.href;
571
+ },
572
+ /*
573
+ To be activated once the FLP shows the count - see comment above
574
+ bookmarkServiceUrl: function() {
575
+ //var oTable = oTable.getInnerTable(); oTable is already the sap.fe table (but not the inner one)
576
+ // we should use table.getListBindingInfo instead of the binding
577
+ var oBinding = oTable.getBinding("rows") || oTable.getBinding("items");
578
+ return oBinding ? fnGetDownloadUrl(oBinding) : "";
579
+ },*/
580
+ isShareInJamActive: !!fnGetUser && fnGetUser().isJamActive()
581
+ };
582
+
583
+ const oTemplatePrivateModel = this.getOwnerComponent().getModel("_templPriv") as JSONModel;
584
+ oTemplatePrivateModel.setProperty("/listReport/share", oShareInfo);
585
+ }
586
+
587
+ /**
588
+ * Hidden tables must be marked as hidden to avoid sending
589
+ * requests when FilterBar is changed or LR is initialized
590
+ * Best workflow would be to suspend table binding but
591
+ * if the user switch quickly between tabs the batch response of previous
592
+ * is received when previous tab is already disabled (binding is suspended) and
593
+ * generates error.
594
+ * A temporary solution (if we find better workflow) is to set a customData and don't trigger
595
+ * rebindTable if this customData is set to true.
596
+ */
597
+ _updateMultiControlHiddenStatus() {
598
+ const oDisplayedControl = this._getCurrentControl();
599
+ if (this._isMultiMode() && oDisplayedControl) {
600
+ const sDisplayControlId = oDisplayedControl.getId();
601
+ const aControls = this._getControls();
602
+ aControls.forEach(function (oControl: any) {
603
+ const sControlId = oControl.getId();
604
+ oControl.data("controlHidden", sControlId !== sDisplayControlId);
605
+ });
606
+ }
607
+ }
608
+
609
+ /**
610
+ * Method to update the local UI model of the page with the fields that are not applicable to the filter bar (this is specific to the multiple table scenario).
611
+ *
612
+ * @param {sap.ui.model.context} oInternalModelContext The internal model context
613
+ * @param {sap.ui.mdc.FilterBar} oFilterBar MDC filter bar
614
+ */
615
+ _updateMultiTabNotApplicableFields(oInternalModelContext: any, oFilterBar: any) {
616
+ const mCache: any = {};
617
+ const ignoredFields: any = {},
618
+ ignoredFieldsTitle: any = {},
619
+ aTables = this._getControls("table"),
620
+ aCharts = this._getControls("Chart");
621
+ aTables.forEach((oTable: any) => {
622
+ const sTableEntityPath = oTable.data("targetCollectionPath"),
623
+ sTableEntitySet = sTableEntityPath.slice(1),
624
+ sTabId = oTable.getParent().getParent().getKey(),
625
+ sTabTitle = oTable.getParent().getParent().getText(),
626
+ sCacheKey = sTableEntitySet + (oTable.data("enableAnalytics") === "true" ? "Analytical" : "Regular");
627
+ if (!mCache[sCacheKey]) {
628
+ mCache[sCacheKey] = FilterUtils.getNotApplicableFilters(oFilterBar, oTable);
629
+ }
630
+ ignoredFields[sTabId] = mCache[sCacheKey];
631
+ ignoredFieldsTitle[sTabId] = this.formatters.setTabMessageStrip.call(this, mCache[sCacheKey], sTabTitle, "false", {});
632
+ });
633
+ aCharts.forEach((oChart: any) => {
634
+ const sChartEntityPath = oChart.data("targetCollectionPath"),
635
+ sChartEntitySet = sChartEntityPath.slice(1),
636
+ sTabId = oChart.getParent().getParent().getKey(),
637
+ sTabTitle = oChart.getParent().getParent().getText(),
638
+ sCacheKey = sChartEntitySet + "Chart";
639
+ if (!mCache[sCacheKey]) {
640
+ mCache[sCacheKey] = FilterUtils.getNotApplicableFilters(oFilterBar, oChart);
641
+ }
642
+ ignoredFields[sTabId] = mCache[sCacheKey];
643
+ ignoredFieldsTitle[sTabId] = this.formatters.setTabMessageStrip.call(this, mCache[sCacheKey], sTabTitle, "false", {});
644
+ });
645
+ oInternalModelContext.setProperty("tabs/ignoredFields", ignoredFields);
646
+ oInternalModelContext.setProperty("tabs/ignoredFieldsTitle", ignoredFieldsTitle);
647
+ }
648
+
649
+ /**
650
+ * Method to update the local UI model of the page with the fields that are not applicable to the filter bar (this is specific to the ALP scenario).
651
+ *
652
+ * @param {sap.ui.model.context} oInternalModelContext The internal model context
653
+ * @param {sap.ui.mdc.FilterBar} oFilterBar MDC filter bar
654
+ */
655
+ _updateALPNotApplicableFields(oInternalModelContext: any, oFilterBar: any) {
656
+ const mCache: any = {};
657
+ const ignoredFields: any = {},
658
+ aTables = this._getControls("table"),
659
+ aCharts = this._getControls("Chart");
660
+
661
+ if (!aTables.length || !aCharts.length) {
662
+ // If there's not a table and a chart, we're not in the ALP case
663
+ return;
664
+ }
665
+
666
+ // For the moment, there's nothing for tables...
667
+ aCharts.forEach(function (oChart: any) {
668
+ const sChartEntityPath = oChart.data("targetCollectionPath"),
669
+ sChartEntitySet = sChartEntityPath.slice(1),
670
+ sCacheKey = sChartEntitySet + "Chart";
671
+ if (!mCache[sCacheKey]) {
672
+ mCache[sCacheKey] = FilterUtils.getNotApplicableFilters(oFilterBar, oChart);
673
+ }
674
+ ignoredFields[sCacheKey] = mCache[sCacheKey];
675
+ });
676
+ oInternalModelContext.setProperty("controls/ignoredFields", ignoredFields);
677
+ }
678
+
679
+ _updateMultiModeSelectedControl() {
680
+ this._sEntitySet = undefined;
681
+ this._oListReportControl = undefined;
682
+ this._getCurrentControl();
683
+ }
684
+
685
+ _updateCounts() {
686
+ this._updateMultiModeCounts();
687
+ }
688
+
689
+ /**
690
+ * Method to determine if a tab from the list report is a custom tab.
691
+ *
692
+ * @function
693
+ * @name _isCustomTab
694
+ * @returns {boolean} Determines if the tab is a custom tab.
695
+ */
696
+ _isCustomTab() {
697
+ const oMultiModeControl = this._getMultiModeControl();
698
+ return oMultiModeControl && oMultiModeControl.getSelectedKey().indexOf("::CustomTab::") > -1;
699
+ }
700
+
701
+ _setCountsOutDated() {
702
+ const oMultiModeControl = this._getMultiModeControl();
703
+ if (oMultiModeControl && oMultiModeControl.data("showCounts") === "true") {
704
+ const aItems = oMultiModeControl.getItems();
705
+ aItems.forEach(function (oItem: any) {
706
+ if (oItem.getKey().indexOf("fe::Chart") === -1) {
707
+ oItem.data("outdatedCounts", true);
708
+ }
709
+ });
710
+ }
711
+ }
712
+
713
+ _updateMultiModeCounts() {
714
+ let aBindingPromises = [];
715
+ const oMultiModeControl = this._getMultiModeControl();
716
+ if (oMultiModeControl && oMultiModeControl.data("showCounts") === "true" && !this._isCustomTab()) {
717
+ const oDisplayedControl = this._getCurrentControl();
718
+ const sDisplayedControlId = oDisplayedControl.getId();
719
+ const aCompliantTabs: any[] = [];
720
+ const aItems = oMultiModeControl.getItems();
721
+ aItems.forEach((oItem: any) => {
722
+ const oControl = this.getView().byId(oItem.getKey());
723
+ if (
724
+ oControl &&
725
+ !oControl.isA("sap.ui.mdc.Chart") &&
726
+ (oItem.data("outdatedCounts") || oControl.getId() === sDisplayedControlId)
727
+ ) {
728
+ aCompliantTabs.push({
729
+ control: oControl,
730
+ item: oItem
731
+ });
732
+ }
733
+ });
734
+
735
+ aBindingPromises = aCompliantTabs.map((mTab: any) => {
736
+ mTab.item.setCount("...");
737
+ const oControl = mTab.control;
738
+ const oFilterInfos = TableUtils.getFiltersInfoForSV(oControl, mTab.item.data("selectionVariant")) as any;
739
+ return TableUtils.getListBindingForCount(oControl, this.getView().getBindingContext(), {
740
+ batchGroupId: oControl.getId() === sDisplayedControlId ? oControl.data("batchGroupId") : "$auto",
741
+ additionalFilters: oFilterInfos.filters
742
+ });
743
+ });
744
+
745
+ Promise.all(aBindingPromises)
746
+ .then(function (aCounts: any[]) {
747
+ for (const k in aCounts) {
748
+ const oItem = aCompliantTabs[k].item;
749
+ oItem.setCount(TableUtils.getCountFormatted(aCounts[k]));
750
+ oItem.data("outdatedCounts", false);
751
+ }
752
+ })
753
+ .catch(function (oError: any) {
754
+ Log.error("Error while retrieving the values for the icon tab bar", oError);
755
+ });
756
+ }
757
+ }
758
+
759
+ _isFilterBarHidden() {
760
+ return (this.getView().getViewData() as any).hideFilterBar;
761
+ }
762
+
763
+ _shouldAutoTriggerSearch(oVM: any) {
764
+ if (
765
+ (this.getView().getViewData() as any).initialLoad === InitialLoadMode.Auto &&
766
+ (!oVM || oVM.getStandardVariantKey() === oVM.getCurrentVariantKey())
767
+ ) {
768
+ const oFilterBar = this._getFilterBarControl();
769
+ if (oFilterBar) {
770
+ const oConditions = oFilterBar.getConditions();
771
+ for (const sKey in oConditions) {
772
+ // ignore filters starting with $ (e.g. $search, $editState)
773
+ if (!sKey.startsWith("$") && Array.isArray(oConditions[sKey]) && oConditions[sKey].length) {
774
+ // load data as per user's setting of applyAutomatically on the variant
775
+ const standardVariant: any = oVM.getVariants().find((variant: any) => {
776
+ return variant.key === oVM.getCurrentVariantKey();
777
+ });
778
+ return standardVariant && standardVariant.executeOnSelect;
779
+ }
780
+ }
781
+ }
782
+ }
783
+ return false;
784
+ }
785
+
786
+ _updateTable(oTable: any) {
787
+ if (!oTable.isTableBound() || this.hasPendingChartChanges) {
788
+ oTable.rebind();
789
+ this.hasPendingChartChanges = false;
790
+ }
791
+ }
792
+
793
+ _updateChart(oChart: any) {
794
+ const oInnerChart = oChart.getControlDelegate()._getChart(oChart);
795
+ if (!(oInnerChart && oInnerChart.isBound("data")) || this.hasPendingTableChanges) {
796
+ oChart.getControlDelegate().rebind(oChart, oInnerChart.getBindingInfo("data"));
797
+ this.hasPendingTableChanges = false;
798
+ }
799
+ }
800
+
801
+ handlers = {
802
+ onTabMultiModeChange(this: ListReportController, oEvent: any) {
803
+ this._updateMultiModeSelectedControl();
804
+ this._updateMultiControlHiddenStatus();
805
+
806
+ const oFilterBar = this._getFilterBarControl();
807
+ const oInternalModelContext = this.getView().getBindingContext("internal") as InternalModelContext;
808
+ const oDisplayedControl = this._getCurrentControl() as any;
809
+ const oMultiModeControl = this._getMultiModeControl();
810
+ const sSelectedKey = oMultiModeControl.getSelectedKey();
811
+ const sPreviousSelectedKey = oEvent && oEvent.mParameters ? oEvent.mParameters.previousKey : undefined;
812
+
813
+ oInternalModelContext.setProperty("tabs/selected", sSelectedKey);
814
+ if (oInternalModelContext.getProperty("hasPendingFilters") !== true) {
815
+ // No pending filters into FilterBar
816
+ if (oFilterBar && this._isCustomTab()) {
817
+ const oFilterConditions = oFilterBar.getFilterConditions();
818
+ this.onViewNeedsRefresh({
819
+ filterConditions: oFilterConditions,
820
+ currentTabId: sSelectedKey,
821
+ refreshCause: "tabChanged"
822
+ });
823
+ } else if (
824
+ !oDisplayedControl.isA("sap.ui.mdc.Chart") &&
825
+ (!oDisplayedControl.getRowBinding() || // first time the tab/table is displayed
826
+ oDisplayedControl.data("outdatedRows") === true)
827
+ ) {
828
+ // Search has been triggered on a different tab {}
829
+ oDisplayedControl.rebind();
830
+ oDisplayedControl.data("outdatedRows", false);
831
+ } else if (
832
+ oDisplayedControl.isA("sap.ui.mdc.Chart") &&
833
+ (!oDisplayedControl.getControlDelegate()._getChart(oDisplayedControl).getBinding("data") || // first time the tab/chart is displayed
834
+ oDisplayedControl.data("outdatedRows") === true)
835
+ ) {
836
+ const oInnerChart = oDisplayedControl.getControlDelegate()._getChart(oDisplayedControl);
837
+ oDisplayedControl.getControlDelegate().rebind(oDisplayedControl, oInnerChart.getBindingInfo("data"));
838
+ oDisplayedControl.data("outdatedRows", false);
839
+ }
840
+ }
841
+
842
+ if (oEvent && oEvent.mParameters && sPreviousSelectedKey !== oEvent.mParameters.selectedKey) {
843
+ ControlPersonalizationWriteAPI.add({
844
+ changes: [
845
+ {
846
+ changeSpecificData: {
847
+ changeType: "selectIconTabBarFilter",
848
+ content: {
849
+ selectedKey: sSelectedKey,
850
+ previousSelectedKey: sPreviousSelectedKey
851
+ }
852
+ },
853
+ selectorElement: oMultiModeControl
854
+ }
855
+ ]
856
+ });
857
+ }
858
+ this.getExtensionAPI().updateAppState();
859
+ },
860
+ onFiltersChanged(this: ListReportController, oEvent: any) {
861
+ const oFilterBar = this._getFilterBarControl();
862
+ if (oFilterBar) {
863
+ const oInternalModelContext = this.getView().getBindingContext("internal") as InternalModelContext;
864
+ // Pending filters into FilterBar to be used for custom views
865
+ this.onPendingFilters();
866
+ oInternalModelContext.setProperty("appliedFilters", oFilterBar.getAssignedFiltersText().filtersText);
867
+ if (oEvent.getParameter("conditionsBased")) {
868
+ oInternalModelContext.setProperty("hasPendingFilters", true);
869
+ }
870
+ }
871
+ },
872
+ onVariantSelected(this: ListReportController, oEvent: any) {
873
+ const oVM = oEvent.getSource();
874
+ // setTimeout cause the variant needs to be applied before judging the auto search or updating the app state
875
+ setTimeout(() => {
876
+ if (this._isMultiMode()) {
877
+ (this.handlers as any).onTabMultiModeChange.apply(this, [oEvent]);
878
+ }
879
+ if (this._shouldAutoTriggerSearch(oVM)) {
880
+ // the app state will be updated via onSearch handler
881
+ return this._getFilterBarControl().triggerSearch();
882
+ } else {
883
+ this.getExtensionAPI().updateAppState();
884
+ }
885
+ }, 0);
886
+ },
887
+ onVariantSaved(this: ListReportController) {
888
+ //TODO: Should remove this setTimeOut once Variant Management provides an api to fetch the current variant key on save!!!
889
+ setTimeout(() => {
890
+ this.getExtensionAPI().updateAppState();
891
+ }, 1000);
892
+ },
893
+ onSearch(this: ListReportController) {
894
+ const oFilterBar = this._getFilterBarControl();
895
+ const oInternalModelContext = this.getView().getBindingContext("internal") as InternalModelContext;
896
+ const oMdcChart = this.getChartControl();
897
+ const bHideDraft = FilterUtils.getEditStateIsHideDraft(oFilterBar.getConditions());
898
+ oInternalModelContext.setProperty("hasPendingFilters", false);
899
+ oInternalModelContext.setProperty("hideDraftInfo", bHideDraft);
900
+ if (this._isMultiMode()) {
901
+ const aControls = this._getControls(),
902
+ oMultiModeControl = this._getMultiModeControl();
903
+ this._setCountsOutDated();
904
+ if (!this._isCustomTab()) {
905
+ const sDisplayedControlId = this._getCurrentControl().getId();
906
+ this._updateMultiTabNotApplicableFields(oInternalModelContext, oFilterBar);
907
+ // This should be done outside the search event handler of the filter bar.
908
+ // The same logic is required when filter bar is hidden and multiple tables exist on the LR.
909
+ // This is currently done in ListReport/overrides/ViewState.js#onAfterStateApplied()
910
+ aControls.forEach(function (oControl: any) {
911
+ oControl.data("outdatedRows", oControl.getId() !== sDisplayedControlId);
912
+ });
913
+ } else {
914
+ const oFilterConditions = oFilterBar.getFilterConditions();
915
+ this.onViewNeedsRefresh({
916
+ filterConditions: oFilterConditions,
917
+ currentTabId: oMultiModeControl.getSelectedKey(),
918
+ refreshCause: "search"
919
+ });
920
+ }
921
+ } else {
922
+ this._updateALPNotApplicableFields(oInternalModelContext, oFilterBar);
923
+ }
924
+ if (oMdcChart) {
925
+ // disable bound actions TODO: this clears everything for the chart?
926
+ (oMdcChart.getBindingContext("internal") as InternalModelContext).setProperty("", {});
927
+
928
+ const oPageInternalModelContext = oMdcChart.getBindingContext("pageInternal") as InternalModelContext;
929
+ const sTemplateContentView = oPageInternalModelContext.getProperty(oPageInternalModelContext.getPath() + "/alpContentView");
930
+ if (sTemplateContentView === TemplateContentView.Chart) {
931
+ this.hasPendingChartChanges = true;
932
+ }
933
+ if (sTemplateContentView === TemplateContentView.Table) {
934
+ this.hasPendingTableChanges = true;
935
+ }
936
+ }
937
+ // store filter bar conditions to use later while navigation
938
+ StateUtil.retrieveExternalState(oFilterBar)
939
+ .then((oExternalState: any) => {
940
+ this.filterBarConditions = oExternalState.filter;
941
+ })
942
+ .catch(function (oError: any) {
943
+ Log.error("Error while retrieving the external state", oError);
944
+ });
945
+ if ((this.getView().getViewData() as any).liveMode === false) {
946
+ this.getExtensionAPI().updateAppState();
947
+ }
948
+
949
+ if (system.phone) {
950
+ const oDynamicPage = this.getView().byId("fe::ListReport") as DynamicPage;
951
+ oDynamicPage.setHeaderExpanded(false);
952
+ }
953
+ },
954
+ /**
955
+ * Triggers an outbound navigation when a user chooses the chevron.
956
+ *
957
+ * @param {object} oController
958
+ * @param {string} sOutboundTarget Name of the outbound target (needs to be defined in the manifest)
959
+ * @param {sap.ui.model.odata.v4.Context} oContext The context that contains the data for the target app
960
+ * @param {string} sCreatePath Create path when the chevron is created.
961
+ * @returns {Promise} Promise which is resolved once the navigation is triggered
962
+ * @ui5-restricted
963
+ * @final
964
+ */
965
+ onChevronPressNavigateOutBound(oController: ListReportController, sOutboundTarget: string, oContext: any, sCreatePath: string) {
966
+ return oController._intentBasedNavigation.onChevronPressNavigateOutBound(oController, sOutboundTarget, oContext, sCreatePath);
967
+ },
968
+ onChartSelectionChanged(this: ListReportController, oEvent: any) {
969
+ const oMdcChart = oEvent.getSource().getContent(),
970
+ oTable = this._getTable(),
971
+ aData = oEvent.getParameter("data"),
972
+ oInternalModelContext = this.getView().getBindingContext("internal") as InternalModelContext;
973
+ if (aData) {
974
+ // update action buttons enablement / disablement
975
+ ChartRuntime.fnUpdateChart(oEvent);
976
+ // update selections on selection or deselection
977
+ ChartUtils.setChartFilters(oMdcChart);
978
+ }
979
+ const sTemplateContentView = oInternalModelContext.getProperty(oInternalModelContext.getPath() + "/alpContentView");
980
+ if (sTemplateContentView === TemplateContentView.Chart) {
981
+ this.hasPendingChartChanges = true;
982
+ } else {
983
+ oTable && (oTable as any).rebind();
984
+ this.hasPendingChartChanges = false;
985
+ }
986
+ },
987
+ onSegmentedButtonPressed(this: ListReportController, oEvent: any) {
988
+ const sSelectedKey = oEvent.mParameters.key ? oEvent.mParameters.key : null;
989
+ const oInternalModelContext = this.getView().getBindingContext("internal") as InternalModelContext;
990
+ oInternalModelContext.setProperty("alpContentView", sSelectedKey);
991
+ const oChart = this._getChart();
992
+ const oTable = this._getTable();
993
+ const oSegmentedButtonDelegate = {
994
+ onAfterRendering() {
995
+ const aItems = oSegmentedButton.getItems();
996
+ aItems.forEach(function (oItem: any) {
997
+ if (oItem.getKey() === sSelectedKey) {
998
+ oItem.focus();
999
+ }
1000
+ });
1001
+ oSegmentedButton.removeEventDelegate(oSegmentedButtonDelegate);
1002
+ }
1003
+ };
1004
+ const oSegmentedButton = (
1005
+ sSelectedKey === TemplateContentView.Table ? this._getSegmentedButton("Table") : this._getSegmentedButton("Chart")
1006
+ ) as SegmentedButton;
1007
+ if (oSegmentedButton !== oEvent.getSource()) {
1008
+ oSegmentedButton.addEventDelegate(oSegmentedButtonDelegate);
1009
+ }
1010
+ switch (sSelectedKey) {
1011
+ case TemplateContentView.Table:
1012
+ this._updateTable(oTable);
1013
+ break;
1014
+ case TemplateContentView.Chart:
1015
+ this._updateChart(oChart);
1016
+ break;
1017
+ case TemplateContentView.Hybrid:
1018
+ this._updateTable(oTable);
1019
+ this._updateChart(oChart);
1020
+ break;
1021
+ default:
1022
+ break;
1023
+ }
1024
+ this.getExtensionAPI().updateAppState();
1025
+ },
1026
+ onFiltersSegmentedButtonPressed(this: ListReportController, oEvent: any) {
1027
+ if (oEvent.getParameter("key") === "Compact") {
1028
+ this._getFilterBarControl().setVisible(true);
1029
+ (this.getView().byId(this.getView().getContent()[0].data("visualFilterBarId")) as Control).setVisible(false);
1030
+ } else {
1031
+ this._getFilterBarControl().setVisible(false);
1032
+ (this.getView().byId(this.getView().getContent()[0].data("visualFilterBarId")) as Control).setVisible(true);
1033
+ }
1034
+ },
1035
+ onStateChange(this: ListReportController) {
1036
+ this.getExtensionAPI().updateAppState();
1037
+ }
1038
+ };
1039
+ formatters = {
1040
+ /**
1041
+ * Method to set the message text for the multiple entity sets when fields in the FilterBar need to be ignored.
1042
+ *
1043
+ * @param this
1044
+ * @param {Array} aIgnoredFields Array of ignored fields in the FilterBar for the current tab (multiple entity sets)
1045
+ * @param {string} sTabTitle Tab title
1046
+ * @param {boolean} bIsChart Flag that indicates whether the control is a chart or not
1047
+ * @param {object} oApplySupported ApplySupported for the control
1048
+ * @returns {string} Message text
1049
+ */
1050
+ setTabMessageStrip(this: ListReportController, aIgnoredFields: any[], sTabTitle: string, bIsChart?: any, oApplySupported?: any) {
1051
+ let sText = "";
1052
+ bIsChart = bIsChart === "true" || bIsChart === true;
1053
+ const oFilterBar = this._getFilterBarControl();
1054
+ if (oFilterBar && Array.isArray(aIgnoredFields) && aIgnoredFields.length > 0 && (sTabTitle || bIsChart)) {
1055
+ const sFilterBarEntityPath = oFilterBar.data("entityType"),
1056
+ oMetaModel = this.getView().getModel().getMetaModel(),
1057
+ oResourceBundle = Core.getLibraryResourceBundle("sap.fe.templates") as ResourceBundle,
1058
+ aIgnoredLabels = aIgnoredFields.map(function (sProperty) {
1059
+ const oMacroResourceBundle = Core.getLibraryResourceBundle("sap.fe.macros") as ResourceBundle;
1060
+ if (sProperty === "$search") {
1061
+ return oMacroResourceBundle ? oMacroResourceBundle.getText("M_FILTERBAR_SEARCH") : "";
1062
+ }
1063
+ if (sProperty === "$editState") {
1064
+ return oMacroResourceBundle ? oMacroResourceBundle.getText("M_COMMON_FILTERBAR_EDITING_STATUS") : "";
1065
+ }
1066
+ const sLabel = oMetaModel.getObject(sFilterBarEntityPath + sProperty + "@com.sap.vocabularies.Common.v1.Label");
1067
+ return DelegateUtil.getLocalizedText(sLabel, oFilterBar);
1068
+ });
1069
+ const bIsSearchIgnored = !oApplySupported.enableSearch;
1070
+ if (oResourceBundle) {
1071
+ sText = CommonUtils.getMessageStripText(
1072
+ this.getView(),
1073
+ aIgnoredLabels,
1074
+ oFilterBar,
1075
+ bIsChart,
1076
+ bIsSearchIgnored,
1077
+ sTabTitle,
1078
+ oResourceBundle,
1079
+ DelegateUtil.getLocalizedText
1080
+ );
1081
+ }
1082
+ }
1083
+ return sText;
1084
+ }
1085
+ };
1086
+ }
1087
+
1088
+ export default ListReportController;