@sap-ux/preview-middleware 0.18.18 → 0.18.19

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.
@@ -0,0 +1,128 @@
1
+ 'use strict';
2
+ sap.ui.define([
3
+ 'sap/ui/model/json/JSONModel',
4
+ '../../i18n',
5
+ '../command-executor',
6
+ './BaseDialog.controller',
7
+ 'sap/ui/rta/command/CommandFactory',
8
+ '../../cpe/communication-service',
9
+ 'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common'
10
+ ], function (JSONModel, ____i18n, __CommandExecutor, __BaseDialog, CommandFactory, ____cpe_communication_service, ___sap_ux_private_control_property_editor_common) {
11
+ 'use strict';
12
+ function _interopRequireDefault(obj) {
13
+ return obj && obj.__esModule && typeof obj.default !== 'undefined' ? obj.default : obj;
14
+ }
15
+ const getResourceModel = ____i18n['getResourceModel'];
16
+ const CommandExecutor = _interopRequireDefault(__CommandExecutor);
17
+ const BaseDialog = _interopRequireDefault(__BaseDialog);
18
+ const CommunicationService = ____cpe_communication_service['CommunicationService'];
19
+ const setApplicationRequiresReload = ___sap_ux_private_control_property_editor_common['setApplicationRequiresReload'];
20
+ const AddSubpage = BaseDialog.extend('open.ux.preview.client.adp.controllers.AddSubpage', {
21
+ constructor: function _constructor(name, overlays, rta, options) {
22
+ BaseDialog.prototype.constructor.call(this, name);
23
+ this.options = options;
24
+ this.rta = rta;
25
+ this.overlays = overlays;
26
+ this.model = new JSONModel({
27
+ appType: options.appType,
28
+ appReference: options.appReference,
29
+ pageType: options.pageDescriptor.pageType,
30
+ title: options.title,
31
+ navigationData: options.pageDescriptor.navProperties,
32
+ currentEntitySet: options.pageDescriptor.entitySet
33
+ });
34
+ this.commandExecutor = new CommandExecutor(this.rta);
35
+ },
36
+ setup: async function _setup(dialog) {
37
+ this.dialog = dialog;
38
+ this.setEscapeHandler();
39
+ await this.buildDialogData();
40
+ const resourceModel = await getResourceModel('open.ux.preview.client');
41
+ this.dialog.setModel(resourceModel, 'i18n');
42
+ this.dialog.setModel(this.model);
43
+ this.dialog.open();
44
+ },
45
+ onPageTypeChange: function _onPageTypeChange() {
46
+ },
47
+ onNavigationChange: function _onNavigationChange(event) {
48
+ const source = event.getSource();
49
+ const selectedKey = source.getSelectedKey();
50
+ this.model.setProperty('/selectedNavigation/key', selectedKey);
51
+ },
52
+ onCreateBtnPress: async function _onCreateBtnPress(event) {
53
+ const source = event.getSource();
54
+ source.setEnabled(false);
55
+ const flexSettings = this.rta.getFlexSettings();
56
+ const navProperty = this.model.getProperty('/selectedNavigation/key');
57
+ const navigation = this.model.getProperty('/navigationData').find(item => item.navProperty = navProperty);
58
+ const targetEntitySet = navigation?.entitySet ?? '';
59
+ const appType = this.model.getProperty('/appType');
60
+ const pageType = this.model.getProperty('/pageType');
61
+ const modifiedValue = appType === 'fe-v2' ? {
62
+ changeType: 'appdescr_ui_generic_app_addNewObjectPage',
63
+ reference: this.model.getProperty('/appReference'),
64
+ parameters: {
65
+ parentPage: {
66
+ component: pageType,
67
+ entitySet: this.model.getProperty('/currentEntitySet')
68
+ },
69
+ childPage: {
70
+ id: `ObjectPage|${ navProperty }`,
71
+ definition: {
72
+ entitySet: targetEntitySet,
73
+ navigationProperty: navProperty
74
+ }
75
+ }
76
+ }
77
+ } : {
78
+ changeType: 'appdescr_fe_addNewPage',
79
+ parameters: {
80
+ sourcePage: {
81
+ id: this.runtimeControl.getId(),
82
+ navigationSource: targetEntitySet
83
+ },
84
+ targetPage: {
85
+ type: 'Component',
86
+ id: `${ targetEntitySet }ObjectPage`,
87
+ name: 'sap.fe.templates.ObjectPage',
88
+ routePattern: `${ targetEntitySet }({key}):?query:`,
89
+ settings: {
90
+ contextPath: `/${ targetEntitySet }`,
91
+ editableHeaderContent: false
92
+ }
93
+ }
94
+ }
95
+ };
96
+ const command = await CommandFactory.getCommandFor(this.runtimeControl, 'appDescriptor', modifiedValue, null, flexSettings);
97
+ await this.commandExecutor.pushAndExecuteCommand(command);
98
+ CommunicationService.sendAction(setApplicationRequiresReload(true));
99
+ this.handleDialogClose();
100
+ },
101
+ buildDialogData: async function _buildDialogData() {
102
+ this.getControlMetadata();
103
+ const pageTypeOptions = [
104
+ {
105
+ key: 'ObjectPage',
106
+ value: 'Object Page'
107
+ },
108
+ {
109
+ key: 'CustomPage',
110
+ value: 'Custom Page'
111
+ }
112
+ ];
113
+ this.model.setProperty('/pageTypeOptions', pageTypeOptions);
114
+ this.model.setProperty('/selectedPageType', pageTypeOptions[0]);
115
+ const navigationOptions = this.model.getProperty('/navigationData').map(item => {
116
+ const value = item.entitySet === item.navProperty ? item.entitySet : `${ item.entitySet } (${ item.navProperty })`;
117
+ return {
118
+ key: item.navProperty,
119
+ value
120
+ };
121
+ });
122
+ this.model.setProperty('/navigationOptions', navigationOptions);
123
+ this.model.setProperty('/selectedNavigation', navigationOptions[0]);
124
+ return Promise.resolve();
125
+ }
126
+ });
127
+ return AddSubpage;
128
+ });
@@ -0,0 +1,195 @@
1
+ /** sap.m */
2
+ import Button from 'sap/m/Button';
3
+ import type Dialog from 'sap/m/Dialog';
4
+ import type ComboBox from 'sap/m/ComboBox';
5
+
6
+ /** sap.ui.core */
7
+ import type UI5Element from 'sap/ui/core/Element';
8
+
9
+ /** sap.ui.base */
10
+ import type Event from 'sap/ui/base/Event';
11
+
12
+ /** sap.ui.model */
13
+ import JSONModel from 'sap/ui/model/json/JSONModel';
14
+
15
+ /** sap.ui.rta */
16
+ import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
17
+
18
+ import { getResourceModel } from '../../i18n';
19
+
20
+ import CommandExecutor from '../command-executor';
21
+
22
+ import BaseDialog from './BaseDialog.controller';
23
+
24
+ import CommandFactory from 'sap/ui/rta/command/CommandFactory';
25
+ import { ApplicationType } from '../../utils/application';
26
+ import { CommunicationService } from '../../cpe/communication-service';
27
+ import { setApplicationRequiresReload } from '@sap-ux-private/control-property-editor-common';
28
+
29
+ type SubpageType = 'ObjectPage' | 'CustomPage';
30
+
31
+ export type AddSubpageModel = JSONModel & {
32
+ getProperty(sPath: '/appType'): ApplicationType;
33
+ getProperty(sPath: '/pageType'): string;
34
+ getProperty(sPath: '/appReference'): string;
35
+ getProperty(sPath: '/currentEntitySet'): string;
36
+ getProperty(sPath: '/title'): string;
37
+ getProperty(sPath: '/navigationData'): { navProperty: string; entitySet: string }[];
38
+ getProperty(sPath: '/selectedPageType/key'): SubpageType;
39
+ getProperty(sPath: '/selectedNavigation/key'): string;
40
+ };
41
+
42
+ export interface AddSubpageOptions {
43
+ appType: ApplicationType;
44
+ appReference: string;
45
+ title: string;
46
+ pageDescriptor: {
47
+ pageType: string;
48
+ entitySet: string;
49
+ navProperties: { navProperty: string; entitySet: string }[];
50
+ }
51
+ }
52
+
53
+ /**
54
+ * @namespace open.ux.preview.client.adp.controllers
55
+ */
56
+ export default class AddSubpage extends BaseDialog<AddSubpageModel> {
57
+ constructor(name: string, overlays: UI5Element, rta: RuntimeAuthoring, readonly options: AddSubpageOptions) {
58
+ super(name);
59
+ this.rta = rta;
60
+ this.overlays = overlays;
61
+ this.model = new JSONModel({
62
+ appType: options.appType,
63
+ appReference: options.appReference,
64
+ pageType: options.pageDescriptor.pageType,
65
+ title: options.title,
66
+ navigationData: options.pageDescriptor.navProperties,
67
+ currentEntitySet: options.pageDescriptor.entitySet
68
+ });
69
+ this.commandExecutor = new CommandExecutor(this.rta);
70
+ }
71
+
72
+ /**
73
+ * Setups the Dialog and the JSON Model
74
+ *
75
+ * @param {Dialog} dialog - Dialog instance
76
+ */
77
+ async setup(dialog: Dialog): Promise<void> {
78
+ this.dialog = dialog;
79
+
80
+ this.setEscapeHandler();
81
+
82
+ await this.buildDialogData();
83
+ const resourceModel = await getResourceModel('open.ux.preview.client');
84
+
85
+ this.dialog.setModel(resourceModel, 'i18n');
86
+ this.dialog.setModel(this.model);
87
+
88
+ this.dialog.open();
89
+ }
90
+
91
+ onPageTypeChange() {
92
+ // TODO: to be supported in future releases
93
+ }
94
+
95
+ onNavigationChange(event: Event) {
96
+ const source = event.getSource<ComboBox>();
97
+ const selectedKey = source.getSelectedKey();
98
+ this.model.setProperty('/selectedNavigation/key', selectedKey);
99
+ }
100
+
101
+ /**
102
+ * Handles create button press
103
+ *
104
+ * @param event Event
105
+ */
106
+ async onCreateBtnPress(event: Event) {
107
+ const source = event.getSource<Button>();
108
+ source.setEnabled(false);
109
+
110
+ const flexSettings = this.rta.getFlexSettings();
111
+ const navProperty = this.model.getProperty('/selectedNavigation/key');
112
+ const navigation = this.model.getProperty('/navigationData').find((item) => (item.navProperty = navProperty));
113
+ const targetEntitySet = navigation?.entitySet ?? '';
114
+ const appType = this.model.getProperty('/appType');
115
+ const pageType = this.model.getProperty('/pageType');
116
+
117
+ const modifiedValue =
118
+ appType === 'fe-v2'
119
+ ? {
120
+ changeType: 'appdescr_ui_generic_app_addNewObjectPage',
121
+ reference: this.model.getProperty('/appReference'),
122
+ parameters: {
123
+ parentPage: {
124
+ component: pageType,
125
+ entitySet: this.model.getProperty('/currentEntitySet')
126
+ },
127
+ childPage: {
128
+ id: `ObjectPage|${navProperty}`,
129
+ definition: {
130
+ entitySet: targetEntitySet,
131
+ navigationProperty: navProperty
132
+ }
133
+ }
134
+ }
135
+ }
136
+ : {
137
+ changeType: 'appdescr_fe_addNewPage',
138
+ parameters: {
139
+ sourcePage: {
140
+ id: this.runtimeControl.getId(),
141
+ navigationSource: targetEntitySet
142
+ },
143
+ targetPage: {
144
+ type: 'Component',
145
+ id: `${targetEntitySet}ObjectPage`,
146
+ name: 'sap.fe.templates.ObjectPage',
147
+ routePattern: `${targetEntitySet}({key}):?query:`,
148
+ settings: {
149
+ contextPath: `/${targetEntitySet}`,
150
+ editableHeaderContent: false
151
+ }
152
+ }
153
+ }
154
+ };
155
+
156
+ const command = await CommandFactory.getCommandFor(
157
+ this.runtimeControl,
158
+ 'appDescriptor',
159
+ modifiedValue,
160
+ null,
161
+ flexSettings
162
+ );
163
+
164
+ await this.commandExecutor.pushAndExecuteCommand(command);
165
+ CommunicationService.sendAction(setApplicationRequiresReload(true));
166
+
167
+ this.handleDialogClose();
168
+ }
169
+
170
+ /**
171
+ * Builds data that is used in the dialog
172
+ */
173
+ async buildDialogData(): Promise<void> {
174
+ this.getControlMetadata(); // is called to fill this.runtimeControl
175
+
176
+ const pageTypeOptions: { key: string; value: string }[] = [
177
+ { key: 'ObjectPage', value: 'Object Page' },
178
+ { key: 'CustomPage', value: 'Custom Page' }
179
+ ];
180
+ this.model.setProperty('/pageTypeOptions', pageTypeOptions);
181
+ this.model.setProperty('/selectedPageType', pageTypeOptions[0]);
182
+
183
+ const navigationOptions: { key: string; value: string }[] = (
184
+ this.model.getProperty('/navigationData') as { navProperty: string; entitySet: string }[]
185
+ ).map((item) => {
186
+ const value =
187
+ item.entitySet === item.navProperty ? item.entitySet : `${item.entitySet} (${item.navProperty})`;
188
+ return { key: item.navProperty, value };
189
+ });
190
+ this.model.setProperty('/navigationOptions', navigationOptions);
191
+ this.model.setProperty('/selectedNavigation', navigationOptions[0]);
192
+
193
+ return Promise.resolve();
194
+ }
195
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- sap.ui.define(["sap/ui/core/Fragment", "../i18n", "./controllers/AddFragment.controller", "./controllers/AddTableColumnFragments.controller", "./controllers/ControllerExtension.controller", "./controllers/ExtensionPoint.controller", "./controllers/FileExistsDialog.controller"], function (Fragment, ___i18n, __AddFragment, __AddTableColumnFragments, __ControllerExtension, __ExtensionPoint, __FileExistsDialog) {
3
+ sap.ui.define(["sap/ui/core/Fragment", "../i18n", "./controllers/AddFragment.controller", "./controllers/AddTableColumnFragments.controller", "./controllers/ControllerExtension.controller", "./controllers/ExtensionPoint.controller", "./controllers/FileExistsDialog.controller", "./controllers/AddSubpage.controller"], function (Fragment, ___i18n, __AddFragment, __AddTableColumnFragments, __ControllerExtension, __ExtensionPoint, __FileExistsDialog, __AddSubpage) {
4
4
  "use strict";
5
5
 
6
6
  function _interopRequireDefault(obj) {
@@ -12,12 +12,14 @@ sap.ui.define(["sap/ui/core/Fragment", "../i18n", "./controllers/AddFragment.con
12
12
  const ControllerExtension = _interopRequireDefault(__ControllerExtension);
13
13
  const ExtensionPoint = _interopRequireDefault(__ExtensionPoint);
14
14
  const FileExistsDialog = _interopRequireDefault(__FileExistsDialog);
15
+ const AddSubpage = _interopRequireDefault(__AddSubpage);
15
16
  var DialogNames = /*#__PURE__*/function (DialogNames) {
16
17
  DialogNames["ADD_FRAGMENT"] = "AddFragment";
17
18
  DialogNames["ADD_TABLE_COLUMN_FRAGMENTS"] = "AddTableColumnFragments";
18
19
  DialogNames["CONTROLLER_EXTENSION"] = "ControllerExtension";
19
20
  DialogNames["ADD_FRAGMENT_AT_EXTENSION_POINT"] = "ExtensionPoint";
20
21
  DialogNames["FILE_EXISTS"] = "FileExistsDialog";
22
+ DialogNames["ADD_SUBPAGE"] = "AddSubpage";
21
23
  return DialogNames;
22
24
  }(DialogNames || {});
23
25
  const OPEN_DIALOG_STATUS_CHANGED = 'OPEN_DIALOG_STATUS_CHANGED';
@@ -77,6 +79,12 @@ sap.ui.define(["sap/ui/core/Fragment", "../i18n", "./controllers/AddFragment.con
77
79
  case DialogNames.FILE_EXISTS:
78
80
  controller = new FileExistsDialog(`open.ux.preview.client.adp.controllers.${dialogName}`, options);
79
81
  break;
82
+ case DialogNames.ADD_SUBPAGE:
83
+ controller = new AddSubpage(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta, {
84
+ ...options,
85
+ title: resources.getText(options.title ?? 'ADD_SUB_PAGE_DIALOG_TITLE')
86
+ });
87
+ break;
80
88
  }
81
89
  const id = dialogName === DialogNames.ADD_FRAGMENT_AT_EXTENSION_POINT ? `dialog--${dialogName}` : undefined;
82
90
  const dialog = await Fragment.load({
@@ -12,16 +12,24 @@ import ExtensionPoint from './controllers/ExtensionPoint.controller';
12
12
 
13
13
  import { ExtensionPointData } from './extension-point';
14
14
  import FileExistsDialog, { FileExistsDialogOptions } from './controllers/FileExistsDialog.controller';
15
+ import AddSubpage, { AddSubpageOptions } from './controllers/AddSubpage.controller';
15
16
 
16
17
  export const enum DialogNames {
17
18
  ADD_FRAGMENT = 'AddFragment',
18
19
  ADD_TABLE_COLUMN_FRAGMENTS = 'AddTableColumnFragments',
19
20
  CONTROLLER_EXTENSION = 'ControllerExtension',
20
21
  ADD_FRAGMENT_AT_EXTENSION_POINT = 'ExtensionPoint',
21
- FILE_EXISTS = 'FileExistsDialog'
22
+ FILE_EXISTS = 'FileExistsDialog',
23
+ ADD_SUBPAGE = 'AddSubpage'
22
24
  }
23
25
 
24
- type Controller = AddFragment | AddTableColumnFragments | ControllerExtension | ExtensionPoint | FileExistsDialog;
26
+ type Controller =
27
+ | AddFragment
28
+ | AddTableColumnFragments
29
+ | ControllerExtension
30
+ | ExtensionPoint
31
+ | FileExistsDialog
32
+ | AddSubpage;
25
33
 
26
34
  export const OPEN_DIALOG_STATUS_CHANGED = 'OPEN_DIALOG_STATUS_CHANGED';
27
35
 
@@ -50,7 +58,7 @@ export class DialogFactory {
50
58
  rta: RuntimeAuthoring,
51
59
  dialogName: DialogNames,
52
60
  extensionPointData?: ExtensionPointData,
53
- options: Partial<AddFragmentOptions> | Partial<FileExistsDialogOptions> = {}
61
+ options: Partial<AddFragmentOptions> | Partial<FileExistsDialogOptions> | AddSubpageOptions = {}
54
62
  ): Promise<void> {
55
63
  if (this.isDialogOpen) {
56
64
  return;
@@ -100,6 +108,12 @@ export class DialogFactory {
100
108
  options as FileExistsDialogOptions
101
109
  );
102
110
  break;
111
+ case DialogNames.ADD_SUBPAGE:
112
+ controller = new AddSubpage(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta, {
113
+ ...options,
114
+ title: resources.getText(options.title ?? 'ADD_SUB_PAGE_DIALOG_TITLE')
115
+ } as AddSubpageOptions);
116
+ break;
103
117
  }
104
118
 
105
119
  const id = dialogName === DialogNames.ADD_FRAGMENT_AT_EXTENSION_POINT ? `dialog--${dialogName}` : undefined;
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/ui/core/Component", "sap/ui/dt/OverlayRegistry", "../../../cpe/quick-actions/utils", "../../../utils/core", "../../../utils/application", "../../dialog-factory", "../fe-v2/utils", "../../../utils/fe-v2", "../../../utils/fe-v4", "../../../i18n", "../simple-quick-action-base", "../../../cpe/feature-service"], function (Component, OverlayRegistry, _____cpe_quick_actions_utils, _____utils_core, _____utils_application, ____dialog_factory, ___fe_v2_utils, _____utils_fe_v2, _____utils_fe_v4, _____i18n, ___simple_quick_action_base, _____cpe_feature_service) {
4
+ "use strict";
5
+
6
+ const pageHasControlId = _____cpe_quick_actions_utils["pageHasControlId"];
7
+ const getControlById = _____utils_core["getControlById"];
8
+ const isA = _____utils_core["isA"];
9
+ const getApplicationType = _____utils_application["getApplicationType"];
10
+ const DialogFactory = ____dialog_factory["DialogFactory"];
11
+ const DialogNames = ____dialog_factory["DialogNames"];
12
+ const areManifestChangesSupported = ___fe_v2_utils["areManifestChangesSupported"];
13
+ const getV2ApplicationPages = _____utils_fe_v2["getV2ApplicationPages"];
14
+ const getV4ApplicationPages = _____utils_fe_v4["getV4ApplicationPages"];
15
+ const getTextBundle = _____i18n["getTextBundle"];
16
+ const SimpleQuickActionDefinitionBase = ___simple_quick_action_base["SimpleQuickActionDefinitionBase"];
17
+ const FeatureService = _____cpe_feature_service["FeatureService"];
18
+ const ADD_NEW_OBJECT_PAGE_ACTION = 'add-new-subpage';
19
+ const CONTROL_TYPES = ['sap.f.DynamicPage', 'sap.uxap.ObjectPageLayout'];
20
+
21
+ /**
22
+ * Quick Action for adding a custom page action.
23
+ */
24
+ class AddNewSubpage extends SimpleQuickActionDefinitionBase {
25
+ currentPageDescriptor = {
26
+ entitySet: '',
27
+ pageType: '',
28
+ navProperties: []
29
+ };
30
+ constructor(context) {
31
+ super(ADD_NEW_OBJECT_PAGE_ACTION, [], 'QUICK_ACTION_ADD_NEW_SUB_PAGE', context, [{
32
+ run: async () => {
33
+ const i18n = await getTextBundle();
34
+ if (this.currentPageDescriptor.navProperties.length === 0) {
35
+ return {
36
+ type: 'error',
37
+ message: i18n.getText('NO_SUB_PAGES_TO_ADD')
38
+ };
39
+ }
40
+ return undefined;
41
+ }
42
+ }]);
43
+ }
44
+ getApplicationPages() {
45
+ if (this.appType === 'fe-v2') {
46
+ return getV2ApplicationPages(this.context.manifest);
47
+ } else if (this.appType === 'fe-v4') {
48
+ return getV4ApplicationPages(this.context.manifest);
49
+ }
50
+ return [];
51
+ }
52
+ prepareNavigationData(entityType, metaModel) {
53
+ const existingPages = this.getApplicationPages();
54
+ if (this.currentPageDescriptor.pageType === 'sap.suite.ui.generic.template.ObjectPage') {
55
+ // Navigation from Object Page
56
+ for (const navProp of entityType?.navigationProperty || []) {
57
+ const associationEnd = metaModel.getODataAssociationEnd(entityType, navProp.name);
58
+ if (associationEnd?.multiplicity !== '*') {
59
+ continue;
60
+ }
61
+ const entityContainer = metaModel.getODataEntityContainer();
62
+ if (!entityContainer?.entitySet?.length) {
63
+ continue;
64
+ }
65
+ const targetEntitySet = entityContainer.entitySet.find(item => item.entityType === associationEnd.type);
66
+ const pageExists = existingPages.some(page => page.entitySet === targetEntitySet?.name);
67
+ if (targetEntitySet && !pageExists) {
68
+ this.currentPageDescriptor.navProperties.push({
69
+ entitySet: targetEntitySet.name,
70
+ navProperty: navProp.name
71
+ });
72
+ }
73
+ }
74
+ return;
75
+ }
76
+
77
+ // navigation from LR or ALP (only OP based on current entitySet is possible)
78
+ const pageExists = existingPages.some(page => page.entitySet === this.currentPageDescriptor.entitySet);
79
+ if (!pageExists) {
80
+ this.currentPageDescriptor.navProperties.push({
81
+ entitySet: this.currentPageDescriptor.entitySet,
82
+ navProperty: this.currentPageDescriptor.entitySet
83
+ });
84
+ }
85
+ }
86
+ async initialize() {
87
+ if (FeatureService.isFeatureEnabled('cpe.beta.quick-actions') === false) {
88
+ return Promise.resolve();
89
+ }
90
+ if (!(await areManifestChangesSupported(this.context.manifest))) {
91
+ return Promise.resolve();
92
+ }
93
+ this.appType = getApplicationType(this.context.manifest);
94
+ const allControls = CONTROL_TYPES.flatMap(item => this.context.controlIndex[item] ?? []);
95
+ const control = allControls.find(c => pageHasControlId(this.context.view, c.controlId));
96
+ const pageType = this.context.view.getViewName().split('.view.')[0];
97
+ this.currentPageDescriptor.pageType = pageType;
98
+ const metaModel = this.context.rta.getRootControlInstance().getModel()?.getMetaModel();
99
+ if (!metaModel || !control) {
100
+ return Promise.resolve();
101
+ }
102
+ const modifiedControl = getControlById(control.controlId);
103
+ if (!modifiedControl) {
104
+ return Promise.resolve();
105
+ }
106
+ const component = Component.getOwnerComponentFor(modifiedControl);
107
+ if (!isA('sap.suite.ui.generic.template.lib.TemplateComponent', component)) {
108
+ return Promise.reject(new Error('Unexpected type of page owner component'));
109
+ }
110
+ const entitySetName = component.getEntitySet();
111
+ if (!entitySetName) {
112
+ return Promise.resolve();
113
+ }
114
+ this.currentPageDescriptor.entitySet = entitySetName;
115
+ const entitySet = metaModel.getODataEntitySet(entitySetName);
116
+ const entityType = metaModel.getODataEntityType(entitySet.entityType);
117
+ this.prepareNavigationData(entityType, metaModel);
118
+ this.control = modifiedControl;
119
+ return Promise.resolve();
120
+ }
121
+ async execute() {
122
+ const overlay = OverlayRegistry.getOverlay(this.control);
123
+ const appReference = this.context.flexSettings.projectId;
124
+ await DialogFactory.createDialog(overlay, this.context.rta, DialogNames.ADD_SUBPAGE, undefined, {
125
+ appType: this.appType,
126
+ appReference,
127
+ title: 'ADD_SUB_PAGE_DIALOG_TITLE',
128
+ pageDescriptor: this.currentPageDescriptor
129
+ });
130
+ return [];
131
+ }
132
+ }
133
+ var __exports = {
134
+ __esModule: true
135
+ };
136
+ __exports.ADD_NEW_OBJECT_PAGE_ACTION = ADD_NEW_OBJECT_PAGE_ACTION;
137
+ __exports.AddNewSubpage = AddNewSubpage;
138
+ return __exports;
139
+ });
140
+ //# sourceMappingURL=add-new-subpage.js.map
@@ -0,0 +1,164 @@
1
+ import Component from 'sap/ui/core/Component';
2
+ import FlexCommand from 'sap/ui/rta/command/FlexCommand';
3
+ import ObjectPageLayout from 'sap/uxap/ObjectPageLayout';
4
+ import ODataModel from 'sap/ui/model/odata/v2/ODataModel';
5
+ import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
6
+ import TemplateComponent from 'sap/suite/ui/generic/template/lib/TemplateComponent';
7
+
8
+ import { QuickActionContext, SimpleQuickActionDefinition } from '../../../cpe/quick-actions/quick-action-definition';
9
+ import { pageHasControlId } from '../../../cpe/quick-actions/utils';
10
+ import { getControlById, isA } from '../../../utils/core';
11
+ import ODataMetaModel, { EntityContainer, EntitySet, EntityType } from 'sap/ui/model/odata/ODataMetaModel';
12
+ import { ApplicationType, getApplicationType } from '../../../utils/application';
13
+ import { DialogFactory, DialogNames } from '../../dialog-factory';
14
+ import { areManifestChangesSupported } from '../fe-v2/utils';
15
+ import { getV2ApplicationPages } from '../../../utils/fe-v2';
16
+ import { getV4ApplicationPages } from '../../../utils/fe-v4';
17
+ import { EnablementValidatorResult } from '../enablement-validator';
18
+ import { getTextBundle } from '../../../i18n';
19
+ import { SimpleQuickActionDefinitionBase } from '../simple-quick-action-base';
20
+ import { FeatureService } from '../../../cpe/feature-service';
21
+
22
+ export const ADD_NEW_OBJECT_PAGE_ACTION = 'add-new-subpage';
23
+ const CONTROL_TYPES = ['sap.f.DynamicPage', 'sap.uxap.ObjectPageLayout'];
24
+
25
+ /**
26
+ * Quick Action for adding a custom page action.
27
+ */
28
+ export class AddNewSubpage extends SimpleQuickActionDefinitionBase implements SimpleQuickActionDefinition {
29
+ private readonly currentPageDescriptor: {
30
+ pageType: string;
31
+ entitySet: string;
32
+ navProperties: { navProperty: string; entitySet: string }[]; // only navProperty with 1:n relationship and the entitySet
33
+ } = {
34
+ entitySet: '',
35
+ pageType: '',
36
+ navProperties: []
37
+ };
38
+
39
+ private appType: ApplicationType;
40
+
41
+ constructor(context: QuickActionContext) {
42
+ super(ADD_NEW_OBJECT_PAGE_ACTION, [], 'QUICK_ACTION_ADD_NEW_SUB_PAGE', context, [
43
+ {
44
+ run: async (): Promise<EnablementValidatorResult> => {
45
+ const i18n = await getTextBundle();
46
+ if (this.currentPageDescriptor.navProperties.length === 0) {
47
+ return {
48
+ type: 'error',
49
+ message: i18n.getText('NO_SUB_PAGES_TO_ADD')
50
+ };
51
+ }
52
+ return undefined;
53
+ }
54
+ }
55
+ ]);
56
+ }
57
+
58
+ private getApplicationPages() {
59
+ if (this.appType === 'fe-v2') {
60
+ return getV2ApplicationPages(this.context.manifest);
61
+ } else if (this.appType === 'fe-v4') {
62
+ return getV4ApplicationPages(this.context.manifest);
63
+ }
64
+ return [];
65
+ }
66
+
67
+ private prepareNavigationData(entityType: EntityType, metaModel: ODataMetaModel): void {
68
+ const existingPages = this.getApplicationPages();
69
+ if (this.currentPageDescriptor.pageType === 'sap.suite.ui.generic.template.ObjectPage') {
70
+ // Navigation from Object Page
71
+ for (const navProp of entityType?.navigationProperty || []) {
72
+ const associationEnd = metaModel.getODataAssociationEnd(entityType, navProp.name);
73
+ if (associationEnd?.multiplicity !== '*') {
74
+ continue;
75
+ }
76
+ const entityContainer = metaModel.getODataEntityContainer() as EntityContainer;
77
+ if (!entityContainer?.entitySet?.length) {
78
+ continue;
79
+ }
80
+ const targetEntitySet = entityContainer.entitySet.find(
81
+ (item) => item.entityType === associationEnd.type
82
+ );
83
+ const pageExists = existingPages.some((page) => page.entitySet === targetEntitySet?.name);
84
+ if (targetEntitySet && !pageExists) {
85
+ this.currentPageDescriptor.navProperties.push({
86
+ entitySet: targetEntitySet.name,
87
+ navProperty: navProp.name
88
+ });
89
+ }
90
+ }
91
+ return;
92
+ }
93
+
94
+ // navigation from LR or ALP (only OP based on current entitySet is possible)
95
+ const pageExists = existingPages.some((page) => page.entitySet === this.currentPageDescriptor.entitySet);
96
+ if (!pageExists) {
97
+ this.currentPageDescriptor.navProperties.push({
98
+ entitySet: this.currentPageDescriptor.entitySet,
99
+ navProperty: this.currentPageDescriptor.entitySet
100
+ });
101
+ }
102
+ }
103
+
104
+ async initialize(): Promise<void> {
105
+ if (FeatureService.isFeatureEnabled('cpe.beta.quick-actions') === false) {
106
+ return Promise.resolve();
107
+ }
108
+
109
+ if (!(await areManifestChangesSupported(this.context.manifest))) {
110
+ return Promise.resolve();
111
+ }
112
+
113
+ this.appType = getApplicationType(this.context.manifest);
114
+
115
+ const allControls = CONTROL_TYPES.flatMap((item) => this.context.controlIndex[item] ?? []);
116
+ const control = allControls.find((c) => pageHasControlId(this.context.view, c.controlId));
117
+
118
+ const pageType = this.context.view.getViewName().split('.view.')[0];
119
+ this.currentPageDescriptor.pageType = pageType;
120
+
121
+ const metaModel = (this.context.rta.getRootControlInstance().getModel() as ODataModel)?.getMetaModel();
122
+ if (!metaModel || !control) {
123
+ return Promise.resolve();
124
+ }
125
+
126
+ const modifiedControl = getControlById<ObjectPageLayout>(control.controlId);
127
+ if (!modifiedControl) {
128
+ return Promise.resolve();
129
+ }
130
+
131
+ const component = Component.getOwnerComponentFor(modifiedControl);
132
+ if (!isA<TemplateComponent>('sap.suite.ui.generic.template.lib.TemplateComponent', component)) {
133
+ return Promise.reject(new Error('Unexpected type of page owner component'));
134
+ }
135
+
136
+ const entitySetName = component.getEntitySet();
137
+ if (!entitySetName) {
138
+ return Promise.resolve();
139
+ }
140
+
141
+ this.currentPageDescriptor.entitySet = entitySetName;
142
+
143
+ const entitySet = metaModel.getODataEntitySet(entitySetName) as EntitySet;
144
+ const entityType = metaModel.getODataEntityType(entitySet.entityType) as EntityType;
145
+
146
+ this.prepareNavigationData(entityType, metaModel);
147
+
148
+ this.control = modifiedControl;
149
+
150
+ return Promise.resolve();
151
+ }
152
+
153
+ async execute(): Promise<FlexCommand[]> {
154
+ const overlay = OverlayRegistry.getOverlay(this.control!);
155
+ const appReference = this.context.flexSettings.projectId;
156
+ await DialogFactory.createDialog(overlay, this.context.rta, DialogNames.ADD_SUBPAGE, undefined, {
157
+ appType: this.appType,
158
+ appReference,
159
+ title: 'ADD_SUB_PAGE_DIALOG_TITLE',
160
+ pageDescriptor: this.currentPageDescriptor
161
+ });
162
+ return [];
163
+ }
164
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- sap.ui.define(["sap/ui/core/mvc/XMLView", "sap/ui/core/ComponentContainer", "../../../cpe/quick-actions/registry", "../common/add-controller-to-page", "./lr-toggle-clear-filter-bar", "./change-table-columns", "../common/op-add-header-field", "../common/op-add-custom-section", "../fe-v2/create-table-action", "./create-table-custom-column", "../common/create-page-action", "./lr-enable-table-filtering", "./lr-enable-semantic-date-range-filter-bar", "./op-enable-empty-row-mode", "../common/add-new-annotation-file", "./op-enable-variant-management", "./lr-enable-variant-management"], function (XMLView, ComponentContainer, _____cpe_quick_actions_registry, ___common_add_controller_to_page, ___lr_toggle_clear_filter_bar, ___change_table_columns, ___common_op_add_header_field, ___common_op_add_custom_section, ___fe_v2_create_table_action, ___create_table_custom_column, ___common_create_page_action, ___lr_enable_table_filtering, ___lr_enable_semantic_date_range_filter_bar, ___op_enable_empty_row_mode, ___common_add_new_annotation_file, ___op_enable_variant_management, ___lr_enable_variant_management) {
3
+ sap.ui.define(["sap/ui/core/mvc/XMLView", "sap/ui/core/ComponentContainer", "../../../cpe/quick-actions/registry", "../common/add-controller-to-page", "./lr-toggle-clear-filter-bar", "./change-table-columns", "../common/op-add-header-field", "../common/op-add-custom-section", "../fe-v2/create-table-action", "./create-table-custom-column", "../common/create-page-action", "./lr-enable-table-filtering", "./lr-enable-semantic-date-range-filter-bar", "./op-enable-empty-row-mode", "../common/add-new-annotation-file", "./op-enable-variant-management", "./lr-enable-variant-management", "../common/add-new-subpage"], function (XMLView, ComponentContainer, _____cpe_quick_actions_registry, ___common_add_controller_to_page, ___lr_toggle_clear_filter_bar, ___change_table_columns, ___common_op_add_header_field, ___common_op_add_custom_section, ___fe_v2_create_table_action, ___create_table_custom_column, ___common_create_page_action, ___lr_enable_table_filtering, ___lr_enable_semantic_date_range_filter_bar, ___op_enable_empty_row_mode, ___common_add_new_annotation_file, ___op_enable_variant_management, ___lr_enable_variant_management, ___common_add_new_subpage) {
4
4
  "use strict";
5
5
 
6
6
  const QuickActionDefinitionRegistry = _____cpe_quick_actions_registry["QuickActionDefinitionRegistry"];
@@ -18,6 +18,7 @@ sap.ui.define(["sap/ui/core/mvc/XMLView", "sap/ui/core/ComponentContainer", "../
18
18
  const AddNewAnnotationFile = ___common_add_new_annotation_file["AddNewAnnotationFile"];
19
19
  const EnableObjectPageVariantManagementQuickAction = ___op_enable_variant_management["EnableObjectPageVariantManagementQuickAction"];
20
20
  const EnableListReportVariantManagementQuickAction = ___lr_enable_variant_management["EnableListReportVariantManagementQuickAction"];
21
+ const AddNewSubpage = ___common_add_new_subpage["AddNewSubpage"];
21
22
  const OBJECT_PAGE_TYPE = 'sap.suite.ui.generic.template.ObjectPage.view.Details';
22
23
  const LIST_REPORT_TYPE = 'sap.suite.ui.generic.template.ListReport.view.ListReport';
23
24
  const ANALYTICAL_LIST_PAGE_TYPE = 'sap.suite.ui.generic.template.AnalyticalListPage.view.AnalyticalListPage';
@@ -41,21 +42,21 @@ sap.ui.define(["sap/ui/core/mvc/XMLView", "sap/ui/core/ComponentContainer", "../
41
42
  if (name === 'listReport') {
42
43
  definitionGroups.push({
43
44
  title: 'LIST REPORT',
44
- definitions: [AddControllerToPageQuickAction, AddPageActionQuickAction, ToggleClearFilterBarQuickAction, ToggleSemanticDateRangeFilterBar, EnableListReportVariantManagementQuickAction, ChangeTableColumnsQuickAction, AddTableActionQuickAction, AddTableCustomColumnQuickAction, EnableTableFilteringQuickAction, AddNewAnnotationFile],
45
+ definitions: [AddControllerToPageQuickAction, AddPageActionQuickAction, ToggleClearFilterBarQuickAction, ToggleSemanticDateRangeFilterBar, EnableListReportVariantManagementQuickAction, ChangeTableColumnsQuickAction, AddTableActionQuickAction, AddTableCustomColumnQuickAction, EnableTableFilteringQuickAction, AddNewAnnotationFile, AddNewSubpage],
45
46
  view,
46
47
  key: name + index
47
48
  });
48
49
  } else if (name === 'objectPage') {
49
50
  definitionGroups.push({
50
51
  title: 'OBJECT PAGE',
51
- definitions: [AddControllerToPageQuickAction, AddPageActionQuickAction, AddHeaderFieldQuickAction, AddCustomSectionQuickAction, EnableObjectPageVariantManagementQuickAction, ChangeTableColumnsQuickAction, AddTableActionQuickAction, AddTableCustomColumnQuickAction, EnableTableEmptyRowModeQuickAction, AddNewAnnotationFile],
52
+ definitions: [AddControllerToPageQuickAction, AddPageActionQuickAction, AddHeaderFieldQuickAction, AddCustomSectionQuickAction, EnableObjectPageVariantManagementQuickAction, ChangeTableColumnsQuickAction, AddTableActionQuickAction, AddTableCustomColumnQuickAction, EnableTableEmptyRowModeQuickAction, AddNewAnnotationFile, AddNewSubpage],
52
53
  view,
53
54
  key: name + index
54
55
  });
55
56
  } else if (name === 'analyticalListPage') {
56
57
  definitionGroups.push({
57
58
  title: 'ANALYTICAL LIST PAGE',
58
- definitions: [AddControllerToPageQuickAction, AddPageActionQuickAction, ToggleClearFilterBarQuickAction, ToggleSemanticDateRangeFilterBar, EnableListReportVariantManagementQuickAction, ChangeTableColumnsQuickAction, AddTableActionQuickAction, AddTableCustomColumnQuickAction, EnableTableFilteringQuickAction, AddNewAnnotationFile],
59
+ definitions: [AddControllerToPageQuickAction, AddPageActionQuickAction, ToggleClearFilterBarQuickAction, ToggleSemanticDateRangeFilterBar, EnableListReportVariantManagementQuickAction, ChangeTableColumnsQuickAction, AddTableActionQuickAction, AddTableCustomColumnQuickAction, EnableTableFilteringQuickAction, AddNewAnnotationFile, AddNewSubpage],
59
60
  view,
60
61
  key: name + index
61
62
  });
@@ -23,6 +23,7 @@ import { EnableTableEmptyRowModeQuickAction } from './op-enable-empty-row-mode';
23
23
  import { AddNewAnnotationFile } from '../common/add-new-annotation-file';
24
24
  import { EnableObjectPageVariantManagementQuickAction } from './op-enable-variant-management';
25
25
  import { EnableListReportVariantManagementQuickAction } from './lr-enable-variant-management';
26
+ import { AddNewSubpage } from '../common/add-new-subpage';
26
27
  type PageName = 'listReport' | 'objectPage' | 'analyticalListPage';
27
28
 
28
29
  const OBJECT_PAGE_TYPE = 'sap.suite.ui.generic.template.ObjectPage.view.Details';
@@ -56,7 +57,8 @@ export default class FEV2QuickActionRegistry extends QuickActionDefinitionRegist
56
57
  AddTableActionQuickAction,
57
58
  AddTableCustomColumnQuickAction,
58
59
  EnableTableFilteringQuickAction,
59
- AddNewAnnotationFile
60
+ AddNewAnnotationFile,
61
+ AddNewSubpage
60
62
  ],
61
63
  view,
62
64
  key: name + index
@@ -74,7 +76,8 @@ export default class FEV2QuickActionRegistry extends QuickActionDefinitionRegist
74
76
  AddTableActionQuickAction,
75
77
  AddTableCustomColumnQuickAction,
76
78
  EnableTableEmptyRowModeQuickAction,
77
- AddNewAnnotationFile
79
+ AddNewAnnotationFile,
80
+ AddNewSubpage
78
81
  ],
79
82
  view,
80
83
  key: name + index
@@ -92,7 +95,8 @@ export default class FEV2QuickActionRegistry extends QuickActionDefinitionRegist
92
95
  AddTableActionQuickAction,
93
96
  AddTableCustomColumnQuickAction,
94
97
  EnableTableFilteringQuickAction,
95
- AddNewAnnotationFile
98
+ AddNewAnnotationFile,
99
+ AddNewSubpage
96
100
  ],
97
101
  view,
98
102
  key: name + index
@@ -0,0 +1,73 @@
1
+ <Dialog
2
+ id="addSubpageDialog"
3
+ xmlns="sap.m"
4
+ xmlns:core="sap.ui.core"
5
+ xmlns:l="sap.ui.layout"
6
+ xmlns:f="sap.ui.layout.form"
7
+ title="{/title}"
8
+ contentWidth="500px"
9
+ initialFocus="aggregationName"
10
+ class="sapUiRTABorder"
11
+ >
12
+ <content>
13
+ <f:SimpleForm
14
+ id="addSubpageDialog_Form"
15
+ editable="true"
16
+ layout="ResponsiveGridLayout"
17
+ labelSpanS="4"
18
+ singleContainerFullSize="false"
19
+ >
20
+ <f:content>
21
+ <Label text="{i18n>ADP_ADD_SUB_PAGE_DIALOG_PAGE_TYPE_LABEL}" />
22
+ <Select
23
+ id="pageType"
24
+ change="onPageTypeChange"
25
+ selectedKey="{/selectedPageType/key}"
26
+ editable="false"
27
+ items="{
28
+ path: '/pageTypeOptions',
29
+ sorter: { path: 'text' }
30
+ }"
31
+ >
32
+ <core:Item
33
+ key="{key}"
34
+ text="{value}"
35
+ />
36
+ </Select>
37
+ <Label text="{i18n>ADP_ADD_SUB_PAGE_DIALOG_NAVIGATION_LABEL}" />
38
+ <Select
39
+ id="navigation"
40
+ visible="true"
41
+ change="onNavigationChange"
42
+ selectedKey="{/selectedNavigation/key}"
43
+ items="{
44
+ path: '/navigationOptions',
45
+ sorter: { path: 'text' }
46
+ }"
47
+ >
48
+ <core:Item
49
+ key="{key}"
50
+ text="{value}"
51
+ />
52
+ </Select>
53
+ </f:content>
54
+ </f:SimpleForm>
55
+ </content>
56
+ <beginButton>
57
+ <Button
58
+ id="createDialogBtn"
59
+ text="{i18n>CREATE_BUTTON_LABEL}"
60
+ press="onCreateBtnPress"
61
+ enabled="true"
62
+ type="Emphasized"
63
+ />
64
+ </beginButton>
65
+ <endButton>
66
+ <Button
67
+ id="closeDialogBtn"
68
+ text="{i18n>CANCEL_BUTTON_LABEL}"
69
+ press="handleDialogClose"
70
+ type="Reject"
71
+ />
72
+ </endButton>
73
+ </Dialog>
@@ -1,3 +1,4 @@
1
+ CREATE_BUTTON_LABEL=Create
1
2
  CANCEL_BUTTON_LABEL=Cancel
2
3
 
3
4
  QUICK_ACTION_ADD_PAGE_CONTROLLER=Add Controller to Page
@@ -13,6 +14,7 @@ QUICK_ACTION_ENABLE_TABLE_FILTERING=Enable Table Filtering for Page Variants
13
14
  QUICK_ACTION_ENABLE_TABLE_EMPTY_ROW_MODE=Enable Empty Row Mode for Tables
14
15
  QUICK_ACTION_ENABLE_TABLES_AND_CHARTS_VARIANT_MANAGEMENT=Enable Variant Management in Tables and Charts
15
16
  QUICK_ACTION_ENABLE_TABLES_AND_VARIANT_MANAGEMENT=Enable Variant Management in Tables
17
+ QUICK_ACTION_ADD_NEW_SUB_PAGE=Add Subpage
16
18
 
17
19
  V2_QUICK_ACTION_CHANGE_TABLE_COLUMNS=Change Table Columns
18
20
  V2_QUICK_ACTION_LR_ENABLE_CLEAR_FILTER_BAR=Enable "Clear" Button in Filter Bar
@@ -31,6 +33,8 @@ ADP_ADD_FRAGMENT_DIALOG_INDEX_LABEL = Index
31
33
  ADP_ADD_FRAGMENT_DIALOG_FRAGMENT_NAME_LABEL = Fragment Name
32
34
  ADP_ADD_FRAGMENT_DIALOG_COLUMN_FRAGMENT_NAME_LABEL = Column Fragment Name
33
35
  ADP_ADD_FRAGMENT_DIALOG_CELL_FRAGMENT_NAME_LABEL = Cell Fragment Name
36
+ ADP_ADD_SUB_PAGE_DIALOG_PAGE_TYPE_LABEL = Page Type
37
+ ADP_ADD_SUB_PAGE_DIALOG_NAVIGATION_LABEL = Navigation
34
38
  ADP_ADD_FRAGMENT_NOTIFICATION = Note: The "{0}.fragment.xml" fragment will be created once you save the change.
35
39
  ADP_ADD_FRAGMENT_WITH_TEMPLATE_NOTIFICATION = Note: The "{0}.fragment.xml" fragment will be created once you save the changes.
36
40
  ADP_ADD_TWO_FRAGMENTS_WITH_TEMPLATE_NOTIFICATION = Note: The "{0}.fragment.xml" and "{1}.fragment.xml" fragments will be created once you save the changes.
@@ -64,3 +68,5 @@ INVALID_BINDING_STRING_FORMAT=Invalid binding string. Supported value pattern is
64
68
  INVALID_BINDING_MODEL=Invalid binding model.
65
69
  INVALID_BINDING_MODEL_KEY=Invalid key in the binding string. Supported value pattern is {i18n>YOUR_KEY}. Check if the key already exists in i18n.properties.If not, add the key in the i18n.properties file and reload the editor for the new key to take effect.
66
70
 
71
+ NO_SUB_PAGES_TO_ADD=This option has been disabled because there are no subpages to add
72
+ ADD_SUB_PAGE_DIALOG_TITLE=Add Subpage
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ sap.ui.define([], function () {
4
+ "use strict";
5
+
6
+ const OBJECT_PAGE_COMPONENT_NAME = 'sap.suite.ui.generic.template.ObjectPage';
7
+
8
+ /**
9
+ * Returns application object page definitions found in manifest
10
+ *
11
+ * @param manifest - manifest object
12
+ * @returns array with page descriptors
13
+ */
14
+ function getV2ApplicationPages(manifest) {
15
+ // do we need to distinguish both navigation source and target entitySets to differentiate alternative routes?
16
+ const rootEntry = manifest['sap.ui.generic.app'] || manifest['sap.ovp'];
17
+ if (rootEntry) {
18
+ const result = [];
19
+ const collectPageData = (pagesDefinitions, idPrefix) => {
20
+ if (!pagesDefinitions) {
21
+ return;
22
+ }
23
+ if (Array.isArray(pagesDefinitions)) {
24
+ pagesDefinitions.forEach((entry, idx) => {
25
+ const id = `${idPrefix}-${idx}`;
26
+ if (entry.component.name === OBJECT_PAGE_COMPONENT_NAME) {
27
+ result.push({
28
+ id,
29
+ entitySet: entry.entitySet
30
+ });
31
+ }
32
+ collectPageData(entry.pages, id);
33
+ });
34
+ } else {
35
+ const pageIds = Object.keys(pagesDefinitions);
36
+ for (const pageId of pageIds) {
37
+ if (pagesDefinitions[pageId].component.name === OBJECT_PAGE_COMPONENT_NAME) {
38
+ result.push({
39
+ id: pageId,
40
+ entitySet: pagesDefinitions[pageId].entitySet
41
+ });
42
+ }
43
+ collectPageData(pagesDefinitions[pageId].pages, idPrefix);
44
+ }
45
+ }
46
+ };
47
+ collectPageData(rootEntry.pages, 'page');
48
+ return result;
49
+ }
50
+ return [];
51
+ }
52
+ var __exports = {
53
+ __esModule: true
54
+ };
55
+ __exports.getV2ApplicationPages = getV2ApplicationPages;
56
+ return __exports;
57
+ });
58
+ //# sourceMappingURL=fe-v2.js.map
@@ -0,0 +1,63 @@
1
+ import type { Manifest } from 'sap/ui/rta/RuntimeAuthoring';
2
+
3
+ interface V2ManifestPageDefinition {
4
+ component: {
5
+ name: string;
6
+ };
7
+ entitySet: string;
8
+ pages?: Record<string, V2ManifestPageDefinition> | Array<V2ManifestPageDefinition>;
9
+ }
10
+
11
+ const OBJECT_PAGE_COMPONENT_NAME = 'sap.suite.ui.generic.template.ObjectPage';
12
+
13
+ /**
14
+ * Returns application object page definitions found in manifest
15
+ *
16
+ * @param manifest - manifest object
17
+ * @returns array with page descriptors
18
+ */
19
+ export function getV2ApplicationPages(manifest: Manifest): { id: string; entitySet: string | undefined }[] {
20
+ // do we need to distinguish both navigation source and target entitySets to differentiate alternative routes?
21
+ const rootEntry = manifest['sap.ui.generic.app'] || manifest['sap.ovp'];
22
+ if (rootEntry) {
23
+ const result: { id: string; entitySet: string | undefined }[] = [];
24
+
25
+ const collectPageData = <
26
+ T extends Record<string, V2ManifestPageDefinition> | Array<V2ManifestPageDefinition>
27
+ >(
28
+ pagesDefinitions: T | undefined,
29
+ idPrefix: string
30
+ ) => {
31
+ if (!pagesDefinitions) {
32
+ return;
33
+ }
34
+
35
+ if (Array.isArray(pagesDefinitions)) {
36
+ pagesDefinitions.forEach((entry, idx) => {
37
+ const id = `${idPrefix}-${idx}`;
38
+ if (entry.component.name === OBJECT_PAGE_COMPONENT_NAME) {
39
+ result.push({
40
+ id,
41
+ entitySet: entry.entitySet
42
+ });
43
+ }
44
+ collectPageData(entry.pages, id);
45
+ });
46
+ } else {
47
+ const pageIds = Object.keys(pagesDefinitions);
48
+ for (const pageId of pageIds) {
49
+ if (pagesDefinitions[pageId].component.name === OBJECT_PAGE_COMPONENT_NAME) {
50
+ result.push({
51
+ id: pageId,
52
+ entitySet: pagesDefinitions[pageId].entitySet
53
+ });
54
+ }
55
+ collectPageData(pagesDefinitions[pageId].pages, idPrefix);
56
+ }
57
+ }
58
+ };
59
+ collectPageData(rootEntry.pages, 'page');
60
+ return result;
61
+ }
62
+ return [];
63
+ }
@@ -106,6 +106,28 @@ sap.ui.define(["sap/ui/core/Component", "./core", "sap/ui/rta/command/CommandFac
106
106
  const command = await CommandFactory.getCommandFor(modifiedControl, 'appDescriptor', modifiedValue, null, flexSettings);
107
107
  return command;
108
108
  }
109
+
110
+ /**
111
+ * Returns application object page definitions found in manifest
112
+ *
113
+ * @param manifest - manifest object
114
+ * @returns array with page descriptors
115
+ */
116
+ function getV4ApplicationPages(manifest) {
117
+ if (manifest['sap.ui5']?.routing?.targets) {
118
+ const targets = manifest['sap.ui5'].routing?.targets ?? {};
119
+ const result = Object.keys(targets).map(key => {
120
+ const entitySet = targets[key].options?.settings?.entitySet;
121
+ const id = targets[key].id;
122
+ return {
123
+ id,
124
+ entitySet
125
+ };
126
+ });
127
+ return result;
128
+ }
129
+ return [];
130
+ }
109
131
  var __exports = {
110
132
  __esModule: true
111
133
  };
@@ -115,6 +137,7 @@ sap.ui.define(["sap/ui/core/Component", "./core", "sap/ui/rta/command/CommandFac
115
137
  __exports.getPageName = getPageName;
116
138
  __exports.getConfigMapControlIdMap = getConfigMapControlIdMap;
117
139
  __exports.createManifestPropertyChange = createManifestPropertyChange;
140
+ __exports.getV4ApplicationPages = getV4ApplicationPages;
118
141
  return __exports;
119
142
  });
120
143
  //# sourceMappingURL=fe-v4.js.map
@@ -131,3 +131,22 @@ export async function createManifestPropertyChange(
131
131
 
132
132
  return command;
133
133
  }
134
+
135
+ /**
136
+ * Returns application object page definitions found in manifest
137
+ *
138
+ * @param manifest - manifest object
139
+ * @returns array with page descriptors
140
+ */
141
+ export function getV4ApplicationPages(manifest: Manifest): { id: string; entitySet: string | undefined }[] {
142
+ if (manifest['sap.ui5']?.routing?.targets) {
143
+ const targets = manifest['sap.ui5'].routing?.targets ?? {};
144
+ const result = Object.keys(targets).map((key) => {
145
+ const entitySet = targets[key].options?.settings?.entitySet;
146
+ const id = targets[key].id;
147
+ return { id, entitySet };
148
+ });
149
+ return result;
150
+ }
151
+ return [];
152
+ }
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "bugs": {
10
10
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Apreview-middleware"
11
11
  },
12
- "version": "0.18.18",
12
+ "version": "0.18.19",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -28,10 +28,10 @@
28
28
  "@sap-ux/adp-tooling": "0.13.14",
29
29
  "@sap-ux/btp-utils": "1.0.2",
30
30
  "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.6.1",
31
- "@sap-ux/feature-toggle": "0.2.3",
32
31
  "@sap-ux/logger": "0.6.0",
33
- "@sap-ux/system-access": "0.5.33",
34
- "@sap-ux/project-access": "1.29.16"
32
+ "@sap-ux/feature-toggle": "0.2.3",
33
+ "@sap-ux/project-access": "1.29.16",
34
+ "@sap-ux/system-access": "0.5.33"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@sap-ux-private/playwright": "0.1.0",
@@ -49,11 +49,11 @@
49
49
  "nock": "13.4.0",
50
50
  "npm-run-all2": "6.2.0",
51
51
  "supertest": "6.3.3",
52
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.13.4",
53
52
  "@sap-ux/axios-extension": "1.19.1",
53
+ "@sap-ux/store": "1.0.0",
54
54
  "@sap-ux/i18n": "0.2.3",
55
55
  "@sap-ux/ui5-info": "0.9.1",
56
- "@sap-ux/store": "1.0.0"
56
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.13.5"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "express": "4"