@sapui5/sap.fe.core 1.124.1 → 1.124.3

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.
@@ -1,5 +1,6 @@
1
1
  import Log from "sap/base/Log";
2
2
  import type { FEView } from "sap/fe/core/BaseController";
3
+ import { getInvolvedDataModelObjectsForTargetPath } from "sap/fe/core/converters/MetaModelConverter";
3
4
  import { getResourceModel } from "sap/fe/core/helpers/ResourceModelHelper";
4
5
  import type {
5
6
  ControlSideEffectsType,
@@ -11,13 +12,13 @@ import type {
11
12
  import Button from "sap/m/Button";
12
13
  import Dialog from "sap/m/Dialog";
13
14
  import MessageToast from "sap/m/MessageToast";
15
+ import type { RadioButtonGroup$SelectEvent } from "sap/m/RadioButtonGroup";
14
16
  import Text from "sap/m/Text";
15
17
  import type UI5Event from "sap/ui/base/Event";
16
18
  import type Control from "sap/ui/core/Control";
17
19
  import type { Control$ValidateFieldGroupEvent } from "sap/ui/core/Control";
18
20
  import ControllerExtension from "sap/ui/core/mvc/ControllerExtension";
19
21
  import OverrideExecution from "sap/ui/core/mvc/OverrideExecution";
20
- import type Field from "sap/ui/mdc/Field";
21
22
  import type { Field$ChangeEvent } from "sap/ui/mdc/Field";
22
23
  import type { MultiValueField$ChangeEvent } from "sap/ui/mdc/MultiValueField";
23
24
  import type Context from "sap/ui/model/odata/v4/Context";
@@ -25,9 +26,13 @@ import type ODataContextBinding from "sap/ui/model/odata/v4/ODataContextBinding"
25
26
  import type ODataListBinding from "sap/ui/model/odata/v4/ODataListBinding";
26
27
  import CommonUtils from "../CommonUtils";
27
28
  import type PageController from "../PageController";
28
- import type { BaseManifestSettings } from "../converters/ManifestSettings";
29
+ import type { EnhanceWithUI5 } from "../helpers/ClassSupport";
29
30
  import { defineUI5Class, extensible, finalExtension, methodOverride, privateExtension, publicExtension } from "../helpers/ClassSupport";
30
31
 
32
+ import type { EntitySet, NavigationProperty } from "@sap-ux/vocabularies-types";
33
+ import Component from "sap/ui/core/Component";
34
+ import type TemplateComponent from "../TemplateComponent";
35
+
31
36
  type BaseSideEffectPropertyType = {
32
37
  name: string;
33
38
  immediate?: boolean;
@@ -56,6 +61,8 @@ class SideEffectsControllerExtension extends ControllerExtension {
56
61
 
57
62
  private _view!: FEView;
58
63
 
64
+ private _pageComponent: EnhanceWithUI5<TemplateComponent> | undefined;
65
+
59
66
  private _registeredFieldGroupMap!: Record<string, FieldGroupSideEffectType>;
60
67
 
61
68
  private _fieldGroupInvalidity!: Record<string, Record<string, boolean>>;
@@ -69,6 +76,8 @@ class SideEffectsControllerExtension extends ControllerExtension {
69
76
  @methodOverride()
70
77
  onInit(): void {
71
78
  this._view = this.base.getView();
79
+ this._pageComponent = Component.getOwnerComponentFor(this._view) as EnhanceWithUI5<TemplateComponent> | undefined;
80
+
72
81
  this._sideEffectsService = CommonUtils.getAppComponent(this._view).getSideEffectsService();
73
82
  this._registeredFieldGroupMap = {};
74
83
  this._fieldGroupInvalidity = {};
@@ -148,38 +157,45 @@ class SideEffectsControllerExtension extends ControllerExtension {
148
157
  @finalExtension()
149
158
  getFieldSideEffectsMap(field: Control): FieldSideEffectDictionary {
150
159
  let sideEffectsMap: FieldSideEffectDictionary = {};
151
- const fieldGroupIds = field.getFieldGroupIds(),
152
- viewEntitySetSetName = (this._view.getViewData() as BaseManifestSettings).entitySet,
153
- viewEntitySet = this._sideEffectsService.getConvertedMetaModel().entitySets.find((entitySet) => {
154
- return entitySet.name === viewEntitySetSetName;
155
- });
156
-
157
- // SideEffects coming from an OData Service
158
- sideEffectsMap = this.getSideEffectsMapForFieldGroups(
159
- fieldGroupIds,
160
- field.getBindingContext() as Context | null | undefined
161
- ) as FieldSideEffectDictionary;
162
-
163
- // SideEffects coming from control(s)
164
- if (viewEntitySetSetName && viewEntitySet) {
165
- const viewEntityType = viewEntitySet.entityType.fullyQualifiedName,
166
- fieldPath = this.getTargetProperty(field),
167
- context = this.getContextForSideEffects(field.getBindingContext() as Context, viewEntityType);
168
-
169
- if (fieldPath && context) {
170
- const controlSideEffectsEntityType = this._sideEffectsService.getControlEntitySideEffects(viewEntityType);
171
- Object.keys(controlSideEffectsEntityType).forEach((sideEffectsName) => {
172
- const oControlSideEffects = controlSideEffectsEntityType[sideEffectsName];
173
- if (oControlSideEffects.sourceProperties.includes(fieldPath)) {
174
- const name = `${sideEffectsName}::${viewEntityType}`;
175
- sideEffectsMap[name] = {
176
- name: name,
177
- immediate: true,
178
- sideEffects: oControlSideEffects,
179
- context: context
180
- };
160
+ if (this._pageComponent) {
161
+ const entitySet = this._pageComponent.getEntitySet?.();
162
+ const contextPath = this._pageComponent.getContextPath?.() || (entitySet && `/${entitySet}`);
163
+
164
+ if (contextPath) {
165
+ const fieldGroupIds = field.getFieldGroupIds(),
166
+ contextDataModelObject = getInvolvedDataModelObjectsForTargetPath<EntitySet | NavigationProperty>(
167
+ contextPath,
168
+ this._view.getModel().getMetaModel()
169
+ );
170
+
171
+ // SideEffects coming from an OData Service
172
+ sideEffectsMap = this.getSideEffectsMapForFieldGroups(
173
+ fieldGroupIds,
174
+ field.getBindingContext() as Context | null | undefined
175
+ ) as FieldSideEffectDictionary;
176
+
177
+ // SideEffects coming from control(s)
178
+ if (contextDataModelObject) {
179
+ const viewEntityType = contextDataModelObject.targetEntityType.fullyQualifiedName,
180
+ fieldPath = this.getTargetProperty(field),
181
+ context = this.getContextForSideEffects(field.getBindingContext() as Context, viewEntityType);
182
+
183
+ if (fieldPath && context) {
184
+ const controlSideEffectsEntityType = this._sideEffectsService.getControlEntitySideEffects(viewEntityType);
185
+ Object.keys(controlSideEffectsEntityType).forEach((sideEffectsName) => {
186
+ const oControlSideEffects = controlSideEffectsEntityType[sideEffectsName];
187
+ if (oControlSideEffects.sourceProperties.includes(fieldPath)) {
188
+ const name = `${sideEffectsName}::${viewEntityType}`;
189
+ sideEffectsMap[name] = {
190
+ name: name,
191
+ immediate: true,
192
+ sideEffects: oControlSideEffects,
193
+ context: context
194
+ };
195
+ }
196
+ });
181
197
  }
182
- });
198
+ }
183
199
  }
184
200
  }
185
201
  return sideEffectsMap;
@@ -267,11 +283,11 @@ class SideEffectsControllerExtension extends ControllerExtension {
267
283
  @publicExtension()
268
284
  @finalExtension()
269
285
  prepareDeferredSideEffectsForField(
270
- event: Field$ChangeEvent | MultiValueField$ChangeEvent,
286
+ event: Field$ChangeEvent | MultiValueField$ChangeEvent | RadioButtonGroup$SelectEvent,
271
287
  fieldValidity: boolean,
272
288
  fieldGroupPreRequisite?: Promise<unknown>
273
289
  ): void {
274
- const field = (event as UI5Event<{}, Field>).getSource();
290
+ const field = (event as UI5Event<{}, Control>).getSource();
275
291
  this._saveFieldPropertiesStatus(field, fieldValidity);
276
292
  if (!fieldValidity) {
277
293
  return;
@@ -302,12 +318,12 @@ class SideEffectsControllerExtension extends ControllerExtension {
302
318
  @publicExtension()
303
319
  @finalExtension()
304
320
  async handleFieldChange(
305
- event: Field$ChangeEvent,
321
+ event: Field$ChangeEvent | MultiValueField$ChangeEvent | RadioButtonGroup$SelectEvent,
306
322
  fieldValidity: boolean,
307
323
  fieldGroupPreRequisite?: Promise<unknown>,
308
324
  skipDeferredRegistration = false
309
325
  ): Promise<void> {
310
- const field = event.getSource() as Control;
326
+ const field = (event as UI5Event<{}, Control>).getSource();
311
327
  if (!skipDeferredRegistration) {
312
328
  this.prepareDeferredSideEffectsForField(event, fieldValidity, fieldGroupPreRequisite);
313
329
  } else {