@sap-ux/preview-middleware 0.19.7 → 0.19.9

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 (38) hide show
  1. package/dist/client/adp/controllers/AddSubpage.controller.js +49 -40
  2. package/dist/client/adp/controllers/AddSubpage.controller.ts +79 -62
  3. package/dist/client/adp/init-dialogs.js +52 -21
  4. package/dist/client/adp/init-dialogs.ts +53 -21
  5. package/dist/client/adp/init.js +1 -1
  6. package/dist/client/adp/init.ts +2 -1
  7. package/dist/client/adp/quick-actions/add-new-subpage-quick-action-base.js +98 -0
  8. package/dist/client/adp/quick-actions/add-new-subpage-quick-action-base.ts +138 -0
  9. package/dist/client/adp/quick-actions/common/add-controller-to-page.js +4 -2
  10. package/dist/client/adp/quick-actions/common/add-controller-to-page.ts +5 -8
  11. package/dist/client/adp/quick-actions/fe-v2/add-new-subpage.js +83 -0
  12. package/dist/client/adp/quick-actions/fe-v2/add-new-subpage.ts +88 -0
  13. package/dist/client/adp/quick-actions/fe-v2/registry.js +2 -2
  14. package/dist/client/adp/quick-actions/fe-v2/registry.ts +1 -1
  15. package/dist/client/adp/quick-actions/fe-v4/add-new-subpage.js +132 -0
  16. package/dist/client/adp/quick-actions/fe-v4/add-new-subpage.ts +170 -0
  17. package/dist/client/adp/quick-actions/fe-v4/registry.js +4 -3
  18. package/dist/client/adp/quick-actions/fe-v4/registry.ts +5 -2
  19. package/dist/client/adp/quick-actions/fe-v4/utils.js +25 -0
  20. package/dist/client/adp/quick-actions/fe-v4/utils.ts +29 -0
  21. package/dist/client/adp/quick-actions/supported-ui5versions.md +34 -33
  22. package/dist/client/adp/utils.js +59 -1
  23. package/dist/client/adp/utils.ts +65 -0
  24. package/dist/client/cpe/outline/nodes.js +5 -24
  25. package/dist/client/cpe/outline/nodes.ts +2 -29
  26. package/dist/client/cpe/outline/service.js +3 -23
  27. package/dist/client/cpe/outline/service.ts +6 -25
  28. package/dist/client/cpe/types.ts +1 -0
  29. package/dist/client/cpe/utils.js +1 -28
  30. package/dist/client/cpe/utils.ts +1 -27
  31. package/dist/client/flp/initRta.js +2 -2
  32. package/dist/client/flp/initRta.ts +7 -6
  33. package/dist/client/messagebundle.properties +7 -4
  34. package/dist/client/utils/fe-v4.js +11 -12
  35. package/dist/client/utils/fe-v4.ts +12 -10
  36. package/package.json +7 -7
  37. package/dist/client/adp/quick-actions/common/add-new-subpage.js +0 -140
  38. package/dist/client/adp/quick-actions/common/add-new-subpage.ts +0 -168
@@ -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
+ }
@@ -6,6 +6,7 @@ sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../../utils/version", "../../uti
6
6
  const getUi5Version = _____utils_version["getUi5Version"];
7
7
  const getAllSyncViewsIds = ____utils["getAllSyncViewsIds"];
8
8
  const getControllerInfoForControl = ____utils["getControllerInfoForControl"];
9
+ const getReuseComponentChecker = ____utils["getReuseComponentChecker"];
9
10
  const getRelevantControlFromActivePage = _____cpe_quick_actions_utils["getRelevantControlFromActivePage"];
10
11
  const DialogFactory = ____dialog_factory["DialogFactory"];
11
12
  const DialogNames = ____dialog_factory["DialogNames"];
@@ -25,13 +26,14 @@ sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../../utils/version", "../../uti
25
26
  }
26
27
  controllerExists = false;
27
28
  async initialize() {
29
+ const version = await getUi5Version();
30
+ const isReuseComponent = await getReuseComponentChecker(version);
28
31
  for (const control of getRelevantControlFromActivePage(this.context.controlIndex, this.context.view, CONTROL_TYPES)) {
29
- const version = await getUi5Version();
30
32
  const syncViewsIds = await getAllSyncViewsIds(version);
31
33
  const controlInfo = getControllerInfoForControl(control);
32
34
  const data = await getExistingController(controlInfo.controllerName);
33
35
  this.controllerExists = data?.controllerExists;
34
- const isActiveAction = isControllerExtensionEnabledForControl(control, syncViewsIds, version, this.context.flexSettings.isCloud);
36
+ const isActiveAction = isControllerExtensionEnabledForControl(control, syncViewsIds, isReuseComponent, this.context.flexSettings.isCloud);
35
37
  this.control = isActiveAction ? control : undefined;
36
38
  break;
37
39
  }
@@ -2,7 +2,7 @@ import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
2
2
  import FlexCommand from 'sap/ui/rta/command/FlexCommand';
3
3
 
4
4
  import { getUi5Version } from '../../../utils/version';
5
- import { getAllSyncViewsIds, getControllerInfoForControl } from '../../utils';
5
+ import { getAllSyncViewsIds, getControllerInfoForControl, getReuseComponentChecker } from '../../utils';
6
6
  import { getRelevantControlFromActivePage } from '../../../cpe/quick-actions/utils';
7
7
  import type {
8
8
  QuickActionContext,
@@ -31,22 +31,19 @@ export class AddControllerToPageQuickAction
31
31
  private controllerExists = false;
32
32
 
33
33
  async initialize(): Promise<void> {
34
+ const version = await getUi5Version();
35
+ const isReuseComponent = await getReuseComponentChecker(version);
36
+
34
37
  for (const control of getRelevantControlFromActivePage(
35
38
  this.context.controlIndex,
36
39
  this.context.view,
37
40
  CONTROL_TYPES
38
41
  )) {
39
- const version = await getUi5Version();
40
42
  const syncViewsIds = await getAllSyncViewsIds(version);
41
43
  const controlInfo = getControllerInfoForControl(control);
42
44
  const data = await getExistingController(controlInfo.controllerName);
43
45
  this.controllerExists = data?.controllerExists;
44
- const isActiveAction = isControllerExtensionEnabledForControl(
45
- control,
46
- syncViewsIds,
47
- version,
48
- this.context.flexSettings.isCloud
49
- );
46
+ const isActiveAction = isControllerExtensionEnabledForControl(control, syncViewsIds, isReuseComponent, this.context.flexSettings.isCloud);
50
47
  this.control = isActiveAction ? control : undefined;
51
48
  break;
52
49
  }
@@ -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
@@ -0,0 +1,88 @@
1
+ import ODataModelV2 from 'sap/ui/model/odata/v2/ODataModel';
2
+ import ODataMetaModelV2, { EntityContainer, EntitySet, EntityType } from 'sap/ui/model/odata/ODataMetaModel';
3
+ import TemplateComponent from 'sap/suite/ui/generic/template/lib/TemplateComponent';
4
+ import type AppComponent from 'sap/suite/ui/generic/template/lib/AppComponent';
5
+
6
+ import { getV2ApplicationPages } from '../../../utils/fe-v2';
7
+ import { AddNewSubpageBase, ApplicationPageData } from '../add-new-subpage-quick-action-base';
8
+ import Component from 'sap/ui/core/Component';
9
+ import { isA } from '../../../utils/core';
10
+ import { areManifestChangesSupported, getV2AppComponent } from './utils';
11
+ import { PageDescriptorV2 } from '../../controllers/AddSubpage.controller';
12
+
13
+ const OBJECT_PAGE_COMPONENT_NAME_V2 = 'sap.suite.ui.generic.template.ObjectPage';
14
+
15
+ /**
16
+ * Quick Action for adding a custom page action.
17
+ */
18
+ export class AddNewSubpage extends AddNewSubpageBase<ODataMetaModelV2> {
19
+ protected appComponent: AppComponent | undefined;
20
+
21
+ protected get currentPageDescriptor(): PageDescriptorV2 {
22
+ if (!this.entitySet) {
23
+ throw new Error('entitySet is not defined');
24
+ }
25
+ if (!this.pageType) {
26
+ throw new Error('pageType is not defined');
27
+ }
28
+ if (!this.appComponent) {
29
+ throw new Error('appComponent is not defined');
30
+ }
31
+ return {
32
+ appType: 'fe-v2',
33
+ appComponent: this.appComponent,
34
+ entitySet: this.entitySet,
35
+ pageType: this.pageType
36
+ };
37
+ }
38
+
39
+ protected getApplicationPages(): ApplicationPageData[] {
40
+ return getV2ApplicationPages(this.context.manifest);
41
+ }
42
+
43
+ protected isPageExists(targetEntitySet: string): boolean {
44
+ return this.existingPages.some((page) => page.entitySet === targetEntitySet);
45
+ }
46
+
47
+ protected isCurrentObjectPage(): boolean {
48
+ return this.pageType === OBJECT_PAGE_COMPONENT_NAME_V2;
49
+ }
50
+
51
+ protected getODataMetaModel(): ODataMetaModelV2 | undefined {
52
+ return (this.context.rta.getRootControlInstance().getModel() as ODataModelV2)?.getMetaModel();
53
+ }
54
+
55
+ protected getEntitySetNameFromPageComponent(component: Component | undefined): string {
56
+ if (!isA<TemplateComponent>('sap.suite.ui.generic.template.lib.TemplateComponent', component)) {
57
+ throw new Error('Unexpected type of page owner component');
58
+ }
59
+ return component.getEntitySet();
60
+ }
61
+
62
+ protected async prepareNavigationData(entitySetName: string, metaModel: ODataMetaModelV2): Promise<void> {
63
+ const entitySet = metaModel.getODataEntitySet(entitySetName) as EntitySet;
64
+ const entityType = metaModel.getODataEntityType(entitySet.entityType) as EntityType;
65
+
66
+ for (const navProp of entityType?.navigationProperty || []) {
67
+ const associationEnd = metaModel.getODataAssociationEnd(entityType, navProp.name);
68
+ if (associationEnd?.multiplicity !== '*') {
69
+ continue;
70
+ }
71
+ const entityContainer = metaModel.getODataEntityContainer() as EntityContainer;
72
+ if (!entityContainer?.entitySet?.length) {
73
+ continue;
74
+ }
75
+ const targetEntitySet = entityContainer.entitySet.find((item) => item.entityType === associationEnd.type);
76
+ await this.addNavigationOptionIfAvailable(metaModel, targetEntitySet?.name, navProp.name);
77
+ }
78
+ return Promise.resolve();
79
+ }
80
+
81
+ async initialize(): Promise<void> {
82
+ if (!(await areManifestChangesSupported(this.context.manifest))) {
83
+ return Promise.resolve();
84
+ }
85
+ this.appComponent = getV2AppComponent(this.context.view);
86
+ return super.initialize();
87
+ }
88
+ }
@@ -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", "../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) {
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", "../fe-v2/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, ___fe_v2_add_new_subpage) {
4
4
  "use strict";
5
5
 
6
6
  const QuickActionDefinitionRegistry = _____cpe_quick_actions_registry["QuickActionDefinitionRegistry"];
@@ -18,7 +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
+ const AddNewSubpage = ___fe_v2_add_new_subpage["AddNewSubpage"];
22
22
  const OBJECT_PAGE_TYPE = 'sap.suite.ui.generic.template.ObjectPage.view.Details';
23
23
  const LIST_REPORT_TYPE = 'sap.suite.ui.generic.template.ListReport.view.ListReport';
24
24
  const ANALYTICAL_LIST_PAGE_TYPE = 'sap.suite.ui.generic.template.AnalyticalListPage.view.AnalyticalListPage';
@@ -23,7 +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
+ import { AddNewSubpage } from '../fe-v2/add-new-subpage';
27
27
  type PageName = 'listReport' | 'objectPage' | 'analyticalListPage';
28
28
 
29
29
  const OBJECT_PAGE_TYPE = 'sap.suite.ui.generic.template.ObjectPage.view.Details';
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+
3
+ sap.ui.define(["../../../utils/fe-v4", "../add-new-subpage-quick-action-base", "../../../utils/core", "../../../utils/version"], function (_____utils_fe_v4, ___add_new_subpage_quick_action_base, _____utils_core, _____utils_version) {
4
+ "use strict";
5
+
6
+ const getV4AppComponent = _____utils_fe_v4["getV4AppComponent"];
7
+ const getV4ApplicationPages = _____utils_fe_v4["getV4ApplicationPages"];
8
+ const AddNewSubpageBase = ___add_new_subpage_quick_action_base["AddNewSubpageBase"];
9
+ const isA = _____utils_core["isA"];
10
+ const getUi5Version = _____utils_version["getUi5Version"];
11
+ const isLowerThanMinimalUi5Version = _____utils_version["isLowerThanMinimalUi5Version"];
12
+ const OBJECT_PAGE_COMPONENT_NAME_V4 = 'sap.fe.templates.ObjectPage.ObjectPage';
13
+ /**
14
+ * Quick Action for adding a custom page action.
15
+ */
16
+ class AddNewSubpage extends AddNewSubpageBase {
17
+ get currentPageDescriptor() {
18
+ if (!this.pageId) {
19
+ throw new Error('pageId is not defined');
20
+ }
21
+ if (!this.routePattern) {
22
+ throw new Error('routePattern is not defined');
23
+ }
24
+ if (!this.appComponent) {
25
+ throw new Error('appComponent is not defined');
26
+ }
27
+ return {
28
+ appType: 'fe-v4',
29
+ appComponent: this.appComponent,
30
+ pageId: this.pageId,
31
+ routePattern: this.routePattern
32
+ };
33
+ }
34
+ getApplicationPages() {
35
+ return getV4ApplicationPages(this.context.manifest);
36
+ }
37
+ async resolveContextPathTargetName(contextPath, metaModel) {
38
+ let result;
39
+ const segments = contextPath.split('/').filter(s => !!s);
40
+ if (segments.length === 1) {
41
+ // one segment - assumed it is the direct name of entitySet
42
+ result = segments[0];
43
+ } else {
44
+ // resolve segment by segment
45
+ let targetObject = await metaModel.requestObject(`/${segments[0]}`); // NO SONAR;
46
+
47
+ let idx = 1;
48
+ let targetSetName = '';
49
+ while (targetObject && idx < segments.length) {
50
+ const navProp = segments[idx];
51
+ targetSetName = targetObject.$NavigationPropertyBinding[navProp];
52
+ if (!targetSetName) {
53
+ targetObject = undefined;
54
+ } else {
55
+ targetObject = await metaModel.requestObject(`/${targetSetName}`); // NO SONAR;
56
+ idx++;
57
+ }
58
+ }
59
+ if (targetObject) {
60
+ result = targetSetName;
61
+ }
62
+ }
63
+ return result;
64
+ }
65
+ async isPageExists(targetEntitySet, metaModel) {
66
+ let pageFound = false;
67
+ let entitySetName;
68
+ for (const page of this.existingPages) {
69
+ if (page.contextPath) {
70
+ // resolve contextPath to target entitySet
71
+ entitySetName = await this.resolveContextPathTargetName(page.contextPath, metaModel);
72
+ } else {
73
+ entitySetName = page.entitySet;
74
+ }
75
+ if (entitySetName === targetEntitySet) {
76
+ pageFound = true;
77
+ break;
78
+ }
79
+ }
80
+ return pageFound;
81
+ }
82
+ isCurrentObjectPage() {
83
+ return this.pageType === OBJECT_PAGE_COMPONENT_NAME_V4;
84
+ }
85
+ getODataMetaModel() {
86
+ return this.context.rta.getRootControlInstance().getModel()?.getMetaModel();
87
+ }
88
+ getEntitySetNameFromPageComponent(component) {
89
+ if (!isA('sap.fe.templates.ListReport.Component', component) && !isA('sap.fe.templates.ObjectPage.Component', component)) {
90
+ throw new Error('Unexpected type of page owner component');
91
+ }
92
+ return component.getEntitySet();
93
+ }
94
+ async prepareNavigationData(entitySetName, metaModel) {
95
+ const entitySet = await metaModel.requestObject(`/${entitySetName}`); // NO SONAR;
96
+ const entityTypePath = entitySet.$Type;
97
+ const entitySetNavigationKeys = Object.keys(entitySet.$NavigationPropertyBinding);
98
+ for (const navigationProperty of entitySetNavigationKeys) {
99
+ const associationEnd = await metaModel.requestObject(`/${entityTypePath}/${navigationProperty}`);
100
+ if (associationEnd?.$isCollection) {
101
+ const targetEntitySet = entitySet.$NavigationPropertyBinding[navigationProperty];
102
+ await this.addNavigationOptionIfAvailable(metaModel, targetEntitySet, navigationProperty);
103
+ }
104
+ }
105
+ }
106
+ async initialize() {
107
+ const version = await getUi5Version();
108
+ if (isLowerThanMinimalUi5Version(version, {
109
+ major: 1,
110
+ minor: 135
111
+ })) {
112
+ return;
113
+ }
114
+ await super.initialize();
115
+ this.appComponent = getV4AppComponent(this.context.view);
116
+ this.pageId = this.context.view.getViewData()?.stableId.split('::').pop();
117
+ // remember current page route pattern (used in dialog controller for new page change)
118
+ const currentPageRoute = (this.context.manifest['sap.ui5'].routing?.routes ?? []).find(r => r.name === this.pageId);
119
+ if (!currentPageRoute) {
120
+ throw new Error('Current page navigation route not found in manifest');
121
+ }
122
+ this.routePattern = currentPageRoute.pattern;
123
+ }
124
+ }
125
+ var __exports = {
126
+ __esModule: true
127
+ };
128
+ __exports.OBJECT_PAGE_COMPONENT_NAME_V4 = OBJECT_PAGE_COMPONENT_NAME_V4;
129
+ __exports.AddNewSubpage = AddNewSubpage;
130
+ return __exports;
131
+ });
132
+ //# sourceMappingURL=add-new-subpage.js.map