@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
@@ -1,140 +0,0 @@
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", "../dialog-enablement-validator"], 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, ___dialog_enablement_validator) {
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 DIALOG_ENABLEMENT_VALIDATOR = ___dialog_enablement_validator["DIALOG_ENABLEMENT_VALIDATOR"];
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
- }, DIALOG_ENABLEMENT_VALIDATOR]);
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 (!(await areManifestChangesSupported(this.context.manifest))) {
88
- return Promise.resolve();
89
- }
90
- this.appType = getApplicationType(this.context.manifest);
91
- const allControls = CONTROL_TYPES.flatMap(item => this.context.controlIndex[item] ?? []);
92
- const control = allControls.find(c => pageHasControlId(this.context.view, c.controlId));
93
- const pageType = this.context.view.getViewName().split('.view.')[0];
94
- this.currentPageDescriptor.pageType = pageType;
95
- const metaModel = this.context.rta.getRootControlInstance().getModel()?.getMetaModel();
96
- if (!metaModel || !control) {
97
- return Promise.resolve();
98
- }
99
- const modifiedControl = getControlById(control.controlId);
100
- if (!modifiedControl) {
101
- return Promise.resolve();
102
- }
103
- const component = Component.getOwnerComponentFor(modifiedControl);
104
- if (!isA('sap.suite.ui.generic.template.lib.TemplateComponent', component)) {
105
- return Promise.reject(new Error('Unexpected type of page owner component'));
106
- }
107
- const entitySetName = component.getEntitySet();
108
- if (!entitySetName) {
109
- return Promise.resolve();
110
- }
111
- this.currentPageDescriptor.entitySet = entitySetName;
112
- const entitySet = metaModel.getODataEntitySet(entitySetName);
113
- const entityType = metaModel.getODataEntityType(entitySet.entityType);
114
- this.prepareNavigationData(entityType, metaModel);
115
- this.control = modifiedControl;
116
- return Promise.resolve();
117
- }
118
- async execute() {
119
- const overlay = OverlayRegistry.getOverlay(this.control);
120
- const appReference = this.context.flexSettings.projectId;
121
- await DialogFactory.createDialog(overlay, this.context.rta, DialogNames.ADD_SUBPAGE, undefined, {
122
- appType: this.appType,
123
- appReference,
124
- title: 'ADD_SUB_PAGE_DIALOG_TITLE',
125
- pageDescriptor: this.currentPageDescriptor
126
- }, {
127
- actionName: this.type,
128
- telemetryEventIdentifier: this.getTelemetryIdentifier()
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
@@ -1,168 +0,0 @@
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 { DIALOG_ENABLEMENT_VALIDATOR } from '../dialog-enablement-validator';
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
- DIALOG_ENABLEMENT_VALIDATOR
56
- ]);
57
- }
58
-
59
- private getApplicationPages() {
60
- if (this.appType === 'fe-v2') {
61
- return getV2ApplicationPages(this.context.manifest);
62
- } else if (this.appType === 'fe-v4') {
63
- return getV4ApplicationPages(this.context.manifest);
64
- }
65
- return [];
66
- }
67
-
68
- private prepareNavigationData(entityType: EntityType, metaModel: ODataMetaModel): void {
69
- const existingPages = this.getApplicationPages();
70
- if (this.currentPageDescriptor.pageType === 'sap.suite.ui.generic.template.ObjectPage') {
71
- // Navigation from Object Page
72
- for (const navProp of entityType?.navigationProperty || []) {
73
- const associationEnd = metaModel.getODataAssociationEnd(entityType, navProp.name);
74
- if (associationEnd?.multiplicity !== '*') {
75
- continue;
76
- }
77
- const entityContainer = metaModel.getODataEntityContainer() as EntityContainer;
78
- if (!entityContainer?.entitySet?.length) {
79
- continue;
80
- }
81
- const targetEntitySet = entityContainer.entitySet.find(
82
- (item) => item.entityType === associationEnd.type
83
- );
84
- const pageExists = existingPages.some((page) => page.entitySet === targetEntitySet?.name);
85
- if (targetEntitySet && !pageExists) {
86
- this.currentPageDescriptor.navProperties.push({
87
- entitySet: targetEntitySet.name,
88
- navProperty: navProp.name
89
- });
90
- }
91
- }
92
- return;
93
- }
94
-
95
- // navigation from LR or ALP (only OP based on current entitySet is possible)
96
- const pageExists = existingPages.some((page) => page.entitySet === this.currentPageDescriptor.entitySet);
97
- if (!pageExists) {
98
- this.currentPageDescriptor.navProperties.push({
99
- entitySet: this.currentPageDescriptor.entitySet,
100
- navProperty: this.currentPageDescriptor.entitySet
101
- });
102
- }
103
- }
104
-
105
- async initialize(): Promise<void> {
106
- if (!(await areManifestChangesSupported(this.context.manifest))) {
107
- return Promise.resolve();
108
- }
109
-
110
- this.appType = getApplicationType(this.context.manifest);
111
-
112
- const allControls = CONTROL_TYPES.flatMap((item) => this.context.controlIndex[item] ?? []);
113
- const control = allControls.find((c) => pageHasControlId(this.context.view, c.controlId));
114
-
115
- const pageType = this.context.view.getViewName().split('.view.')[0];
116
- this.currentPageDescriptor.pageType = pageType;
117
-
118
- const metaModel = (this.context.rta.getRootControlInstance().getModel() as ODataModel)?.getMetaModel();
119
- if (!metaModel || !control) {
120
- return Promise.resolve();
121
- }
122
-
123
- const modifiedControl = getControlById<ObjectPageLayout>(control.controlId);
124
- if (!modifiedControl) {
125
- return Promise.resolve();
126
- }
127
-
128
- const component = Component.getOwnerComponentFor(modifiedControl);
129
- if (!isA<TemplateComponent>('sap.suite.ui.generic.template.lib.TemplateComponent', component)) {
130
- return Promise.reject(new Error('Unexpected type of page owner component'));
131
- }
132
-
133
- const entitySetName = component.getEntitySet();
134
- if (!entitySetName) {
135
- return Promise.resolve();
136
- }
137
-
138
- this.currentPageDescriptor.entitySet = entitySetName;
139
-
140
- const entitySet = metaModel.getODataEntitySet(entitySetName) as EntitySet;
141
- const entityType = metaModel.getODataEntityType(entitySet.entityType) as EntityType;
142
-
143
- this.prepareNavigationData(entityType, metaModel);
144
-
145
- this.control = modifiedControl;
146
-
147
- return Promise.resolve();
148
- }
149
-
150
- async execute(): Promise<FlexCommand[]> {
151
- const overlay = OverlayRegistry.getOverlay(this.control!);
152
- const appReference = this.context.flexSettings.projectId;
153
- await DialogFactory.createDialog(
154
- overlay,
155
- this.context.rta,
156
- DialogNames.ADD_SUBPAGE,
157
- undefined,
158
- {
159
- appType: this.appType,
160
- appReference,
161
- title: 'ADD_SUB_PAGE_DIALOG_TITLE',
162
- pageDescriptor: this.currentPageDescriptor
163
- },
164
- { actionName: this.type, telemetryEventIdentifier: this.getTelemetryIdentifier() }
165
- );
166
- return [];
167
- }
168
- }