@sap-ux/preview-middleware 0.23.122 → 0.23.124
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.
- package/dist/client/adp/controllers/AddFragment.controller.js +5 -1
- package/dist/client/adp/controllers/AddFragment.controller.ts +3 -1
- package/dist/client/adp/quick-actions/fe-v4/utils.js +2 -1
- package/dist/client/adp/quick-actions/fe-v4/utils.ts +6 -1
- package/dist/client/cpe/additional-change-info/add-xml-additional-info.js +7 -7
- package/dist/client/cpe/additional-change-info/add-xml-additional-info.ts +16 -7
- package/dist/client/cpe/changes/service.js +1 -1
- package/dist/client/cpe/changes/service.ts +1 -1
- package/dist/client/utils/additional-change-info.js +3 -2
- package/dist/client/utils/additional-change-info.ts +7 -2
- package/dist/client/utils/core.js +26 -1
- package/dist/client/utils/core.ts +33 -1
- package/package.json +4 -4
|
@@ -95,7 +95,11 @@ sap.ui.define(["sap/ui/model/json/JSONModel", "sap/ui/dt/OverlayRegistry", "../.
|
|
|
95
95
|
} else {
|
|
96
96
|
await this.createFragmentChange(modifiedValue);
|
|
97
97
|
}
|
|
98
|
-
const
|
|
98
|
+
const selector = {
|
|
99
|
+
id: this.getRuntimeControl().getId(),
|
|
100
|
+
idIsLocal: false
|
|
101
|
+
};
|
|
102
|
+
const templateName = getFragmentTemplateName(selector, targetAggregation);
|
|
99
103
|
if (templateName) {
|
|
100
104
|
CommunicationService.sendAction(setApplicationRequiresReload(true));
|
|
101
105
|
}
|
|
@@ -20,6 +20,7 @@ import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
|
|
|
20
20
|
|
|
21
21
|
/** sap.ui.fl */
|
|
22
22
|
import { type AddFragmentChangeContentType } from 'sap/ui/fl/Change';
|
|
23
|
+
import type Selector from 'sap/ui/fl/Selector';
|
|
23
24
|
|
|
24
25
|
import { getResourceModel } from '../../i18n';
|
|
25
26
|
|
|
@@ -158,7 +159,8 @@ export default class AddFragment extends BaseDialog<AddFragmentModel> {
|
|
|
158
159
|
await this.createFragmentChange(modifiedValue);
|
|
159
160
|
}
|
|
160
161
|
|
|
161
|
-
const
|
|
162
|
+
const selector: Selector = { id: this.getRuntimeControl().getId(), idIsLocal: false };
|
|
163
|
+
const templateName = getFragmentTemplateName(selector, targetAggregation);
|
|
162
164
|
if (templateName) {
|
|
163
165
|
CommunicationService.sendAction(setApplicationRequiresReload(true));
|
|
164
166
|
}
|
|
@@ -89,10 +89,11 @@ sap.ui.define(["../../../utils/core", "sap/ui/rta/command/CommandFactory", "../.
|
|
|
89
89
|
* @param table - table control
|
|
90
90
|
* @returns string
|
|
91
91
|
*/
|
|
92
|
+
|
|
92
93
|
function getActionsPropertyPath(table) {
|
|
93
94
|
const macroTable = table.getParent();
|
|
94
95
|
const configPath = '';
|
|
95
|
-
if (macroTable && isA('sap.fe.macros.table.TableAPI', macroTable)) {
|
|
96
|
+
if (macroTable && (isA('sap.fe.macros.Table', macroTable) || isA('sap.fe.macros.table.TableAPI', macroTable))) {
|
|
96
97
|
const lineItemAnnotation = getLineItemAnnotation(macroTable);
|
|
97
98
|
const navigationPath = macroTable.metaPath.split(macroTable.getProperty('contextPath'))[1];
|
|
98
99
|
if (!lineItemAnnotation) {
|
|
@@ -108,10 +108,15 @@ function getLineItemAnnotation(table: MacroTable): string | undefined {
|
|
|
108
108
|
* @param table - table control
|
|
109
109
|
* @returns string
|
|
110
110
|
*/
|
|
111
|
+
|
|
111
112
|
export function getActionsPropertyPath(table: UI5Element): string | undefined {
|
|
112
113
|
const macroTable = table.getParent();
|
|
113
114
|
const configPath = '';
|
|
114
|
-
if (
|
|
115
|
+
if (
|
|
116
|
+
macroTable &&
|
|
117
|
+
(isA<MacroTable>('sap.fe.macros.Table', macroTable) ||
|
|
118
|
+
isA<MacroTable>('sap.fe.macros.table.TableAPI', macroTable))
|
|
119
|
+
) {
|
|
115
120
|
const lineItemAnnotation = getLineItemAnnotation(macroTable);
|
|
116
121
|
|
|
117
122
|
const navigationPath = macroTable.metaPath.split(macroTable.getProperty('contextPath'))[1];
|
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
sap.ui.define(["../../utils/core", "../../adp/quick-actions/control-types"], function (____utils_core, ____adp_quick_actions_control_types) {
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const getControlBySelector = ____utils_core["getControlBySelector"];
|
|
7
7
|
const findViewByControl = ____utils_core["findViewByControl"];
|
|
8
8
|
const ANALYTICAL_TABLE_TYPE = ____adp_quick_actions_control_types["ANALYTICAL_TABLE_TYPE"];
|
|
9
9
|
const GRID_TABLE_TYPE = ____adp_quick_actions_control_types["GRID_TABLE_TYPE"];
|
|
10
10
|
const MDC_TABLE_TYPE = ____adp_quick_actions_control_types["MDC_TABLE_TYPE"];
|
|
11
11
|
const TREE_TABLE_TYPE = ____adp_quick_actions_control_types["TREE_TABLE_TYPE"];
|
|
12
|
-
function getAddXMLAdditionalInfo(change) {
|
|
13
|
-
const
|
|
12
|
+
function getAddXMLAdditionalInfo(change, appComponent) {
|
|
13
|
+
const selector = change.getSelector();
|
|
14
14
|
const targetAggregation = change.getContent()?.targetAggregation ?? '';
|
|
15
|
-
const targetControl =
|
|
15
|
+
const targetControl = getControlBySelector(selector, appComponent);
|
|
16
16
|
const controlType = targetControl?.getMetadata().getName() ?? '';
|
|
17
|
-
const templateName = getFragmentTemplateName(
|
|
17
|
+
const templateName = getFragmentTemplateName(selector, targetAggregation, appComponent);
|
|
18
18
|
const viewName = targetControl ? findViewByControl(targetControl)?.getViewName() ?? '' : '';
|
|
19
19
|
const result = {};
|
|
20
20
|
if (templateName) {
|
|
@@ -27,8 +27,8 @@ sap.ui.define(["../../utils/core", "../../adp/quick-actions/control-types"], fun
|
|
|
27
27
|
}
|
|
28
28
|
return Object.keys(result).length > 0 ? result : undefined;
|
|
29
29
|
}
|
|
30
|
-
function getFragmentTemplateName(
|
|
31
|
-
const control =
|
|
30
|
+
function getFragmentTemplateName(selector, targetAggregation, appComponent) {
|
|
31
|
+
const control = getControlBySelector(selector, appComponent);
|
|
32
32
|
if (!control) {
|
|
33
33
|
return '';
|
|
34
34
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import FlexChange from 'sap/ui/fl/Change';
|
|
2
|
-
import {
|
|
2
|
+
import { getControlBySelector, findViewByControl } from '../../utils/core';
|
|
3
3
|
import {
|
|
4
4
|
ANALYTICAL_TABLE_TYPE,
|
|
5
5
|
GRID_TABLE_TYPE,
|
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
TREE_TABLE_TYPE
|
|
8
8
|
} from '../../adp/quick-actions/control-types';
|
|
9
9
|
import Element from 'sap/ui/core/Element';
|
|
10
|
+
import type Component from 'sap/ui/core/Component';
|
|
11
|
+
import type Selector from 'sap/ui/fl/Selector';
|
|
10
12
|
|
|
11
13
|
export type AddXMLAdditionalInfo = {
|
|
12
14
|
templateName?: string;
|
|
@@ -19,12 +21,15 @@ export type AddXMLChangeContent = {
|
|
|
19
21
|
targetAggregation?: string;
|
|
20
22
|
};
|
|
21
23
|
|
|
22
|
-
export function getAddXMLAdditionalInfo(
|
|
23
|
-
|
|
24
|
+
export function getAddXMLAdditionalInfo(
|
|
25
|
+
change: FlexChange<AddXMLChangeContent>,
|
|
26
|
+
appComponent?: Component
|
|
27
|
+
): AddXMLAdditionalInfo | undefined {
|
|
28
|
+
const selector = change.getSelector();
|
|
24
29
|
const targetAggregation = change.getContent()?.targetAggregation ?? '';
|
|
25
|
-
const targetControl =
|
|
30
|
+
const targetControl = getControlBySelector(selector, appComponent);
|
|
26
31
|
const controlType = targetControl?.getMetadata().getName() ?? '';
|
|
27
|
-
const templateName = getFragmentTemplateName(
|
|
32
|
+
const templateName = getFragmentTemplateName(selector, targetAggregation, appComponent);
|
|
28
33
|
const viewName = targetControl ? (findViewByControl(targetControl)?.getViewName() ?? '') : '';
|
|
29
34
|
|
|
30
35
|
const result: AddXMLAdditionalInfo = {};
|
|
@@ -40,8 +45,12 @@ export function getAddXMLAdditionalInfo(change: FlexChange<AddXMLChangeContent>)
|
|
|
40
45
|
return Object.keys(result).length > 0 ? result : undefined;
|
|
41
46
|
}
|
|
42
47
|
|
|
43
|
-
export function getFragmentTemplateName(
|
|
44
|
-
|
|
48
|
+
export function getFragmentTemplateName(
|
|
49
|
+
selector: Selector | undefined,
|
|
50
|
+
targetAggregation: string,
|
|
51
|
+
appComponent?: Component
|
|
52
|
+
): string {
|
|
53
|
+
const control = getControlBySelector(selector, appComponent);
|
|
45
54
|
|
|
46
55
|
if (!control) {
|
|
47
56
|
return '';
|
|
@@ -354,7 +354,7 @@ sap.ui.define(["open/ux/preview/client/thirdparty/@sap-ux-private/control-proper
|
|
|
354
354
|
* @returns {Promise<void>} A promise that resolves when the command is handled.
|
|
355
355
|
*/
|
|
356
356
|
async handleCommand(command, inactiveCommandCount, index, pendingChanges) {
|
|
357
|
-
setAdditionalChangeInfo(command?.getPreparedChange?.());
|
|
357
|
+
setAdditionalChangeInfo(command?.getPreparedChange?.(), this.options.rta.getRootControlInstance());
|
|
358
358
|
const pendingChange = await this.prepareChangeType(command, inactiveCommandCount, index);
|
|
359
359
|
if (pendingChange) {
|
|
360
360
|
pendingChanges.push(pendingChange);
|
|
@@ -416,7 +416,7 @@ export class ChangeService extends EventTarget {
|
|
|
416
416
|
index: number,
|
|
417
417
|
pendingChanges: PendingChange[]
|
|
418
418
|
): Promise<void> {
|
|
419
|
-
setAdditionalChangeInfo(command?.getPreparedChange?.());
|
|
419
|
+
setAdditionalChangeInfo(command?.getPreparedChange?.(), this.options.rta.getRootControlInstance());
|
|
420
420
|
const pendingChange = await this.prepareChangeType(command, inactiveCommandCount, index);
|
|
421
421
|
if (pendingChange) {
|
|
422
422
|
pendingChanges.push(pendingChange);
|
|
@@ -10,15 +10,16 @@ sap.ui.define(["../cpe/additional-change-info/add-xml-additional-info"], functio
|
|
|
10
10
|
* This function is used to set additional change information for a given change.
|
|
11
11
|
*
|
|
12
12
|
* @param change - The change object for which additional information is to be set.
|
|
13
|
+
* @param appComponent - The app component (optional), used to resolve controls in projects with local IDs.
|
|
13
14
|
*/
|
|
14
|
-
function setAdditionalChangeInfo(change) {
|
|
15
|
+
function setAdditionalChangeInfo(change, appComponent) {
|
|
15
16
|
if (!change) {
|
|
16
17
|
return;
|
|
17
18
|
}
|
|
18
19
|
let additionalChangeInfo;
|
|
19
20
|
const key = change.getDefinition().fileName;
|
|
20
21
|
if (change?.getChangeType?.() === 'addXML') {
|
|
21
|
-
additionalChangeInfo = getAddXMLAdditionalInfo(change);
|
|
22
|
+
additionalChangeInfo = getAddXMLAdditionalInfo(change, appComponent);
|
|
22
23
|
}
|
|
23
24
|
if (additionalChangeInfo) {
|
|
24
25
|
const existingInfo = additionalChangeInfoMap.get(key);
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
type AddXMLChangeContent
|
|
6
6
|
} from '../cpe/additional-change-info/add-xml-additional-info';
|
|
7
7
|
import { FlexChange as Change } from '../flp/common';
|
|
8
|
+
import type Component from 'sap/ui/core/Component';
|
|
8
9
|
|
|
9
10
|
export type AdditionalChangeInfo = AddXMLAdditionalInfo | undefined;
|
|
10
11
|
|
|
@@ -14,8 +15,12 @@ const additionalChangeInfoMap = new Map<string, AdditionalChangeInfo>();
|
|
|
14
15
|
* This function is used to set additional change information for a given change.
|
|
15
16
|
*
|
|
16
17
|
* @param change - The change object for which additional information is to be set.
|
|
18
|
+
* @param appComponent - The app component (optional), used to resolve controls in projects with local IDs.
|
|
17
19
|
*/
|
|
18
|
-
export function setAdditionalChangeInfo(
|
|
20
|
+
export function setAdditionalChangeInfo(
|
|
21
|
+
change: FlexChange<AddXMLChangeContent> | undefined,
|
|
22
|
+
appComponent?: Component
|
|
23
|
+
): void {
|
|
19
24
|
if (!change) {
|
|
20
25
|
return;
|
|
21
26
|
}
|
|
@@ -23,7 +28,7 @@ export function setAdditionalChangeInfo(change: FlexChange<AddXMLChangeContent>
|
|
|
23
28
|
let additionalChangeInfo;
|
|
24
29
|
const key = change.getDefinition().fileName;
|
|
25
30
|
if (change?.getChangeType?.() === 'addXML') {
|
|
26
|
-
additionalChangeInfo = getAddXMLAdditionalInfo(change);
|
|
31
|
+
additionalChangeInfo = getAddXMLAdditionalInfo(change, appComponent);
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
if (additionalChangeInfo) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
sap.ui.define(["sap/ui/core/Component", "sap/ui/core/Element"], function (Component, Element) {
|
|
3
|
+
sap.ui.define(["sap/ui/core/Component", "sap/ui/core/Element", "sap/ui/core/util/reflection/JsControlTreeModifier", "sap/base/Log", "./error"], function (Component, Element, JsControlTreeModifier, Log, ___error) {
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
|
+
const getError = ___error["getError"];
|
|
6
7
|
/**
|
|
7
8
|
* Gets Component by id.
|
|
8
9
|
*
|
|
@@ -35,6 +36,29 @@ sap.ui.define(["sap/ui/core/Component", "sap/ui/core/Element"], function (Compon
|
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Gets target control by trying getControlById first, then falling back to JsControlTreeModifier.bySelector
|
|
41
|
+
* for projects where the control may not be found by global ID.
|
|
42
|
+
*
|
|
43
|
+
* @param selector - The selector object from the change.
|
|
44
|
+
* @param appComponent - The app component (optional).
|
|
45
|
+
* @returns The target control element or undefined.
|
|
46
|
+
*/
|
|
47
|
+
function getControlBySelector(selector, appComponent) {
|
|
48
|
+
if (!selector?.id) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
let control = getControlById(selector.id);
|
|
52
|
+
if (!control && appComponent && selector) {
|
|
53
|
+
try {
|
|
54
|
+
control = JsControlTreeModifier.bySelector(selector, appComponent);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
Log.warning('Failed to get control by selector:', getError(error));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return control;
|
|
60
|
+
}
|
|
61
|
+
|
|
38
62
|
/**
|
|
39
63
|
* Checks wether this object is an instance of a ManagedObject.
|
|
40
64
|
*
|
|
@@ -109,6 +133,7 @@ sap.ui.define(["sap/ui/core/Component", "sap/ui/core/Element"], function (Compon
|
|
|
109
133
|
};
|
|
110
134
|
__exports.getComponent = getComponent;
|
|
111
135
|
__exports.getControlById = getControlById;
|
|
136
|
+
__exports.getControlBySelector = getControlBySelector;
|
|
112
137
|
__exports.isManagedObject = isManagedObject;
|
|
113
138
|
__exports.isA = isA;
|
|
114
139
|
__exports.hasParent = hasParent;
|
|
@@ -3,6 +3,10 @@ import type { ID } from 'sap/ui/core/library';
|
|
|
3
3
|
import type ManagedObject from 'sap/ui/base/ManagedObject';
|
|
4
4
|
import Element from 'sap/ui/core/Element';
|
|
5
5
|
import View from 'sap/ui/core/mvc/View';
|
|
6
|
+
import type Selector from 'sap/ui/fl/Selector';
|
|
7
|
+
import JsControlTreeModifier from 'sap/ui/core/util/reflection/JsControlTreeModifier';
|
|
8
|
+
import Log from 'sap/base/Log';
|
|
9
|
+
import { getError } from './error';
|
|
6
10
|
|
|
7
11
|
/**
|
|
8
12
|
* Gets Component by id.
|
|
@@ -36,6 +40,34 @@ export function getControlById<T extends Element = Element>(id: string): T | und
|
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Gets target control by trying getControlById first, then falling back to JsControlTreeModifier.bySelector
|
|
45
|
+
* for projects where the control may not be found by global ID.
|
|
46
|
+
*
|
|
47
|
+
* @param selector - The selector object from the change.
|
|
48
|
+
* @param appComponent - The app component (optional).
|
|
49
|
+
* @returns The target control element or undefined.
|
|
50
|
+
*/
|
|
51
|
+
export function getControlBySelector<T extends Element = Element>(
|
|
52
|
+
selector: Selector | undefined,
|
|
53
|
+
appComponent?: Component
|
|
54
|
+
): T | undefined {
|
|
55
|
+
if (!selector?.id) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let control = getControlById<T>(selector.id);
|
|
60
|
+
if (!control && appComponent && selector) {
|
|
61
|
+
try {
|
|
62
|
+
control = JsControlTreeModifier.bySelector(selector, appComponent) as unknown as T | undefined;
|
|
63
|
+
} catch (error) {
|
|
64
|
+
Log.warning('Failed to get control by selector:', getError(error));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return control;
|
|
69
|
+
}
|
|
70
|
+
|
|
39
71
|
/**
|
|
40
72
|
* Checks wether this object is an instance of a ManagedObject.
|
|
41
73
|
*
|
|
@@ -110,4 +142,4 @@ export function findNestedElements(
|
|
|
110
142
|
): Element[] {
|
|
111
143
|
const ownerId = ownerElement.getId();
|
|
112
144
|
return candidates.filter((item) => hasParent(item, ownerId));
|
|
113
|
-
}
|
|
145
|
+
}
|
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.23.
|
|
12
|
+
"version": "0.23.124",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
"qrcode": "1.5.4",
|
|
29
29
|
"@sap/bas-sdk": "3.13.3",
|
|
30
30
|
"@sap-ux/adp-tooling": "0.18.65",
|
|
31
|
-
"@sap-ux/btp-utils": "1.1.9",
|
|
32
31
|
"@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.7.11",
|
|
33
32
|
"@sap-ux/feature-toggle": "0.3.6",
|
|
34
33
|
"@sap-ux/logger": "0.8.1",
|
|
35
34
|
"@sap-ux/project-access": "1.35.4",
|
|
36
35
|
"@sap-ux/system-access": "0.6.53",
|
|
37
|
-
"@sap-ux/i18n": "0.3.7"
|
|
36
|
+
"@sap-ux/i18n": "0.3.7",
|
|
37
|
+
"@sap-ux/btp-utils": "1.1.9"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@sap-ux-private/playwright": "0.2.6",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"nock": "13.4.0",
|
|
54
54
|
"npm-run-all2": "6.2.0",
|
|
55
55
|
"supertest": "7.1.4",
|
|
56
|
-
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.18.
|
|
56
|
+
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.18.19",
|
|
57
57
|
"@sap-ux/axios-extension": "1.25.13",
|
|
58
58
|
"@sap-ux/store": "1.5.6",
|
|
59
59
|
"@sap-ux/ui5-info": "0.13.12"
|