@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,837 @@
1
+ // Formatters for the Object Page
2
+ import { DataField, HeaderInfoType, UIAnnotationTerms, UIAnnotationTypes } from "@sap-ux/vocabularies-types";
3
+ import { DataFieldTypes } from "@sap-ux/vocabularies-types/dist/generated/UI";
4
+ import ResourceBundle from "sap/base/i18n/ResourceBundle";
5
+ import CommonUtils from "sap/fe/core/CommonUtils";
6
+ import { ConverterAction } from "sap/fe/core/converters/controls/Common/Action";
7
+ import { Draft, Entity, UI } from "sap/fe/core/converters/helpers/BindingHelper";
8
+ import { ManifestAction } from "sap/fe/core/converters/ManifestSettings";
9
+ import {
10
+ and,
11
+ annotationExpression,
12
+ BindingExpression,
13
+ compileBinding,
14
+ concat,
15
+ Expression,
16
+ ifElse,
17
+ isEmpty,
18
+ or,
19
+ resolveBindingString
20
+ } from "sap/fe/core/helpers/BindingExpression";
21
+ import { DataModelObjectPath } from "sap/fe/core/templating/DataModelPathHelper";
22
+ import CommonHelper from "sap/fe/macros/CommonHelper";
23
+ import { addTextArrangementToBindingExpression, formatValueRecursively } from "sap/fe/macros/field/FieldTemplating";
24
+ import mLibrary from "sap/m/library";
25
+ import ManagedObject from "sap/ui/base/ManagedObject";
26
+ import ODataModelAnnotationHelper from "sap/ui/model/odata/v4/AnnotationHelper";
27
+ import Context from "sap/ui/model/odata/v4/Context";
28
+ const ButtonType = mLibrary.ButtonType;
29
+
30
+ type ViewData = {
31
+ resourceBundle: ResourceBundle;
32
+ entitySet: string;
33
+ };
34
+
35
+ //```mermaid
36
+ // graph TD
37
+ // A[Object Page Title] -->|Get DataField Value| C{Evaluate Create Mode}
38
+ // C -->|In Create Mode| D{Is DataField Value empty}
39
+ // D -->|Yes| F{Is there a TypeName}
40
+ // F -->|Yes| G[Is there an custom title]
41
+ // G -->|Yes| G1[Show the custom title + 'TypeName']
42
+ // G -->|No| G2[Display the default title 'New + TypeName']
43
+ // F -->|No| H[Is there a custom title]
44
+ // H -->|Yes| I[Show the custom title]
45
+ // H -->|No| J[Show the default 'Unamned Object']
46
+ // D -->|No| E
47
+ // C -->|Not in create mode| E[Show DataField Value]
48
+ // ```
49
+ /**
50
+ * Compute the title for the object page.
51
+ * @param oHeaderInfo The @UI.HeaderInfo annotation content
52
+ * @param oViewData The view data object we're currently on
53
+ * @param fullContextPath The full context path used to reach that object page
54
+ * @param oDraftRoot
55
+ * @returns The binding expression for the object page title
56
+ */
57
+ export const getExpressionForTitle = function (
58
+ oHeaderInfo: HeaderInfoType | undefined,
59
+ oViewData: ViewData,
60
+ fullContextPath: DataModelObjectPath,
61
+ oDraftRoot: Object | undefined
62
+ ): BindingExpression<string> {
63
+ const titleNoHeaderInfo = CommonUtils.getTranslatedText("T_NEW_OBJECT", oViewData.resourceBundle, undefined, oViewData.entitySet);
64
+
65
+ const titleWithHeaderInfo = CommonUtils.getTranslatedText(
66
+ "T_ANNOTATION_HELPER_DEFAULT_OBJECT_PAGE_HEADER_TITLE",
67
+ oViewData.resourceBundle,
68
+ undefined,
69
+ oViewData.entitySet
70
+ );
71
+
72
+ const oEmptyHeaderInfoTitle =
73
+ oHeaderInfo?.Title === undefined || (oHeaderInfo?.Title as any) === "" || (oHeaderInfo?.Title as DataFieldTypes)?.Value === "";
74
+
75
+ const titleForActiveHeaderNoHeaderInfo = !oEmptyHeaderInfoTitle
76
+ ? CommonUtils.getTranslatedText("T_ANNOTATION_HELPER_DEFAULT_OBJECT_PAGE_HEADER_TITLE_NO_HEADER_INFO", oViewData.resourceBundle)
77
+ : "";
78
+
79
+ let titleValueExpression = annotationExpression((oHeaderInfo?.Title as DataFieldTypes)?.Value);
80
+ if ((oHeaderInfo?.Title as DataFieldTypes)?.Value?.$target?.annotations?.Common?.Text?.annotations?.UI?.TextArrangement) {
81
+ // In case an explicit text arrangement was set we make use of it in the description as well
82
+ titleValueExpression = addTextArrangementToBindingExpression(titleValueExpression, fullContextPath);
83
+ }
84
+
85
+ titleValueExpression = formatValueRecursively(titleValueExpression, fullContextPath);
86
+
87
+ // If there is a TypeName defined, show the default title 'New + TypeName', otherwise show the custom title or the default 'New object'
88
+ const createModeTitle = oHeaderInfo?.TypeName
89
+ ? concat(titleWithHeaderInfo, ": ", annotationExpression(oHeaderInfo.TypeName.toString()))
90
+ : titleNoHeaderInfo;
91
+ const activeExpression = oDraftRoot ? Entity.IsActive : true;
92
+
93
+ return compileBinding(
94
+ ifElse(
95
+ // If Create Mode && Empty expression
96
+ and(or(UI.IsCreateModeSticky, UI.IsCreateMode), titleValueExpression && isEmpty(titleValueExpression)),
97
+
98
+ createModeTitle,
99
+ // Otherwise show the default expression
100
+ ifElse(
101
+ and(activeExpression, titleValueExpression && isEmpty(titleValueExpression)),
102
+ titleForActiveHeaderNoHeaderInfo,
103
+ titleValueExpression
104
+ )
105
+ )
106
+ );
107
+ };
108
+
109
+ /**
110
+ * Retrieves the expression for the description of an object page.
111
+ *
112
+ * @param oHeaderInfo The @UI.HeaderInfo annotation content
113
+ * @param fullContextPath The full context path used to reach that object page
114
+ * @returns The binding expression for the object page description
115
+ */
116
+ export const getExpressionForDescription = function (
117
+ oHeaderInfo: HeaderInfoType | undefined,
118
+ fullContextPath: DataModelObjectPath
119
+ ): BindingExpression<string> {
120
+ let bindingExpression = annotationExpression((oHeaderInfo?.Description as DataFieldTypes)?.Value);
121
+ if ((oHeaderInfo?.Description as DataFieldTypes)?.Value?.$target?.annotations?.Common?.Text?.annotations?.UI?.TextArrangement) {
122
+ // In case an explicit text arrangement was set we make use of it in the description as well
123
+ bindingExpression = addTextArrangementToBindingExpression(bindingExpression, fullContextPath);
124
+ }
125
+
126
+ return compileBinding(formatValueRecursively(bindingExpression, fullContextPath));
127
+ };
128
+
129
+ /**
130
+ * Return the expression for the save button.
131
+ *
132
+ * @param oViewData The current view data
133
+ * @param fullContextPath The path used up until here
134
+ * @returns The binding expression that shows the right save button text
135
+ */
136
+ export const getExpressionForSaveButton = function (oViewData: ViewData, fullContextPath: DataModelObjectPath): BindingExpression<string> {
137
+ const saveButtonText = CommonUtils.getTranslatedText("T_OP_OBJECT_PAGE_SAVE", oViewData.resourceBundle);
138
+ const createButtonText = CommonUtils.getTranslatedText("T_OP_OBJECT_PAGE_CREATE", oViewData.resourceBundle);
139
+ let saveExpression;
140
+
141
+ if (fullContextPath.startingEntitySet.annotations.Session?.StickySessionSupported) {
142
+ // If we're in sticky mode AND the ui is in create mode, show Create, else show Save
143
+ saveExpression = ifElse(UI.IsCreateModeSticky, createButtonText, saveButtonText);
144
+ } else {
145
+ // If we're in draft AND the draft is a new object (!IsActiveEntity && !HasActiveEntity), show create, else show save
146
+ saveExpression = ifElse(Draft.IsNewObject, createButtonText, saveButtonText);
147
+ }
148
+ return compileBinding(saveExpression);
149
+ };
150
+
151
+ /**
152
+ * Method returns whether footer is visible or not on object / subobject page.
153
+ *
154
+ * @function
155
+ * @name getFooterVisible
156
+ * @param {ConverterAction[]} footerActions The footer action object coming from the converter
157
+ * @param {DataField[]} dataFields Data field array for normal footer visibility processing
158
+ * @returns {boolean | BindingExpression<string>} `true` if any action is true, otherwise compiled Binding or `false`
159
+ */
160
+ export const getFooterVisible = function (footerActions: ConverterAction[], dataFields: DataField[]): boolean | BindingExpression<string> {
161
+ const manifestActions = footerActions.filter((action) => isManifestAction(action)) as ManifestAction[];
162
+ let customActionVisibility: Expression<boolean>;
163
+ if (manifestActions.length) {
164
+ // If we have manifest actions
165
+ const customActionIndividualVisibility = manifestActions.map((action) => {
166
+ return resolveBindingString<boolean>(action.visible as string | boolean, "boolean");
167
+ });
168
+ // construct the footer's visibility-binding out of all actions' visibility-bindings, first the binding of all custom actions ...
169
+ customActionVisibility = or(...customActionIndividualVisibility);
170
+ // and then the binding of all annotation actions inside the footer ...
171
+ const annotationActionVisibility = getDataFieldBasedFooterVisibility(dataFields, true);
172
+ // finally, return everything.
173
+ return compileBinding(or(customActionVisibility, resolveBindingString<boolean>(annotationActionVisibility, "boolean")));
174
+ }
175
+ return getDataFieldBasedFooterVisibility(dataFields, true);
176
+ };
177
+
178
+ /**
179
+ * Checks if the footer is visible or not.
180
+ *
181
+ * @function
182
+ * @static
183
+ * @name sap.fe.templates.ObjectPage.ObjectPageTemplating.getDataFieldBasedFooterVisibility
184
+ * @memberof sap.fe.templates.ObjectPage.ObjectPageTemplating
185
+ * @param {Array} aDataFields Array of DataFields in the identification
186
+ * @param {boolean} bConsiderEditable Whether the edit mode binding is required or not
187
+ * @returns {string} An expression if all the actions are ui.hidden, true otherwise
188
+ * @private
189
+ * @ui5-restricted
190
+ **/
191
+ export const getDataFieldBasedFooterVisibility = function (aDataFields: any[], bConsiderEditable: boolean) {
192
+ let sHiddenExpression = "";
193
+ let sSemiHiddenExpression;
194
+ const aHiddenActionPath = [];
195
+
196
+ for (const i in aDataFields) {
197
+ const oDataField = aDataFields[i];
198
+ if (oDataField.$Type === UIAnnotationTypes.DataFieldForAction && oDataField.Determining === true) {
199
+ const hiddenExpression = oDataField[`@${UIAnnotationTerms.Hidden}`];
200
+ if (!hiddenExpression) {
201
+ return true;
202
+ } else if (hiddenExpression.$Path) {
203
+ if (aHiddenActionPath.indexOf(hiddenExpression.$Path) === -1) {
204
+ aHiddenActionPath.push(hiddenExpression.$Path);
205
+ }
206
+ }
207
+ }
208
+ }
209
+
210
+ if (aHiddenActionPath.length) {
211
+ for (let index = 0; index < aHiddenActionPath.length; index++) {
212
+ if (aHiddenActionPath[index]) {
213
+ sSemiHiddenExpression = "(%{" + aHiddenActionPath[index] + "} === true ? false : true )";
214
+ }
215
+ if (index == aHiddenActionPath.length - 1) {
216
+ sHiddenExpression = sHiddenExpression + sSemiHiddenExpression;
217
+ } else {
218
+ sHiddenExpression = sHiddenExpression + sSemiHiddenExpression + "||";
219
+ }
220
+ }
221
+ return (
222
+ "{= " +
223
+ (bConsiderEditable ? "(" : "") +
224
+ sHiddenExpression +
225
+ (bConsiderEditable ? " || ${ui>/isEditable}) " : " ") +
226
+ "&& ${internal>isCreateDialogOpen} !== true}"
227
+ );
228
+ } else {
229
+ return "{= " + (bConsiderEditable ? "${ui>/isEditable} && " : "") + "${internal>isCreateDialogOpen} !== true}";
230
+ }
231
+ };
232
+
233
+ /**
234
+ * Method returns Whether the action type is manifest or not.
235
+ *
236
+ * @function
237
+ * @name isManifestActionVisible
238
+ * @param {object} oAction The action object
239
+ * @returns {boolean} `true` if action is coming from manifest, `false` otherwise
240
+ */
241
+ export const isManifestAction = function (oAction: any) {
242
+ const aActions = [
243
+ "Primary",
244
+ "DefaultApply",
245
+ "Secondary",
246
+ "ForAction",
247
+ "ForNavigation",
248
+ "SwitchToActiveObject",
249
+ "SwitchToDraftObject",
250
+ "DraftActions"
251
+ ];
252
+ return aActions.indexOf(oAction.type) < 0;
253
+ };
254
+
255
+ /**
256
+ * Returns an expression to determine Emphasized button type based on Criticality across all actions
257
+ * If critical action is rendered, its considered to be the primary action. Hence template's default primary action is set back to Default.
258
+ *
259
+ * @function
260
+ * @static
261
+ * @name sap.fe.templates.ObjectPage.ObjectPageTemplating.buildEmphasizedButtonExpression
262
+ * @memberof sap.fe.templates.ObjectPage.ObjectPageTemplating
263
+ * @param {Array} aIdentification Array of all the DataFields in Identification
264
+ * @returns {string} An expression to deduce if button type is Default or Emphasized
265
+ * @private
266
+ * @ui5-restricted
267
+ **/
268
+ export const buildEmphasizedButtonExpression = function (aIdentification?: any[]) {
269
+ if (!aIdentification) {
270
+ return ButtonType.Emphasized;
271
+ }
272
+ let sFormatEmphasizedExpression: string | undefined;
273
+ let bIsAlwaysDefault: boolean,
274
+ sHiddenSimplePath,
275
+ sHiddenExpression = "";
276
+ aIdentification.forEach(function (oDataField: any) {
277
+ const oCriticalityProperty = oDataField.Criticality;
278
+ const oDataFieldHidden = oDataField["@com.sap.vocabularies.UI.v1.Hidden"];
279
+ if (oDataField.$Type === "com.sap.vocabularies.UI.v1.DataFieldForAction" && !bIsAlwaysDefault && oCriticalityProperty) {
280
+ if (!sFormatEmphasizedExpression && oDataFieldHidden === true) {
281
+ // if DataField is set to hidden, we can skip other checks and return Default button type
282
+ sFormatEmphasizedExpression = ButtonType.Emphasized;
283
+ return;
284
+ }
285
+ if (oDataFieldHidden && oDataFieldHidden.$Path) {
286
+ // when visibility of critical button is based on path, collect all paths for expression
287
+ sHiddenSimplePath = oDataFieldHidden.$Path;
288
+ if (sHiddenExpression) {
289
+ sHiddenExpression = sHiddenExpression + " && ";
290
+ }
291
+ sHiddenExpression = sHiddenExpression + "%{" + sHiddenSimplePath + "} === true";
292
+ sFormatEmphasizedExpression = "{= (" + sHiddenExpression + ") ? 'Emphasized' : 'Default' }";
293
+ }
294
+ switch (oCriticalityProperty.$EnumMember) {
295
+ // supported criticality are [Positive/3/'3'] and [Negative/1/'1']
296
+ case "com.sap.vocabularies.UI.v1.CriticalityType/Negative":
297
+ case "com.sap.vocabularies.UI.v1.CriticalityType/Positive":
298
+ case "1":
299
+ case 1:
300
+ case "3":
301
+ case 3:
302
+ if (!oDataFieldHidden) {
303
+ sFormatEmphasizedExpression = ButtonType.Default;
304
+ bIsAlwaysDefault = true;
305
+ }
306
+ sFormatEmphasizedExpression = sFormatEmphasizedExpression || ButtonType.Default;
307
+ break;
308
+ default:
309
+ sFormatEmphasizedExpression = ButtonType.Emphasized;
310
+ }
311
+ if (oCriticalityProperty.$Path) {
312
+ // when Criticality is set using a path, use the path for deducing the Emphsized type for default Primary Action
313
+ const sCombinedHiddenExpression = sHiddenExpression ? "!(" + sHiddenExpression + ") && " : "";
314
+ sFormatEmphasizedExpression =
315
+ "{= " +
316
+ sCombinedHiddenExpression +
317
+ "((${" +
318
+ oCriticalityProperty.$Path +
319
+ "} === 'com.sap.vocabularies.UI.v1.CriticalityType/Negative') || (${" +
320
+ oCriticalityProperty.$Path +
321
+ "} === '1') || (${" +
322
+ oCriticalityProperty.$Path +
323
+ "} === 1) " +
324
+ "|| (${" +
325
+ oCriticalityProperty.$Path +
326
+ "} === 'com.sap.vocabularies.UI.v1.CriticalityType/Positive') || (${" +
327
+ oCriticalityProperty.$Path +
328
+ "} === '3') || (${" +
329
+ oCriticalityProperty.$Path +
330
+ "} === 3)) ? " +
331
+ "'Default'" +
332
+ " : " +
333
+ "'Emphasized'" +
334
+ " }";
335
+ }
336
+ }
337
+ });
338
+ return sFormatEmphasizedExpression || ButtonType.Emphasized;
339
+ };
340
+
341
+ export const getElementBinding = function (sPath: any) {
342
+ const sNavigationPath = ODataModelAnnotationHelper.getNavigationPath(sPath);
343
+ if (sNavigationPath) {
344
+ return "{path:'" + sNavigationPath + "'}";
345
+ } else {
346
+ //no navigation property needs empty object
347
+ return "{path: ''}";
348
+ }
349
+ };
350
+
351
+ /**
352
+ * Function to check if draft pattern is supported.
353
+ *
354
+ * @param {object} oAnnotations Annotations of the current entity set.
355
+ * @returns {string} Returns the Boolean value based on draft state
356
+ */
357
+ export const checkDraftState = function (oAnnotations: any) {
358
+ if (
359
+ oAnnotations["@com.sap.vocabularies.Common.v1.DraftRoot"] &&
360
+ oAnnotations["@com.sap.vocabularies.Common.v1.DraftRoot"]["EditAction"]
361
+ ) {
362
+ return true;
363
+ } else {
364
+ return false;
365
+ }
366
+ };
367
+
368
+ /**
369
+ * Function to get the visibility for the SwitchToActive button in the object page or subobject page.
370
+ *
371
+ * @param {object} oAnnotations Annotations of the current entity set.
372
+ * @returns {string} Returns expression binding or Boolean value based on the draft state
373
+ */
374
+ export const getSwitchToActiveVisibility = function (oAnnotations: any): any {
375
+ if (checkDraftState(oAnnotations)) {
376
+ return "{= (%{DraftAdministrativeData/DraftIsCreatedByMe}) ? ( ${ui>/isEditable} && !${ui>createMode} && %{DraftAdministrativeData/DraftIsCreatedByMe} ) : false }";
377
+ } else {
378
+ return false;
379
+ }
380
+ };
381
+
382
+ /**
383
+ * Function to get the visibility for the SwitchToDraft button in the object page or subobject page.
384
+ *
385
+ * @param {object} oAnnotations Annotations of the current entity set.
386
+ * @returns {string} Returns expression binding or Boolean value based on the draft state
387
+ */
388
+ export const getSwitchToDraftVisibility = function (oAnnotations: any): any {
389
+ if (checkDraftState(oAnnotations)) {
390
+ return "{= (%{DraftAdministrativeData/DraftIsCreatedByMe}) ? ( !(${ui>/isEditable}) && !${ui>createMode} && ${HasDraftEntity} && %{DraftAdministrativeData/DraftIsCreatedByMe} ) : false }";
391
+ } else {
392
+ return false;
393
+ }
394
+ };
395
+
396
+ /**
397
+ * Function to get the visibility for the SwitchDraftAndActive button in the object page or subobject page.
398
+ *
399
+ * @param {object} oAnnotations Annotations of the current entity set.
400
+ * @returns {string} Returns expression binding or Boolean value based on the draft state
401
+ */
402
+ export const getSwitchDraftAndActiveVisibility = function (oAnnotations: any): any {
403
+ if (checkDraftState(oAnnotations)) {
404
+ return "{= (%{DraftAdministrativeData/DraftIsCreatedByMe}) ? ( !${ui>createMode} && %{DraftAdministrativeData/DraftIsCreatedByMe} ) : false }";
405
+ } else {
406
+ return false;
407
+ }
408
+ };
409
+
410
+ /**
411
+ * Function to find an action from the array of header actions in the converter context.
412
+ *
413
+ * @param {object[]} aConverterContextHeaderActions Array of 'header' actions on the object page.
414
+ * @param {string} sActionType The action type
415
+ * @returns {object | undefined} The action with the matching action type
416
+ * @private
417
+ */
418
+ export const _findAction = function (aConverterContextHeaderActions: any[], sActionType: string) {
419
+ let oAction;
420
+ if (aConverterContextHeaderActions && aConverterContextHeaderActions.length) {
421
+ oAction = aConverterContextHeaderActions.find(function (oHeaderAction: any) {
422
+ return oHeaderAction.type === sActionType;
423
+ });
424
+ }
425
+ return oAction;
426
+ };
427
+
428
+ /**
429
+ * Function to format the 'enabled' property for the Delete button on the object page or subobject page in case of a Command Execution.
430
+ *
431
+ * @param {Array} aConverterContextHeaderActions Array of header actions on the object page
432
+ * @returns {string} Returns expression binding or Boolean value from the converter output
433
+ */
434
+ export const getDeleteCommandExecutionEnabled = function (aConverterContextHeaderActions: any[]) {
435
+ const oDeleteAction = _findAction(aConverterContextHeaderActions, "Secondary");
436
+ return oDeleteAction ? oDeleteAction.enabled : "true";
437
+ };
438
+
439
+ /**
440
+ * Function to format the 'visible' property for the Delete button on the object page or subobject page in case of a Command Execution.
441
+ *
442
+ * @param {Array} aConverterContextHeaderActions Array of header actions on the object page
443
+ * @returns {string} Returns expression binding or Boolean value from the converter output
444
+ */
445
+ export const getDeleteCommandExecutionVisible = function (aConverterContextHeaderActions: any[]) {
446
+ const oDeleteAction = _findAction(aConverterContextHeaderActions, "Secondary");
447
+ return oDeleteAction ? oDeleteAction.visible : "true";
448
+ };
449
+
450
+ /**
451
+ * Function to format the 'visible' property for the Edit button on the object page or subobject page in case of a Command Execution.
452
+ *
453
+ * @param {Array} aConverterContextHeaderActions Array of header actions on the object page
454
+ * @returns {string} Returns expression binding or Boolean value from the converter output
455
+ */
456
+ export const getEditCommandExecutionVisible = function (aConverterContextHeaderActions: any[]) {
457
+ const oEditAction = _findAction(aConverterContextHeaderActions, "Primary");
458
+ return oEditAction ? oEditAction.visible : "true";
459
+ };
460
+
461
+ /**
462
+ * Function to format the 'enabled' property for the Edit button on the object page or subobject page in case of a Command Execution.
463
+ *
464
+ * @param {Array} aConverterContextHeaderActions Array of header actions on the object page
465
+ * @returns {string} Returns expression binding or Boolean value from the converter output
466
+ */
467
+ export const getEditCommandExecutionEnabled = function (aConverterContextHeaderActions: any[]) {
468
+ const oEditAction = _findAction(aConverterContextHeaderActions, "Primary");
469
+ return oEditAction ? oEditAction.enabled : "true";
470
+ };
471
+
472
+ /**
473
+ * Function to get the EditAction from the Entityset based on Draft or sticky based application.
474
+ *
475
+ * @param {object} [oEntitySet] The value from the expression.
476
+ * @returns {string} Returns expression binding or boolean value based on vRawValue & oDraftNode
477
+ */
478
+ export const getEditAction = function (oEntitySet: Context) {
479
+ const sPath = oEntitySet.getPath(),
480
+ oAnnotations = oEntitySet.getObject(sPath + "@");
481
+ const bDraftRoot = oAnnotations.hasOwnProperty("@com.sap.vocabularies.Common.v1.DraftRoot");
482
+ const bStickySession = oAnnotations.hasOwnProperty("@com.sap.vocabularies.Session.v1.StickySessionSupported");
483
+ let sActionName;
484
+ if (bDraftRoot) {
485
+ sActionName = oEntitySet.getObject(sPath + "@com.sap.vocabularies.Common.v1.DraftRoot/EditAction");
486
+ } else if (bStickySession) {
487
+ sActionName = oEntitySet.getObject(sPath + "@com.sap.vocabularies.Session.v1.StickySessionSupported/EditAction");
488
+ }
489
+ return !sActionName ? sActionName : sPath + "/" + sActionName;
490
+ };
491
+
492
+ export const isReadOnlyFromStaticAnnotations = function (oAnnotations: any, oFieldControl: any) {
493
+ let bComputed, bImmutable, bReadOnly;
494
+ if (oAnnotations["@Org.OData.Core.V1.Computed"]) {
495
+ bComputed = oAnnotations["@Org.OData.Core.V1.Computed"].Bool ? oAnnotations["@Org.OData.Core.V1.Computed"].Bool == "true" : true;
496
+ }
497
+ if (oAnnotations["@Org.OData.Core.V1.Immutable"]) {
498
+ bImmutable = oAnnotations["@Org.OData.Core.V1.Immutable"].Bool ? oAnnotations["@Org.OData.Core.V1.Immutable"].Bool == "true" : true;
499
+ }
500
+ bReadOnly = bComputed || bImmutable;
501
+
502
+ if (oFieldControl) {
503
+ bReadOnly = bReadOnly || oFieldControl == "com.sap.vocabularies.Common.v1.FieldControlType/ReadOnly";
504
+ }
505
+ if (bReadOnly) {
506
+ return true;
507
+ } else {
508
+ return false;
509
+ }
510
+ };
511
+
512
+ export const readOnlyExpressionFromDynamicAnnotations = function (oFieldControl: any) {
513
+ let sIsFieldControlPathReadOnly;
514
+ if (oFieldControl) {
515
+ if ((ManagedObject as any).bindingParser(oFieldControl)) {
516
+ sIsFieldControlPathReadOnly = "%" + oFieldControl + " === 1 ";
517
+ }
518
+ }
519
+ if (sIsFieldControlPathReadOnly) {
520
+ return "{= " + sIsFieldControlPathReadOnly + "? false : true }";
521
+ } else {
522
+ return;
523
+ }
524
+ };
525
+
526
+ /*
527
+ * Function to get the expression for chart Title Press
528
+ *
529
+ * @function
530
+ * @param {oConfiguration} [oConfigurations] control configuration from manifest
531
+ * @param {oManifest} [oManifest] Outbounds from manifest
532
+ * returns {String} [sCollectionName] Collection Name of the Micro Chart
533
+ *
534
+ * returns {String} [Expression] Handler Expression for the title press
535
+ *
536
+ */
537
+ export const getExpressionForMicroChartTitlePress = function (oConfiguration: any, oManifestOutbound: any, sCollectionName: any) {
538
+ if (oConfiguration) {
539
+ if (
540
+ (oConfiguration["targetOutbound"] && oConfiguration["targetOutbound"]["outbound"]) ||
541
+ (oConfiguration["targetOutbound"] && oConfiguration["targetOutbound"]["outbound"] && oConfiguration["targetSections"])
542
+ ) {
543
+ return (
544
+ ".handlers.onDataPointTitlePressed($controller, ${$source>/},'" +
545
+ JSON.stringify(oManifestOutbound) +
546
+ "','" +
547
+ oConfiguration["targetOutbound"]["outbound"] +
548
+ "','" +
549
+ sCollectionName +
550
+ "' )"
551
+ );
552
+ } else if (oConfiguration["targetSections"]) {
553
+ return ".handlers.navigateToSubSection($controller, '" + JSON.stringify(oConfiguration["targetSections"]) + "')";
554
+ } else {
555
+ return undefined;
556
+ }
557
+ }
558
+ };
559
+
560
+ /*
561
+ * Function to render Chart Title as Link
562
+ *
563
+ * @function
564
+ * @param {oControlConfiguration} [oConfigurations] control configuration from manifest
565
+ * returns {String} [sKey] For the TargetOutbound and TargetSection
566
+ *
567
+ */
568
+ export const getMicroChartTitleAsLink = function (oControlConfiguration: any) {
569
+ if (
570
+ oControlConfiguration &&
571
+ (oControlConfiguration["targetOutbound"] || (oControlConfiguration["targetOutbound"] && oControlConfiguration["targetSections"]))
572
+ ) {
573
+ return "External";
574
+ } else if (oControlConfiguration && oControlConfiguration["targetSections"]) {
575
+ return "InPage";
576
+ } else {
577
+ return "None";
578
+ }
579
+ };
580
+
581
+ /* Get groupId from control configuration
582
+ *
583
+ * @function
584
+ * @param {Object} [oConfigurations] control configuration from manifest
585
+ * @param {String} [sAnnotationPath] Annotation Path for the configuration
586
+ * @description Used to get the groupId for DataPoints and MicroCharts in the Header.
587
+ *
588
+ */
589
+ export const getGroupIdFromConfig = function (oConfigurations: any, sAnnotationPath: any, sDefaultGroupId?: any) {
590
+ const oConfiguration = oConfigurations[sAnnotationPath],
591
+ aAutoPatterns = ["Heroes", "Decoration", "Workers", "LongRunners"];
592
+ let sGroupId = sDefaultGroupId;
593
+ if (
594
+ oConfiguration &&
595
+ oConfiguration.requestGroupId &&
596
+ aAutoPatterns.some(function (autoPattern: string) {
597
+ return autoPattern === oConfiguration.requestGroupId;
598
+ })
599
+ ) {
600
+ sGroupId = "$auto." + oConfiguration.requestGroupId;
601
+ }
602
+ return sGroupId;
603
+ };
604
+
605
+ /*
606
+ * Get Context Binding with groupId from control configuration
607
+ *
608
+ * @function
609
+ * @param {Object} [oConfigurations] control configuration from manifest
610
+ * @param {String} [sKey] Annotation Path for of the configuration
611
+ * @description Used to get the binding for DataPoints in the Header.
612
+ *
613
+ */
614
+ export const getBindingWithGroupIdFromConfig = function (oConfigurations: any, sKey: any) {
615
+ const sGroupId = getGroupIdFromConfig(oConfigurations, sKey);
616
+ let sBinding;
617
+ if (sGroupId) {
618
+ sBinding = "{ path : '', parameters : { $$groupId : '" + sGroupId + "' } }";
619
+ }
620
+ return sBinding;
621
+ };
622
+
623
+ /**
624
+ * Method to check whether a FieldGroup consists of only 1 DataField with MultiLine Text annotation.
625
+ *
626
+ * @param {DataFieldAbstractTypes[]} aFormElements A collection of form elements used in the current field group
627
+ * @returns {boolean} Returns true if only 1 data field with Multiline Text annotation exists.
628
+ */
629
+ export const doesFieldGroupContainOnlyOneMultiLineDataField = function (aFormElements: any[]) {
630
+ return aFormElements && aFormElements.length === 1 && !!aFormElements[0].isValueMultilineText;
631
+ };
632
+
633
+ /*
634
+ * Get Visiblity of breadcrumbs.
635
+ *
636
+ * @function
637
+ * @param {Object} [oViewData] ViewData model
638
+ * returns {*} Expression or boolean
639
+ */
640
+ export const getVisibleExpressionForBreadcrumbs = function (oViewData: any) {
641
+ return oViewData.showBreadCrumbs && oViewData.fclEnabled !== undefined ? "{fclhelper>/breadCrumbIsVisible}" : oViewData.showBreadCrumbs;
642
+ };
643
+
644
+ export const getShareButtonVisibility = function (viewData: any) {
645
+ let sShareButtonVisibilityExp = "!${ui>createMode}";
646
+ if (viewData.fclEnabled) {
647
+ sShareButtonVisibilityExp = "${fclhelper>/showShareIcon} && " + sShareButtonVisibilityExp;
648
+ }
649
+ return "{= " + sShareButtonVisibilityExp + " }";
650
+ };
651
+
652
+ /*
653
+ * Get visiblity for editable header facet.
654
+ *
655
+ * If either the title or description field from the header annotations are editable, then the
656
+ * editable header facet is visible.
657
+ *
658
+ * @function
659
+ * @param {object} [oAnnotations] Annotations object for given entity set
660
+ * @param {object} [oFieldControl] field control
661
+ * returns {*} binding expression or boolean value resolved form funcitons isReadOnlyFromStaticAnnotations and isReadOnlyFromDynamicAnnotations
662
+ */
663
+ export const getVisiblityOfHeaderFacet = function (
664
+ oTitleAnnotations: any,
665
+ oDescriptionAnnotations: any,
666
+ oFieldTitleFieldControl: any,
667
+ oFieldDescriptionFieldControl: any
668
+ ) {
669
+ // Check Annotations for Title Field
670
+ const bIsTitleReadOnly = isReadOnlyFromStaticAnnotations(oTitleAnnotations, oFieldTitleFieldControl);
671
+ const titleExpression = readOnlyExpressionFromDynamicAnnotations(oFieldTitleFieldControl);
672
+ // There is no expression and the title is not ready only, this is sufficient for an editable header
673
+ if (!bIsTitleReadOnly && !titleExpression) {
674
+ return true;
675
+ }
676
+
677
+ // Check Annotations for Description Field
678
+ const bIsDescriptionReadOnly = isReadOnlyFromStaticAnnotations(oDescriptionAnnotations, oFieldDescriptionFieldControl);
679
+ const descriptionExpression = readOnlyExpressionFromDynamicAnnotations(oFieldDescriptionFieldControl);
680
+ // There is no expression and the description is not ready only, this is sufficient for an editable header
681
+ if (!bIsDescriptionReadOnly && !descriptionExpression) {
682
+ return true;
683
+ }
684
+
685
+ // Both title and description are not editable and there are no dynamic annotations
686
+ if (bIsTitleReadOnly && bIsDescriptionReadOnly && !titleExpression && !descriptionExpression) {
687
+ return false;
688
+ }
689
+
690
+ // Now combine expressions
691
+ if (titleExpression && !descriptionExpression) {
692
+ return titleExpression;
693
+ } else if (!titleExpression && descriptionExpression) {
694
+ return descriptionExpression;
695
+ } else {
696
+ return combineTitleAndDescriptionExpression(oFieldTitleFieldControl, oFieldDescriptionFieldControl);
697
+ }
698
+ };
699
+
700
+ export const combineTitleAndDescriptionExpression = function (oTitleFieldControl: any, oDescriptionFieldControl: any) {
701
+ // If both header and title field are based on dynmaic field control, the editable header
702
+ // is visible if at least one of these is not ready only
703
+ return "{= %" + oTitleFieldControl + " === 1 ? ( %" + oDescriptionFieldControl + " === 1 ? false : true ) : true }";
704
+ };
705
+
706
+ /*
707
+ * Get Expression of press event of delete button.
708
+ *
709
+ * @function
710
+ * @param {string} [sEntitySetName] Entity set name
711
+ * returns {string} binding expression / function string generated from commanhelper's function generateFunction
712
+ */
713
+ export const getPressExpressionForDelete = function (sEntitySetName: any) {
714
+ const sDeletableContexts = "${$view>/getBindingContext}",
715
+ sTitle = "${$view>/#fe::ObjectPage/getHeaderTitle/getExpandedHeading/getItems/1/getText}",
716
+ sDescription = "${$view>/#fe::ObjectPage/getHeaderTitle/getExpandedContent/0/getItems/0/getText}";
717
+ const oParams = {
718
+ title: sTitle,
719
+ entitySetName: CommonHelper.addSingleQuotes(sEntitySetName),
720
+ description: sDescription
721
+ };
722
+ return CommonHelper.generateFunction(".editFlow.deleteDocument", sDeletableContexts, CommonHelper.objectToString(oParams));
723
+ };
724
+
725
+ /*
726
+ * Get Expression of press event of Edit button.
727
+ *
728
+ * @function
729
+ * @param {object} [oDataField] Data field object
730
+ * @param {string} [sEntitySetName] Entity set name
731
+ * @param {object} [oHeaderAction] Header action object
732
+ * returns {string} binding expression / function string generated from commanhelper's function generateFunction
733
+ */
734
+ export const getPressExpressionForEdit = function (oDataField: any, sEntitySetName: any, oHeaderAction: any) {
735
+ const sEditableContexts = CommonHelper.addSingleQuotes(oDataField && oDataField.Action),
736
+ sDataFieldEnumMember = oDataField && oDataField.InvocationGrouping && oDataField.InvocationGrouping["$EnumMember"],
737
+ sInvocationGroup = sDataFieldEnumMember === "com.sap.vocabularies.UI.v1.OperationGroupingType/ChangeSet" ? "ChangeSet" : "Isolated";
738
+ const oParams = {
739
+ contexts: "${$view>/getBindingContext}",
740
+ entitySetName: CommonHelper.addSingleQuotes(sEntitySetName),
741
+ invocationGrouping: CommonHelper.addSingleQuotes(sInvocationGroup),
742
+ model: "${$source>/}.getModel()",
743
+ label: CommonHelper.addSingleQuotes(oDataField && oDataField.Label, true),
744
+ isNavigable: oHeaderAction && oHeaderAction.isNavigable,
745
+ defaultValuesExtensionFunction:
746
+ oHeaderAction && oHeaderAction.defaultValuesExtensionFunction
747
+ ? "'" + oHeaderAction.defaultValuesExtensionFunction + "'"
748
+ : undefined
749
+ };
750
+ return CommonHelper.generateFunction(".handlers.onCallAction", "${$view>/}", sEditableContexts, CommonHelper.objectToString(oParams));
751
+ };
752
+
753
+ /*
754
+ * Method to get the expression for the 'press' event for footer annotation actions
755
+ *
756
+ * @function
757
+ * @param {object} [oDataField] Data field object
758
+ * @param {string} [sEntitySetName] Entity set name
759
+ * @param {object} [oHeaderAction] Header action object
760
+ * returns {string} Binding expression or function string that is generated from the Commonhelper's function generateFunction
761
+ */
762
+ export const getPressExpressionForFooterAnnotationAction = function (oDataField: any, sEntitySetName: any, oHeaderAction: any) {
763
+ const sActionContexts = CommonHelper.addSingleQuotes(oDataField && oDataField.Action),
764
+ sDataFieldEnumMember = oDataField && oDataField.InvocationGrouping && oDataField.InvocationGrouping["$EnumMember"],
765
+ sInvocationGroup = sDataFieldEnumMember === "com.sap.vocabularies.UI.v1.OperationGroupingType/ChangeSet" ? "ChangeSet" : "Isolated";
766
+ const oParams = {
767
+ contexts: "${$view>/#fe::ObjectPage/}.getBindingContext()",
768
+ entitySetName: CommonHelper.addSingleQuotes(sEntitySetName),
769
+ invocationGrouping: CommonHelper.addSingleQuotes(sInvocationGroup),
770
+ model: "${$source>/}.getModel()",
771
+ label: CommonHelper.addSingleQuotes(oDataField && oDataField.Label, true),
772
+ isNavigable: oHeaderAction && oHeaderAction.isNavigable,
773
+ defaultValuesExtensionFunction:
774
+ oHeaderAction && oHeaderAction.defaultValuesExtensionFunction
775
+ ? "'" + oHeaderAction.defaultValuesExtensionFunction + "'"
776
+ : undefined
777
+ };
778
+ return CommonHelper.generateFunction(".handlers.onCallAction", "${$view>/}", sActionContexts, CommonHelper.objectToString(oParams));
779
+ };
780
+
781
+ /*
782
+ * Gets the binding of the container HBox for the header facet.
783
+ *
784
+ * @function
785
+ * @param {object} [oControlConfiguration] The control configuration form of the viewData model
786
+ * @param {object} [oHeaderFacet] The object of the header facet
787
+ * returns {*} The binding expression from function getBindingWithGroupIdFromConfig or undefined.
788
+ */
789
+ export const getStashableHBoxBinding = function (oControlConfiguration: any, oHeaderFacet: any) {
790
+ if (oHeaderFacet && oHeaderFacet.Facet && oHeaderFacet.Facet.targetAnnotationType === "DataPoint") {
791
+ return getBindingWithGroupIdFromConfig(oControlConfiguration, oHeaderFacet.Facet.targetAnnotationValue);
792
+ }
793
+ };
794
+
795
+ /*
796
+ * Gets the 'Press' event expression for the external and internal data point link.
797
+ *
798
+ * @function
799
+ * @param {object} [oConfiguration] Control configuration from manifest
800
+ * @param {object} [oManifestOutbound] Outbounds from manifest
801
+ * returns {string} The runtime binding of the 'Press' event
802
+ */
803
+ export const getPressExpressionForLink = function (oConfiguration: any, oManifestOutbound: any) {
804
+ if (oConfiguration) {
805
+ if (oConfiguration["targetOutbound"] && oConfiguration["targetOutbound"]["outbound"]) {
806
+ return (
807
+ ".handlers.onDataPointTitlePressed($controller, ${$source>}, " +
808
+ JSON.stringify(oManifestOutbound) +
809
+ "," +
810
+ JSON.stringify(oConfiguration["targetOutbound"]["outbound"]) +
811
+ ")"
812
+ );
813
+ } else if (oConfiguration["targetSections"]) {
814
+ return ".handlers.navigateToSubSection($controller, '" + JSON.stringify(oConfiguration["targetSections"]) + "')";
815
+ } else {
816
+ return undefined;
817
+ }
818
+ }
819
+ };
820
+
821
+ export const isSubSectionTitleVisible = function (sSubSectionvisible: any, sSubSectiontitle: any, sSubSectionshowTitle: any) {
822
+ if (sSubSectionvisible.indexOf("{=") === 0) {
823
+ // Dynamic expression
824
+ const sExpressionResult = sSubSectionvisible.substring(sSubSectionvisible.indexOf("{=") + 2, sSubSectionvisible.lastIndexOf("}"));
825
+ return (
826
+ "{= (" +
827
+ sExpressionResult +
828
+ ") && ('" +
829
+ sSubSectiontitle +
830
+ "' !=='undefined') && (" +
831
+ sSubSectionshowTitle +
832
+ " ? true : false) }"
833
+ );
834
+ } else {
835
+ return sSubSectionvisible && sSubSectiontitle !== "undefined" && (sSubSectionshowTitle ? "true" : "false");
836
+ }
837
+ };