@sap-ux/preview-middleware 0.19.29 → 0.19.31
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/base/flp.d.ts +2 -2
- package/dist/base/flp.js +3 -3
- package/dist/client/adp/add-fragment.js +48 -0
- package/dist/client/adp/add-fragment.ts +51 -0
- package/dist/client/adp/api-handler.js +155 -153
- package/dist/client/adp/api-handler.ts +2 -2
- package/dist/client/adp/command-executor.js +75 -75
- package/dist/client/adp/control-utils.js +44 -44
- package/dist/client/adp/controllers/AddFragment.controller.js +26 -86
- package/dist/client/adp/controllers/AddFragment.controller.ts +29 -113
- package/dist/client/adp/controllers/ControllerExtension.controller.js +210 -210
- package/dist/client/adp/controllers/ExtensionPoint.controller.js +139 -139
- package/dist/client/adp/controllers/FileExistsDialog.controller.js +66 -66
- package/dist/client/adp/dialog-factory.js +135 -135
- package/dist/client/adp/dialog-factory.ts +21 -13
- package/dist/client/adp/extension-point.js +3 -3
- package/dist/client/adp/extension-point.ts +3 -3
- package/dist/client/adp/init-dialogs.js +163 -138
- package/dist/client/adp/init-dialogs.ts +13 -8
- package/dist/client/adp/init.js +2 -0
- package/dist/client/adp/init.ts +5 -0
- package/dist/client/adp/quick-actions/add-new-subpage-quick-action-base.js +96 -96
- package/dist/client/adp/quick-actions/common/add-controller-to-page.js +60 -60
- package/dist/client/adp/quick-actions/common/create-page-action.js +54 -54
- package/dist/client/adp/quick-actions/common/op-add-custom-section.js +39 -39
- package/dist/client/adp/quick-actions/common/op-add-header-field.js +67 -67
- package/dist/client/adp/quick-actions/common/utils.js +18 -18
- package/dist/client/adp/quick-actions/control-types.js +23 -23
- package/dist/client/adp/quick-actions/dialog-enablement-validator.js +24 -24
- package/dist/client/adp/quick-actions/enablement-validator.js +4 -4
- package/dist/client/adp/quick-actions/fe-v2/add-new-subpage.js +81 -81
- package/dist/client/adp/quick-actions/fe-v2/change-table-actions.js +67 -67
- package/dist/client/adp/quick-actions/fe-v2/change-table-columns.js +101 -101
- package/dist/client/adp/quick-actions/fe-v2/create-table-action.js +107 -107
- package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.js +99 -99
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-semantic-date-range-filter-bar.js +78 -78
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-table-filtering.js +77 -77
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-variant-management.js +69 -69
- package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.js +59 -59
- package/dist/client/adp/quick-actions/fe-v2/op-enable-empty-row-mode.js +93 -93
- package/dist/client/adp/quick-actions/fe-v2/op-enable-variant-management.js +84 -84
- package/dist/client/adp/quick-actions/fe-v2/registry.js +77 -77
- package/dist/client/adp/quick-actions/fe-v2/utils.js +116 -116
- package/dist/client/adp/quick-actions/fe-v4/add-new-subpage.js +138 -138
- package/dist/client/adp/quick-actions/fe-v4/change-table-actions.js +79 -79
- package/dist/client/adp/quick-actions/fe-v4/change-table-columns.js +75 -75
- package/dist/client/adp/quick-actions/fe-v4/create-table-action.js +53 -53
- package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column.js +49 -49
- package/dist/client/adp/quick-actions/fe-v4/enable-variant-management.js +81 -81
- package/dist/client/adp/quick-actions/fe-v4/lr-enable-semantic-date-range-filter-bar.js +56 -56
- package/dist/client/adp/quick-actions/fe-v4/lr-enable-table-filtering.js +84 -84
- package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.js +53 -53
- package/dist/client/adp/quick-actions/fe-v4/op-enable-empty-row-mode.js +89 -89
- package/dist/client/adp/quick-actions/fe-v4/registry.js +60 -60
- package/dist/client/adp/quick-actions/fe-v4/utils.js +72 -72
- package/dist/client/adp/quick-actions/load.js +44 -44
- package/dist/client/adp/quick-actions/quick-action-base.js +64 -64
- package/dist/client/adp/utils.js +218 -218
- package/dist/client/cpe/additional-change-info/add-xml-additional-info.js +77 -0
- package/dist/client/cpe/additional-change-info/add-xml-additional-info.ts +84 -0
- package/dist/client/cpe/changes/index.js +10 -10
- package/dist/client/cpe/changes/service.js +5 -2
- package/dist/client/cpe/changes/service.ts +2 -0
- package/dist/client/cpe/changes/validator.js +39 -39
- package/dist/client/cpe/connector-service.js +2 -1
- package/dist/client/cpe/connector-service.ts +8 -4
- package/dist/client/cpe/documentation.js +164 -164
- package/dist/client/cpe/feature-service.js +36 -36
- package/dist/client/cpe/logger.js +30 -30
- package/dist/client/cpe/outline/editable.js +37 -37
- package/dist/client/cpe/outline/nodes.js +203 -203
- package/dist/client/cpe/quick-actions/quick-action-definition.js +4 -4
- package/dist/client/cpe/quick-actions/registry.js +143 -143
- package/dist/client/cpe/quick-actions/utils.js +92 -92
- package/dist/client/cpe/types.js +4 -4
- package/dist/client/cpe/ui5-utils.js +33 -33
- package/dist/client/cpe/utils.js +111 -111
- package/dist/client/flp/WorkspaceConnector.js +92 -86
- package/dist/client/flp/WorkspaceConnector.ts +10 -2
- package/dist/client/flp/common.js +28 -28
- package/dist/client/flp/enableFakeConnector.js +89 -83
- package/dist/client/flp/enableFakeConnector.ts +11 -2
- package/dist/client/flp/homepage/Component.js +14 -14
- package/dist/client/flp/initCdm.js +117 -117
- package/dist/client/flp/initConnectors.js +28 -28
- package/dist/client/flp/initRta.js +178 -178
- package/dist/client/i18n.js +56 -56
- package/dist/client/utils/additional-change-info.js +43 -0
- package/dist/client/utils/additional-change-info.ts +42 -0
- package/dist/client/utils/application.js +32 -32
- package/dist/client/utils/core.js +84 -84
- package/dist/client/utils/error.js +19 -19
- package/dist/client/utils/fe-v2.js +56 -56
- package/dist/client/utils/fe-v4.js +140 -140
- package/dist/client/utils/version.js +104 -104
- package/package.json +4 -4
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
sap.ui.define([], function () {
|
|
4
|
-
"use strict";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Handles calling control specific functions for retrieving control data
|
|
8
|
-
*/
|
|
9
|
-
class ControlUtils {
|
|
10
|
-
/**
|
|
11
|
-
* Returns ManagedObject runtime control
|
|
12
|
-
*
|
|
13
|
-
* @param overlayControl Overlay
|
|
14
|
-
* @returns {ManagedObject} Managed Object instance
|
|
15
|
-
*/
|
|
16
|
-
static getRuntimeControl(overlayControl) {
|
|
17
|
-
let runtimeControl;
|
|
18
|
-
if (overlayControl.getElementInstance) {
|
|
19
|
-
runtimeControl = overlayControl.getElementInstance();
|
|
20
|
-
} else {
|
|
21
|
-
runtimeControl = overlayControl.getElement();
|
|
22
|
-
}
|
|
23
|
-
return runtimeControl;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Returns control aggregation names in an array
|
|
28
|
-
*
|
|
29
|
-
* @param control Managed Object runtime control
|
|
30
|
-
* @param name Aggregation name
|
|
31
|
-
* @returns Array of control aggregations
|
|
32
|
-
*/
|
|
33
|
-
static getControlAggregationByName(control, name) {
|
|
34
|
-
let result = [];
|
|
35
|
-
const aggregation = (control ? control.getMetadata().getAllAggregations() : {})[name];
|
|
36
|
-
if (aggregation) {
|
|
37
|
-
// This executes a _sGetter function that can vary from control to control (_sGetter can be: getContent, getItems, etc)
|
|
38
|
-
const names = aggregation._sGetter && control[aggregation._sGetter]() || [];
|
|
39
|
-
result = Array.isArray(names) ? names : [names];
|
|
40
|
-
}
|
|
41
|
-
return result;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return ControlUtils;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
sap.ui.define([], function () {
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Handles calling control specific functions for retrieving control data
|
|
8
|
+
*/
|
|
9
|
+
class ControlUtils {
|
|
10
|
+
/**
|
|
11
|
+
* Returns ManagedObject runtime control
|
|
12
|
+
*
|
|
13
|
+
* @param overlayControl Overlay
|
|
14
|
+
* @returns {ManagedObject} Managed Object instance
|
|
15
|
+
*/
|
|
16
|
+
static getRuntimeControl(overlayControl) {
|
|
17
|
+
let runtimeControl;
|
|
18
|
+
if (overlayControl.getElementInstance) {
|
|
19
|
+
runtimeControl = overlayControl.getElementInstance();
|
|
20
|
+
} else {
|
|
21
|
+
runtimeControl = overlayControl.getElement();
|
|
22
|
+
}
|
|
23
|
+
return runtimeControl;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Returns control aggregation names in an array
|
|
28
|
+
*
|
|
29
|
+
* @param control Managed Object runtime control
|
|
30
|
+
* @param name Aggregation name
|
|
31
|
+
* @returns Array of control aggregations
|
|
32
|
+
*/
|
|
33
|
+
static getControlAggregationByName(control, name) {
|
|
34
|
+
let result = [];
|
|
35
|
+
const aggregation = (control ? control.getMetadata().getAllAggregations() : {})[name];
|
|
36
|
+
if (aggregation) {
|
|
37
|
+
// This executes a _sGetter function that can vary from control to control (_sGetter can be: getContent, getItems, etc)
|
|
38
|
+
const names = aggregation._sGetter && control[aggregation._sGetter]() || [];
|
|
39
|
+
result = Array.isArray(names) ? names : [names];
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return ControlUtils;
|
|
45
45
|
});
|
|
46
46
|
//# sourceMappingURL=control-utils.js.map
|
|
@@ -2,36 +2,33 @@
|
|
|
2
2
|
sap.ui.define([
|
|
3
3
|
'sap/ui/model/json/JSONModel',
|
|
4
4
|
'sap/ui/dt/OverlayRegistry',
|
|
5
|
-
'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
|
|
6
5
|
'../../i18n',
|
|
7
|
-
'../../cpe/communication-service',
|
|
8
6
|
'../control-utils',
|
|
9
7
|
'../command-executor',
|
|
10
8
|
'../api-handler',
|
|
11
9
|
'./BaseDialog.controller',
|
|
12
10
|
'../utils',
|
|
13
|
-
'
|
|
14
|
-
|
|
11
|
+
'../../cpe/additional-change-info/add-xml-additional-info',
|
|
12
|
+
'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
|
|
13
|
+
'../../cpe/communication-service'
|
|
14
|
+
], function (JSONModel, OverlayRegistry, ____i18n, __ControlUtils, __CommandExecutor, ___api_handler, __BaseDialog, ___utils, ____cpe_additional_change_info_add_xml_additional_info, ___sap_ux_private_control_property_editor_common, ____cpe_communication_service) {
|
|
15
15
|
'use strict';
|
|
16
16
|
function _interopRequireDefault(obj) {
|
|
17
17
|
return obj && obj.__esModule && typeof obj.default !== 'undefined' ? obj.default : obj;
|
|
18
18
|
}
|
|
19
|
-
const setApplicationRequiresReload = ___sap_ux_private_control_property_editor_common['setApplicationRequiresReload'];
|
|
20
19
|
const getResourceModel = ____i18n['getResourceModel'];
|
|
21
20
|
const getTextBundle = ____i18n['getTextBundle'];
|
|
22
|
-
const CommunicationService = ____cpe_communication_service['CommunicationService'];
|
|
23
21
|
const ControlUtils = _interopRequireDefault(__ControlUtils);
|
|
24
22
|
const CommandExecutor = _interopRequireDefault(__CommandExecutor);
|
|
25
23
|
const getFragments = ___api_handler['getFragments'];
|
|
26
24
|
const BaseDialog = _interopRequireDefault(__BaseDialog);
|
|
27
25
|
const notifyUser = ___utils['notifyUser'];
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const TREE_TABLE_TYPE = ___quick_actions_control_types['TREE_TABLE_TYPE'];
|
|
26
|
+
const getFragmentTemplateName = ____cpe_additional_change_info_add_xml_additional_info['getFragmentTemplateName'];
|
|
27
|
+
const setApplicationRequiresReload = ___sap_ux_private_control_property_editor_common['setApplicationRequiresReload'];
|
|
28
|
+
const CommunicationService = ____cpe_communication_service['CommunicationService'];
|
|
32
29
|
const radix = 10;
|
|
33
30
|
const AddFragment = BaseDialog.extend('open.ux.preview.client.adp.controllers.AddFragment', {
|
|
34
|
-
constructor: function _constructor(name, overlays, rta, options, telemetryData) {
|
|
31
|
+
constructor: function _constructor(name, overlays, rta, options, data, telemetryData) {
|
|
35
32
|
BaseDialog.prototype.constructor.call(this, name, telemetryData);
|
|
36
33
|
this.options = options;
|
|
37
34
|
this.rta = rta;
|
|
@@ -41,6 +38,7 @@ sap.ui.define([
|
|
|
41
38
|
completeView: options.aggregation === undefined
|
|
42
39
|
});
|
|
43
40
|
this.commandExecutor = new CommandExecutor(this.rta);
|
|
41
|
+
this.data = data;
|
|
44
42
|
},
|
|
45
43
|
setup: async function _setup(dialog) {
|
|
46
44
|
this.dialog = dialog;
|
|
@@ -76,16 +74,24 @@ sap.ui.define([
|
|
|
76
74
|
await BaseDialog.prototype.onCreateBtnPressHandler.call(this);
|
|
77
75
|
const fragmentName = this.model.getProperty('/newFragmentName');
|
|
78
76
|
const index = this.model.getProperty('/selectedIndex');
|
|
79
|
-
const targetAggregation = this.model.getProperty('/selectedAggregation/value');
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
fragmentName
|
|
83
|
-
|
|
77
|
+
const targetAggregation = this.model.getProperty('/selectedAggregation/value') ?? 'content';
|
|
78
|
+
const modifiedValue = {
|
|
79
|
+
fragment: `<core:FragmentDefinition xmlns:core='sap.ui.core'></core:FragmentDefinition>`,
|
|
80
|
+
fragmentPath: `fragments/${ fragmentName }.fragment.xml`,
|
|
81
|
+
index: index ?? 0,
|
|
82
|
+
targetAggregation: targetAggregation ?? 'content'
|
|
84
83
|
};
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
if (this.data) {
|
|
85
|
+
this.data.deferred.resolve(modifiedValue);
|
|
86
|
+
} else {
|
|
87
|
+
await this.createFragmentChange(modifiedValue);
|
|
88
|
+
}
|
|
89
|
+
const templateName = getFragmentTemplateName(this.runtimeControl.getId(), targetAggregation);
|
|
90
|
+
if (templateName) {
|
|
91
|
+
CommunicationService.sendAction(setApplicationRequiresReload(true));
|
|
92
|
+
}
|
|
87
93
|
const bundle = await getTextBundle();
|
|
88
|
-
notifyUser(bundle.getText(
|
|
94
|
+
notifyUser(bundle.getText('ADP_ADD_FRAGMENT_NOTIFICATION', [fragmentName]), 8000);
|
|
89
95
|
this.handleDialogClose();
|
|
90
96
|
},
|
|
91
97
|
buildDialogData: async function _buildDialogData() {
|
|
@@ -133,78 +139,12 @@ sap.ui.define([
|
|
|
133
139
|
this.model.setProperty('/selectedIndex', indexArray.length - 1 > 0 ? defaultIndex : 0);
|
|
134
140
|
}
|
|
135
141
|
},
|
|
136
|
-
createFragmentChange: async function _createFragmentChange(
|
|
137
|
-
const {fragmentName, index, targetAggregation} = fragmentData;
|
|
142
|
+
createFragmentChange: async function _createFragmentChange(modifiedValue) {
|
|
138
143
|
const flexSettings = this.rta.getFlexSettings();
|
|
139
144
|
const overlay = OverlayRegistry.getOverlay(this.runtimeControl);
|
|
140
145
|
const designMetadata = overlay.getDesignTimeMetadata();
|
|
141
|
-
const modifiedValue = {
|
|
142
|
-
fragment: `<core:FragmentDefinition xmlns:core='sap.ui.core'></core:FragmentDefinition>`,
|
|
143
|
-
fragmentPath: `fragments/${ fragmentName }.fragment.xml`,
|
|
144
|
-
index: index ?? 0,
|
|
145
|
-
targetAggregation: targetAggregation ?? 'content'
|
|
146
|
-
};
|
|
147
146
|
const command = await this.commandExecutor.getCommand(this.runtimeControl, 'addXML', modifiedValue, designMetadata, flexSettings);
|
|
148
|
-
const templateName = this.getFragmentTemplateName(modifiedValue.targetAggregation);
|
|
149
|
-
if (templateName) {
|
|
150
|
-
const preparedChange = command.getPreparedChange();
|
|
151
|
-
const content = preparedChange.getContent();
|
|
152
|
-
preparedChange.setContent({
|
|
153
|
-
...content,
|
|
154
|
-
templateName
|
|
155
|
-
});
|
|
156
|
-
CommunicationService.sendAction(setApplicationRequiresReload(true));
|
|
157
|
-
}
|
|
158
147
|
await this.commandExecutor.pushAndExecuteCommand(command);
|
|
159
|
-
return templateName;
|
|
160
|
-
},
|
|
161
|
-
getFragmentTemplateName: function _getFragmentTemplateName(targetAggregation) {
|
|
162
|
-
const currentControlName = this.runtimeControl.getMetadata().getName();
|
|
163
|
-
if (currentControlName === 'sap.uxap.ObjectPageLayout' && targetAggregation === 'sections') {
|
|
164
|
-
return 'OBJECT_PAGE_CUSTOM_SECTION';
|
|
165
|
-
} else if (this.isCustomAction(currentControlName, targetAggregation)) {
|
|
166
|
-
return 'CUSTOM_ACTION';
|
|
167
|
-
} else if (this.isObjectPageHeaderField(currentControlName, targetAggregation)) {
|
|
168
|
-
return 'OBJECT_PAGE_HEADER_FIELD';
|
|
169
|
-
} else if (targetAggregation === 'columns') {
|
|
170
|
-
switch (currentControlName) {
|
|
171
|
-
case MDC_TABLE_TYPE:
|
|
172
|
-
return 'V4_MDC_TABLE_COLUMN';
|
|
173
|
-
case TREE_TABLE_TYPE:
|
|
174
|
-
case GRID_TABLE_TYPE:
|
|
175
|
-
return 'GRID_TREE_TABLE_COLUMN';
|
|
176
|
-
case ANALYTICAL_TABLE_TYPE:
|
|
177
|
-
return 'ANALYTICAL_TABLE_COLUMN';
|
|
178
|
-
default:
|
|
179
|
-
return '';
|
|
180
|
-
}
|
|
181
|
-
} else if (currentControlName === 'sap.ui.mdc.Table' && targetAggregation === 'actions') {
|
|
182
|
-
return 'TABLE_ACTION';
|
|
183
|
-
}
|
|
184
|
-
return '';
|
|
185
|
-
},
|
|
186
|
-
isCustomAction: function _isCustomAction(currentControlName, targetAggregation) {
|
|
187
|
-
if ([
|
|
188
|
-
'sap.f.DynamicPageTitle',
|
|
189
|
-
'sap.uxap.ObjectPageHeader',
|
|
190
|
-
'sap.uxap.ObjectPageDynamicHeaderTitle'
|
|
191
|
-
].includes(currentControlName)) {
|
|
192
|
-
return targetAggregation === 'actions';
|
|
193
|
-
} else if (currentControlName === 'sap.m.OverflowToolbar' || currentControlName === 'sap.m.Toolbar') {
|
|
194
|
-
return targetAggregation === 'content';
|
|
195
|
-
}
|
|
196
|
-
return false;
|
|
197
|
-
},
|
|
198
|
-
isObjectPageHeaderField: function _isObjectPageHeaderField(currentControlName, targetAggregation) {
|
|
199
|
-
if (currentControlName === 'sap.uxap.ObjectPageLayout') {
|
|
200
|
-
return targetAggregation === 'headerContent';
|
|
201
|
-
} else if (currentControlName === 'sap.m.FlexBox') {
|
|
202
|
-
const parentName = this.runtimeControl.getParent()?.getMetadata().getName();
|
|
203
|
-
if (parentName === 'sap.uxap.ObjectPageDynamicHeaderContent' || parentName === 'sap.uxap.ObjectPageLayout') {
|
|
204
|
-
return targetAggregation === 'items';
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return false;
|
|
208
148
|
}
|
|
209
149
|
});
|
|
210
150
|
return AddFragment;
|
|
@@ -21,29 +21,18 @@ import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
|
|
|
21
21
|
/** sap.ui.fl */
|
|
22
22
|
import { type AddFragmentChangeContentType } from 'sap/ui/fl/Change';
|
|
23
23
|
|
|
24
|
-
import { setApplicationRequiresReload } from '@sap-ux-private/control-property-editor-common';
|
|
25
|
-
|
|
26
24
|
import { getResourceModel, getTextBundle } from '../../i18n';
|
|
27
|
-
import { CommunicationService } from '../../cpe/communication-service';
|
|
28
25
|
|
|
29
26
|
import ControlUtils from '../control-utils';
|
|
30
27
|
import CommandExecutor from '../command-executor';
|
|
31
28
|
import { getFragments } from '../api-handler';
|
|
32
29
|
import BaseDialog from './BaseDialog.controller';
|
|
33
30
|
import { notifyUser } from '../utils';
|
|
34
|
-
import {
|
|
35
|
-
ANALYTICAL_TABLE_TYPE,
|
|
36
|
-
GRID_TABLE_TYPE,
|
|
37
|
-
MDC_TABLE_TYPE,
|
|
38
|
-
TREE_TABLE_TYPE
|
|
39
|
-
} from '../quick-actions/control-types';
|
|
40
31
|
import { QuickActionTelemetryData } from '../../cpe/quick-actions/quick-action-definition';
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
targetAggregation: string;
|
|
46
|
-
}
|
|
32
|
+
import { getFragmentTemplateName } from '../../cpe/additional-change-info/add-xml-additional-info';
|
|
33
|
+
import type { AddFragmentData, DeferredXmlFragmentData } from '../add-fragment';
|
|
34
|
+
import { setApplicationRequiresReload } from '@sap-ux-private/control-property-editor-common';
|
|
35
|
+
import { CommunicationService } from '../../cpe/communication-service';
|
|
47
36
|
|
|
48
37
|
const radix = 10;
|
|
49
38
|
|
|
@@ -65,11 +54,14 @@ export interface AddFragmentOptions {
|
|
|
65
54
|
* @namespace open.ux.preview.client.adp.controllers
|
|
66
55
|
*/
|
|
67
56
|
export default class AddFragment extends BaseDialog<AddFragmentModel> {
|
|
57
|
+
private readonly data?: AddFragmentData;
|
|
58
|
+
|
|
68
59
|
constructor(
|
|
69
60
|
name: string,
|
|
70
61
|
overlays: UI5Element,
|
|
71
62
|
rta: RuntimeAuthoring,
|
|
72
63
|
readonly options: AddFragmentOptions,
|
|
64
|
+
data?: AddFragmentData,
|
|
73
65
|
telemetryData?: QuickActionTelemetryData
|
|
74
66
|
) {
|
|
75
67
|
super(name, telemetryData);
|
|
@@ -80,6 +72,7 @@ export default class AddFragment extends BaseDialog<AddFragmentModel> {
|
|
|
80
72
|
completeView: options.aggregation === undefined
|
|
81
73
|
});
|
|
82
74
|
this.commandExecutor = new CommandExecutor(this.rta);
|
|
75
|
+
this.data = data;
|
|
83
76
|
}
|
|
84
77
|
|
|
85
78
|
/**
|
|
@@ -149,18 +142,28 @@ export default class AddFragment extends BaseDialog<AddFragmentModel> {
|
|
|
149
142
|
|
|
150
143
|
const fragmentName = this.model.getProperty('/newFragmentName');
|
|
151
144
|
const index = this.model.getProperty('/selectedIndex');
|
|
152
|
-
const targetAggregation = this.model.getProperty('/selectedAggregation/value');
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
145
|
+
const targetAggregation = this.model.getProperty('/selectedAggregation/value') ?? 'content';
|
|
146
|
+
|
|
147
|
+
const modifiedValue = {
|
|
148
|
+
fragment: `<core:FragmentDefinition xmlns:core='sap.ui.core'></core:FragmentDefinition>`,
|
|
149
|
+
fragmentPath: `fragments/${fragmentName}.fragment.xml`,
|
|
150
|
+
index: index ?? 0,
|
|
151
|
+
targetAggregation: targetAggregation ?? 'content'
|
|
157
152
|
};
|
|
158
153
|
|
|
159
|
-
|
|
154
|
+
if (this.data) {
|
|
155
|
+
this.data.deferred.resolve(modifiedValue);
|
|
156
|
+
} else {
|
|
157
|
+
await this.createFragmentChange(modifiedValue);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const templateName = getFragmentTemplateName(this.runtimeControl.getId(), targetAggregation);
|
|
161
|
+
if (templateName) {
|
|
162
|
+
CommunicationService.sendAction(setApplicationRequiresReload(true));
|
|
163
|
+
}
|
|
160
164
|
|
|
161
|
-
const textKey = templateName ? 'ADP_ADD_FRAGMENT_WITH_TEMPLATE_NOTIFICATION' : 'ADP_ADD_FRAGMENT_NOTIFICATION';
|
|
162
165
|
const bundle = await getTextBundle();
|
|
163
|
-
notifyUser(bundle.getText(
|
|
166
|
+
notifyUser(bundle.getText('ADP_ADD_FRAGMENT_NOTIFICATION', [fragmentName]), 8000);
|
|
164
167
|
|
|
165
168
|
this.handleDialogClose();
|
|
166
169
|
}
|
|
@@ -227,23 +230,15 @@ export default class AddFragment extends BaseDialog<AddFragmentModel> {
|
|
|
227
230
|
/**
|
|
228
231
|
* Creates an addXML fragment command and pushes it to the command stack
|
|
229
232
|
*
|
|
230
|
-
* @param
|
|
233
|
+
* @param modifiedValue - modified value
|
|
234
|
+
* @param templateName - fragment template name
|
|
231
235
|
*/
|
|
232
|
-
private async createFragmentChange(
|
|
233
|
-
const { fragmentName, index, targetAggregation } = fragmentData;
|
|
234
|
-
|
|
236
|
+
private async createFragmentChange(modifiedValue: DeferredXmlFragmentData): Promise<void> {
|
|
235
237
|
const flexSettings = this.rta.getFlexSettings();
|
|
236
238
|
|
|
237
239
|
const overlay = OverlayRegistry.getOverlay(this.runtimeControl as UI5Element);
|
|
238
240
|
const designMetadata = overlay.getDesignTimeMetadata();
|
|
239
241
|
|
|
240
|
-
const modifiedValue = {
|
|
241
|
-
fragment: `<core:FragmentDefinition xmlns:core='sap.ui.core'></core:FragmentDefinition>`,
|
|
242
|
-
fragmentPath: `fragments/${fragmentName}.fragment.xml`,
|
|
243
|
-
index: index ?? 0,
|
|
244
|
-
targetAggregation: targetAggregation ?? 'content'
|
|
245
|
-
};
|
|
246
|
-
|
|
247
242
|
const command = await this.commandExecutor.getCommand<AddFragmentChangeContentType>(
|
|
248
243
|
this.runtimeControl,
|
|
249
244
|
'addXML',
|
|
@@ -252,85 +247,6 @@ export default class AddFragment extends BaseDialog<AddFragmentModel> {
|
|
|
252
247
|
flexSettings
|
|
253
248
|
);
|
|
254
249
|
|
|
255
|
-
const templateName = this.getFragmentTemplateName(modifiedValue.targetAggregation);
|
|
256
|
-
if (templateName) {
|
|
257
|
-
const preparedChange = command.getPreparedChange();
|
|
258
|
-
const content = preparedChange.getContent();
|
|
259
|
-
preparedChange.setContent({ ...content, templateName });
|
|
260
|
-
CommunicationService.sendAction(setApplicationRequiresReload(true));
|
|
261
|
-
}
|
|
262
250
|
await this.commandExecutor.pushAndExecuteCommand(command);
|
|
263
|
-
return templateName;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Determines fragment template name based on current control name and provided target aggregation
|
|
268
|
-
* @param targetAggregation - target aggregation name
|
|
269
|
-
* @returns fragment template name or empty string
|
|
270
|
-
*/
|
|
271
|
-
private getFragmentTemplateName(targetAggregation: string): string {
|
|
272
|
-
const currentControlName = this.runtimeControl.getMetadata().getName();
|
|
273
|
-
if (currentControlName === 'sap.uxap.ObjectPageLayout' && targetAggregation === 'sections') {
|
|
274
|
-
return 'OBJECT_PAGE_CUSTOM_SECTION';
|
|
275
|
-
} else if (this.isCustomAction(currentControlName, targetAggregation)) {
|
|
276
|
-
return 'CUSTOM_ACTION';
|
|
277
|
-
} else if (this.isObjectPageHeaderField(currentControlName, targetAggregation)) {
|
|
278
|
-
return 'OBJECT_PAGE_HEADER_FIELD';
|
|
279
|
-
} else if (targetAggregation === 'columns') {
|
|
280
|
-
switch (currentControlName) {
|
|
281
|
-
case MDC_TABLE_TYPE:
|
|
282
|
-
return 'V4_MDC_TABLE_COLUMN';
|
|
283
|
-
case TREE_TABLE_TYPE:
|
|
284
|
-
case GRID_TABLE_TYPE:
|
|
285
|
-
return 'GRID_TREE_TABLE_COLUMN';
|
|
286
|
-
case ANALYTICAL_TABLE_TYPE:
|
|
287
|
-
return 'ANALYTICAL_TABLE_COLUMN';
|
|
288
|
-
default:
|
|
289
|
-
return '';
|
|
290
|
-
}
|
|
291
|
-
} else if (currentControlName === 'sap.ui.mdc.Table' && targetAggregation === 'actions') {
|
|
292
|
-
return 'TABLE_ACTION';
|
|
293
|
-
}
|
|
294
|
-
return '';
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* Determines conditions for custom action fragment creation
|
|
299
|
-
* @param currentControlName - current control name
|
|
300
|
-
* @param targetAggregation - target aggregation name
|
|
301
|
-
* @returns true if control and aggregation combination allows to create custom action fragment
|
|
302
|
-
*/
|
|
303
|
-
private isCustomAction(currentControlName: string, targetAggregation: string): boolean {
|
|
304
|
-
if (
|
|
305
|
-
['sap.f.DynamicPageTitle', 'sap.uxap.ObjectPageHeader', 'sap.uxap.ObjectPageDynamicHeaderTitle'].includes(
|
|
306
|
-
currentControlName
|
|
307
|
-
)
|
|
308
|
-
) {
|
|
309
|
-
return targetAggregation === 'actions';
|
|
310
|
-
} else if (currentControlName === 'sap.m.OverflowToolbar' || currentControlName === 'sap.m.Toolbar') {
|
|
311
|
-
return targetAggregation === 'content';
|
|
312
|
-
}
|
|
313
|
-
return false;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Determines conditions for object page header field fragment creation
|
|
318
|
-
* @param currentControlName - current control name
|
|
319
|
-
* @param targetAggregation - target aggregation name
|
|
320
|
-
* @returns true if conditions allow to create object page header field fragment
|
|
321
|
-
*/
|
|
322
|
-
private isObjectPageHeaderField(currentControlName: string, targetAggregation: string): boolean {
|
|
323
|
-
if (currentControlName === 'sap.uxap.ObjectPageLayout') {
|
|
324
|
-
return targetAggregation === 'headerContent';
|
|
325
|
-
} else if (currentControlName === 'sap.m.FlexBox') {
|
|
326
|
-
const parentName = this.runtimeControl.getParent()?.getMetadata().getName();
|
|
327
|
-
if (
|
|
328
|
-
parentName === 'sap.uxap.ObjectPageDynamicHeaderContent' ||
|
|
329
|
-
parentName === 'sap.uxap.ObjectPageLayout'
|
|
330
|
-
) {
|
|
331
|
-
return targetAggregation === 'items';
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
return false;
|
|
335
251
|
}
|
|
336
252
|
}
|