@sapui5/sap.fe.core 1.136.1 → 1.138.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/core/.library +1 -1
- package/src/sap/fe/core/ActionRuntime.js +76 -28
- package/src/sap/fe/core/ActionRuntime.ts +106 -30
- package/src/sap/fe/core/AppComponent.js +11 -1
- package/src/sap/fe/core/AppComponent.ts +10 -0
- package/src/sap/fe/core/AppStateHandler.js +9 -2
- package/src/sap/fe/core/AppStateHandler.ts +8 -2
- package/src/sap/fe/core/CommonUtils.js +15 -3
- package/src/sap/fe/core/CommonUtils.ts +13 -2
- package/src/sap/fe/core/PageController.controller.js +10 -0
- package/src/sap/fe/core/PageController.controller.ts +3 -0
- package/src/sap/fe/core/buildingBlocks/TraceInfo.js +3 -4
- package/src/sap/fe/core/buildingBlocks/TraceInfo.ts +2 -2
- package/src/sap/fe/core/buildingBlocks/templating/BuildingBlockTemplateProcessor.js +3 -3
- package/src/sap/fe/core/buildingBlocks/templating/BuildingBlockTemplateProcessor.ts +2 -2
- package/src/sap/fe/core/controllerextensions/EditFlow.js +25 -12
- package/src/sap/fe/core/controllerextensions/EditFlow.ts +27 -16
- package/src/sap/fe/core/controllerextensions/InlineEditFlow.js +27 -41
- package/src/sap/fe/core/controllerextensions/InlineEditFlow.ts +27 -41
- package/src/sap/fe/core/controllerextensions/InternalIntentBasedNavigation.js +2 -1
- package/src/sap/fe/core/controllerextensions/InternalIntentBasedNavigation.ts +2 -1
- package/src/sap/fe/core/controllerextensions/InternalRouting.js +2 -1
- package/src/sap/fe/core/controllerextensions/InternalRouting.ts +1 -0
- package/src/sap/fe/core/controllerextensions/MessageHandler.js +4 -4
- package/src/sap/fe/core/controllerextensions/MessageHandler.ts +22 -15
- package/src/sap/fe/core/controllerextensions/Paginator.js +20 -5
- package/src/sap/fe/core/controllerextensions/Paginator.ts +19 -0
- package/src/sap/fe/core/controllerextensions/SideEffects.js +3 -2
- package/src/sap/fe/core/controllerextensions/SideEffects.ts +2 -2
- package/src/sap/fe/core/controllerextensions/collaboration/CollaborationCommon.js +2 -1
- package/src/sap/fe/core/controllerextensions/collaboration/CollaborationCommon.ts +1 -0
- package/src/sap/fe/core/controllerextensions/dialog/ODataStrictDialog.js +9 -5
- package/src/sap/fe/core/controllerextensions/dialog/ODataStrictDialog.tsx +8 -3
- package/src/sap/fe/core/controllerextensions/editFlow/NotApplicableContextDialog.js +4 -2
- package/src/sap/fe/core/controllerextensions/editFlow/NotApplicableContextDialog.tsx +7 -2
- package/src/sap/fe/core/controllerextensions/editFlow/TransactionHelper.js +178 -125
- package/src/sap/fe/core/controllerextensions/editFlow/TransactionHelper.ts +222 -174
- package/src/sap/fe/core/controllerextensions/editFlow/draft.js +5 -3
- package/src/sap/fe/core/controllerextensions/editFlow/draft.ts +2 -3
- package/src/sap/fe/core/controllerextensions/editFlow/operations/ODataOperation.js +39 -5
- package/src/sap/fe/core/controllerextensions/editFlow/operations/ODataOperation.ts +51 -11
- package/src/sap/fe/core/controllerextensions/editFlow/operations/ODataStrictHandling.js +16 -1
- package/src/sap/fe/core/controllerextensions/editFlow/operations/ODataStrictHandling.ts +17 -2
- package/src/sap/fe/core/controllerextensions/editFlow/operations/Operation.js +88 -1
- package/src/sap/fe/core/controllerextensions/editFlow/operations/Operation.ts +106 -7
- package/src/sap/fe/core/controllerextensions/editFlow/operations/OperationMessage.js +16 -1
- package/src/sap/fe/core/controllerextensions/editFlow/operations/OperationMessage.ts +15 -0
- package/src/sap/fe/core/controllerextensions/editFlow/operations/OperationParameters.js +25 -1
- package/src/sap/fe/core/controllerextensions/editFlow/operations/OperationParameters.ts +24 -0
- package/src/sap/fe/core/controllerextensions/messageHandler/messageHandling.js +11 -8
- package/src/sap/fe/core/controllerextensions/messageHandler/messageHandling.ts +13 -10
- package/src/sap/fe/core/controllerextensions/routing/RouterProxy.js +7 -4
- package/src/sap/fe/core/controllerextensions/routing/RouterProxy.ts +7 -3
- package/src/sap/fe/core/controls/DataWatcher.js +2 -2
- package/src/sap/fe/core/controls/DataWatcher.tsx +1 -1
- package/src/sap/fe/core/controls/Recommendations/ConfirmRecommendationDialog.js +11 -6
- package/src/sap/fe/core/controls/Recommendations/ConfirmRecommendationDialog.tsx +13 -9
- package/src/sap/fe/core/controls/inlineEditFlow/InlineEditExitDialog.js +144 -0
- package/src/sap/fe/core/controls/inlineEditFlow/{BeforeNavigationDialog.tsx → InlineEditExitDialog.tsx} +1 -1
- package/src/sap/fe/core/converters/ManifestSettings.js +1 -1
- package/src/sap/fe/core/converters/ManifestSettings.ts +4 -0
- package/src/sap/fe/core/converters/MetaModelConverter.js +3 -2
- package/src/sap/fe/core/converters/MetaModelConverter.ts +12 -4
- package/src/sap/fe/core/converters/controls/Common/Action.js +42 -5
- package/src/sap/fe/core/converters/controls/Common/Action.ts +42 -5
- package/src/sap/fe/core/converters/controls/Common/Chart.js +4 -1
- package/src/sap/fe/core/converters/controls/Common/Chart.ts +2 -1
- package/src/sap/fe/core/converters/controls/Common/Table.js +46 -13
- package/src/sap/fe/core/converters/controls/Common/Table.ts +50 -11
- package/src/sap/fe/core/converters/controls/Common/table/Columns.js +11 -10
- package/src/sap/fe/core/converters/controls/Common/table/Columns.ts +13 -1
- package/src/sap/fe/core/converters/controls/ObjectPage/SubSection.js +2 -2
- package/src/sap/fe/core/converters/controls/ObjectPage/SubSection.ts +2 -1
- package/src/sap/fe/core/fpm/manifest.json +1 -1
- package/src/sap/fe/core/helpers/DeleteHelper.js +9 -9
- package/src/sap/fe/core/helpers/DeleteHelper.ts +8 -9
- package/src/sap/fe/core/helpers/FPMHelper.js +2 -2
- package/src/sap/fe/core/helpers/FPMHelper.ts +1 -1
- package/src/sap/fe/core/helpers/ModelHelper.js +4 -4
- package/src/sap/fe/core/helpers/ModelHelper.ts +8 -4
- package/src/sap/fe/core/helpers/PasteHelper.js +2 -2
- package/src/sap/fe/core/helpers/PasteHelper.ts +1 -1
- package/src/sap/fe/core/library.js +33 -4
- package/src/sap/fe/core/library.ts +33 -2
- package/src/sap/fe/core/messagebundle.properties +18 -2
- package/src/sap/fe/core/messagebundle_ar.properties +3 -2
- package/src/sap/fe/core/messagebundle_bg.properties +2 -1
- package/src/sap/fe/core/messagebundle_ca.properties +2 -1
- package/src/sap/fe/core/messagebundle_cnr.properties +2 -1
- package/src/sap/fe/core/messagebundle_cs.properties +4 -3
- package/src/sap/fe/core/messagebundle_cy.properties +2 -1
- package/src/sap/fe/core/messagebundle_da.properties +2 -1
- package/src/sap/fe/core/messagebundle_de.properties +8 -7
- package/src/sap/fe/core/messagebundle_el.properties +2 -1
- package/src/sap/fe/core/messagebundle_en.properties +2 -1
- package/src/sap/fe/core/messagebundle_en_GB.properties +2 -1
- package/src/sap/fe/core/messagebundle_en_US_saprigi.properties +2 -1
- package/src/sap/fe/core/messagebundle_es.properties +5 -4
- package/src/sap/fe/core/messagebundle_es_MX.properties +2 -1
- package/src/sap/fe/core/messagebundle_et.properties +2 -1
- package/src/sap/fe/core/messagebundle_fi.properties +2 -1
- package/src/sap/fe/core/messagebundle_fr.properties +2 -1
- package/src/sap/fe/core/messagebundle_fr_CA.properties +2 -1
- package/src/sap/fe/core/messagebundle_hi.properties +2 -1
- package/src/sap/fe/core/messagebundle_hr.properties +2 -1
- package/src/sap/fe/core/messagebundle_hu.properties +2 -1
- package/src/sap/fe/core/messagebundle_id.properties +2 -1
- package/src/sap/fe/core/messagebundle_it.properties +2 -1
- package/src/sap/fe/core/messagebundle_iw.properties +2 -1
- package/src/sap/fe/core/messagebundle_ja.properties +3 -2
- package/src/sap/fe/core/messagebundle_kk.properties +2 -1
- package/src/sap/fe/core/messagebundle_ko.properties +2 -1
- package/src/sap/fe/core/messagebundle_lt.properties +2 -1
- package/src/sap/fe/core/messagebundle_lv.properties +2 -1
- package/src/sap/fe/core/messagebundle_mk.properties +2 -1
- package/src/sap/fe/core/messagebundle_ms.properties +2 -1
- package/src/sap/fe/core/messagebundle_nl.properties +2 -1
- package/src/sap/fe/core/messagebundle_no.properties +3 -2
- package/src/sap/fe/core/messagebundle_pl.properties +2 -1
- package/src/sap/fe/core/messagebundle_pt.properties +2 -1
- package/src/sap/fe/core/messagebundle_pt_PT.properties +2 -1
- package/src/sap/fe/core/messagebundle_ro.properties +2 -1
- package/src/sap/fe/core/messagebundle_ru.properties +2 -1
- package/src/sap/fe/core/messagebundle_sh.properties +2 -1
- package/src/sap/fe/core/messagebundle_sk.properties +2 -1
- package/src/sap/fe/core/messagebundle_sl.properties +2 -1
- package/src/sap/fe/core/messagebundle_sr.properties +2 -1
- package/src/sap/fe/core/messagebundle_sv.properties +2 -1
- package/src/sap/fe/core/messagebundle_th.properties +2 -1
- package/src/sap/fe/core/messagebundle_tr.properties +2 -1
- package/src/sap/fe/core/messagebundle_uk.properties +2 -1
- package/src/sap/fe/core/messagebundle_vi.properties +2 -1
- package/src/sap/fe/core/messagebundle_zh_CN.properties +2 -1
- package/src/sap/fe/core/messagebundle_zh_TW.properties +2 -1
- package/src/sap/fe/core/rootView/RootViewBaseController.js +6 -6
- package/src/sap/fe/core/rootView/RootViewBaseController.ts +5 -5
- package/src/sap/fe/core/services/RoutingServiceFactory.js +3 -3
- package/src/sap/fe/core/services/RoutingServiceFactory.ts +2 -2
- package/src/sap/fe/core/services/SideEffectsServiceFactory.js +4 -1
- package/src/sap/fe/core/services/SideEffectsServiceFactory.ts +3 -0
- package/src/sap/fe/core/services/collaborativeDraftServiceFactory.js +8 -2
- package/src/sap/fe/core/services/collaborativeDraftServiceFactory.ts +7 -1
- package/src/sap/fe/core/templating/EntitySetHelper.js +75 -90
- package/src/sap/fe/core/templating/EntitySetHelper.ts +92 -118
- package/src/sap/fe/core/templating/UIFormatters.js +3 -3
- package/src/sap/fe/core/templating/UIFormatters.ts +1 -2
- package/src/sap/fe/core/controllerextensions/editFlow/operations/facade.js +0 -81
- package/src/sap/fe/core/controllerextensions/editFlow/operations/facade.ts +0 -126
- package/src/sap/fe/core/controllerextensions/editFlow/operations.js +0 -10
- package/src/sap/fe/core/controllerextensions/editFlow/operations.ts +0 -2
- package/src/sap/fe/core/controls/inlineEditFlow/BeforeActionDialog.js +0 -68
- package/src/sap/fe/core/controls/inlineEditFlow/BeforeActionDialog.tsx +0 -52
- package/src/sap/fe/core/controls/inlineEditFlow/BeforeNavigationDialog.js +0 -144
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { EntitySet } from "@sap-ux/vocabularies-types";
|
|
1
|
+
import type { EntitySet, NavigationProperty, PropertyPath } from "@sap-ux/vocabularies-types";
|
|
2
|
+
import type { NavigationPropertyRestriction } from "@sap-ux/vocabularies-types/vocabularies/Capabilities";
|
|
2
3
|
import type ConverterContext from "sap/fe/core/converters/ConverterContext";
|
|
3
4
|
import { isEntitySet } from "sap/fe/core/helpers/TypeGuards";
|
|
4
5
|
import { getTargetEntitySetInfo } from "./DataModelPathHelper";
|
|
@@ -10,17 +11,13 @@ export type RestrictionsOnProperties = {
|
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Reads all FilterRestrictions and SortRestrictions of the main and child entities and their dedicated navigation restrictions.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
2.2.1 Retrieve the direct restrictions configured on the child entity displayed in the table or on the root entity.
|
|
21
|
-
2.2.2 If a navigation property restriction is defined on the main entity, it takes precedence over the direct restrictions from 2.2.1.
|
|
22
|
-
2.2.3 NavigationRestrictions on the target (child) entity set are added to the list of restrictions.
|
|
23
|
-
* @param entitySet Entity set to be analyzed
|
|
14
|
+
1. For containment scenario:
|
|
15
|
+
1.1. For LR, Navigation restrictions are evaluated first, followed by the restrictions on the root entity. If Navigation property restriction and a direct restriction exist, both are considered.
|
|
16
|
+
1.2 For the OP, Restrictions are only calculated on the root entity, as there are no child entities. The same approach described in point 1.1 is applied.
|
|
17
|
+
2. For a non containment scenario:
|
|
18
|
+
2.1 The same logic described in point 1.1 applies.
|
|
19
|
+
2.2 For the OP, the direct restrictions configured for the OP are considered along with the navigation restrictions on the target (child) entity displayed.
|
|
20
|
+
* @param entitySet Entity set to be analyzed (target or parent entity set).
|
|
24
21
|
* @param targetEntitySet The target entity set, if available. Not used in the case of containment.
|
|
25
22
|
* @param parentNavigationPath The parent navigation path, specific for containment scenario to get the correct property based on the parent navigation path.
|
|
26
23
|
* @returns Array containing the property names of all non-filterable and non-sortable properties
|
|
@@ -34,39 +31,23 @@ const getPropertiesRestrictionsBasedOnEntities = function (
|
|
|
34
31
|
nonSortableProperties: getSortRestrictionsfromNavigationRestrictions(entitySet, targetEntitySet, parentNavigationPath),
|
|
35
32
|
nonFilterableProperties: getFilterRestrictionsfromNavigationRestrictions(entitySet, targetEntitySet, parentNavigationPath)
|
|
36
33
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
if (!restrictionsFromNavigationRestrictions.nonSortableProperties.length) {
|
|
51
|
-
restrictionsFromNavigationRestrictions.nonSortableProperties = getDirectSortRestrictionsRecursively(
|
|
52
|
-
entitySet,
|
|
53
|
-
targetEntitySet,
|
|
54
|
-
parentNavigationPath
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
if (!restrictionsFromNavigationRestrictions.nonFilterableProperties.length) {
|
|
58
|
-
restrictionsFromNavigationRestrictions.nonFilterableProperties = getDirectFilterRestrictionsRecursively(
|
|
59
|
-
entitySet,
|
|
60
|
-
targetEntitySet,
|
|
61
|
-
parentNavigationPath
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
return restrictionsFromNavigationRestrictions;
|
|
34
|
+
const directRestrictions = {
|
|
35
|
+
nonSortableProperties: getDirectSortRestrictions(entitySet, targetEntitySet, parentNavigationPath),
|
|
36
|
+
nonFilterableProperties: getDirectFilterRestrictions(entitySet, targetEntitySet, parentNavigationPath)
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
nonSortableProperties: Array.from(
|
|
40
|
+
new Set([...restrictionsFromNavigationRestrictions.nonSortableProperties, ...directRestrictions.nonSortableProperties])
|
|
41
|
+
),
|
|
42
|
+
nonFilterableProperties: Array.from(
|
|
43
|
+
new Set([...restrictionsFromNavigationRestrictions.nonFilterableProperties, ...directRestrictions.nonFilterableProperties])
|
|
44
|
+
)
|
|
45
|
+
};
|
|
65
46
|
};
|
|
66
47
|
|
|
67
48
|
/**
|
|
68
49
|
* Gets all SortRestrictions and FilterRestrictions for a given context.
|
|
69
|
-
* This function verifies whether we are in a containment scenario.
|
|
50
|
+
* This function verifies whether we are in a containment scenario.
|
|
70
51
|
* @param converterContext The converter context.
|
|
71
52
|
* @returns Object containing all property names of restrictions separated by sortable and filterable capabilities.
|
|
72
53
|
*/
|
|
@@ -76,24 +57,9 @@ export const getRestrictionsOnProperties = function (converterContext: Converter
|
|
|
76
57
|
const { parentEntitySet, targetEntitySet, parentNavigationPath } = getTargetEntitySetInfo(dataModelObjectPath);
|
|
77
58
|
if (isEntitySet(targetEntitySet)) {
|
|
78
59
|
// Get the restrictions on the target navigation entity set
|
|
79
|
-
|
|
80
|
-
if (parentEntitySet && isEntitySet(parentEntitySet)) {
|
|
81
|
-
// Get the restrictions from the NavigationRestrictions / Restrictions on the parent entity set
|
|
82
|
-
// It's takes precedence over the restrictions on the target entity set
|
|
83
|
-
const parentPropertiesRestrictions = getPropertiesRestrictionsBasedOnEntities(
|
|
84
|
-
parentEntitySet,
|
|
85
|
-
targetEntitySet,
|
|
86
|
-
parentNavigationPath
|
|
87
|
-
);
|
|
88
|
-
if (parentPropertiesRestrictions.nonSortableProperties.length) {
|
|
89
|
-
propertiesRestrictions.nonSortableProperties = parentPropertiesRestrictions.nonSortableProperties;
|
|
90
|
-
}
|
|
91
|
-
if (parentPropertiesRestrictions.nonFilterableProperties.length) {
|
|
92
|
-
propertiesRestrictions.nonFilterableProperties = parentPropertiesRestrictions.nonFilterableProperties;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
60
|
+
return getPropertiesRestrictionsBasedOnEntities(targetEntitySet);
|
|
95
61
|
} else if (parentEntitySet && isEntitySet(parentEntitySet)) {
|
|
96
|
-
// Find the restrictions on the parent entity set, this applies
|
|
62
|
+
// Find the restrictions on the parent entity set, this applies for containment as there isn't an entity set available on the OP
|
|
97
63
|
return getPropertiesRestrictionsBasedOnEntities(parentEntitySet, undefined, parentNavigationPath);
|
|
98
64
|
}
|
|
99
65
|
return propertiesRestrictions;
|
|
@@ -122,25 +88,13 @@ function getSortRestrictionsfromNavigationRestrictions(
|
|
|
122
88
|
const navigationProperty = navigationRestriction.NavigationProperty.$target;
|
|
123
89
|
if (navigationProperty) {
|
|
124
90
|
// add all properties of the navigation property to the nonSortableProperties
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
);
|
|
129
|
-
} else {
|
|
130
|
-
sortRestrictionsFromNavigationRestrictions.push(
|
|
131
|
-
...navigationProperty.targetType.entityProperties.map((property) => `${navigationProperty.name}/${property.name}`)
|
|
132
|
-
);
|
|
133
|
-
}
|
|
91
|
+
sortRestrictionsFromNavigationRestrictions.push(
|
|
92
|
+
...getAllPropertiesOfNavigationProperty(navigationProperty, navigationRestriction, parentNavigationPath)
|
|
93
|
+
);
|
|
134
94
|
}
|
|
135
95
|
} else {
|
|
136
96
|
const nonSortableNavigationProperties = navigationRestriction?.SortRestrictions?.NonSortableProperties?.map((property) => {
|
|
137
|
-
|
|
138
|
-
if ((targetEntitySet || parentNavigationPath) && property.$target?.name) {
|
|
139
|
-
return property.$target?.name;
|
|
140
|
-
} else {
|
|
141
|
-
// leave the property path unchanged (it is relative to the annotation target!)
|
|
142
|
-
return property.value;
|
|
143
|
-
}
|
|
97
|
+
return getRestrictedPropertyRelativePath(property, targetEntitySet, parentNavigationPath);
|
|
144
98
|
});
|
|
145
99
|
if (nonSortableNavigationProperties?.length) {
|
|
146
100
|
sortRestrictionsFromNavigationRestrictions.push(...nonSortableNavigationProperties);
|
|
@@ -157,12 +111,8 @@ function getSortRestrictionsfromNavigationRestrictions(
|
|
|
157
111
|
* @param parentNavigationPath The parent navigation path, specific for containment scenario to get the correct property based on the parent navigation path.
|
|
158
112
|
* @returns Array containing the property names of all non-sortable properties.
|
|
159
113
|
*/
|
|
160
|
-
function
|
|
114
|
+
function getDirectSortRestrictions(entitySet: EntitySet, targetEntitySet?: EntitySet, parentNavigationPath?: string): string[] {
|
|
161
115
|
const sortRestrictionsOnEntitySet: string[] = [];
|
|
162
|
-
if (targetEntitySet) {
|
|
163
|
-
// if the targetEntitySet from a navigation is available, get the direct restriction on the targetEntitySet (child entity set)
|
|
164
|
-
return getDirectSortRestrictionsRecursively(targetEntitySet, undefined, parentNavigationPath);
|
|
165
|
-
}
|
|
166
116
|
if (entitySet.annotations.Capabilities?.SortRestrictions?.Sortable === false) {
|
|
167
117
|
// add all properties of the entity set to the nonSortableProperties
|
|
168
118
|
sortRestrictionsOnEntitySet.push(...entitySet.entityType.entityProperties.map((property) => property.name));
|
|
@@ -173,11 +123,7 @@ function getDirectSortRestrictionsRecursively(entitySet: EntitySet, targetEntity
|
|
|
173
123
|
// skip the non sortable property if it doesn't belong to the parent navigation path in case of containment
|
|
174
124
|
return;
|
|
175
125
|
}
|
|
176
|
-
|
|
177
|
-
nonSortableProperties.push(property.$target?.name);
|
|
178
|
-
} else {
|
|
179
|
-
nonSortableProperties.push(property.value);
|
|
180
|
-
}
|
|
126
|
+
nonSortableProperties.push(getRestrictedPropertyRelativePath(property, targetEntitySet, parentNavigationPath));
|
|
181
127
|
});
|
|
182
128
|
if (nonSortableProperties?.length) {
|
|
183
129
|
sortRestrictionsOnEntitySet.push(...nonSortableProperties);
|
|
@@ -200,8 +146,9 @@ function getFilterRestrictionsfromNavigationRestrictions(
|
|
|
200
146
|
): string[] {
|
|
201
147
|
const filterRestrictionsFromNavigationRestrictions: string[] = [];
|
|
202
148
|
entitySet.annotations.Capabilities?.NavigationRestrictions?.RestrictedProperties?.forEach((navigationRestriction) => {
|
|
203
|
-
//
|
|
204
|
-
if
|
|
149
|
+
// Get the filter restrictions of the related navigation path
|
|
150
|
+
// The navigationRestriction is also relevant if it contains the parent navigation path
|
|
151
|
+
if (parentNavigationPath && !navigationRestriction?.NavigationProperty?.value.includes(parentNavigationPath)) {
|
|
205
152
|
return;
|
|
206
153
|
}
|
|
207
154
|
if (navigationRestriction?.FilterRestrictions?.Filterable === false) {
|
|
@@ -209,26 +156,14 @@ function getFilterRestrictionsfromNavigationRestrictions(
|
|
|
209
156
|
const navigationProperty = navigationRestriction.NavigationProperty.$target;
|
|
210
157
|
if (navigationProperty) {
|
|
211
158
|
// add all properties of the navigation property to the nonFilterableProperties
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
);
|
|
216
|
-
} else {
|
|
217
|
-
filterRestrictionsFromNavigationRestrictions.push(
|
|
218
|
-
...navigationProperty.targetType.entityProperties.map((property) => `${navigationProperty.name}/${property.name}`)
|
|
219
|
-
);
|
|
220
|
-
}
|
|
159
|
+
filterRestrictionsFromNavigationRestrictions.push(
|
|
160
|
+
...getAllPropertiesOfNavigationProperty(navigationProperty, navigationRestriction, parentNavigationPath)
|
|
161
|
+
);
|
|
221
162
|
}
|
|
222
163
|
} else {
|
|
223
164
|
const nonFilterableNavigationProperties = navigationRestriction?.FilterRestrictions?.NonFilterableProperties?.map(
|
|
224
165
|
(property) => {
|
|
225
|
-
|
|
226
|
-
if ((targetEntitySet || parentNavigationPath) && property.$target?.name) {
|
|
227
|
-
return property.$target?.name;
|
|
228
|
-
} else {
|
|
229
|
-
// leave the property path unchanged (it is relative to the annotation target!)
|
|
230
|
-
return property.value;
|
|
231
|
-
}
|
|
166
|
+
return getRestrictedPropertyRelativePath(property, targetEntitySet, parentNavigationPath);
|
|
232
167
|
}
|
|
233
168
|
);
|
|
234
169
|
if (nonFilterableNavigationProperties?.length) {
|
|
@@ -239,6 +174,57 @@ function getFilterRestrictionsfromNavigationRestrictions(
|
|
|
239
174
|
return filterRestrictionsFromNavigationRestrictions;
|
|
240
175
|
}
|
|
241
176
|
|
|
177
|
+
/**
|
|
178
|
+
* Gets all properties of a navigation property based on the navigation restriction and parent navigation path.
|
|
179
|
+
* @param navigationProperty The navigation property to be analyzed.
|
|
180
|
+
* @param navigationRestriction The navigation restriction to be applied.
|
|
181
|
+
* @param parentNavigationPath The parent navigation path, specific for containment scenario to get the correct property based on the parent navigation path.
|
|
182
|
+
* @returns The array of property names of the navigation property.
|
|
183
|
+
*/
|
|
184
|
+
function getAllPropertiesOfNavigationProperty(
|
|
185
|
+
navigationProperty: NavigationProperty,
|
|
186
|
+
navigationRestriction?: NavigationPropertyRestriction,
|
|
187
|
+
parentNavigationPath?: string
|
|
188
|
+
): string[] {
|
|
189
|
+
if (parentNavigationPath) {
|
|
190
|
+
// for containment scenario only
|
|
191
|
+
if (navigationRestriction?.NavigationProperty?.value !== navigationProperty.name) {
|
|
192
|
+
// in case the target entity set is a child entity set (OP), we need to get the properties based on OP target entity set
|
|
193
|
+
const navigationPathBasedOnParent = navigationRestriction?.NavigationProperty?.value.replace(`${parentNavigationPath}/`, "");
|
|
194
|
+
return navigationProperty.targetType.entityProperties.map((property) => `${navigationPathBasedOnParent}/${property.name}`);
|
|
195
|
+
} else {
|
|
196
|
+
return navigationProperty.targetType.entityProperties.map((property) => property.name);
|
|
197
|
+
}
|
|
198
|
+
} else {
|
|
199
|
+
return navigationProperty.targetType.entityProperties.map((property) => `${navigationProperty.name}/${property.name}`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Gets the relative path of the property restricted based on the target entity set and parent navigation path.
|
|
205
|
+
* @param property The property to be analyzed.
|
|
206
|
+
* @param targetEntitySet The target entity set, if available. Not present in the case of containment.
|
|
207
|
+
* @param parentNavigationPath The parent navigation path, specific for containment scenario to get the correct property based on the parent navigation path.
|
|
208
|
+
* @returns The relative path of the restricted property.
|
|
209
|
+
*/
|
|
210
|
+
function getRestrictedPropertyRelativePath(
|
|
211
|
+
property: PropertyPath,
|
|
212
|
+
targetEntitySet: EntitySet | undefined,
|
|
213
|
+
parentNavigationPath?: string
|
|
214
|
+
): string {
|
|
215
|
+
if (parentNavigationPath && property.value.includes(parentNavigationPath)) {
|
|
216
|
+
// if the parentNavigationPath is available, we need to check if the property belongs to the parent navigation path
|
|
217
|
+
// we need to get the property path based on target entity for the child entity set (OP)
|
|
218
|
+
return property.value.replace(`${parentNavigationPath}/`, "");
|
|
219
|
+
} else if (targetEntitySet && property.$target?.name) {
|
|
220
|
+
// we need the property name from the navigation restriction definition when the targetEntitySet is available and it's not a containment scenario
|
|
221
|
+
return property.$target?.name;
|
|
222
|
+
} else {
|
|
223
|
+
// leave the property path unchanged (it is relative to the annotation target!)
|
|
224
|
+
return property.value;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
242
228
|
/**
|
|
243
229
|
* Gets the filter restrictions directly from the entity set.
|
|
244
230
|
* @param entitySet Entity set to be analyzed.
|
|
@@ -246,31 +232,19 @@ function getFilterRestrictionsfromNavigationRestrictions(
|
|
|
246
232
|
* @param parentNavigationPath The parent navigation path, specific for containment scenario to get the correct property based on the parent navigation path.
|
|
247
233
|
* @returns Array containing the property names of all non-filterable properties.
|
|
248
234
|
*/
|
|
249
|
-
function
|
|
250
|
-
entitySet: EntitySet,
|
|
251
|
-
targetEntitySet?: EntitySet,
|
|
252
|
-
parentNavigationPath?: string
|
|
253
|
-
): string[] {
|
|
235
|
+
function getDirectFilterRestrictions(entitySet: EntitySet, targetEntitySet?: EntitySet, parentNavigationPath?: string): string[] {
|
|
254
236
|
const filterRestrictionsOnEntitySet: string[] = [];
|
|
255
|
-
if (targetEntitySet && parentNavigationPath) {
|
|
256
|
-
// if the targetEntitySet from a navigation is available, get the direct restriction on the targetEntitySet (child entity set)
|
|
257
|
-
return getDirectFilterRestrictionsRecursively(targetEntitySet, undefined, parentNavigationPath);
|
|
258
|
-
}
|
|
259
237
|
if (entitySet.annotations.Capabilities?.FilterRestrictions?.Filterable === false) {
|
|
260
238
|
// add all properties of the entity set to the nonFilterableProperties
|
|
261
239
|
filterRestrictionsOnEntitySet.push(...entitySet.entityType.entityProperties.map((property) => property.name));
|
|
262
240
|
} else {
|
|
263
241
|
const nonFilterableProperties: string[] = [];
|
|
264
|
-
entitySet.annotations.Capabilities?.FilterRestrictions?.NonFilterableProperties?.forEach((
|
|
265
|
-
if (parentNavigationPath && !
|
|
242
|
+
entitySet.annotations.Capabilities?.FilterRestrictions?.NonFilterableProperties?.forEach((propertyPath) => {
|
|
243
|
+
if (parentNavigationPath && !propertyPath.value.includes(parentNavigationPath)) {
|
|
266
244
|
// skip the non filterable property if it doesn't belong to the parent navigation path in case of containment
|
|
267
245
|
return;
|
|
268
246
|
}
|
|
269
|
-
|
|
270
|
-
nonFilterableProperties.push(property.$target?.name);
|
|
271
|
-
} else {
|
|
272
|
-
nonFilterableProperties.push(property.value);
|
|
273
|
-
}
|
|
247
|
+
nonFilterableProperties.push(getRestrictedPropertyRelativePath(propertyPath, targetEntitySet, parentNavigationPath));
|
|
274
248
|
});
|
|
275
249
|
if (nonFilterableProperties?.length) {
|
|
276
250
|
filterRestrictionsOnEntitySet.push(...nonFilterableProperties);
|