@sapui5/sap.fe.core 1.93.3 → 1.96.2
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 +2 -2
- package/src/sap/fe/core/.library +1 -1
- package/src/sap/fe/core/AppComponent.js +9 -40
- package/src/sap/fe/core/BusyLocker.js +12 -0
- package/src/sap/fe/core/CommonUtils.js +430 -27
- package/src/sap/fe/core/ExtensionAPI.js +1 -1
- package/src/sap/fe/core/PageController.js +13 -2
- package/src/sap/fe/core/TemplateComponent.js +6 -0
- package/src/sap/fe/core/TransactionHelper.js +248 -170
- package/src/sap/fe/core/actions/draft.js +13 -1
- package/src/sap/fe/core/actions/operations.js +165 -45
- package/src/sap/fe/core/controllerextensions/EditFlow.js +56 -37
- package/src/sap/fe/core/controllerextensions/InternalEditFlow.js +13 -6
- package/src/sap/fe/core/controllerextensions/InternalIntentBasedNavigation.js +127 -24
- package/src/sap/fe/core/controllerextensions/InternalRouting.js +183 -164
- package/src/sap/fe/core/controllerextensions/KPIManagement.js +834 -170
- package/src/sap/fe/core/controllerextensions/KPIManagement.ts +890 -189
- package/src/sap/fe/core/controllerextensions/PageReady.js +48 -33
- package/src/sap/fe/core/controllerextensions/PageReady.ts +49 -14
- package/src/sap/fe/core/controllerextensions/Paginator.js +150 -0
- package/src/sap/fe/core/controllerextensions/Placeholder.js +133 -270
- package/src/sap/fe/core/controllerextensions/Share.js +31 -13
- package/src/sap/fe/core/controllerextensions/SideEffects.js +5 -6
- package/src/sap/fe/core/controllerextensions/SideEffects.ts +13 -12
- package/src/sap/fe/core/controllerextensions/ViewState.js +173 -6
- package/src/sap/fe/core/controls/ActionParameterDialog.fragment.xml +39 -34
- package/src/sap/fe/core/controls/ActionParameterDialogValueHelp.fragment.xml +35 -0
- package/src/sap/fe/core/controls/ActionPartial.fragment.xml +1 -1
- package/src/sap/fe/core/controls/CustomQuickViewPage.js +3 -0
- package/src/sap/fe/core/controls/MultiValueParameterDelegate.js +45 -0
- package/src/sap/fe/core/controls/filterbar/FilterContainer.js +15 -4
- package/src/sap/fe/core/controls/filterbar/VisualFilter.js +250 -94
- package/src/sap/fe/core/controls/filterbar/VisualFilterContainer.js +129 -135
- package/src/sap/fe/core/controls/filterbar/utils/VisualFilterUtils.js +325 -0
- package/src/sap/fe/core/converters/ConverterContext.js +19 -5
- package/src/sap/fe/core/converters/ConverterContext.ts +13 -3
- package/src/sap/fe/core/converters/ManifestSettings.js +1 -1
- package/src/sap/fe/core/converters/ManifestSettings.ts +9 -2
- package/src/sap/fe/core/converters/ManifestWrapper.js +9 -9
- package/src/sap/fe/core/converters/MetaModelConverter.js +858 -871
- package/src/sap/fe/core/converters/MetaModelConverter.ts +763 -826
- package/src/sap/fe/core/converters/TemplateConverter.js +4 -4
- package/src/sap/fe/core/converters/annotations/DataField.js +57 -7
- package/src/sap/fe/core/converters/annotations/DataField.ts +52 -2
- package/src/sap/fe/core/converters/common/AnnotationConverter.js +80 -46
- package/src/sap/fe/core/converters/controls/Common/Action.js +56 -54
- package/src/sap/fe/core/converters/controls/Common/Action.ts +48 -36
- package/src/sap/fe/core/converters/controls/Common/Chart.js +101 -9
- package/src/sap/fe/core/converters/controls/Common/Chart.ts +100 -5
- package/src/sap/fe/core/converters/controls/Common/Criticality.js +1 -1
- package/src/sap/fe/core/converters/controls/Common/DataVisualization.js +15 -16
- package/src/sap/fe/core/converters/controls/Common/DataVisualization.ts +16 -30
- package/src/sap/fe/core/converters/controls/Common/Form.js +21 -12
- package/src/sap/fe/core/converters/controls/Common/Form.ts +28 -8
- package/src/sap/fe/core/converters/controls/Common/KPI.js +287 -109
- package/src/sap/fe/core/converters/controls/Common/KPI.ts +314 -139
- package/src/sap/fe/core/converters/controls/Common/Table.js +414 -171
- package/src/sap/fe/core/converters/controls/Common/Table.ts +412 -130
- package/src/sap/fe/core/converters/controls/ListReport/FilterBar.js +487 -0
- package/src/sap/fe/core/converters/controls/ListReport/FilterBar.ts +541 -0
- package/src/sap/fe/core/converters/controls/ListReport/VisualFilters.js +364 -0
- package/src/sap/fe/core/converters/controls/ListReport/VisualFilters.ts +338 -0
- package/src/sap/fe/core/converters/controls/ObjectPage/Avatar.js +74 -0
- package/src/sap/fe/core/converters/controls/ObjectPage/Avatar.ts +50 -0
- package/src/sap/fe/core/converters/controls/ObjectPage/HeaderFacet.js +11 -11
- package/src/sap/fe/core/converters/controls/ObjectPage/SubSection.js +47 -35
- package/src/sap/fe/core/converters/controls/ObjectPage/SubSection.ts +45 -29
- package/src/sap/fe/core/converters/helpers/Aggregation.js +31 -32
- package/src/sap/fe/core/converters/helpers/Aggregation.ts +26 -27
- package/src/sap/fe/core/converters/helpers/BindingHelper.js +27 -2
- package/src/sap/fe/core/converters/helpers/BindingHelper.ts +22 -2
- package/src/sap/fe/core/converters/helpers/ConfigurableObject.js +1 -1
- package/src/sap/fe/core/converters/helpers/ID.js +1 -3
- package/src/sap/fe/core/converters/helpers/ID.ts +2 -3
- package/src/sap/fe/core/converters/helpers/IssueManager.js +5 -4
- package/src/sap/fe/core/converters/helpers/IssueManager.ts +4 -3
- package/src/sap/fe/core/converters/helpers/Key.js +3 -3
- package/src/sap/fe/core/converters/helpers/SelectionVariantHelper.js +11 -6
- package/src/sap/fe/core/converters/helpers/SelectionVariantHelper.ts +9 -5
- package/src/sap/fe/core/converters/objectPage/FormMenuActions.js +18 -5
- package/src/sap/fe/core/converters/objectPage/FormMenuActions.ts +14 -14
- package/src/sap/fe/core/converters/objectPage/HeaderAndFooterAction.js +91 -20
- package/src/sap/fe/core/converters/objectPage/HeaderAndFooterAction.ts +77 -5
- package/src/sap/fe/core/converters/templates/ListReportConverter.js +76 -714
- package/src/sap/fe/core/converters/templates/ListReportConverter.ts +75 -807
- package/src/sap/fe/core/converters/templates/ObjectPageConverter.js +106 -17
- package/src/sap/fe/core/converters/templates/ObjectPageConverter.ts +121 -16
- package/src/sap/fe/core/formatters/CriticalityFormatter.js +1 -1
- package/src/sap/fe/core/formatters/FPMFormatter.js +1 -1
- package/src/sap/fe/core/formatters/FPMFormatter.ts +8 -3
- package/src/sap/fe/core/formatters/KPIFormatter.js +1 -1
- package/src/sap/fe/core/formatters/TableFormatter.js +1 -1
- package/src/sap/fe/core/formatters/TableFormatterTypes.js +1 -1
- package/src/sap/fe/core/formatters/ValueFormatter.js +1 -1
- package/src/sap/fe/core/fpm/Component.js +1 -1
- package/src/sap/fe/core/helpers/AnnotationEnum.js +3 -3
- package/src/sap/fe/core/helpers/BindingExpression.js +6 -6
- package/src/sap/fe/core/helpers/ClassSupport.js +4 -4
- package/src/sap/fe/core/helpers/ExcelFormatHelper.js +0 -2
- package/src/sap/fe/core/helpers/ModelHelper.js +27 -0
- package/src/sap/fe/core/helpers/PasteHelper.js +6 -0
- package/src/sap/fe/core/helpers/SemanticKeyHelper.js +2 -2
- package/src/sap/fe/core/helpers/StableIdHelper.js +1 -1
- package/src/sap/fe/core/helpers/StableIdHelper.ts +1 -1
- package/src/sap/fe/core/jsx-runtime/jsx.js +2 -2
- package/src/sap/fe/core/jsx-runtime/jsxs.js +1 -1
- package/src/sap/fe/core/library.js +1 -1
- package/src/sap/fe/core/messagebundle.properties +30 -1
- package/src/sap/fe/core/messagebundle_ar.properties +43 -1
- package/src/sap/fe/core/messagebundle_bg.properties +42 -0
- package/src/sap/fe/core/messagebundle_ca.properties +44 -2
- package/src/sap/fe/core/messagebundle_cs.properties +42 -0
- package/src/sap/fe/core/messagebundle_cy.properties +42 -0
- package/src/sap/fe/core/messagebundle_da.properties +43 -1
- package/src/sap/fe/core/messagebundle_de.properties +45 -3
- package/src/sap/fe/core/messagebundle_el.properties +43 -1
- package/src/sap/fe/core/messagebundle_en.properties +42 -0
- package/src/sap/fe/core/messagebundle_en_GB.properties +43 -1
- package/src/sap/fe/core/messagebundle_en_US_sappsd.properties +43 -1
- package/src/sap/fe/core/messagebundle_en_US_saprigi.properties +48 -0
- package/src/sap/fe/core/messagebundle_en_US_saptrc.properties +42 -0
- package/src/sap/fe/core/messagebundle_es.properties +50 -8
- package/src/sap/fe/core/messagebundle_es_MX.properties +45 -3
- package/src/sap/fe/core/messagebundle_et.properties +42 -0
- package/src/sap/fe/core/messagebundle_fi.properties +42 -0
- package/src/sap/fe/core/messagebundle_fr.properties +51 -9
- package/src/sap/fe/core/messagebundle_fr_CA.properties +42 -0
- package/src/sap/fe/core/messagebundle_hi.properties +43 -1
- package/src/sap/fe/core/messagebundle_hr.properties +43 -1
- package/src/sap/fe/core/messagebundle_hu.properties +42 -0
- package/src/sap/fe/core/messagebundle_id.properties +43 -1
- package/src/sap/fe/core/messagebundle_it.properties +43 -1
- package/src/sap/fe/core/messagebundle_iw.properties +44 -2
- package/src/sap/fe/core/messagebundle_ja.properties +43 -1
- package/src/sap/fe/core/messagebundle_kk.properties +43 -1
- package/src/sap/fe/core/messagebundle_ko.properties +43 -1
- package/src/sap/fe/core/messagebundle_lt.properties +43 -1
- package/src/sap/fe/core/messagebundle_lv.properties +43 -1
- package/src/sap/fe/core/messagebundle_ms.properties +43 -1
- package/src/sap/fe/core/messagebundle_nl.properties +47 -5
- package/src/sap/fe/core/messagebundle_no.properties +44 -2
- package/src/sap/fe/core/messagebundle_pl.properties +43 -1
- package/src/sap/fe/core/messagebundle_pt.properties +43 -1
- package/src/sap/fe/core/messagebundle_pt_PT.properties +43 -1
- package/src/sap/fe/core/messagebundle_ro.properties +43 -1
- package/src/sap/fe/core/messagebundle_ru.properties +43 -1
- package/src/sap/fe/core/messagebundle_sh.properties +43 -1
- package/src/sap/fe/core/messagebundle_sk.properties +42 -0
- package/src/sap/fe/core/messagebundle_sl.properties +43 -1
- package/src/sap/fe/core/messagebundle_sv.properties +43 -1
- package/src/sap/fe/core/messagebundle_th.properties +42 -0
- package/src/sap/fe/core/messagebundle_tr.properties +42 -0
- package/src/sap/fe/core/messagebundle_uk.properties +42 -0
- package/src/sap/fe/core/messagebundle_vi.properties +43 -1
- package/src/sap/fe/core/messagebundle_zh_CN.properties +43 -1
- package/src/sap/fe/core/messagebundle_zh_TW.properties +43 -1
- package/src/sap/fe/core/services/AsyncComponentServiceFactory.js +5 -5
- package/src/sap/fe/core/services/EnvironmentServiceFactory.js +5 -5
- package/src/sap/fe/core/services/RoutingServiceFactory.js +155 -76
- package/src/sap/fe/core/services/ShellServicesFactory.js +9 -9
- package/src/sap/fe/core/services/SideEffectsServiceFactory.js +11 -12
- package/src/sap/fe/core/services/TemplatedViewServiceFactory.js +11 -1
- package/src/sap/fe/core/support/AnnotationIssue.support.js +2 -4
- package/src/sap/fe/core/support/CollectionFacetMissingID.support.js +2 -4
- package/src/sap/fe/core/support/CollectionFacetUnsupportedLevel.support.js +2 -4
- package/src/sap/fe/core/support/CommonHelper.js +2 -4
- package/src/sap/fe/core/support/Diagnostics.js +1 -1
- package/src/sap/fe/core/templating/CriticalityFormatters.js +4 -4
- package/src/sap/fe/core/templating/DataFieldFormatters.js +1 -1
- package/src/sap/fe/core/templating/DataModelPathHelper.js +54 -6
- package/src/sap/fe/core/templating/DataModelPathHelper.ts +54 -4
- package/src/sap/fe/core/templating/EntitySetHelper.js +13 -3
- package/src/sap/fe/core/templating/EntitySetHelper.ts +4 -0
- package/src/sap/fe/core/templating/FieldControlHelper.js +1 -1
- package/src/sap/fe/core/templating/FilterHelper.js +23 -5
- package/src/sap/fe/core/templating/FilterHelper.ts +15 -1
- package/src/sap/fe/core/templating/FilterTemplating.js +1 -1
- package/src/sap/fe/core/templating/PropertyFormatters.js +1 -1
- package/src/sap/fe/core/templating/PropertyHelper.js +8 -8
- package/src/sap/fe/core/templating/UIFormatters.js +72 -4
- package/src/sap/fe/core/templating/UIFormatters.ts +98 -3
- package/src/sap/fe/core/type/Email.js +1 -1
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { EntityType } from "@sap-ux/annotation-converter";
|
|
2
|
+
import ConverterContext from "sap/fe/core/converters/ConverterContext";
|
|
3
|
+
import { FilterFieldManifestConfiguration } from "sap/fe/core/converters/ManifestSettings";
|
|
4
|
+
import { isPropertyFilterable, getIsRequired } from "sap/fe/core/templating/FilterTemplating";
|
|
5
|
+
import { compileBinding } from "sap/fe/core/helpers/BindingExpression";
|
|
6
|
+
import { checkFilterExpressionRestrictions } from "sap/fe/core/templating/DataModelPathHelper";
|
|
7
|
+
import { AggregationHelper } from "sap/fe/core/converters/helpers/Aggregation";
|
|
8
|
+
import { IssueType, IssueSeverity, IssueCategory } from "sap/fe/core/converters/helpers/IssueManager";
|
|
9
|
+
import { NavigationPropertyRestrictionTypes } from "@sap-ux/vocabularies-types/dist/generated/Capabilities";
|
|
10
|
+
import { AnnotationTerm } from "@sap-ux/vocabularies-types";
|
|
11
|
+
import { CustomAggregate } from "@sap-ux/vocabularies-types/dist/generated/Aggregation";
|
|
12
|
+
|
|
13
|
+
export type VisualFilters = {
|
|
14
|
+
dimensionPath?: string;
|
|
15
|
+
measurePath?: string;
|
|
16
|
+
label?: string;
|
|
17
|
+
chartAnnotation?: string;
|
|
18
|
+
presentationAnnotation?: string;
|
|
19
|
+
visible?: boolean;
|
|
20
|
+
outParameter?: string;
|
|
21
|
+
inParameters?: object[];
|
|
22
|
+
contextPath?: string;
|
|
23
|
+
selectionVariantAnnotation?: string;
|
|
24
|
+
multipleSelectionAllowed?: boolean;
|
|
25
|
+
required?: boolean;
|
|
26
|
+
showOverlayInitially?: boolean;
|
|
27
|
+
renderLineChart?: boolean;
|
|
28
|
+
requiredProperties?: object[];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Checks that measures and dimensions of the visual filter chart can be aggregated and grouped.
|
|
33
|
+
* @param converterContext The converter context
|
|
34
|
+
* @param chartAnnotation The chart annotation
|
|
35
|
+
* @param aggregationHelper The aggregation helper
|
|
36
|
+
* @returns {boolean | undefined }
|
|
37
|
+
*/
|
|
38
|
+
const _checkVFAggregation = function(
|
|
39
|
+
converterContext: ConverterContext,
|
|
40
|
+
chartAnnotation: any,
|
|
41
|
+
aggregationHelper: any
|
|
42
|
+
): boolean | undefined {
|
|
43
|
+
let sMeasurePath, bGroupable, bAggregatable;
|
|
44
|
+
const sMeasure: string = chartAnnotation?.$target?.Measures[0]?.value;
|
|
45
|
+
const sDimension: string = chartAnnotation?.$target?.Dimensions[0]?.value;
|
|
46
|
+
const customAggregates = aggregationHelper.getCustomAggregateDefinitions();
|
|
47
|
+
const aTransAggregations = aggregationHelper.getTransAggregations();
|
|
48
|
+
|
|
49
|
+
if (
|
|
50
|
+
customAggregates.some(function(custAgg: AnnotationTerm<CustomAggregate>) {
|
|
51
|
+
return custAgg.qualifier === sMeasure;
|
|
52
|
+
})
|
|
53
|
+
) {
|
|
54
|
+
sMeasurePath = sMeasure;
|
|
55
|
+
} else if (aTransAggregations && aTransAggregations[0]) {
|
|
56
|
+
const aAggregations = aTransAggregations[0];
|
|
57
|
+
aAggregations.some(function(oAggregate: any) {
|
|
58
|
+
if (oAggregate.Name === sMeasure) {
|
|
59
|
+
sMeasurePath = oAggregate?.AggregatableProperty.value;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const aAggregatablePropsFromContainer = aggregationHelper.getAggregatableProperties();
|
|
64
|
+
const aGroupablePropsFromContainer = aggregationHelper.getGroupableProperties();
|
|
65
|
+
if (aAggregatablePropsFromContainer && aAggregatablePropsFromContainer.length) {
|
|
66
|
+
for (const aggregatableProp of aAggregatablePropsFromContainer) {
|
|
67
|
+
if (aggregatableProp?.Property?.value === sMeasurePath) {
|
|
68
|
+
bAggregatable = true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (aGroupablePropsFromContainer && aGroupablePropsFromContainer.length) {
|
|
73
|
+
for (const groupableProp of aGroupablePropsFromContainer) {
|
|
74
|
+
if (groupableProp?.value === sDimension) {
|
|
75
|
+
bGroupable = true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return bAggregatable && bGroupable;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Method to get the visual filters object for a property.
|
|
84
|
+
* @param entityType The converter context
|
|
85
|
+
* @param converterContext The chart annotation
|
|
86
|
+
* @param sPropertyPath The aggregation helper
|
|
87
|
+
* @param FilterFields The aggregation helper
|
|
88
|
+
* @returns {VisualFilters | undefined }
|
|
89
|
+
*/
|
|
90
|
+
export function getVisualFilters(
|
|
91
|
+
entityType: EntityType,
|
|
92
|
+
converterContext: ConverterContext,
|
|
93
|
+
sPropertyPath: string,
|
|
94
|
+
FilterFields: Record<string, FilterFieldManifestConfiguration>
|
|
95
|
+
): VisualFilters | undefined {
|
|
96
|
+
const visualFilter: VisualFilters = {};
|
|
97
|
+
const oVisualFilter: FilterFieldManifestConfiguration = FilterFields[sPropertyPath];
|
|
98
|
+
if (oVisualFilter && oVisualFilter?.visualFilter && oVisualFilter?.visualFilter?.valueList) {
|
|
99
|
+
const oVFPath = oVisualFilter?.visualFilter?.valueList;
|
|
100
|
+
const annotationQualifierSplit = oVFPath.split("#");
|
|
101
|
+
const qualifierVL = annotationQualifierSplit.length > 1 ? "ValueList#" + annotationQualifierSplit[1] : annotationQualifierSplit[0];
|
|
102
|
+
const property = entityType.resolvePath(sPropertyPath);
|
|
103
|
+
const valueList: any = property?.annotations?.Common[qualifierVL];
|
|
104
|
+
if (valueList) {
|
|
105
|
+
const collectionPath = valueList?.CollectionPath;
|
|
106
|
+
let collectionPathConverterContext = converterContext.getConverterContextFor(
|
|
107
|
+
"/" + (collectionPath || converterContext.getEntitySet()?.name)
|
|
108
|
+
);
|
|
109
|
+
const valueListParams = valueList?.Parameters;
|
|
110
|
+
let outParameter: any;
|
|
111
|
+
const inParameters: Array<object> = [];
|
|
112
|
+
let aParameters: Array<string> = [];
|
|
113
|
+
if (!collectionPathConverterContext.getDataModelObjectPath().targetEntitySet) {
|
|
114
|
+
const resolvedTarget = collectionPathConverterContext.getEntityTypeAnnotation("");
|
|
115
|
+
collectionPathConverterContext = resolvedTarget.converterContext;
|
|
116
|
+
}
|
|
117
|
+
const parameterEntityType = collectionPathConverterContext.getParameterEntityType();
|
|
118
|
+
aParameters = parameterEntityType
|
|
119
|
+
? parameterEntityType.keys.map(function(key) {
|
|
120
|
+
return key.name;
|
|
121
|
+
})
|
|
122
|
+
: [];
|
|
123
|
+
if (converterContext.getContextPath() === collectionPathConverterContext.getContextPath()) {
|
|
124
|
+
aParameters.forEach(function(parameter: any) {
|
|
125
|
+
inParameters.push({
|
|
126
|
+
localDataProperty: parameter,
|
|
127
|
+
valueListProperty: parameter
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
if (valueListParams) {
|
|
132
|
+
for (const valueListParam of valueListParams) {
|
|
133
|
+
const localDataProperty = (valueListParam as any).LocalDataProperty?.value;
|
|
134
|
+
const valueListProperty = (valueListParam as any).ValueListProperty;
|
|
135
|
+
if (
|
|
136
|
+
(valueListParam?.$Type === "com.sap.vocabularies.Common.v1.ValueListParameterInOut" ||
|
|
137
|
+
valueListParam?.$Type === "com.sap.vocabularies.Common.v1.ValueListParameterOut") &&
|
|
138
|
+
sPropertyPath === localDataProperty
|
|
139
|
+
) {
|
|
140
|
+
outParameter = valueListParam;
|
|
141
|
+
}
|
|
142
|
+
if (
|
|
143
|
+
(valueListParam?.$Type === "com.sap.vocabularies.Common.v1.ValueListParameterInOut" ||
|
|
144
|
+
valueListParam?.$Type === "com.sap.vocabularies.Common.v1.ValueListParameterIn") &&
|
|
145
|
+
sPropertyPath !== localDataProperty
|
|
146
|
+
) {
|
|
147
|
+
const bNotFilterable = isPropertyFilterable(collectionPathConverterContext, valueListProperty);
|
|
148
|
+
if (!bNotFilterable) {
|
|
149
|
+
inParameters.push({
|
|
150
|
+
localDataProperty: localDataProperty,
|
|
151
|
+
valueListProperty: valueListProperty
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (inParameters && inParameters.length) {
|
|
158
|
+
inParameters.forEach(function(oInParameter: any) {
|
|
159
|
+
const mainEntitySetInMappingAllowedExpression = compileBinding(
|
|
160
|
+
checkFilterExpressionRestrictions(
|
|
161
|
+
converterContext
|
|
162
|
+
.getConverterContextFor(converterContext.getAbsoluteAnnotationPath(oInParameter?.localDataProperty))
|
|
163
|
+
.getDataModelObjectPath(),
|
|
164
|
+
["SingleValue"]
|
|
165
|
+
)
|
|
166
|
+
);
|
|
167
|
+
const valueListEntitySetInMappingAllowedExpression = compileBinding(
|
|
168
|
+
checkFilterExpressionRestrictions(
|
|
169
|
+
collectionPathConverterContext
|
|
170
|
+
.getConverterContextFor(
|
|
171
|
+
collectionPathConverterContext.getAbsoluteAnnotationPath(oInParameter?.valueListProperty)
|
|
172
|
+
)
|
|
173
|
+
.getDataModelObjectPath(),
|
|
174
|
+
["SingleValue"]
|
|
175
|
+
)
|
|
176
|
+
);
|
|
177
|
+
if (valueListEntitySetInMappingAllowedExpression === "true" && mainEntitySetInMappingAllowedExpression === "false") {
|
|
178
|
+
throw new Error(
|
|
179
|
+
"FilterRestrictions of " + sPropertyPath + " in MainEntitySet and ValueListEntitySet are different"
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
const pvQualifier = valueList?.PresentationVariantQualifier;
|
|
185
|
+
const svQualifier = valueList?.SelectionVariantQualifier;
|
|
186
|
+
const pvAnnotation: any = collectionPathConverterContext?.getEntityTypeAnnotation("@UI.PresentationVariant#" + pvQualifier)
|
|
187
|
+
?.annotation;
|
|
188
|
+
const aggregationHelper = new AggregationHelper(collectionPathConverterContext.getEntityType(), collectionPathConverterContext);
|
|
189
|
+
if (!aggregationHelper.isAnalyticsSupported()) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
if (pvAnnotation) {
|
|
193
|
+
const aVisualizations = pvAnnotation?.Visualizations;
|
|
194
|
+
const contextPath = "/" + valueList?.CollectionPath || "/" + collectionPathConverterContext?.getEntitySet()?.name;
|
|
195
|
+
visualFilter.contextPath = contextPath;
|
|
196
|
+
let chartAnnotation;
|
|
197
|
+
for (const visualization of aVisualizations) {
|
|
198
|
+
if (visualization.$target?.term === "com.sap.vocabularies.UI.v1.Chart") {
|
|
199
|
+
chartAnnotation = visualization;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (chartAnnotation) {
|
|
204
|
+
const _bgetVFAggregation: boolean | undefined = _checkVFAggregation(
|
|
205
|
+
collectionPathConverterContext,
|
|
206
|
+
chartAnnotation,
|
|
207
|
+
aggregationHelper
|
|
208
|
+
);
|
|
209
|
+
if (!_bgetVFAggregation) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const bDimensionHidden: boolean = chartAnnotation?.$target?.Dimensions[0]?.$target?.annotations?.UI?.Hidden?.valueOf();
|
|
213
|
+
const bDimensionHiddenFilter: boolean = chartAnnotation?.$target?.Dimensions[0]?.$target?.annotations?.UI?.HiddenFilter?.valueOf();
|
|
214
|
+
if (bDimensionHidden === true || bDimensionHiddenFilter === true) {
|
|
215
|
+
return;
|
|
216
|
+
} else if (aVisualizations && aVisualizations.length) {
|
|
217
|
+
visualFilter.chartAnnotation = chartAnnotation
|
|
218
|
+
? collectionPathConverterContext?.getAbsoluteAnnotationPath(
|
|
219
|
+
chartAnnotation.fullyQualifiedName + "/$AnnotationPath/"
|
|
220
|
+
)
|
|
221
|
+
: undefined;
|
|
222
|
+
visualFilter.presentationAnnotation = pvAnnotation
|
|
223
|
+
? collectionPathConverterContext?.getAbsoluteAnnotationPath(pvAnnotation.fullyQualifiedName + "/")
|
|
224
|
+
: undefined;
|
|
225
|
+
visualFilter.outParameter = outParameter?.LocalDataProperty?.value;
|
|
226
|
+
visualFilter.inParameters = inParameters;
|
|
227
|
+
const bIsRange = checkFilterExpressionRestrictions(
|
|
228
|
+
converterContext
|
|
229
|
+
.getConverterContextFor(converterContext.getAbsoluteAnnotationPath(sPropertyPath))
|
|
230
|
+
.getDataModelObjectPath(),
|
|
231
|
+
["SingleRange", "MultiRange"]
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
if (compileBinding(bIsRange) === "true") {
|
|
235
|
+
throw new Error("Range AllowedExpression is not supported for visual filters");
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const bIsMainEntitySetSingleSelection: any = checkFilterExpressionRestrictions(
|
|
239
|
+
converterContext
|
|
240
|
+
.getConverterContextFor(converterContext.getAbsoluteAnnotationPath(sPropertyPath))
|
|
241
|
+
.getDataModelObjectPath(),
|
|
242
|
+
["SingleValue"]
|
|
243
|
+
);
|
|
244
|
+
visualFilter.multipleSelectionAllowed = compileBinding(!bIsMainEntitySetSingleSelection.value) as any;
|
|
245
|
+
visualFilter.required = getIsRequired(converterContext, sPropertyPath);
|
|
246
|
+
let svAnnotation: any;
|
|
247
|
+
if (svQualifier) {
|
|
248
|
+
svAnnotation = collectionPathConverterContext?.getEntityTypeAnnotation("@UI.SelectionVariant#" + svQualifier)
|
|
249
|
+
?.annotation;
|
|
250
|
+
visualFilter.selectionVariantAnnotation = svAnnotation
|
|
251
|
+
? collectionPathConverterContext?.getAbsoluteAnnotationPath(svAnnotation.fullyQualifiedName + "/")
|
|
252
|
+
: undefined;
|
|
253
|
+
}
|
|
254
|
+
let requiredProperties = [];
|
|
255
|
+
if (parameterEntityType) {
|
|
256
|
+
const sEntitySet = collectionPath.split("/")[0];
|
|
257
|
+
const sNavigationProperty = collectionPath.split("/")[1];
|
|
258
|
+
const oEntitySetConverterContext = converterContext.getConverterContextFor("/" + sEntitySet);
|
|
259
|
+
const aRestrictedProperties = oEntitySetConverterContext?.getDataModelObjectPath().startingEntitySet
|
|
260
|
+
?.annotations?.Capabilities?.NavigationRestrictions?.RestrictedProperties;
|
|
261
|
+
const oRestrictedProperty = aRestrictedProperties?.find(
|
|
262
|
+
(restrictedNavProp: NavigationPropertyRestrictionTypes) => {
|
|
263
|
+
if (restrictedNavProp.NavigationProperty?.type === "NavigationPropertyPath") {
|
|
264
|
+
return restrictedNavProp.NavigationProperty.value === sNavigationProperty;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
);
|
|
268
|
+
requiredProperties = oRestrictedProperty?.FilterRestrictions?.RequiredProperties as any[];
|
|
269
|
+
} else {
|
|
270
|
+
const entitySetAnnotations = collectionPathConverterContext.getEntitySet()?.annotations;
|
|
271
|
+
requiredProperties = entitySetAnnotations?.Capabilities?.FilterRestrictions?.RequiredProperties as any[];
|
|
272
|
+
}
|
|
273
|
+
let requiredPropertyPaths: Array<object> = [];
|
|
274
|
+
if (requiredProperties?.length) {
|
|
275
|
+
requiredProperties.forEach(function(oRequireProperty: any) {
|
|
276
|
+
requiredPropertyPaths.push(oRequireProperty.value);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
requiredPropertyPaths = requiredPropertyPaths.concat(aParameters);
|
|
280
|
+
visualFilter.requiredProperties = requiredPropertyPaths;
|
|
281
|
+
if (visualFilter.requiredProperties?.length) {
|
|
282
|
+
if (!visualFilter.inParameters || !visualFilter.inParameters.length) {
|
|
283
|
+
if (!visualFilter.selectionVariantAnnotation) {
|
|
284
|
+
visualFilter.showOverlayInitially = true;
|
|
285
|
+
} else {
|
|
286
|
+
let selectOptions =
|
|
287
|
+
svAnnotation?.SelectOptions?.map((oSelectOption: any) => oSelectOption.PropertyName.value) || [];
|
|
288
|
+
const parameterOptions =
|
|
289
|
+
svAnnotation?.Parameters?.map((oParameterOption: any) => oParameterOption.PropertyName.value) || [];
|
|
290
|
+
selectOptions = selectOptions.concat(parameterOptions);
|
|
291
|
+
requiredPropertyPaths = requiredPropertyPaths.sort();
|
|
292
|
+
selectOptions = selectOptions.sort();
|
|
293
|
+
visualFilter.showOverlayInitially = requiredPropertyPaths.some(function(sPath) {
|
|
294
|
+
return selectOptions.indexOf(sPath) === -1;
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
} else {
|
|
298
|
+
visualFilter.showOverlayInitially = false;
|
|
299
|
+
}
|
|
300
|
+
} else {
|
|
301
|
+
visualFilter.showOverlayInitially = false;
|
|
302
|
+
}
|
|
303
|
+
const sDimensionType = chartAnnotation?.$target?.Dimensions[0]?.$target?.type;
|
|
304
|
+
if (
|
|
305
|
+
!(
|
|
306
|
+
sDimensionType === "Edm.DateTimeOffset" ||
|
|
307
|
+
sDimensionType === "Edm.Date" ||
|
|
308
|
+
sDimensionType === "Edm.TimeOfDay"
|
|
309
|
+
) &&
|
|
310
|
+
chartAnnotation.$target.ChartType === "UI.ChartType/Line"
|
|
311
|
+
) {
|
|
312
|
+
visualFilter.renderLineChart = false;
|
|
313
|
+
} else {
|
|
314
|
+
visualFilter.renderLineChart = true;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
} else {
|
|
318
|
+
converterContext
|
|
319
|
+
.getDiagnostics()
|
|
320
|
+
.addIssue(IssueCategory.Annotation, IssueSeverity.High, IssueType.MALFORMED_VISUALFILTERS.CHART);
|
|
321
|
+
}
|
|
322
|
+
} else {
|
|
323
|
+
converterContext
|
|
324
|
+
.getDiagnostics()
|
|
325
|
+
.addIssue(IssueCategory.Annotation, IssueSeverity.High, IssueType.MALFORMED_VISUALFILTERS.PRESENTATIONVARIANT);
|
|
326
|
+
}
|
|
327
|
+
} else {
|
|
328
|
+
converterContext
|
|
329
|
+
.getDiagnostics()
|
|
330
|
+
.addIssue(IssueCategory.Annotation, IssueSeverity.High, IssueType.MALFORMED_VISUALFILTERS.VALUELIST);
|
|
331
|
+
}
|
|
332
|
+
} else {
|
|
333
|
+
converterContext.getDiagnostics().addIssue(IssueCategory.Manifest, IssueSeverity.High, IssueType.MALFORMED_VISUALFILTERS.VALUELIST);
|
|
334
|
+
}
|
|
335
|
+
if (Object.keys(visualFilter).length > 1) {
|
|
336
|
+
return visualFilter;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* SAP UI development toolkit for HTML5 (SAPUI5)
|
|
3
|
+
* (c) Copyright 2009-2021 SAP SE. All rights reserved
|
|
4
|
+
*/
|
|
5
|
+
sap.ui.define(["sap/fe/core/helpers/BindingExpression"], function (BindingExpression) {
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
var _exports = {};
|
|
9
|
+
var compileBinding = BindingExpression.compileBinding;
|
|
10
|
+
var annotationExpression = BindingExpression.annotationExpression;
|
|
11
|
+
|
|
12
|
+
var AvatarShape;
|
|
13
|
+
|
|
14
|
+
(function (AvatarShape) {
|
|
15
|
+
AvatarShape["Circle"] = "Circle";
|
|
16
|
+
AvatarShape["Square"] = "Square";
|
|
17
|
+
})(AvatarShape || (AvatarShape = {}));
|
|
18
|
+
|
|
19
|
+
var isNaturalPerson = function (converterContext) {
|
|
20
|
+
var _converterContext$get, _converterContext$get2;
|
|
21
|
+
|
|
22
|
+
return ((_converterContext$get = converterContext.getEntityType().annotations.Common) === null || _converterContext$get === void 0 ? void 0 : (_converterContext$get2 = _converterContext$get.IsNaturalPerson) === null || _converterContext$get2 === void 0 ? void 0 : _converterContext$get2.valueOf()) === true;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
var getFallBackIcon = function (converterContext) {
|
|
26
|
+
var _converterContext$get3, _converterContext$get4;
|
|
27
|
+
|
|
28
|
+
var headerInfo = (_converterContext$get3 = converterContext.getEntityType().annotations) === null || _converterContext$get3 === void 0 ? void 0 : (_converterContext$get4 = _converterContext$get3.UI) === null || _converterContext$get4 === void 0 ? void 0 : _converterContext$get4.HeaderInfo;
|
|
29
|
+
|
|
30
|
+
if (!headerInfo || headerInfo && !headerInfo.ImageUrl && !headerInfo.TypeImageUrl) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (headerInfo.ImageUrl && headerInfo.TypeImageUrl) {
|
|
35
|
+
return compileBinding(annotationExpression(headerInfo.TypeImageUrl));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return compileBinding(isNaturalPerson(converterContext) ? "sap-icon://person-placeholder" : "sap-icon://product");
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
var getSource = function (converterContext) {
|
|
42
|
+
var _converterContext$get5, _converterContext$get6;
|
|
43
|
+
|
|
44
|
+
var headerInfo = (_converterContext$get5 = converterContext.getEntityType().annotations) === null || _converterContext$get5 === void 0 ? void 0 : (_converterContext$get6 = _converterContext$get5.UI) === null || _converterContext$get6 === void 0 ? void 0 : _converterContext$get6.HeaderInfo;
|
|
45
|
+
|
|
46
|
+
if (!headerInfo || !(headerInfo.ImageUrl || headerInfo.TypeImageUrl)) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return compileBinding(annotationExpression(headerInfo.ImageUrl || headerInfo.TypeImageUrl));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
var getAvatar = function (converterContext) {
|
|
54
|
+
var _converterContext$get7, _converterContext$get8;
|
|
55
|
+
|
|
56
|
+
var headerInfo = (_converterContext$get7 = converterContext.getEntityType().annotations) === null || _converterContext$get7 === void 0 ? void 0 : (_converterContext$get8 = _converterContext$get7.UI) === null || _converterContext$get8 === void 0 ? void 0 : _converterContext$get8.HeaderInfo;
|
|
57
|
+
var oSource = headerInfo && (headerInfo.ImageUrl || headerInfo.TypeImageUrl || headerInfo.Initials);
|
|
58
|
+
|
|
59
|
+
if (!oSource) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
src: getSource(converterContext),
|
|
65
|
+
initials: compileBinding(annotationExpression((headerInfo === null || headerInfo === void 0 ? void 0 : headerInfo.Initials) || "")),
|
|
66
|
+
fallbackIcon: getFallBackIcon(converterContext),
|
|
67
|
+
displayShape: compileBinding(isNaturalPerson(converterContext) ? AvatarShape.Circle : AvatarShape.Square)
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
_exports.getAvatar = getAvatar;
|
|
72
|
+
return _exports;
|
|
73
|
+
}, false);
|
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RlckluZm8uSW1hZ2VVcmwgfHwgaGVhZGVySW5mby5UeXBlSW1hZ2VVcmwgfHwgaGVhZGVySW5mby5Jbml0aWFscyk7XG5cdGlmICghb1NvdXJjZSkge1xuXHRcdHJldHVybiB1bmRlZmluZWQ7XG5cdH1cblx0cmV0dXJuIHtcblx0XHRzcmM6IGdldFNvdXJjZShjb252ZXJ0ZXJDb250ZXh0KSxcblx0XHRpbml0aWFsczogY29tcGlsZUJpbmRpbmcoYW5ub3RhdGlvbkV4cHJlc3Npb24oaGVhZGVySW5mbz8uSW5pdGlhbHMgfHwgXCJcIikpLFxuXHRcdGZhbGxiYWNrSWNvbjogZ2V0RmFsbEJhY2tJY29uKGNvbnZlcnRlckNvbnRleHQpLFxuXHRcdGRpc3BsYXlTaGFwZTogY29tcGlsZUJpbmRpbmcoaXNOYXR1cmFsUGVyc29uKGNvbnZlcnRlckNvbnRleHQpID8gQXZhdGFyU2hhcGUuQ2lyY2xlIDogQXZhdGFyU2hhcGUuU3F1YXJlKVxuXHR9O1xufTtcbiJdfQ==
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import ConverterContext from "../../ConverterContext";
|
|
2
|
+
import { annotationExpression, BindingExpression, compileBinding } from "sap/fe/core/helpers/BindingExpression";
|
|
3
|
+
enum AvatarShape {
|
|
4
|
+
Circle = "Circle",
|
|
5
|
+
Square = "Square"
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type Avatar = {
|
|
9
|
+
src?: BindingExpression<string>;
|
|
10
|
+
initials: BindingExpression<string>;
|
|
11
|
+
fallbackIcon?: BindingExpression<string>;
|
|
12
|
+
displayShape: BindingExpression<string>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const isNaturalPerson = (converterContext: ConverterContext): Boolean => {
|
|
16
|
+
return converterContext.getEntityType().annotations.Common?.IsNaturalPerson?.valueOf() === true;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const getFallBackIcon = (converterContext: ConverterContext): BindingExpression<string> | undefined => {
|
|
20
|
+
const headerInfo = converterContext.getEntityType().annotations?.UI?.HeaderInfo;
|
|
21
|
+
if (!headerInfo || (headerInfo && !headerInfo.ImageUrl && !headerInfo.TypeImageUrl)) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
if (headerInfo.ImageUrl && headerInfo.TypeImageUrl) {
|
|
25
|
+
return compileBinding(annotationExpression(headerInfo.TypeImageUrl));
|
|
26
|
+
}
|
|
27
|
+
return compileBinding(isNaturalPerson(converterContext) ? "sap-icon://person-placeholder" : "sap-icon://product");
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const getSource = (converterContext: ConverterContext): BindingExpression<string> | undefined => {
|
|
31
|
+
const headerInfo = converterContext.getEntityType().annotations?.UI?.HeaderInfo;
|
|
32
|
+
if (!headerInfo || !(headerInfo.ImageUrl || headerInfo.TypeImageUrl)) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
return compileBinding(annotationExpression(headerInfo.ImageUrl || headerInfo.TypeImageUrl));
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const getAvatar = (converterContext: ConverterContext): Avatar | undefined => {
|
|
39
|
+
const headerInfo = converterContext.getEntityType().annotations?.UI?.HeaderInfo;
|
|
40
|
+
const oSource: any = headerInfo && (headerInfo.ImageUrl || headerInfo.TypeImageUrl || headerInfo.Initials);
|
|
41
|
+
if (!oSource) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
src: getSource(converterContext),
|
|
46
|
+
initials: compileBinding(annotationExpression(headerInfo?.Initials || "")),
|
|
47
|
+
fallbackIcon: getFallBackIcon(converterContext),
|
|
48
|
+
displayShape: compileBinding(isNaturalPerson(converterContext) ? AvatarShape.Circle : AvatarShape.Square)
|
|
49
|
+
};
|
|
50
|
+
};
|