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