@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.
Files changed (154) hide show
  1. package/package.json +1 -1
  2. package/src/sap/fe/core/.library +1 -1
  3. package/src/sap/fe/core/ActionRuntime.js +76 -28
  4. package/src/sap/fe/core/ActionRuntime.ts +106 -30
  5. package/src/sap/fe/core/AppComponent.js +11 -1
  6. package/src/sap/fe/core/AppComponent.ts +10 -0
  7. package/src/sap/fe/core/AppStateHandler.js +9 -2
  8. package/src/sap/fe/core/AppStateHandler.ts +8 -2
  9. package/src/sap/fe/core/CommonUtils.js +15 -3
  10. package/src/sap/fe/core/CommonUtils.ts +13 -2
  11. package/src/sap/fe/core/PageController.controller.js +10 -0
  12. package/src/sap/fe/core/PageController.controller.ts +3 -0
  13. package/src/sap/fe/core/buildingBlocks/TraceInfo.js +3 -4
  14. package/src/sap/fe/core/buildingBlocks/TraceInfo.ts +2 -2
  15. package/src/sap/fe/core/buildingBlocks/templating/BuildingBlockTemplateProcessor.js +3 -3
  16. package/src/sap/fe/core/buildingBlocks/templating/BuildingBlockTemplateProcessor.ts +2 -2
  17. package/src/sap/fe/core/controllerextensions/EditFlow.js +25 -12
  18. package/src/sap/fe/core/controllerextensions/EditFlow.ts +27 -16
  19. package/src/sap/fe/core/controllerextensions/InlineEditFlow.js +27 -41
  20. package/src/sap/fe/core/controllerextensions/InlineEditFlow.ts +27 -41
  21. package/src/sap/fe/core/controllerextensions/InternalIntentBasedNavigation.js +2 -1
  22. package/src/sap/fe/core/controllerextensions/InternalIntentBasedNavigation.ts +2 -1
  23. package/src/sap/fe/core/controllerextensions/InternalRouting.js +2 -1
  24. package/src/sap/fe/core/controllerextensions/InternalRouting.ts +1 -0
  25. package/src/sap/fe/core/controllerextensions/MessageHandler.js +4 -4
  26. package/src/sap/fe/core/controllerextensions/MessageHandler.ts +22 -15
  27. package/src/sap/fe/core/controllerextensions/Paginator.js +20 -5
  28. package/src/sap/fe/core/controllerextensions/Paginator.ts +19 -0
  29. package/src/sap/fe/core/controllerextensions/SideEffects.js +3 -2
  30. package/src/sap/fe/core/controllerextensions/SideEffects.ts +2 -2
  31. package/src/sap/fe/core/controllerextensions/collaboration/CollaborationCommon.js +2 -1
  32. package/src/sap/fe/core/controllerextensions/collaboration/CollaborationCommon.ts +1 -0
  33. package/src/sap/fe/core/controllerextensions/dialog/ODataStrictDialog.js +9 -5
  34. package/src/sap/fe/core/controllerextensions/dialog/ODataStrictDialog.tsx +8 -3
  35. package/src/sap/fe/core/controllerextensions/editFlow/NotApplicableContextDialog.js +4 -2
  36. package/src/sap/fe/core/controllerextensions/editFlow/NotApplicableContextDialog.tsx +7 -2
  37. package/src/sap/fe/core/controllerextensions/editFlow/TransactionHelper.js +178 -125
  38. package/src/sap/fe/core/controllerextensions/editFlow/TransactionHelper.ts +222 -174
  39. package/src/sap/fe/core/controllerextensions/editFlow/draft.js +5 -3
  40. package/src/sap/fe/core/controllerextensions/editFlow/draft.ts +2 -3
  41. package/src/sap/fe/core/controllerextensions/editFlow/operations/ODataOperation.js +39 -5
  42. package/src/sap/fe/core/controllerextensions/editFlow/operations/ODataOperation.ts +51 -11
  43. package/src/sap/fe/core/controllerextensions/editFlow/operations/ODataStrictHandling.js +16 -1
  44. package/src/sap/fe/core/controllerextensions/editFlow/operations/ODataStrictHandling.ts +17 -2
  45. package/src/sap/fe/core/controllerextensions/editFlow/operations/Operation.js +88 -1
  46. package/src/sap/fe/core/controllerextensions/editFlow/operations/Operation.ts +106 -7
  47. package/src/sap/fe/core/controllerextensions/editFlow/operations/OperationMessage.js +16 -1
  48. package/src/sap/fe/core/controllerextensions/editFlow/operations/OperationMessage.ts +15 -0
  49. package/src/sap/fe/core/controllerextensions/editFlow/operations/OperationParameters.js +25 -1
  50. package/src/sap/fe/core/controllerextensions/editFlow/operations/OperationParameters.ts +24 -0
  51. package/src/sap/fe/core/controllerextensions/messageHandler/messageHandling.js +11 -8
  52. package/src/sap/fe/core/controllerextensions/messageHandler/messageHandling.ts +13 -10
  53. package/src/sap/fe/core/controllerextensions/routing/RouterProxy.js +7 -4
  54. package/src/sap/fe/core/controllerextensions/routing/RouterProxy.ts +7 -3
  55. package/src/sap/fe/core/controls/DataWatcher.js +2 -2
  56. package/src/sap/fe/core/controls/DataWatcher.tsx +1 -1
  57. package/src/sap/fe/core/controls/Recommendations/ConfirmRecommendationDialog.js +11 -6
  58. package/src/sap/fe/core/controls/Recommendations/ConfirmRecommendationDialog.tsx +13 -9
  59. package/src/sap/fe/core/controls/inlineEditFlow/InlineEditExitDialog.js +144 -0
  60. package/src/sap/fe/core/controls/inlineEditFlow/{BeforeNavigationDialog.tsx → InlineEditExitDialog.tsx} +1 -1
  61. package/src/sap/fe/core/converters/ManifestSettings.js +1 -1
  62. package/src/sap/fe/core/converters/ManifestSettings.ts +4 -0
  63. package/src/sap/fe/core/converters/MetaModelConverter.js +3 -2
  64. package/src/sap/fe/core/converters/MetaModelConverter.ts +12 -4
  65. package/src/sap/fe/core/converters/controls/Common/Action.js +42 -5
  66. package/src/sap/fe/core/converters/controls/Common/Action.ts +42 -5
  67. package/src/sap/fe/core/converters/controls/Common/Chart.js +4 -1
  68. package/src/sap/fe/core/converters/controls/Common/Chart.ts +2 -1
  69. package/src/sap/fe/core/converters/controls/Common/Table.js +46 -13
  70. package/src/sap/fe/core/converters/controls/Common/Table.ts +50 -11
  71. package/src/sap/fe/core/converters/controls/Common/table/Columns.js +11 -10
  72. package/src/sap/fe/core/converters/controls/Common/table/Columns.ts +13 -1
  73. package/src/sap/fe/core/converters/controls/ObjectPage/SubSection.js +2 -2
  74. package/src/sap/fe/core/converters/controls/ObjectPage/SubSection.ts +2 -1
  75. package/src/sap/fe/core/fpm/manifest.json +1 -1
  76. package/src/sap/fe/core/helpers/DeleteHelper.js +9 -9
  77. package/src/sap/fe/core/helpers/DeleteHelper.ts +8 -9
  78. package/src/sap/fe/core/helpers/FPMHelper.js +2 -2
  79. package/src/sap/fe/core/helpers/FPMHelper.ts +1 -1
  80. package/src/sap/fe/core/helpers/ModelHelper.js +4 -4
  81. package/src/sap/fe/core/helpers/ModelHelper.ts +8 -4
  82. package/src/sap/fe/core/helpers/PasteHelper.js +2 -2
  83. package/src/sap/fe/core/helpers/PasteHelper.ts +1 -1
  84. package/src/sap/fe/core/library.js +33 -4
  85. package/src/sap/fe/core/library.ts +33 -2
  86. package/src/sap/fe/core/messagebundle.properties +18 -2
  87. package/src/sap/fe/core/messagebundle_ar.properties +3 -2
  88. package/src/sap/fe/core/messagebundle_bg.properties +2 -1
  89. package/src/sap/fe/core/messagebundle_ca.properties +2 -1
  90. package/src/sap/fe/core/messagebundle_cnr.properties +2 -1
  91. package/src/sap/fe/core/messagebundle_cs.properties +4 -3
  92. package/src/sap/fe/core/messagebundle_cy.properties +2 -1
  93. package/src/sap/fe/core/messagebundle_da.properties +2 -1
  94. package/src/sap/fe/core/messagebundle_de.properties +8 -7
  95. package/src/sap/fe/core/messagebundle_el.properties +2 -1
  96. package/src/sap/fe/core/messagebundle_en.properties +2 -1
  97. package/src/sap/fe/core/messagebundle_en_GB.properties +2 -1
  98. package/src/sap/fe/core/messagebundle_en_US_saprigi.properties +2 -1
  99. package/src/sap/fe/core/messagebundle_es.properties +5 -4
  100. package/src/sap/fe/core/messagebundle_es_MX.properties +2 -1
  101. package/src/sap/fe/core/messagebundle_et.properties +2 -1
  102. package/src/sap/fe/core/messagebundle_fi.properties +2 -1
  103. package/src/sap/fe/core/messagebundle_fr.properties +2 -1
  104. package/src/sap/fe/core/messagebundle_fr_CA.properties +2 -1
  105. package/src/sap/fe/core/messagebundle_hi.properties +2 -1
  106. package/src/sap/fe/core/messagebundle_hr.properties +2 -1
  107. package/src/sap/fe/core/messagebundle_hu.properties +2 -1
  108. package/src/sap/fe/core/messagebundle_id.properties +2 -1
  109. package/src/sap/fe/core/messagebundle_it.properties +2 -1
  110. package/src/sap/fe/core/messagebundle_iw.properties +2 -1
  111. package/src/sap/fe/core/messagebundle_ja.properties +3 -2
  112. package/src/sap/fe/core/messagebundle_kk.properties +2 -1
  113. package/src/sap/fe/core/messagebundle_ko.properties +2 -1
  114. package/src/sap/fe/core/messagebundle_lt.properties +2 -1
  115. package/src/sap/fe/core/messagebundle_lv.properties +2 -1
  116. package/src/sap/fe/core/messagebundle_mk.properties +2 -1
  117. package/src/sap/fe/core/messagebundle_ms.properties +2 -1
  118. package/src/sap/fe/core/messagebundle_nl.properties +2 -1
  119. package/src/sap/fe/core/messagebundle_no.properties +3 -2
  120. package/src/sap/fe/core/messagebundle_pl.properties +2 -1
  121. package/src/sap/fe/core/messagebundle_pt.properties +2 -1
  122. package/src/sap/fe/core/messagebundle_pt_PT.properties +2 -1
  123. package/src/sap/fe/core/messagebundle_ro.properties +2 -1
  124. package/src/sap/fe/core/messagebundle_ru.properties +2 -1
  125. package/src/sap/fe/core/messagebundle_sh.properties +2 -1
  126. package/src/sap/fe/core/messagebundle_sk.properties +2 -1
  127. package/src/sap/fe/core/messagebundle_sl.properties +2 -1
  128. package/src/sap/fe/core/messagebundle_sr.properties +2 -1
  129. package/src/sap/fe/core/messagebundle_sv.properties +2 -1
  130. package/src/sap/fe/core/messagebundle_th.properties +2 -1
  131. package/src/sap/fe/core/messagebundle_tr.properties +2 -1
  132. package/src/sap/fe/core/messagebundle_uk.properties +2 -1
  133. package/src/sap/fe/core/messagebundle_vi.properties +2 -1
  134. package/src/sap/fe/core/messagebundle_zh_CN.properties +2 -1
  135. package/src/sap/fe/core/messagebundle_zh_TW.properties +2 -1
  136. package/src/sap/fe/core/rootView/RootViewBaseController.js +6 -6
  137. package/src/sap/fe/core/rootView/RootViewBaseController.ts +5 -5
  138. package/src/sap/fe/core/services/RoutingServiceFactory.js +3 -3
  139. package/src/sap/fe/core/services/RoutingServiceFactory.ts +2 -2
  140. package/src/sap/fe/core/services/SideEffectsServiceFactory.js +4 -1
  141. package/src/sap/fe/core/services/SideEffectsServiceFactory.ts +3 -0
  142. package/src/sap/fe/core/services/collaborativeDraftServiceFactory.js +8 -2
  143. package/src/sap/fe/core/services/collaborativeDraftServiceFactory.ts +7 -1
  144. package/src/sap/fe/core/templating/EntitySetHelper.js +75 -90
  145. package/src/sap/fe/core/templating/EntitySetHelper.ts +92 -118
  146. package/src/sap/fe/core/templating/UIFormatters.js +3 -3
  147. package/src/sap/fe/core/templating/UIFormatters.ts +1 -2
  148. package/src/sap/fe/core/controllerextensions/editFlow/operations/facade.js +0 -81
  149. package/src/sap/fe/core/controllerextensions/editFlow/operations/facade.ts +0 -126
  150. package/src/sap/fe/core/controllerextensions/editFlow/operations.js +0 -10
  151. package/src/sap/fe/core/controllerextensions/editFlow/operations.ts +0 -2
  152. package/src/sap/fe/core/controls/inlineEditFlow/BeforeActionDialog.js +0 -68
  153. package/src/sap/fe/core/controls/inlineEditFlow/BeforeActionDialog.tsx +0 -52
  154. 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
- 1. For containment scenario:
14
- 1.1. For LR, Navigation restrictions are evaluated first, followed by the restrictions on the root entity. If both a navigation property restriction and a direct restriction exist, the navigation restriction is the most precise definition and takes precedence over the direct restriction.
15
- 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.
16
-
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
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
- if (!targetEntitySet) {
38
- // if the targetEntitySet is not available, we need to get all the list of resctrictions from the root entitySet, this applies for on the list report
39
- const directSortRestrictions = getDirectSortRestrictionsRecursively(entitySet, undefined, parentNavigationPath);
40
- const directFilterRestrictions = getDirectFilterRestrictionsRecursively(entitySet, undefined, parentNavigationPath);
41
- return {
42
- nonSortableProperties: Array.from(
43
- new Set([...restrictionsFromNavigationRestrictions.nonSortableProperties, ...directSortRestrictions])
44
- ),
45
- nonFilterableProperties: Array.from(
46
- new Set([...restrictionsFromNavigationRestrictions.nonFilterableProperties, ...directFilterRestrictions])
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. In a non containment scenario it determines if we are in a List Report or an Object Page.
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
- propertiesRestrictions = getPropertiesRestrictionsBasedOnEntities(targetEntitySet);
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 also for containment as there isn't an entity set on the OP
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
- if (parentNavigationPath) {
126
- sortRestrictionsFromNavigationRestrictions.push(
127
- ...navigationProperty.targetType.entityProperties.map((property) => property.name)
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
- // We need the property name from the navigation restriction definition when the targetEntitySet is available
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 getDirectSortRestrictionsRecursively(entitySet: EntitySet, targetEntitySet?: EntitySet, parentNavigationPath?: string): string[] {
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
- if ((targetEntitySet || parentNavigationPath) && property.$target?.name) {
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
- // if containment enabled get only the filter restrictions of the related navigation path
204
- if (parentNavigationPath && parentNavigationPath !== navigationRestriction?.NavigationProperty?.value) {
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
- if (parentNavigationPath) {
213
- filterRestrictionsFromNavigationRestrictions.push(
214
- ...navigationProperty.targetType.entityProperties.map((property) => property.name)
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
- // we need the property name from the navigation restriction definition when the targetEntitySet is available and it's not a containment scenario
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 getDirectFilterRestrictionsRecursively(
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((property) => {
265
- if (parentNavigationPath && !property.value.includes(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
- if ((targetEntitySet || parentNavigationPath) && property.$target?.name) {
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);