@sap-ux/preview-middleware 0.19.7 → 0.19.8

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.
@@ -6,8 +6,9 @@ sap.ui.define([
6
6
  './BaseDialog.controller',
7
7
  'sap/ui/rta/command/CommandFactory',
8
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) {
9
+ 'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
10
+ '../quick-actions/fe-v4/utils'
11
+ ], function (JSONModel, ____i18n, __CommandExecutor, __BaseDialog, CommandFactory, ____cpe_communication_service, ___sap_ux_private_control_property_editor_common, ___quick_actions_fe_v4_utils) {
11
12
  'use strict';
12
13
  function _interopRequireDefault(obj) {
13
14
  return obj && obj.__esModule && typeof obj.default !== 'undefined' ? obj.default : obj;
@@ -17,6 +18,7 @@ sap.ui.define([
17
18
  const BaseDialog = _interopRequireDefault(__BaseDialog);
18
19
  const CommunicationService = ____cpe_communication_service['CommunicationService'];
19
20
  const setApplicationRequiresReload = ___sap_ux_private_control_property_editor_common['setApplicationRequiresReload'];
21
+ const generateRoutePattern = ___quick_actions_fe_v4_utils['generateRoutePattern'];
20
22
  const AddSubpage = BaseDialog.extend('open.ux.preview.client.adp.controllers.AddSubpage', {
21
23
  constructor: function _constructor(name, overlays, rta, options, telemetryData) {
22
24
  BaseDialog.prototype.constructor.call(this, name, telemetryData);
@@ -24,12 +26,8 @@ sap.ui.define([
24
26
  this.rta = rta;
25
27
  this.overlays = overlays;
26
28
  this.model = new JSONModel({
27
- appType: options.appType,
28
- appReference: options.appReference,
29
- pageType: options.pageDescriptor.pageType,
30
29
  title: options.title,
31
- navigationData: options.pageDescriptor.navProperties,
32
- currentEntitySet: options.pageDescriptor.entitySet
30
+ navigationData: options.navProperties
33
31
  });
34
32
  this.commandExecutor = new CommandExecutor(this.rta);
35
33
  },
@@ -57,43 +55,54 @@ sap.ui.define([
57
55
  const navProperty = this.model.getProperty('/selectedNavigation/key');
58
56
  const navigation = this.model.getProperty('/navigationData').find(item => item.navProperty = navProperty);
59
57
  const targetEntitySet = navigation?.entitySet ?? '';
60
- const appType = this.model.getProperty('/appType');
61
- const pageType = this.model.getProperty('/pageType');
62
- const modifiedValue = appType === 'fe-v2' ? {
63
- changeType: 'appdescr_ui_generic_app_addNewObjectPage',
64
- reference: this.model.getProperty('/appReference'),
65
- parameters: {
66
- parentPage: {
67
- component: pageType,
68
- entitySet: this.model.getProperty('/currentEntitySet')
69
- },
70
- childPage: {
71
- id: `ObjectPage|${ navProperty }`,
72
- definition: {
73
- entitySet: targetEntitySet,
74
- navigationProperty: navProperty
58
+ const pageDescriptor = this.options.pageDescriptor;
59
+ let modifiedValue;
60
+ if (pageDescriptor.appType === 'fe-v2') {
61
+ modifiedValue = {
62
+ appComponent: pageDescriptor.appComponent,
63
+ changeType: 'appdescr_ui_generic_app_addNewObjectPage',
64
+ reference: this.options.appReference,
65
+ parameters: {
66
+ parentPage: {
67
+ component: pageDescriptor.pageType,
68
+ entitySet: pageDescriptor.entitySet
69
+ },
70
+ childPage: {
71
+ id: `ObjectPage|${ navProperty }`,
72
+ definition: {
73
+ entitySet: targetEntitySet,
74
+ navigationProperty: navProperty
75
+ }
75
76
  }
76
77
  }
77
- }
78
- } : {
79
- changeType: 'appdescr_fe_addNewPage',
80
- parameters: {
81
- sourcePage: {
82
- id: this.runtimeControl.getId(),
83
- navigationSource: targetEntitySet
84
- },
85
- targetPage: {
86
- type: 'Component',
87
- id: `${ targetEntitySet }ObjectPage`,
88
- name: 'sap.fe.templates.ObjectPage',
89
- routePattern: `${ targetEntitySet }({key}):?query:`,
90
- settings: {
91
- contextPath: `/${ targetEntitySet }`,
92
- editableHeaderContent: false
78
+ };
79
+ } else {
80
+ const routePattern = generateRoutePattern(pageDescriptor.routePattern, navProperty, targetEntitySet);
81
+ modifiedValue = {
82
+ appComponent: pageDescriptor.appComponent,
83
+ changeType: 'appdescr_fe_addNewPage',
84
+ reference: this.options.appReference,
85
+ parameters: {
86
+ sourcePage: {
87
+ id: pageDescriptor.pageId,
88
+ navigationSource: navProperty
89
+ },
90
+ targetPage: {
91
+ type: 'Component',
92
+ id: `${ targetEntitySet }ObjectPage`,
93
+ name: 'sap.fe.templates.ObjectPage',
94
+ routePattern,
95
+ settings: {
96
+ contextPath: `/${ targetEntitySet }`,
97
+ editableHeaderContent: false,
98
+ entitySet: targetEntitySet,
99
+ pageLayout: '',
100
+ controlConfiguration: {}
101
+ }
93
102
  }
94
103
  }
95
- }
96
- };
104
+ };
105
+ }
97
106
  const command = await CommandFactory.getCommandFor(this.runtimeControl, 'appDescriptor', modifiedValue, null, flexSettings);
98
107
  await this.commandExecutor.pushAndExecuteCommand(command);
99
108
  CommunicationService.sendAction(setApplicationRequiresReload(true));
@@ -15,6 +15,12 @@ import JSONModel from 'sap/ui/model/json/JSONModel';
15
15
  /** sap.ui.rta */
16
16
  import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
17
17
 
18
+ /** sap.fe.core */
19
+ import type AppComponentV4 from 'sap/fe/core/AppComponent';
20
+
21
+ /** sap.suite.ui.generic */
22
+ import type AppComponentV2 from 'sap/suite/ui/generic/template/lib/AppComponent';
23
+
18
24
  import { getResourceModel } from '../../i18n';
19
25
 
20
26
  import CommandExecutor from '../command-executor';
@@ -22,35 +28,41 @@ import CommandExecutor from '../command-executor';
22
28
  import BaseDialog from './BaseDialog.controller';
23
29
 
24
30
  import CommandFactory from 'sap/ui/rta/command/CommandFactory';
25
- import { ApplicationType } from '../../utils/application';
26
31
  import { CommunicationService } from '../../cpe/communication-service';
27
32
  import { setApplicationRequiresReload } from '@sap-ux-private/control-property-editor-common';
33
+ import { generateRoutePattern } from '../quick-actions/fe-v4/utils';
28
34
  import { QuickActionTelemetryData } from '../../cpe/quick-actions/quick-action-definition';
29
35
 
30
36
  type SubpageType = 'ObjectPage' | 'CustomPage';
31
37
 
38
+ export interface PageDescriptorV2 {
39
+ appType: 'fe-v2';
40
+ appComponent: AppComponentV2;
41
+ entitySet: string;
42
+ pageType: string;
43
+ }
44
+
45
+ export interface PageDescriptorV4 {
46
+ appType: 'fe-v4';
47
+ appComponent: AppComponentV4;
48
+ pageId: string;
49
+ routePattern: string;
50
+ }
51
+
52
+ export interface AddSubpageOptions {
53
+ appReference: string;
54
+ title: string;
55
+ navProperties: { navProperty: string; entitySet: string }[];
56
+ pageDescriptor: PageDescriptorV2 | PageDescriptorV4;
57
+ }
58
+
32
59
  export type AddSubpageModel = JSONModel & {
33
- getProperty(sPath: '/appType'): ApplicationType;
34
- getProperty(sPath: '/pageType'): string;
35
- getProperty(sPath: '/appReference'): string;
36
- getProperty(sPath: '/currentEntitySet'): string;
37
60
  getProperty(sPath: '/title'): string;
38
61
  getProperty(sPath: '/navigationData'): { navProperty: string; entitySet: string }[];
39
62
  getProperty(sPath: '/selectedPageType/key'): SubpageType;
40
63
  getProperty(sPath: '/selectedNavigation/key'): string;
41
64
  };
42
65
 
43
- export interface AddSubpageOptions {
44
- appType: ApplicationType;
45
- appReference: string;
46
- title: string;
47
- pageDescriptor: {
48
- pageType: string;
49
- entitySet: string;
50
- navProperties: { navProperty: string; entitySet: string }[];
51
- };
52
- }
53
-
54
66
  /**
55
67
  * @namespace open.ux.preview.client.adp.controllers
56
68
  */
@@ -66,12 +78,8 @@ export default class AddSubpage extends BaseDialog<AddSubpageModel> {
66
78
  this.rta = rta;
67
79
  this.overlays = overlays;
68
80
  this.model = new JSONModel({
69
- appType: options.appType,
70
- appReference: options.appReference,
71
- pageType: options.pageDescriptor.pageType,
72
81
  title: options.title,
73
- navigationData: options.pageDescriptor.navProperties,
74
- currentEntitySet: options.pageDescriptor.entitySet
82
+ navigationData: options.navProperties
75
83
  });
76
84
  this.commandExecutor = new CommandExecutor(this.rta);
77
85
  }
@@ -119,47 +127,56 @@ export default class AddSubpage extends BaseDialog<AddSubpageModel> {
119
127
  const navProperty = this.model.getProperty('/selectedNavigation/key');
120
128
  const navigation = this.model.getProperty('/navigationData').find((item) => (item.navProperty = navProperty));
121
129
  const targetEntitySet = navigation?.entitySet ?? '';
122
- const appType = this.model.getProperty('/appType');
123
- const pageType = this.model.getProperty('/pageType');
124
-
125
- const modifiedValue =
126
- appType === 'fe-v2'
127
- ? {
128
- changeType: 'appdescr_ui_generic_app_addNewObjectPage',
129
- reference: this.model.getProperty('/appReference'),
130
- parameters: {
131
- parentPage: {
132
- component: pageType,
133
- entitySet: this.model.getProperty('/currentEntitySet')
134
- },
135
- childPage: {
136
- id: `ObjectPage|${navProperty}`,
137
- definition: {
138
- entitySet: targetEntitySet,
139
- navigationProperty: navProperty
140
- }
141
- }
142
- }
143
- }
144
- : {
145
- changeType: 'appdescr_fe_addNewPage',
146
- parameters: {
147
- sourcePage: {
148
- id: this.runtimeControl.getId(),
149
- navigationSource: targetEntitySet
150
- },
151
- targetPage: {
152
- type: 'Component',
153
- id: `${targetEntitySet}ObjectPage`,
154
- name: 'sap.fe.templates.ObjectPage',
155
- routePattern: `${targetEntitySet}({key}):?query:`,
156
- settings: {
157
- contextPath: `/${targetEntitySet}`,
158
- editableHeaderContent: false
159
- }
160
- }
161
- }
162
- };
130
+
131
+ const pageDescriptor = this.options.pageDescriptor;
132
+
133
+ let modifiedValue;
134
+ if (pageDescriptor.appType === 'fe-v2') {
135
+ modifiedValue = {
136
+ appComponent: pageDescriptor.appComponent,
137
+ changeType: 'appdescr_ui_generic_app_addNewObjectPage',
138
+ reference: this.options.appReference,
139
+ parameters: {
140
+ parentPage: {
141
+ component: pageDescriptor.pageType,
142
+ entitySet: pageDescriptor.entitySet
143
+ },
144
+ childPage: {
145
+ id: `ObjectPage|${navProperty}`,
146
+ definition: {
147
+ entitySet: targetEntitySet,
148
+ navigationProperty: navProperty
149
+ }
150
+ }
151
+ }
152
+ };
153
+ } else {
154
+ const routePattern = generateRoutePattern(pageDescriptor.routePattern, navProperty, targetEntitySet);
155
+ modifiedValue = {
156
+ appComponent: pageDescriptor.appComponent,
157
+ changeType: 'appdescr_fe_addNewPage',
158
+ reference: this.options.appReference,
159
+ parameters: {
160
+ sourcePage: {
161
+ id: pageDescriptor.pageId,
162
+ navigationSource: navProperty
163
+ },
164
+ targetPage: {
165
+ type: 'Component',
166
+ id: `${targetEntitySet}ObjectPage`,
167
+ name: 'sap.fe.templates.ObjectPage',
168
+ routePattern,
169
+ settings: {
170
+ contextPath: `/${targetEntitySet}`,
171
+ editableHeaderContent: false,
172
+ entitySet: targetEntitySet,
173
+ pageLayout: '',
174
+ controlConfiguration: {}
175
+ }
176
+ }
177
+ }
178
+ };
179
+ }
163
180
 
164
181
  const command = await CommandFactory.getCommandFor(
165
182
  this.runtimeControl,
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/ui/core/Component", "sap/ui/dt/OverlayRegistry", "../../cpe/quick-actions/utils", "../../utils/core", "../dialog-factory", "../../i18n", "./simple-quick-action-base", "./dialog-enablement-validator"], function (Component, OverlayRegistry, ____cpe_quick_actions_utils, ____utils_core, ___dialog_factory, ____i18n, ___simple_quick_action_base, ___dialog_enablement_validator) {
4
+ "use strict";
5
+
6
+ const pageHasControlId = ____cpe_quick_actions_utils["pageHasControlId"];
7
+ const getControlById = ____utils_core["getControlById"];
8
+ const DialogFactory = ___dialog_factory["DialogFactory"];
9
+ const DialogNames = ___dialog_factory["DialogNames"];
10
+ const getTextBundle = ____i18n["getTextBundle"];
11
+ const SimpleQuickActionDefinitionBase = ___simple_quick_action_base["SimpleQuickActionDefinitionBase"];
12
+ const DIALOG_ENABLEMENT_VALIDATOR = ___dialog_enablement_validator["DIALOG_ENABLEMENT_VALIDATOR"];
13
+ const ADD_NEW_OBJECT_PAGE_ACTION = 'add-new-subpage';
14
+ const CONTROL_TYPES = ['sap.f.DynamicPage', 'sap.uxap.ObjectPageLayout'];
15
+ /**
16
+ * Base Quick Action class for adding a custom page action.
17
+ */
18
+ class AddNewSubpageBase extends SimpleQuickActionDefinitionBase {
19
+ constructor(context) {
20
+ super(ADD_NEW_OBJECT_PAGE_ACTION, [], 'QUICK_ACTION_ADD_NEW_SUB_PAGE', context, [{
21
+ run: async () => {
22
+ const i18n = await getTextBundle();
23
+ if (this.navProperties.length === 0) {
24
+ return {
25
+ type: 'error',
26
+ message: i18n.getText('NO_SUB_PAGES_TO_ADD')
27
+ };
28
+ }
29
+ return undefined;
30
+ }
31
+ }, DIALOG_ENABLEMENT_VALIDATOR]);
32
+ this.appReference = context.flexSettings.projectId ?? '';
33
+ this.existingPages = this.getApplicationPages();
34
+ }
35
+ async addNavigationOptionIfAvailable(metaModel, targetEntitySet, navProperty) {
36
+ if (!targetEntitySet) {
37
+ return;
38
+ }
39
+ const pageExists = await this.isPageExists(targetEntitySet, metaModel);
40
+ if (!pageExists) {
41
+ this.navProperties.push({
42
+ entitySet: targetEntitySet,
43
+ navProperty: navProperty ?? targetEntitySet
44
+ });
45
+ }
46
+ }
47
+ async initialize() {
48
+ if (!this.appReference) {
49
+ throw new Error('App reference not defined');
50
+ }
51
+ const allControls = CONTROL_TYPES.flatMap(item => this.context.controlIndex[item] ?? []);
52
+ const control = allControls.find(c => pageHasControlId(this.context.view, c.controlId));
53
+ this.pageType = this.context.view.getViewName().split('.view.')[0];
54
+ const metaModel = this.getODataMetaModel();
55
+ if (!metaModel || !control) {
56
+ return Promise.resolve();
57
+ }
58
+ const modifiedControl = getControlById(control.controlId);
59
+ if (!modifiedControl) {
60
+ return Promise.resolve();
61
+ }
62
+ const component = Component.getOwnerComponentFor(modifiedControl);
63
+ const entitySetName = this.getEntitySetNameFromPageComponent(component);
64
+ if (!entitySetName) {
65
+ return Promise.resolve();
66
+ }
67
+ this.entitySet = entitySetName;
68
+ this.navProperties = [];
69
+ if (!this.isCurrentObjectPage()) {
70
+ await this.addNavigationOptionIfAvailable(metaModel, this.entitySet);
71
+ } else {
72
+ await this.prepareNavigationData(entitySetName, metaModel);
73
+ }
74
+ this.control = modifiedControl;
75
+ return Promise.resolve();
76
+ }
77
+ async execute() {
78
+ const overlay = OverlayRegistry.getOverlay(this.control);
79
+ await DialogFactory.createDialog(overlay, this.context.rta, DialogNames.ADD_SUBPAGE, undefined, {
80
+ appReference: this.appReference,
81
+ navProperties: this.navProperties,
82
+ title: 'ADD_SUB_PAGE_DIALOG_TITLE',
83
+ pageDescriptor: this.currentPageDescriptor
84
+ }, {
85
+ actionName: this.type,
86
+ telemetryEventIdentifier: this.getTelemetryIdentifier()
87
+ });
88
+ return [];
89
+ }
90
+ }
91
+ var __exports = {
92
+ __esModule: true
93
+ };
94
+ __exports.ADD_NEW_OBJECT_PAGE_ACTION = ADD_NEW_OBJECT_PAGE_ACTION;
95
+ __exports.AddNewSubpageBase = AddNewSubpageBase;
96
+ return __exports;
97
+ });
98
+ //# sourceMappingURL=add-new-subpage-quick-action-base.js.map
@@ -0,0 +1,138 @@
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 OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
5
+
6
+ import { QuickActionContext, SimpleQuickActionDefinition } from '../../cpe/quick-actions/quick-action-definition';
7
+ import { pageHasControlId } from '../../cpe/quick-actions/utils';
8
+ import { getControlById } from '../../utils/core';
9
+ import { DialogFactory, DialogNames } from '../dialog-factory';
10
+ import { EnablementValidatorResult } from './enablement-validator';
11
+ import { getTextBundle } from '../../i18n';
12
+ import { SimpleQuickActionDefinitionBase } from './simple-quick-action-base';
13
+ import { DIALOG_ENABLEMENT_VALIDATOR } from './dialog-enablement-validator';
14
+ import { PageDescriptorV2, PageDescriptorV4 } from '../controllers/AddSubpage.controller';
15
+
16
+ export const ADD_NEW_OBJECT_PAGE_ACTION = 'add-new-subpage';
17
+ const CONTROL_TYPES = ['sap.f.DynamicPage', 'sap.uxap.ObjectPageLayout'];
18
+
19
+ export interface ApplicationPageData {
20
+ id: string;
21
+ entitySet?: string;
22
+ contextPath?: string;
23
+ }
24
+
25
+ /**
26
+ * Base Quick Action class for adding a custom page action.
27
+ */
28
+ export abstract class AddNewSubpageBase<ODataMetaModelType>
29
+ extends SimpleQuickActionDefinitionBase
30
+ implements SimpleQuickActionDefinition
31
+ {
32
+ protected appReference: string;
33
+ protected abstract readonly currentPageDescriptor: PageDescriptorV2 | PageDescriptorV4;
34
+ protected entitySet: string | undefined;
35
+ protected navProperties: { navProperty: string; entitySet: string }[];
36
+ protected existingPages: ApplicationPageData[];
37
+ protected pageType: string | undefined;
38
+
39
+ constructor(context: QuickActionContext) {
40
+ super(ADD_NEW_OBJECT_PAGE_ACTION, [], 'QUICK_ACTION_ADD_NEW_SUB_PAGE', context, [
41
+ {
42
+ run: async (): Promise<EnablementValidatorResult> => {
43
+ const i18n = await getTextBundle();
44
+ if (this.navProperties.length === 0) {
45
+ return {
46
+ type: 'error',
47
+ message: i18n.getText('NO_SUB_PAGES_TO_ADD')
48
+ };
49
+ }
50
+ return undefined;
51
+ }
52
+ },
53
+ DIALOG_ENABLEMENT_VALIDATOR
54
+ ]);
55
+
56
+ this.appReference = context.flexSettings.projectId ?? '';
57
+ this.existingPages = this.getApplicationPages();
58
+ }
59
+
60
+ protected abstract getApplicationPages(): ApplicationPageData[];
61
+ protected abstract isPageExists(targetEntitySet: string, metaModel: ODataMetaModelType): boolean | Promise<boolean>;
62
+ protected abstract isCurrentObjectPage(): boolean;
63
+ protected abstract getEntitySetNameFromPageComponent(component: Component | undefined): string;
64
+ protected abstract prepareNavigationData(entitySetName: string, metaModel: ODataMetaModelType): Promise<void>;
65
+ protected abstract getODataMetaModel(): ODataMetaModelType | undefined;
66
+
67
+ protected async addNavigationOptionIfAvailable(
68
+ metaModel: ODataMetaModelType,
69
+ targetEntitySet?: string,
70
+ navProperty?: string
71
+ ) {
72
+ if (!targetEntitySet) {
73
+ return;
74
+ }
75
+ const pageExists = await this.isPageExists(targetEntitySet, metaModel);
76
+ if (!pageExists) {
77
+ this.navProperties.push({
78
+ entitySet: targetEntitySet,
79
+ navProperty: navProperty ?? targetEntitySet
80
+ });
81
+ }
82
+ }
83
+
84
+ async initialize(): Promise<void> {
85
+ if (!this.appReference) {
86
+ throw new Error('App reference not defined');
87
+ }
88
+ const allControls = CONTROL_TYPES.flatMap((item) => this.context.controlIndex[item] ?? []);
89
+ const control = allControls.find((c) => pageHasControlId(this.context.view, c.controlId));
90
+
91
+ this.pageType = this.context.view.getViewName().split('.view.')[0];
92
+
93
+ const metaModel = this.getODataMetaModel();
94
+ if (!metaModel || !control) {
95
+ return Promise.resolve();
96
+ }
97
+
98
+ const modifiedControl = getControlById<ObjectPageLayout>(control.controlId);
99
+ if (!modifiedControl) {
100
+ return Promise.resolve();
101
+ }
102
+
103
+ const component = Component.getOwnerComponentFor(modifiedControl);
104
+ const entitySetName = this.getEntitySetNameFromPageComponent(component);
105
+ if (!entitySetName) {
106
+ return Promise.resolve();
107
+ }
108
+ this.entitySet = entitySetName;
109
+
110
+ this.navProperties = [];
111
+ if (!this.isCurrentObjectPage()) {
112
+ await this.addNavigationOptionIfAvailable(metaModel, this.entitySet);
113
+ } else {
114
+ await this.prepareNavigationData(entitySetName, metaModel);
115
+ }
116
+ this.control = modifiedControl;
117
+
118
+ return Promise.resolve();
119
+ }
120
+
121
+ async execute(): Promise<FlexCommand[]> {
122
+ const overlay = OverlayRegistry.getOverlay(this.control!);
123
+ await DialogFactory.createDialog(
124
+ overlay,
125
+ this.context.rta,
126
+ DialogNames.ADD_SUBPAGE,
127
+ undefined,
128
+ {
129
+ appReference: this.appReference,
130
+ navProperties: this.navProperties,
131
+ title: 'ADD_SUB_PAGE_DIALOG_TITLE',
132
+ pageDescriptor: this.currentPageDescriptor
133
+ },
134
+ { actionName: this.type, telemetryEventIdentifier: this.getTelemetryIdentifier() }
135
+ );
136
+ return [];
137
+ }
138
+ }
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ sap.ui.define(["../../../utils/fe-v2", "../add-new-subpage-quick-action-base", "../../../utils/core", "./utils"], function (_____utils_fe_v2, ___add_new_subpage_quick_action_base, _____utils_core, ___utils) {
4
+ "use strict";
5
+
6
+ const getV2ApplicationPages = _____utils_fe_v2["getV2ApplicationPages"];
7
+ const AddNewSubpageBase = ___add_new_subpage_quick_action_base["AddNewSubpageBase"];
8
+ const isA = _____utils_core["isA"];
9
+ const areManifestChangesSupported = ___utils["areManifestChangesSupported"];
10
+ const getV2AppComponent = ___utils["getV2AppComponent"];
11
+ const OBJECT_PAGE_COMPONENT_NAME_V2 = 'sap.suite.ui.generic.template.ObjectPage';
12
+
13
+ /**
14
+ * Quick Action for adding a custom page action.
15
+ */
16
+ class AddNewSubpage extends AddNewSubpageBase {
17
+ get currentPageDescriptor() {
18
+ if (!this.entitySet) {
19
+ throw new Error('entitySet is not defined');
20
+ }
21
+ if (!this.pageType) {
22
+ throw new Error('pageType is not defined');
23
+ }
24
+ if (!this.appComponent) {
25
+ throw new Error('appComponent is not defined');
26
+ }
27
+ return {
28
+ appType: 'fe-v2',
29
+ appComponent: this.appComponent,
30
+ entitySet: this.entitySet,
31
+ pageType: this.pageType
32
+ };
33
+ }
34
+ getApplicationPages() {
35
+ return getV2ApplicationPages(this.context.manifest);
36
+ }
37
+ isPageExists(targetEntitySet) {
38
+ return this.existingPages.some(page => page.entitySet === targetEntitySet);
39
+ }
40
+ isCurrentObjectPage() {
41
+ return this.pageType === OBJECT_PAGE_COMPONENT_NAME_V2;
42
+ }
43
+ getODataMetaModel() {
44
+ return this.context.rta.getRootControlInstance().getModel()?.getMetaModel();
45
+ }
46
+ getEntitySetNameFromPageComponent(component) {
47
+ if (!isA('sap.suite.ui.generic.template.lib.TemplateComponent', component)) {
48
+ throw new Error('Unexpected type of page owner component');
49
+ }
50
+ return component.getEntitySet();
51
+ }
52
+ async prepareNavigationData(entitySetName, metaModel) {
53
+ const entitySet = metaModel.getODataEntitySet(entitySetName);
54
+ const entityType = metaModel.getODataEntityType(entitySet.entityType);
55
+ for (const navProp of entityType?.navigationProperty || []) {
56
+ const associationEnd = metaModel.getODataAssociationEnd(entityType, navProp.name);
57
+ if (associationEnd?.multiplicity !== '*') {
58
+ continue;
59
+ }
60
+ const entityContainer = metaModel.getODataEntityContainer();
61
+ if (!entityContainer?.entitySet?.length) {
62
+ continue;
63
+ }
64
+ const targetEntitySet = entityContainer.entitySet.find(item => item.entityType === associationEnd.type);
65
+ await this.addNavigationOptionIfAvailable(metaModel, targetEntitySet?.name, navProp.name);
66
+ }
67
+ return Promise.resolve();
68
+ }
69
+ async initialize() {
70
+ if (!(await areManifestChangesSupported(this.context.manifest))) {
71
+ return Promise.resolve();
72
+ }
73
+ this.appComponent = getV2AppComponent(this.context.view);
74
+ return super.initialize();
75
+ }
76
+ }
77
+ var __exports = {
78
+ __esModule: true
79
+ };
80
+ __exports.AddNewSubpage = AddNewSubpage;
81
+ return __exports;
82
+ });
83
+ //# sourceMappingURL=add-new-subpage.js.map