@sap-ux/preview-middleware 0.19.29 → 0.19.30

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 (29) hide show
  1. package/dist/base/flp.d.ts +2 -2
  2. package/dist/base/flp.js +3 -3
  3. package/dist/client/adp/add-fragment.js +48 -0
  4. package/dist/client/adp/add-fragment.ts +51 -0
  5. package/dist/client/adp/api-handler.js +3 -1
  6. package/dist/client/adp/api-handler.ts +2 -2
  7. package/dist/client/adp/controllers/AddFragment.controller.js +26 -86
  8. package/dist/client/adp/controllers/AddFragment.controller.ts +29 -113
  9. package/dist/client/adp/dialog-factory.js +4 -4
  10. package/dist/client/adp/dialog-factory.ts +21 -13
  11. package/dist/client/adp/extension-point.js +3 -3
  12. package/dist/client/adp/extension-point.ts +3 -3
  13. package/dist/client/adp/init-dialogs.js +33 -8
  14. package/dist/client/adp/init-dialogs.ts +13 -8
  15. package/dist/client/adp/init.js +2 -0
  16. package/dist/client/adp/init.ts +5 -0
  17. package/dist/client/cpe/additional-change-info/add-xml-additional-info.js +77 -0
  18. package/dist/client/cpe/additional-change-info/add-xml-additional-info.ts +84 -0
  19. package/dist/client/cpe/changes/service.js +5 -2
  20. package/dist/client/cpe/changes/service.ts +2 -0
  21. package/dist/client/cpe/connector-service.js +2 -1
  22. package/dist/client/cpe/connector-service.ts +8 -4
  23. package/dist/client/flp/WorkspaceConnector.js +9 -3
  24. package/dist/client/flp/WorkspaceConnector.ts +10 -2
  25. package/dist/client/flp/enableFakeConnector.js +9 -3
  26. package/dist/client/flp/enableFakeConnector.ts +11 -2
  27. package/dist/client/utils/additional-change-info.js +43 -0
  28. package/dist/client/utils/additional-change-info.ts +42 -0
  29. package/package.json +3 -3
@@ -4,7 +4,7 @@ import type { Request, Router } from 'express';
4
4
  import type { Logger, ToolsLogger } from '@sap-ux/logger';
5
5
  import type { MiddlewareUtils } from '@ui5/server';
6
6
  import { type Manifest } from '@sap-ux/project-access';
7
- import { AdpPreview, type AdpPreviewConfig, type CommonChangeProperties, type OperationType } from '@sap-ux/adp-tooling';
7
+ import { AdpPreview, type AdpPreviewConfig, type CommonChangeProperties, type OperationType, type CommonAdditionalChangeInfoProperties } from '@sap-ux/adp-tooling';
8
8
  import type { FlpConfig, MiddlewareConfig, RtaConfig, TestConfig } from '../types';
9
9
  import { type TemplateConfig } from './config';
10
10
  /**
@@ -21,7 +21,7 @@ export type EnhancedRequest = Request & {
21
21
  baseUrl?: string;
22
22
  };
23
23
  };
24
- type OnChangeRequestHandler = (type: OperationType, change: CommonChangeProperties, fs: MemFsEditor, logger: Logger) => Promise<void>;
24
+ type OnChangeRequestHandler = (type: OperationType, change: CommonChangeProperties, fs: MemFsEditor, logger: Logger, extendedChange?: CommonAdditionalChangeInfoProperties) => Promise<void>;
25
25
  /**
26
26
  * Class handling preview of a sandbox FLP.
27
27
  */
package/dist/base/flp.js CHANGED
@@ -464,11 +464,11 @@ class FlpSandbox {
464
464
  async flexPostHandler(req, res) {
465
465
  this.fs = this.fs ?? (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
466
466
  try {
467
- const change = req.body;
467
+ const body = req.body;
468
468
  if (this.onChangeRequest) {
469
- await this.onChangeRequest('write', change, this.fs, this.logger);
469
+ await this.onChangeRequest('write', body.change, this.fs, this.logger, body.additionalChangeInfo);
470
470
  }
471
- const { success, message } = (0, flex_1.writeChange)(change, this.utils.getProject().getSourcePath(), this.fs, this.logger);
471
+ const { success, message } = (0, flex_1.writeChange)(body.change, this.utils.getProject().getSourcePath(), this.fs, this.logger);
472
472
  if (success) {
473
473
  this.fs.commit(() => this.sendResponse(res, 'text/plain', 200, message ?? ''));
474
474
  }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/ui/rta/command/CommandFactory", "./utils", "./dialog-factory", "sap/ui/rta/plugin/AddXMLPlugin"], function (CommandFactory, ___utils, ___dialog_factory, AddXMLPlugin) {
4
+ "use strict";
5
+
6
+ const createDeferred = ___utils["createDeferred"];
7
+ const DialogFactory = ___dialog_factory["DialogFactory"];
8
+ const DialogNames = ___dialog_factory["DialogNames"];
9
+ /**
10
+ * Initializes the AddXMLPlugin and includes it in the Runtime Authoring (RTA) plugins.
11
+ *
12
+ * @param rta Runtime Authoring instance
13
+ */
14
+ function initAddXMLPlugin(rta) {
15
+ const flexSettings = rta.getFlexSettings();
16
+ const commandFactory = new CommandFactory({
17
+ flexSettings
18
+ });
19
+ const plugin = new AddXMLPlugin({
20
+ commandFactory,
21
+ fragmentHandler: async overlay => await handleFragmentCreation(rta, overlay)
22
+ });
23
+ const plugins = rta.getPlugins();
24
+ plugins.addXMLPlugin = plugin;
25
+ rta.setPlugins(plugins);
26
+ }
27
+
28
+ /**
29
+ * Handles the creation of a fragment by opening a dialog and resolving the deferred data.
30
+ *
31
+ * @param rta Runtime Authoring instance
32
+ * @param overlay UI5 Element overlay
33
+ * @returns A promise that resolves with DeferredXmlFragmentData
34
+ */
35
+ async function handleFragmentCreation(rta, overlay) {
36
+ const deferred = createDeferred();
37
+ await DialogFactory.createDialog(overlay, rta, DialogNames.ADD_FRAGMENT, {
38
+ deferred
39
+ });
40
+ return deferred.promise;
41
+ }
42
+ var __exports = {
43
+ __esModule: true
44
+ };
45
+ __exports.initAddXMLPlugin = initAddXMLPlugin;
46
+ return __exports;
47
+ });
48
+ //# sourceMappingURL=add-fragment.js.map
@@ -0,0 +1,51 @@
1
+ import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
2
+ import type UI5Element from 'sap/ui/core/Element';
3
+ import CommandFactory from 'sap/ui/rta/command/CommandFactory';
4
+ import { Deferred, createDeferred } from './utils';
5
+ import { DialogFactory, DialogNames } from './dialog-factory';
6
+ import AddXMLPlugin from 'sap/ui/rta/plugin/AddXMLPlugin';
7
+
8
+ export interface AddFragmentData {
9
+ deferred: Deferred<DeferredXmlFragmentData>;
10
+ }
11
+
12
+ export type DeferredXmlFragmentData = {
13
+ fragment: string;
14
+ fragmentPath: string;
15
+ targetAggregation: string;
16
+ index: number;
17
+ };
18
+
19
+ /**
20
+ * Initializes the AddXMLPlugin and includes it in the Runtime Authoring (RTA) plugins.
21
+ *
22
+ * @param rta Runtime Authoring instance
23
+ */
24
+ export function initAddXMLPlugin(rta: RuntimeAuthoring): void {
25
+ const flexSettings = rta.getFlexSettings();
26
+ const commandFactory = new CommandFactory({ flexSettings });
27
+
28
+ const plugin = new AddXMLPlugin({
29
+ commandFactory,
30
+ fragmentHandler: async (overlay: UI5Element) => await handleFragmentCreation(rta, overlay)
31
+ });
32
+
33
+ const plugins = rta.getPlugins();
34
+ plugins.addXMLPlugin = plugin;
35
+ rta.setPlugins(plugins);
36
+ }
37
+
38
+ /**
39
+ * Handles the creation of a fragment by opening a dialog and resolving the deferred data.
40
+ *
41
+ * @param rta Runtime Authoring instance
42
+ * @param overlay UI5 Element overlay
43
+ * @returns A promise that resolves with DeferredXmlFragmentData
44
+ */
45
+ async function handleFragmentCreation(rta: RuntimeAuthoring, overlay: UI5Element): Promise<DeferredXmlFragmentData> {
46
+ const deferred = createDeferred<DeferredXmlFragmentData>();
47
+
48
+ await DialogFactory.createDialog(overlay, rta, DialogNames.ADD_FRAGMENT, { deferred });
49
+
50
+ return deferred.promise;
51
+ }
@@ -134,7 +134,9 @@ sap.ui.define(["../utils/error"], function (___utils_error) {
134
134
  * @returns Generic Promise<T>
135
135
  */
136
136
  async function writeChange(data) {
137
- return request(ApiEndpoints.CHANGES, RequestMethod.POST, data);
137
+ return request(ApiEndpoints.CHANGES, RequestMethod.POST, {
138
+ change: data
139
+ });
138
140
  }
139
141
  var __exports = {
140
142
  __esModule: true
@@ -42,7 +42,7 @@ export interface AnnotationFileDetails {
42
42
  }
43
43
 
44
44
  export interface AnnotationDataSourceMap {
45
- [key: string]: { serviceUrl: string; annotationDetails: AnnotationFileDetails, metadataReadErrorMsg: string };
45
+ [key: string]: { serviceUrl: string; annotationDetails: AnnotationFileDetails; metadataReadErrorMsg: string };
46
46
  }
47
47
 
48
48
  export interface AnnotationDataSourceResponse {
@@ -181,5 +181,5 @@ export async function getExistingController(controllerName: string): Promise<Cod
181
181
  * @returns Generic Promise<T>
182
182
  */
183
183
  export async function writeChange<T>(data: T): Promise<T> {
184
- return request<T>(ApiEndpoints.CHANGES, RequestMethod.POST, data);
184
+ return request<T>(ApiEndpoints.CHANGES, RequestMethod.POST, { change: data });
185
185
  }
@@ -2,36 +2,33 @@
2
2
  sap.ui.define([
3
3
  'sap/ui/model/json/JSONModel',
4
4
  'sap/ui/dt/OverlayRegistry',
5
- 'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
6
5
  '../../i18n',
7
- '../../cpe/communication-service',
8
6
  '../control-utils',
9
7
  '../command-executor',
10
8
  '../api-handler',
11
9
  './BaseDialog.controller',
12
10
  '../utils',
13
- '../quick-actions/control-types'
14
- ], function (JSONModel, OverlayRegistry, ___sap_ux_private_control_property_editor_common, ____i18n, ____cpe_communication_service, __ControlUtils, __CommandExecutor, ___api_handler, __BaseDialog, ___utils, ___quick_actions_control_types) {
11
+ '../../cpe/additional-change-info/add-xml-additional-info',
12
+ 'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
13
+ '../../cpe/communication-service'
14
+ ], function (JSONModel, OverlayRegistry, ____i18n, __ControlUtils, __CommandExecutor, ___api_handler, __BaseDialog, ___utils, ____cpe_additional_change_info_add_xml_additional_info, ___sap_ux_private_control_property_editor_common, ____cpe_communication_service) {
15
15
  'use strict';
16
16
  function _interopRequireDefault(obj) {
17
17
  return obj && obj.__esModule && typeof obj.default !== 'undefined' ? obj.default : obj;
18
18
  }
19
- const setApplicationRequiresReload = ___sap_ux_private_control_property_editor_common['setApplicationRequiresReload'];
20
19
  const getResourceModel = ____i18n['getResourceModel'];
21
20
  const getTextBundle = ____i18n['getTextBundle'];
22
- const CommunicationService = ____cpe_communication_service['CommunicationService'];
23
21
  const ControlUtils = _interopRequireDefault(__ControlUtils);
24
22
  const CommandExecutor = _interopRequireDefault(__CommandExecutor);
25
23
  const getFragments = ___api_handler['getFragments'];
26
24
  const BaseDialog = _interopRequireDefault(__BaseDialog);
27
25
  const notifyUser = ___utils['notifyUser'];
28
- const ANALYTICAL_TABLE_TYPE = ___quick_actions_control_types['ANALYTICAL_TABLE_TYPE'];
29
- const GRID_TABLE_TYPE = ___quick_actions_control_types['GRID_TABLE_TYPE'];
30
- const MDC_TABLE_TYPE = ___quick_actions_control_types['MDC_TABLE_TYPE'];
31
- const TREE_TABLE_TYPE = ___quick_actions_control_types['TREE_TABLE_TYPE'];
26
+ const getFragmentTemplateName = ____cpe_additional_change_info_add_xml_additional_info['getFragmentTemplateName'];
27
+ const setApplicationRequiresReload = ___sap_ux_private_control_property_editor_common['setApplicationRequiresReload'];
28
+ const CommunicationService = ____cpe_communication_service['CommunicationService'];
32
29
  const radix = 10;
33
30
  const AddFragment = BaseDialog.extend('open.ux.preview.client.adp.controllers.AddFragment', {
34
- constructor: function _constructor(name, overlays, rta, options, telemetryData) {
31
+ constructor: function _constructor(name, overlays, rta, options, data, telemetryData) {
35
32
  BaseDialog.prototype.constructor.call(this, name, telemetryData);
36
33
  this.options = options;
37
34
  this.rta = rta;
@@ -41,6 +38,7 @@ sap.ui.define([
41
38
  completeView: options.aggregation === undefined
42
39
  });
43
40
  this.commandExecutor = new CommandExecutor(this.rta);
41
+ this.data = data;
44
42
  },
45
43
  setup: async function _setup(dialog) {
46
44
  this.dialog = dialog;
@@ -76,16 +74,24 @@ sap.ui.define([
76
74
  await BaseDialog.prototype.onCreateBtnPressHandler.call(this);
77
75
  const fragmentName = this.model.getProperty('/newFragmentName');
78
76
  const index = this.model.getProperty('/selectedIndex');
79
- const targetAggregation = this.model.getProperty('/selectedAggregation/value');
80
- const fragmentData = {
81
- index,
82
- fragmentName,
83
- targetAggregation
77
+ const targetAggregation = this.model.getProperty('/selectedAggregation/value') ?? 'content';
78
+ const modifiedValue = {
79
+ fragment: `<core:FragmentDefinition xmlns:core='sap.ui.core'></core:FragmentDefinition>`,
80
+ fragmentPath: `fragments/${ fragmentName }.fragment.xml`,
81
+ index: index ?? 0,
82
+ targetAggregation: targetAggregation ?? 'content'
84
83
  };
85
- const templateName = await this.createFragmentChange(fragmentData);
86
- const textKey = templateName ? 'ADP_ADD_FRAGMENT_WITH_TEMPLATE_NOTIFICATION' : 'ADP_ADD_FRAGMENT_NOTIFICATION';
84
+ if (this.data) {
85
+ this.data.deferred.resolve(modifiedValue);
86
+ } else {
87
+ await this.createFragmentChange(modifiedValue);
88
+ }
89
+ const templateName = getFragmentTemplateName(this.runtimeControl.getId(), targetAggregation);
90
+ if (templateName) {
91
+ CommunicationService.sendAction(setApplicationRequiresReload(true));
92
+ }
87
93
  const bundle = await getTextBundle();
88
- notifyUser(bundle.getText(textKey, [fragmentName]), 8000);
94
+ notifyUser(bundle.getText('ADP_ADD_FRAGMENT_NOTIFICATION', [fragmentName]), 8000);
89
95
  this.handleDialogClose();
90
96
  },
91
97
  buildDialogData: async function _buildDialogData() {
@@ -133,78 +139,12 @@ sap.ui.define([
133
139
  this.model.setProperty('/selectedIndex', indexArray.length - 1 > 0 ? defaultIndex : 0);
134
140
  }
135
141
  },
136
- createFragmentChange: async function _createFragmentChange(fragmentData) {
137
- const {fragmentName, index, targetAggregation} = fragmentData;
142
+ createFragmentChange: async function _createFragmentChange(modifiedValue) {
138
143
  const flexSettings = this.rta.getFlexSettings();
139
144
  const overlay = OverlayRegistry.getOverlay(this.runtimeControl);
140
145
  const designMetadata = overlay.getDesignTimeMetadata();
141
- const modifiedValue = {
142
- fragment: `<core:FragmentDefinition xmlns:core='sap.ui.core'></core:FragmentDefinition>`,
143
- fragmentPath: `fragments/${ fragmentName }.fragment.xml`,
144
- index: index ?? 0,
145
- targetAggregation: targetAggregation ?? 'content'
146
- };
147
146
  const command = await this.commandExecutor.getCommand(this.runtimeControl, 'addXML', modifiedValue, designMetadata, flexSettings);
148
- const templateName = this.getFragmentTemplateName(modifiedValue.targetAggregation);
149
- if (templateName) {
150
- const preparedChange = command.getPreparedChange();
151
- const content = preparedChange.getContent();
152
- preparedChange.setContent({
153
- ...content,
154
- templateName
155
- });
156
- CommunicationService.sendAction(setApplicationRequiresReload(true));
157
- }
158
147
  await this.commandExecutor.pushAndExecuteCommand(command);
159
- return templateName;
160
- },
161
- getFragmentTemplateName: function _getFragmentTemplateName(targetAggregation) {
162
- const currentControlName = this.runtimeControl.getMetadata().getName();
163
- if (currentControlName === 'sap.uxap.ObjectPageLayout' && targetAggregation === 'sections') {
164
- return 'OBJECT_PAGE_CUSTOM_SECTION';
165
- } else if (this.isCustomAction(currentControlName, targetAggregation)) {
166
- return 'CUSTOM_ACTION';
167
- } else if (this.isObjectPageHeaderField(currentControlName, targetAggregation)) {
168
- return 'OBJECT_PAGE_HEADER_FIELD';
169
- } else if (targetAggregation === 'columns') {
170
- switch (currentControlName) {
171
- case MDC_TABLE_TYPE:
172
- return 'V4_MDC_TABLE_COLUMN';
173
- case TREE_TABLE_TYPE:
174
- case GRID_TABLE_TYPE:
175
- return 'GRID_TREE_TABLE_COLUMN';
176
- case ANALYTICAL_TABLE_TYPE:
177
- return 'ANALYTICAL_TABLE_COLUMN';
178
- default:
179
- return '';
180
- }
181
- } else if (currentControlName === 'sap.ui.mdc.Table' && targetAggregation === 'actions') {
182
- return 'TABLE_ACTION';
183
- }
184
- return '';
185
- },
186
- isCustomAction: function _isCustomAction(currentControlName, targetAggregation) {
187
- if ([
188
- 'sap.f.DynamicPageTitle',
189
- 'sap.uxap.ObjectPageHeader',
190
- 'sap.uxap.ObjectPageDynamicHeaderTitle'
191
- ].includes(currentControlName)) {
192
- return targetAggregation === 'actions';
193
- } else if (currentControlName === 'sap.m.OverflowToolbar' || currentControlName === 'sap.m.Toolbar') {
194
- return targetAggregation === 'content';
195
- }
196
- return false;
197
- },
198
- isObjectPageHeaderField: function _isObjectPageHeaderField(currentControlName, targetAggregation) {
199
- if (currentControlName === 'sap.uxap.ObjectPageLayout') {
200
- return targetAggregation === 'headerContent';
201
- } else if (currentControlName === 'sap.m.FlexBox') {
202
- const parentName = this.runtimeControl.getParent()?.getMetadata().getName();
203
- if (parentName === 'sap.uxap.ObjectPageDynamicHeaderContent' || parentName === 'sap.uxap.ObjectPageLayout') {
204
- return targetAggregation === 'items';
205
- }
206
- }
207
- return false;
208
148
  }
209
149
  });
210
150
  return AddFragment;
@@ -21,29 +21,18 @@ import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
21
21
  /** sap.ui.fl */
22
22
  import { type AddFragmentChangeContentType } from 'sap/ui/fl/Change';
23
23
 
24
- import { setApplicationRequiresReload } from '@sap-ux-private/control-property-editor-common';
25
-
26
24
  import { getResourceModel, getTextBundle } from '../../i18n';
27
- import { CommunicationService } from '../../cpe/communication-service';
28
25
 
29
26
  import ControlUtils from '../control-utils';
30
27
  import CommandExecutor from '../command-executor';
31
28
  import { getFragments } from '../api-handler';
32
29
  import BaseDialog from './BaseDialog.controller';
33
30
  import { notifyUser } from '../utils';
34
- import {
35
- ANALYTICAL_TABLE_TYPE,
36
- GRID_TABLE_TYPE,
37
- MDC_TABLE_TYPE,
38
- TREE_TABLE_TYPE
39
- } from '../quick-actions/control-types';
40
31
  import { QuickActionTelemetryData } from '../../cpe/quick-actions/quick-action-definition';
41
-
42
- interface CreateFragmentProps {
43
- fragmentName: string;
44
- index: string | number;
45
- targetAggregation: string;
46
- }
32
+ import { getFragmentTemplateName } from '../../cpe/additional-change-info/add-xml-additional-info';
33
+ import type { AddFragmentData, DeferredXmlFragmentData } from '../add-fragment';
34
+ import { setApplicationRequiresReload } from '@sap-ux-private/control-property-editor-common';
35
+ import { CommunicationService } from '../../cpe/communication-service';
47
36
 
48
37
  const radix = 10;
49
38
 
@@ -65,11 +54,14 @@ export interface AddFragmentOptions {
65
54
  * @namespace open.ux.preview.client.adp.controllers
66
55
  */
67
56
  export default class AddFragment extends BaseDialog<AddFragmentModel> {
57
+ private readonly data?: AddFragmentData;
58
+
68
59
  constructor(
69
60
  name: string,
70
61
  overlays: UI5Element,
71
62
  rta: RuntimeAuthoring,
72
63
  readonly options: AddFragmentOptions,
64
+ data?: AddFragmentData,
73
65
  telemetryData?: QuickActionTelemetryData
74
66
  ) {
75
67
  super(name, telemetryData);
@@ -80,6 +72,7 @@ export default class AddFragment extends BaseDialog<AddFragmentModel> {
80
72
  completeView: options.aggregation === undefined
81
73
  });
82
74
  this.commandExecutor = new CommandExecutor(this.rta);
75
+ this.data = data;
83
76
  }
84
77
 
85
78
  /**
@@ -149,18 +142,28 @@ export default class AddFragment extends BaseDialog<AddFragmentModel> {
149
142
 
150
143
  const fragmentName = this.model.getProperty('/newFragmentName');
151
144
  const index = this.model.getProperty('/selectedIndex');
152
- const targetAggregation = this.model.getProperty('/selectedAggregation/value');
153
- const fragmentData = {
154
- index,
155
- fragmentName,
156
- targetAggregation
145
+ const targetAggregation = this.model.getProperty('/selectedAggregation/value') ?? 'content';
146
+
147
+ const modifiedValue = {
148
+ fragment: `<core:FragmentDefinition xmlns:core='sap.ui.core'></core:FragmentDefinition>`,
149
+ fragmentPath: `fragments/${fragmentName}.fragment.xml`,
150
+ index: index ?? 0,
151
+ targetAggregation: targetAggregation ?? 'content'
157
152
  };
158
153
 
159
- const templateName = await this.createFragmentChange(fragmentData);
154
+ if (this.data) {
155
+ this.data.deferred.resolve(modifiedValue);
156
+ } else {
157
+ await this.createFragmentChange(modifiedValue);
158
+ }
159
+
160
+ const templateName = getFragmentTemplateName(this.runtimeControl.getId(), targetAggregation);
161
+ if (templateName) {
162
+ CommunicationService.sendAction(setApplicationRequiresReload(true));
163
+ }
160
164
 
161
- const textKey = templateName ? 'ADP_ADD_FRAGMENT_WITH_TEMPLATE_NOTIFICATION' : 'ADP_ADD_FRAGMENT_NOTIFICATION';
162
165
  const bundle = await getTextBundle();
163
- notifyUser(bundle.getText(textKey, [fragmentName]), 8000);
166
+ notifyUser(bundle.getText('ADP_ADD_FRAGMENT_NOTIFICATION', [fragmentName]), 8000);
164
167
 
165
168
  this.handleDialogClose();
166
169
  }
@@ -227,23 +230,15 @@ export default class AddFragment extends BaseDialog<AddFragmentModel> {
227
230
  /**
228
231
  * Creates an addXML fragment command and pushes it to the command stack
229
232
  *
230
- * @param fragmentData Fragment Data
233
+ * @param modifiedValue - modified value
234
+ * @param templateName - fragment template name
231
235
  */
232
- private async createFragmentChange(fragmentData: CreateFragmentProps): Promise<string | undefined> {
233
- const { fragmentName, index, targetAggregation } = fragmentData;
234
-
236
+ private async createFragmentChange(modifiedValue: DeferredXmlFragmentData): Promise<void> {
235
237
  const flexSettings = this.rta.getFlexSettings();
236
238
 
237
239
  const overlay = OverlayRegistry.getOverlay(this.runtimeControl as UI5Element);
238
240
  const designMetadata = overlay.getDesignTimeMetadata();
239
241
 
240
- const modifiedValue = {
241
- fragment: `<core:FragmentDefinition xmlns:core='sap.ui.core'></core:FragmentDefinition>`,
242
- fragmentPath: `fragments/${fragmentName}.fragment.xml`,
243
- index: index ?? 0,
244
- targetAggregation: targetAggregation ?? 'content'
245
- };
246
-
247
242
  const command = await this.commandExecutor.getCommand<AddFragmentChangeContentType>(
248
243
  this.runtimeControl,
249
244
  'addXML',
@@ -252,85 +247,6 @@ export default class AddFragment extends BaseDialog<AddFragmentModel> {
252
247
  flexSettings
253
248
  );
254
249
 
255
- const templateName = this.getFragmentTemplateName(modifiedValue.targetAggregation);
256
- if (templateName) {
257
- const preparedChange = command.getPreparedChange();
258
- const content = preparedChange.getContent();
259
- preparedChange.setContent({ ...content, templateName });
260
- CommunicationService.sendAction(setApplicationRequiresReload(true));
261
- }
262
250
  await this.commandExecutor.pushAndExecuteCommand(command);
263
- return templateName;
264
- }
265
-
266
- /**
267
- * Determines fragment template name based on current control name and provided target aggregation
268
- * @param targetAggregation - target aggregation name
269
- * @returns fragment template name or empty string
270
- */
271
- private getFragmentTemplateName(targetAggregation: string): string {
272
- const currentControlName = this.runtimeControl.getMetadata().getName();
273
- if (currentControlName === 'sap.uxap.ObjectPageLayout' && targetAggregation === 'sections') {
274
- return 'OBJECT_PAGE_CUSTOM_SECTION';
275
- } else if (this.isCustomAction(currentControlName, targetAggregation)) {
276
- return 'CUSTOM_ACTION';
277
- } else if (this.isObjectPageHeaderField(currentControlName, targetAggregation)) {
278
- return 'OBJECT_PAGE_HEADER_FIELD';
279
- } else if (targetAggregation === 'columns') {
280
- switch (currentControlName) {
281
- case MDC_TABLE_TYPE:
282
- return 'V4_MDC_TABLE_COLUMN';
283
- case TREE_TABLE_TYPE:
284
- case GRID_TABLE_TYPE:
285
- return 'GRID_TREE_TABLE_COLUMN';
286
- case ANALYTICAL_TABLE_TYPE:
287
- return 'ANALYTICAL_TABLE_COLUMN';
288
- default:
289
- return '';
290
- }
291
- } else if (currentControlName === 'sap.ui.mdc.Table' && targetAggregation === 'actions') {
292
- return 'TABLE_ACTION';
293
- }
294
- return '';
295
- }
296
-
297
- /**
298
- * Determines conditions for custom action fragment creation
299
- * @param currentControlName - current control name
300
- * @param targetAggregation - target aggregation name
301
- * @returns true if control and aggregation combination allows to create custom action fragment
302
- */
303
- private isCustomAction(currentControlName: string, targetAggregation: string): boolean {
304
- if (
305
- ['sap.f.DynamicPageTitle', 'sap.uxap.ObjectPageHeader', 'sap.uxap.ObjectPageDynamicHeaderTitle'].includes(
306
- currentControlName
307
- )
308
- ) {
309
- return targetAggregation === 'actions';
310
- } else if (currentControlName === 'sap.m.OverflowToolbar' || currentControlName === 'sap.m.Toolbar') {
311
- return targetAggregation === 'content';
312
- }
313
- return false;
314
- }
315
-
316
- /**
317
- * Determines conditions for object page header field fragment creation
318
- * @param currentControlName - current control name
319
- * @param targetAggregation - target aggregation name
320
- * @returns true if conditions allow to create object page header field fragment
321
- */
322
- private isObjectPageHeaderField(currentControlName: string, targetAggregation: string): boolean {
323
- if (currentControlName === 'sap.uxap.ObjectPageLayout') {
324
- return targetAggregation === 'headerContent';
325
- } else if (currentControlName === 'sap.m.FlexBox') {
326
- const parentName = this.runtimeControl.getParent()?.getMetadata().getName();
327
- if (
328
- parentName === 'sap.uxap.ObjectPageDynamicHeaderContent' ||
329
- parentName === 'sap.uxap.ObjectPageLayout'
330
- ) {
331
- return targetAggregation === 'items';
332
- }
333
- }
334
- return false;
335
251
  }
336
252
  }
@@ -40,11 +40,11 @@ sap.ui.define(["sap/ui/core/Fragment", "../i18n", "./controllers/AddFragment.con
40
40
  * @param overlay - Control overlay.
41
41
  * @param rta - Runtime Authoring instance.
42
42
  * @param dialogName - Dialog name.
43
- * @param extensionPointData - Control ID.
43
+ * @param data - Data to be passed to the dialog.
44
44
  * @param options - Dialog options.
45
45
  * @param telemetryData - Telemetry data.
46
46
  */
47
- static async createDialog(overlay, rta, dialogName, extensionPointData) {
47
+ static async createDialog(overlay, rta, dialogName, data) {
48
48
  let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
49
49
  let telemetryData = arguments.length > 5 ? arguments[5] : undefined;
50
50
  if (this.isDialogOpen) {
@@ -62,7 +62,7 @@ sap.ui.define(["sap/ui/core/Fragment", "../i18n", "./controllers/AddFragment.con
62
62
  defaultAggregationArrayIndex: options.defaultAggregationArrayIndex
63
63
  }),
64
64
  title: resources.getText(options.title ?? 'ADP_ADD_FRAGMENT_DIALOG_TITLE')
65
- }, telemetryData);
65
+ }, data, telemetryData);
66
66
  break;
67
67
  case DialogNames.ADD_TABLE_COLUMN_FRAGMENTS:
68
68
  controller = new AddTableColumnFragments(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta, {
@@ -76,7 +76,7 @@ sap.ui.define(["sap/ui/core/Fragment", "../i18n", "./controllers/AddFragment.con
76
76
  controller = new ControllerExtension(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta, telemetryData);
77
77
  break;
78
78
  case DialogNames.ADD_FRAGMENT_AT_EXTENSION_POINT:
79
- controller = new ExtensionPoint(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta, extensionPointData);
79
+ controller = new ExtensionPoint(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta, data);
80
80
  break;
81
81
  case DialogNames.FILE_EXISTS:
82
82
  controller = new FileExistsDialog(`open.ux.preview.client.adp.controllers.${dialogName}`, options);
@@ -10,7 +10,8 @@ import AddTableColumnFragments from './controllers/AddTableColumnFragments.contr
10
10
  import ControllerExtension from './controllers/ControllerExtension.controller';
11
11
  import ExtensionPoint from './controllers/ExtensionPoint.controller';
12
12
 
13
- import { ExtensionPointData } from './extension-point';
13
+ import type { ExtensionPointData } from './extension-point';
14
+ import { AddFragmentData } from './add-fragment';
14
15
  import FileExistsDialog, { FileExistsDialogOptions } from './controllers/FileExistsDialog.controller';
15
16
  import AddSubpage, { AddSubpageOptions } from './controllers/AddSubpage.controller';
16
17
  import { QuickActionTelemetryData } from '../cpe/quick-actions/quick-action-definition';
@@ -32,6 +33,8 @@ type Controller =
32
33
  | FileExistsDialog
33
34
  | AddSubpage;
34
35
 
36
+ type DialogData = ExtensionPointData | AddFragmentData;
37
+
35
38
  export const OPEN_DIALOG_STATUS_CHANGED = 'OPEN_DIALOG_STATUS_CHANGED';
36
39
 
37
40
  export class DialogFactory {
@@ -51,7 +54,7 @@ export class DialogFactory {
51
54
  * @param overlay - Control overlay.
52
55
  * @param rta - Runtime Authoring instance.
53
56
  * @param dialogName - Dialog name.
54
- * @param extensionPointData - Control ID.
57
+ * @param data - Data to be passed to the dialog.
55
58
  * @param options - Dialog options.
56
59
  * @param telemetryData - Telemetry data.
57
60
  */
@@ -59,7 +62,7 @@ export class DialogFactory {
59
62
  overlay: UI5Element,
60
63
  rta: RuntimeAuthoring,
61
64
  dialogName: DialogNames,
62
- extensionPointData?: ExtensionPointData,
65
+ data?: DialogData,
63
66
  options: Partial<AddFragmentOptions> | Partial<FileExistsDialogOptions> | AddSubpageOptions = {},
64
67
  telemetryData?: QuickActionTelemetryData
65
68
  ): Promise<void> {
@@ -71,15 +74,20 @@ export class DialogFactory {
71
74
 
72
75
  switch (dialogName) {
73
76
  case DialogNames.ADD_FRAGMENT:
74
- controller = new AddFragment(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta, {
75
- ...('aggregation' in options && { aggregation: options.aggregation }),
76
- ...('defaultAggregationArrayIndex' in options && {
77
- defaultAggregationArrayIndex: options.defaultAggregationArrayIndex
78
- }),
79
- title: resources.getText(options.title ?? 'ADP_ADD_FRAGMENT_DIALOG_TITLE')
80
- },
81
- telemetryData
82
- );
77
+ controller = new AddFragment(
78
+ `open.ux.preview.client.adp.controllers.${dialogName}`,
79
+ overlay,
80
+ rta,
81
+ {
82
+ ...('aggregation' in options && { aggregation: options.aggregation }),
83
+ ...('defaultAggregationArrayIndex' in options && {
84
+ defaultAggregationArrayIndex: options.defaultAggregationArrayIndex
85
+ }),
86
+ title: resources.getText(options.title ?? 'ADP_ADD_FRAGMENT_DIALOG_TITLE')
87
+ },
88
+ (data as AddFragmentData),
89
+ telemetryData
90
+ );
83
91
  break;
84
92
  case DialogNames.ADD_TABLE_COLUMN_FRAGMENTS:
85
93
  controller = new AddTableColumnFragments(
@@ -106,7 +114,7 @@ export class DialogFactory {
106
114
  `open.ux.preview.client.adp.controllers.${dialogName}`,
107
115
  overlay,
108
116
  rta,
109
- extensionPointData!
117
+ (data as ExtensionPointData)
110
118
  );
111
119
  break;
112
120
  case DialogNames.FILE_EXISTS:
@@ -40,9 +40,9 @@ sap.ui.define([
40
40
  commandFactory,
41
41
  fragmentHandler: async (overlay, info) => await this.fragmentHandler(overlay, info)
42
42
  });
43
- const defaultPlugins = this.rta.getDefaultPlugins();
44
- defaultPlugins.addXMLAtExtensionPoint = plugin;
45
- this.rta.setPlugins(defaultPlugins);
43
+ const plugins = this.rta.getPlugins();
44
+ plugins.addXMLAtExtensionPoint = plugin;
45
+ this.rta.setPlugins(plugins);
46
46
  }
47
47
  async fragmentHandler(overlay, info) {
48
48
  let deferred = createDeferred();