@sap-ux/preview-middleware 0.16.96 → 0.16.98
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/command-executor.js +17 -0
- package/dist/client/adp/command-executor.ts +19 -1
- package/dist/client/adp/controllers/AddFragment.controller.js +14 -63
- package/dist/client/adp/controllers/AddFragment.controller.ts +10 -74
- package/dist/client/adp/controllers/AddTableColumnFragments.controller.js +179 -0
- package/dist/client/adp/controllers/AddTableColumnFragments.controller.ts +298 -0
- package/dist/client/adp/controllers/BaseDialog.controller.js +83 -1
- package/dist/client/adp/controllers/BaseDialog.controller.ts +84 -0
- package/dist/client/adp/init-dialogs.js +9 -1
- package/dist/client/adp/init-dialogs.ts +9 -1
- package/dist/client/adp/quick-actions/fe-v2/change-table-columns.js +1 -1
- package/dist/client/adp/quick-actions/fe-v2/change-table-columns.ts +1 -1
- package/dist/client/adp/quick-actions/fe-v2/create-table-action.js +1 -1
- package/dist/client/adp/quick-actions/fe-v2/create-table-action.ts +1 -1
- package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.js +106 -0
- package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.ts +125 -0
- package/dist/client/adp/quick-actions/fe-v2/registry.js +14 -5
- package/dist/client/adp/quick-actions/fe-v2/registry.ts +18 -4
- package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column.js +58 -0
- package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column.ts +54 -0
- package/dist/client/adp/quick-actions/fe-v4/registry.js +4 -3
- package/dist/client/adp/quick-actions/fe-v4/registry.ts +5 -2
- package/dist/client/adp/quick-actions/{fe-v2/table-quick-action-base.js → table-quick-action-base.js} +29 -21
- package/dist/client/adp/quick-actions/{fe-v2/table-quick-action-base.ts → table-quick-action-base.ts} +16 -17
- package/dist/client/adp/ui/AddTableColumnFragments.fragment.xml +63 -0
- package/dist/client/messagebundle.properties +6 -0
- package/dist/client/tsconfig.tsbuildinfo +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/** sap.m */
|
|
2
|
+
import Button from 'sap/m/Button';
|
|
3
|
+
import type Dialog from 'sap/m/Dialog';
|
|
4
|
+
|
|
5
|
+
/** sap.ui.core */
|
|
6
|
+
import type UI5Element from 'sap/ui/core/Element';
|
|
7
|
+
|
|
8
|
+
/** sap.ui.base */
|
|
9
|
+
import type Event from 'sap/ui/base/Event';
|
|
10
|
+
|
|
11
|
+
/** sap.ui.model */
|
|
12
|
+
import JSONModel from 'sap/ui/model/json/JSONModel';
|
|
13
|
+
|
|
14
|
+
/** sap.ui.rta */
|
|
15
|
+
import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
|
|
16
|
+
|
|
17
|
+
/** sap.ui.dt */
|
|
18
|
+
import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
|
|
19
|
+
|
|
20
|
+
/** sap.ui.fl */
|
|
21
|
+
import { AddTableCellFragmentChangeContentType } from 'sap/ui/fl/Change';
|
|
22
|
+
|
|
23
|
+
/** sap.ui.layout */
|
|
24
|
+
import { type SimpleForm } from 'sap/ui/layout/form';
|
|
25
|
+
|
|
26
|
+
import { setApplicationRequiresReload } from '@sap-ux-private/control-property-editor-common';
|
|
27
|
+
|
|
28
|
+
import { getResourceModel, getTextBundle } from '../../i18n';
|
|
29
|
+
import { CommunicationService } from '../../cpe/communication-service';
|
|
30
|
+
|
|
31
|
+
import ControlUtils from '../control-utils';
|
|
32
|
+
import CommandExecutor from '../command-executor';
|
|
33
|
+
import { getFragments } from '../api-handler';
|
|
34
|
+
import BaseDialog from './BaseDialog.controller';
|
|
35
|
+
import { notifyUser } from '../utils';
|
|
36
|
+
import { type AddFragmentModel, type AddFragmentOptions } from './AddFragment.controller';
|
|
37
|
+
import { ValueState } from 'sap/ui/core/library';
|
|
38
|
+
import Input from 'sap/m/Input';
|
|
39
|
+
import Control from 'sap/ui/core/Control';
|
|
40
|
+
import ManagedObject from 'sap/ui/base/ManagedObject';
|
|
41
|
+
|
|
42
|
+
const radix = 10;
|
|
43
|
+
|
|
44
|
+
type AddTableColumnsFragmentsModel = AddFragmentModel & {
|
|
45
|
+
getProperty(sPath: '/newColumnFragmentName'): string;
|
|
46
|
+
getProperty(sPath: '/newCellFragmentName'): string;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const COLUMNS_AGGREGATION = 'columns';
|
|
50
|
+
const ITEMS_AGGREGATION = 'items';
|
|
51
|
+
const CELLS_AGGREGATION = 'cells';
|
|
52
|
+
|
|
53
|
+
interface CreateFragmentProps {
|
|
54
|
+
index: string | number;
|
|
55
|
+
fragments: { fragmentName: string; targetAggregation: string }[];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @namespace open.ux.preview.client.adp.controllers
|
|
60
|
+
*/
|
|
61
|
+
export default class AddTableColumnFragments extends BaseDialog<AddTableColumnsFragmentsModel> {
|
|
62
|
+
constructor(name: string, overlays: UI5Element, rta: RuntimeAuthoring, readonly options: AddFragmentOptions) {
|
|
63
|
+
super(name);
|
|
64
|
+
this.rta = rta;
|
|
65
|
+
this.overlays = overlays;
|
|
66
|
+
this.model = new JSONModel({
|
|
67
|
+
title: options.title
|
|
68
|
+
}) as AddTableColumnsFragmentsModel;
|
|
69
|
+
this.ui5Version = sap.ui.version;
|
|
70
|
+
this.commandExecutor = new CommandExecutor(this.rta);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Setups the Dialog and the JSON Model
|
|
75
|
+
*
|
|
76
|
+
* @param {Dialog} dialog - Dialog instance
|
|
77
|
+
*/
|
|
78
|
+
async setup(dialog: Dialog): Promise<void> {
|
|
79
|
+
this.dialog = dialog;
|
|
80
|
+
|
|
81
|
+
this.setEscapeHandler();
|
|
82
|
+
|
|
83
|
+
await this.buildDialogData();
|
|
84
|
+
const resourceModel = await getResourceModel('open.ux.preview.client');
|
|
85
|
+
|
|
86
|
+
this.dialog.setModel(resourceModel, 'i18n');
|
|
87
|
+
this.dialog.setModel(this.model);
|
|
88
|
+
|
|
89
|
+
this.dialog.open();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Handles create button press
|
|
94
|
+
*
|
|
95
|
+
* @param event Event
|
|
96
|
+
*/
|
|
97
|
+
async onCreateBtnPress(event: Event) {
|
|
98
|
+
const source = event.getSource<Button>();
|
|
99
|
+
source.setEnabled(false);
|
|
100
|
+
|
|
101
|
+
const columnFragmentName = this.model.getProperty('/newColumnFragmentName');
|
|
102
|
+
const cellFragmentName = this.model.getProperty('/newCellFragmentName');
|
|
103
|
+
const index = this.model.getProperty('/selectedIndex');
|
|
104
|
+
const fragmentData: CreateFragmentProps = {
|
|
105
|
+
index,
|
|
106
|
+
fragments: [
|
|
107
|
+
{
|
|
108
|
+
fragmentName: columnFragmentName,
|
|
109
|
+
targetAggregation: this.model.getProperty('/selectedColumnsAggregation')
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
fragmentName: cellFragmentName,
|
|
113
|
+
targetAggregation: this.model.getProperty('/selectedItemsAggregation')
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
await this.createFragmentChange(fragmentData);
|
|
119
|
+
|
|
120
|
+
const textKey = 'ADP_ADD_TWO_FRAGMENTS_WITH_TEMPLATE_NOTIFICATION';
|
|
121
|
+
const bundle = await getTextBundle();
|
|
122
|
+
notifyUser(
|
|
123
|
+
bundle.getText(
|
|
124
|
+
textKey,
|
|
125
|
+
fragmentData.fragments.map((item) => item.fragmentName)
|
|
126
|
+
),
|
|
127
|
+
8000
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
this.handleDialogClose();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Builds data that is used in the dialog
|
|
135
|
+
*/
|
|
136
|
+
async buildDialogData(): Promise<void> {
|
|
137
|
+
const { controlMetadata, targetAggregation } = this.getControlMetadata();
|
|
138
|
+
const defaultAggregation = this.options.aggregation ?? controlMetadata.getDefaultAggregationName();
|
|
139
|
+
const selectedControlName = controlMetadata.getName();
|
|
140
|
+
|
|
141
|
+
let selectedControlChildren: string[] | number[] = Object.keys(
|
|
142
|
+
ControlUtils.getControlAggregationByName(this.runtimeControl, defaultAggregation)
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
selectedControlChildren = selectedControlChildren.map((key) => {
|
|
146
|
+
return parseInt(key, radix);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
this.model.setProperty('/selectedControlName', selectedControlName);
|
|
150
|
+
|
|
151
|
+
const indexArray = this.fillIndexArray(selectedControlChildren);
|
|
152
|
+
|
|
153
|
+
if (!targetAggregation.includes(COLUMNS_AGGREGATION)) {
|
|
154
|
+
throw new Error(`Selected control does not have "${COLUMNS_AGGREGATION}" aggregation`);
|
|
155
|
+
}
|
|
156
|
+
this.model.setProperty('/selectedColumnsAggregation', COLUMNS_AGGREGATION);
|
|
157
|
+
this.specialIndexHandling(COLUMNS_AGGREGATION);
|
|
158
|
+
|
|
159
|
+
if (!targetAggregation.includes(ITEMS_AGGREGATION)) {
|
|
160
|
+
throw new Error(`Selected control does not have "${ITEMS_AGGREGATION}" aggregation`);
|
|
161
|
+
}
|
|
162
|
+
this.model.setProperty('/selectedItemsAggregation', ITEMS_AGGREGATION);
|
|
163
|
+
|
|
164
|
+
try {
|
|
165
|
+
const { fragments } = await getFragments();
|
|
166
|
+
this.model.setProperty('/fragmentList', fragments);
|
|
167
|
+
} catch (e) {
|
|
168
|
+
this.handleError(e);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
this.model.setProperty('/index', indexArray);
|
|
172
|
+
this.model.setProperty('/selectedIndex', indexArray.length - 1);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Checks input values for duplicates and updates confirmation button state based on input validation states
|
|
177
|
+
*/
|
|
178
|
+
private updateFormState() {
|
|
179
|
+
const form = this.dialog.getContent()[0] as unknown as SimpleForm<Control[]>;
|
|
180
|
+
const formContent = form.getContent();
|
|
181
|
+
const inputs = formContent.filter((item) => item.isA('sap.m.Input')) as Input[];
|
|
182
|
+
|
|
183
|
+
const value1 = inputs[0].getValue();
|
|
184
|
+
const value2 = inputs[1].getValue();
|
|
185
|
+
// check duplicating fragment names
|
|
186
|
+
if (value1 === value2 && value1.length) {
|
|
187
|
+
inputs.forEach((input) => {
|
|
188
|
+
if (input.getValueState() === ValueState.Success) {
|
|
189
|
+
// if there is no other validation error
|
|
190
|
+
input.setValueState(ValueState.Error).setValueStateText('Duplicate name');
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
} else {
|
|
194
|
+
// clear duplicates error
|
|
195
|
+
inputs.forEach((input) => {
|
|
196
|
+
if (input.getValueState() === ValueState.Error && input.getValueStateText() === 'Duplicate name') {
|
|
197
|
+
input.setValueState(ValueState.Success);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const beginBtn = this.dialog.getBeginButton();
|
|
203
|
+
beginBtn.setEnabled(inputs.every((input) => input.getValueState() === ValueState.Success));
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Handles column fragment name input change
|
|
208
|
+
*
|
|
209
|
+
* @param event Event
|
|
210
|
+
*/
|
|
211
|
+
onColumnFragmentNameInputChange(event: Event): void {
|
|
212
|
+
// call parent method to update control state and show warning messages
|
|
213
|
+
super.onFragmentNameInputChange(event);
|
|
214
|
+
|
|
215
|
+
// update model value
|
|
216
|
+
const input = event.getSource<Input>();
|
|
217
|
+
let modelValue: string | null = input.getValue();
|
|
218
|
+
if (modelValue.length < 1) {
|
|
219
|
+
modelValue = null;
|
|
220
|
+
}
|
|
221
|
+
this.model.setProperty('/newColumnFragmentName', modelValue);
|
|
222
|
+
this.updateFormState();
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Handles cell fragment name input change
|
|
227
|
+
*
|
|
228
|
+
* @param event Event
|
|
229
|
+
*/
|
|
230
|
+
onCellFragmentNameInputChange(event: Event): void {
|
|
231
|
+
// call parent method to update control state and show warning messages
|
|
232
|
+
super.onFragmentNameInputChange(event);
|
|
233
|
+
|
|
234
|
+
// update model value
|
|
235
|
+
const input = event.getSource<Input>();
|
|
236
|
+
let modelValue: string | null = input.getValue();
|
|
237
|
+
if (input.getValue().length < 1) {
|
|
238
|
+
modelValue = null;
|
|
239
|
+
}
|
|
240
|
+
this.model.setProperty('/newCellFragmentName', modelValue);
|
|
241
|
+
|
|
242
|
+
this.updateFormState();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Creates an addXML fragment command and pushes it to the command stack
|
|
247
|
+
*
|
|
248
|
+
* @param fragmentData Fragment Data
|
|
249
|
+
*/
|
|
250
|
+
private async createFragmentChange(fragmentData: CreateFragmentProps): Promise<string[] | undefined> {
|
|
251
|
+
const { fragments, index } = fragmentData;
|
|
252
|
+
|
|
253
|
+
const flexSettings = this.rta.getFlexSettings();
|
|
254
|
+
|
|
255
|
+
const overlay = OverlayRegistry.getOverlay(this.runtimeControl as UI5Element);
|
|
256
|
+
const designMetadata = overlay.getDesignTimeMetadata();
|
|
257
|
+
|
|
258
|
+
const result: string[] = [];
|
|
259
|
+
|
|
260
|
+
const compositeCommand = await this.commandExecutor.createCompositeCommand(this.runtimeControl);
|
|
261
|
+
|
|
262
|
+
for (const fragment of fragments) {
|
|
263
|
+
const modifiedValue = {
|
|
264
|
+
fragment: `<core:FragmentDefinition xmlns:core='sap.ui.core'></core:FragmentDefinition>`,
|
|
265
|
+
fragmentPath: `fragments/${fragment.fragmentName}.fragment.xml`,
|
|
266
|
+
index: index ?? 0,
|
|
267
|
+
targetAggregation:
|
|
268
|
+
fragment.targetAggregation === ITEMS_AGGREGATION ? CELLS_AGGREGATION : fragment.targetAggregation
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
const targetObject =
|
|
272
|
+
fragment.targetAggregation === COLUMNS_AGGREGATION
|
|
273
|
+
? this.runtimeControl
|
|
274
|
+
: (this.runtimeControl.getAggregation(ITEMS_AGGREGATION) as ManagedObject[])[0];
|
|
275
|
+
|
|
276
|
+
const command = await this.commandExecutor.getCommand<AddTableCellFragmentChangeContentType>(
|
|
277
|
+
targetObject,
|
|
278
|
+
'addXML',
|
|
279
|
+
modifiedValue,
|
|
280
|
+
designMetadata,
|
|
281
|
+
flexSettings
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
const templateName =
|
|
285
|
+
fragment.targetAggregation === COLUMNS_AGGREGATION ? `V2_SMART_TABLE_COLUMN` : 'V2_SMART_TABLE_CELL';
|
|
286
|
+
const preparedChange = command.getPreparedChange();
|
|
287
|
+
const content = { ...preparedChange.getContent(), templateName };
|
|
288
|
+
preparedChange.setContent(content);
|
|
289
|
+
compositeCommand.addCommand(command, false);
|
|
290
|
+
result.push(templateName);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
await this.commandExecutor.pushAndExecuteCommand(compositeCommand);
|
|
294
|
+
CommunicationService.sendAction(setApplicationRequiresReload(true));
|
|
295
|
+
|
|
296
|
+
return result;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
@@ -1,15 +1,78 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
sap.ui.define(["sap/ui/core/library", "sap/ui/core/mvc/Controller", "sap/m/MessageToast", "../utils", "../../utils/error"], function (sap_ui_core_library, Controller, MessageToast, ___utils, ____utils_error) {
|
|
3
|
+
sap.ui.define(["sap/ui/core/library", "sap/ui/core/mvc/Controller", "sap/m/MessageToast", "../utils", "../../utils/error", "../../utils/core", "../control-utils", "sap/ui/dt/OverlayRegistry"], function (sap_ui_core_library, Controller, MessageToast, ___utils, ____utils_error, ____utils_core, __ControlUtils, OverlayRegistry) {
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
|
+
function _interopRequireDefault(obj) {
|
|
7
|
+
return obj && obj.__esModule && typeof obj.default !== "undefined" ? obj.default : obj;
|
|
8
|
+
}
|
|
6
9
|
const ValueState = sap_ui_core_library["ValueState"];
|
|
7
10
|
const matchesFragmentName = ___utils["matchesFragmentName"];
|
|
8
11
|
const getError = ____utils_error["getError"];
|
|
12
|
+
const getControlById = ____utils_core["getControlById"];
|
|
13
|
+
const ControlUtils = _interopRequireDefault(__ControlUtils);
|
|
9
14
|
/**
|
|
10
15
|
* @namespace open.ux.preview.client.adp.controllers
|
|
11
16
|
*/
|
|
12
17
|
const BaseDialog = Controller.extend("open.ux.preview.client.adp.controllers.BaseDialog", {
|
|
18
|
+
/**
|
|
19
|
+
* Method is used in add fragment dialog controllers to get current control metadata which are needed on the dialog
|
|
20
|
+
* @returns control metadata and target aggregations
|
|
21
|
+
*/
|
|
22
|
+
getControlMetadata: function _getControlMetadata() {
|
|
23
|
+
const selectorId = this.overlays.getId();
|
|
24
|
+
let controlMetadata;
|
|
25
|
+
const overlayControl = getControlById(selectorId);
|
|
26
|
+
if (overlayControl) {
|
|
27
|
+
this.runtimeControl = ControlUtils.getRuntimeControl(overlayControl);
|
|
28
|
+
controlMetadata = this.runtimeControl.getMetadata();
|
|
29
|
+
} else {
|
|
30
|
+
throw new Error('Cannot get overlay control');
|
|
31
|
+
}
|
|
32
|
+
const allAggregations = Object.keys(controlMetadata.getAllAggregations());
|
|
33
|
+
const hiddenAggregations = ['customData', 'layoutData', 'dependents'];
|
|
34
|
+
const targetAggregation = allAggregations.filter(item => {
|
|
35
|
+
if (hiddenAggregations.indexOf(item) === -1) {
|
|
36
|
+
return item;
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
controlMetadata,
|
|
42
|
+
targetAggregation
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
/**
|
|
46
|
+
* Fills indexArray from selected control children
|
|
47
|
+
*
|
|
48
|
+
* @param selectedControlChildren Array of numbers
|
|
49
|
+
* @returns Array of key value pairs
|
|
50
|
+
*/
|
|
51
|
+
fillIndexArray: function _fillIndexArray(selectedControlChildren) {
|
|
52
|
+
let indexArray = [];
|
|
53
|
+
if (selectedControlChildren.length === 0) {
|
|
54
|
+
indexArray.push({
|
|
55
|
+
key: 0,
|
|
56
|
+
value: 0
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
indexArray = selectedControlChildren.map((elem, index) => {
|
|
60
|
+
return {
|
|
61
|
+
key: index + 1,
|
|
62
|
+
value: elem + 1
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
indexArray.unshift({
|
|
66
|
+
key: 0,
|
|
67
|
+
value: 0
|
|
68
|
+
});
|
|
69
|
+
indexArray.push({
|
|
70
|
+
key: selectedControlChildren.length + 1,
|
|
71
|
+
value: selectedControlChildren.length + 1
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return indexArray;
|
|
75
|
+
},
|
|
13
76
|
/**
|
|
14
77
|
* Handles fragment name input change
|
|
15
78
|
*
|
|
@@ -100,6 +163,25 @@ sap.ui.define(["sap/ui/core/library", "sap/ui/core/mvc/Controller", "sap/m/Messa
|
|
|
100
163
|
duration: 5000
|
|
101
164
|
});
|
|
102
165
|
throw error;
|
|
166
|
+
},
|
|
167
|
+
/**
|
|
168
|
+
* Handles the index field whenever a specific aggregation is chosen
|
|
169
|
+
*
|
|
170
|
+
* @param specialIndexAggregation string | number
|
|
171
|
+
*/
|
|
172
|
+
specialIndexHandling: function _specialIndexHandling(specialIndexAggregation) {
|
|
173
|
+
const overlay = OverlayRegistry.getOverlay(this.runtimeControl);
|
|
174
|
+
const aggregations = overlay.getDesignTimeMetadata().getData().aggregations;
|
|
175
|
+
if (specialIndexAggregation in aggregations && 'specialIndexHandling' in aggregations[specialIndexAggregation]) {
|
|
176
|
+
const controlType = this.runtimeControl.getMetadata().getName();
|
|
177
|
+
this.model.setProperty('/indexHandlingFlag', false);
|
|
178
|
+
this.model.setProperty('/specialIndexHandlingIcon', true);
|
|
179
|
+
this.model.setProperty('/iconTooltip', `Index is defined by special logic of ${controlType} and can't be set here`);
|
|
180
|
+
} else {
|
|
181
|
+
this.model.setProperty('/indexHandlingFlag', true);
|
|
182
|
+
this.model.setProperty('/specialIndexHandlingIcon', false);
|
|
183
|
+
this.model.setProperty('/specialIndexHandlingIconPressed', false);
|
|
184
|
+
}
|
|
103
185
|
}
|
|
104
186
|
});
|
|
105
187
|
return BaseDialog;
|
|
@@ -13,6 +13,11 @@ import CommandExecutor from '../command-executor';
|
|
|
13
13
|
import { matchesFragmentName } from '../utils';
|
|
14
14
|
import type { Fragments } from '../api-handler';
|
|
15
15
|
import { getError } from '../../utils/error';
|
|
16
|
+
import ManagedObjectMetadata from 'sap/ui/base/ManagedObjectMetadata';
|
|
17
|
+
import { getControlById } from '../../utils/core';
|
|
18
|
+
import ControlUtils from '../control-utils';
|
|
19
|
+
import type ElementOverlay from 'sap/ui/dt/ElementOverlay';
|
|
20
|
+
import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
|
|
16
21
|
|
|
17
22
|
type BaseDialogModel = JSONModel & {
|
|
18
23
|
getProperty(sPath: '/fragmentList'): Fragments;
|
|
@@ -57,6 +62,57 @@ export default abstract class BaseDialog<T extends BaseDialogModel = BaseDialogM
|
|
|
57
62
|
|
|
58
63
|
abstract buildDialogData(): Promise<void>;
|
|
59
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Method is used in add fragment dialog controllers to get current control metadata which are needed on the dialog
|
|
67
|
+
* @returns control metadata and target aggregations
|
|
68
|
+
*/
|
|
69
|
+
protected getControlMetadata(): { controlMetadata: ManagedObjectMetadata; targetAggregation: string[] } {
|
|
70
|
+
const selectorId = this.overlays.getId();
|
|
71
|
+
|
|
72
|
+
let controlMetadata: ManagedObjectMetadata;
|
|
73
|
+
|
|
74
|
+
const overlayControl = getControlById(selectorId) as unknown as ElementOverlay;
|
|
75
|
+
if (overlayControl) {
|
|
76
|
+
this.runtimeControl = ControlUtils.getRuntimeControl(overlayControl);
|
|
77
|
+
controlMetadata = this.runtimeControl.getMetadata();
|
|
78
|
+
} else {
|
|
79
|
+
throw new Error('Cannot get overlay control');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const allAggregations = Object.keys(controlMetadata.getAllAggregations());
|
|
83
|
+
const hiddenAggregations = ['customData', 'layoutData', 'dependents'];
|
|
84
|
+
const targetAggregation = allAggregations.filter((item) => {
|
|
85
|
+
if (hiddenAggregations.indexOf(item) === -1) {
|
|
86
|
+
return item;
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
});
|
|
90
|
+
return { controlMetadata, targetAggregation };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Fills indexArray from selected control children
|
|
95
|
+
*
|
|
96
|
+
* @param selectedControlChildren Array of numbers
|
|
97
|
+
* @returns Array of key value pairs
|
|
98
|
+
*/
|
|
99
|
+
protected fillIndexArray(selectedControlChildren: number[]) {
|
|
100
|
+
let indexArray: { key: number; value: number }[] = [];
|
|
101
|
+
if (selectedControlChildren.length === 0) {
|
|
102
|
+
indexArray.push({ key: 0, value: 0 });
|
|
103
|
+
} else {
|
|
104
|
+
indexArray = selectedControlChildren.map((elem, index) => {
|
|
105
|
+
return { key: index + 1, value: elem + 1 };
|
|
106
|
+
});
|
|
107
|
+
indexArray.unshift({ key: 0, value: 0 });
|
|
108
|
+
indexArray.push({
|
|
109
|
+
key: selectedControlChildren.length + 1,
|
|
110
|
+
value: selectedControlChildren.length + 1
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return indexArray;
|
|
114
|
+
}
|
|
115
|
+
|
|
60
116
|
/**
|
|
61
117
|
* Handles fragment name input change
|
|
62
118
|
*
|
|
@@ -167,4 +223,32 @@ export default abstract class BaseDialog<T extends BaseDialogModel = BaseDialogM
|
|
|
167
223
|
MessageToast.show(error.message, { duration: 5000 });
|
|
168
224
|
throw error;
|
|
169
225
|
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Handles the index field whenever a specific aggregation is chosen
|
|
229
|
+
*
|
|
230
|
+
* @param specialIndexAggregation string | number
|
|
231
|
+
*/
|
|
232
|
+
protected specialIndexHandling(specialIndexAggregation: string | number): void {
|
|
233
|
+
const overlay = OverlayRegistry.getOverlay(this.runtimeControl as UI5Element);
|
|
234
|
+
const aggregations = overlay.getDesignTimeMetadata().getData().aggregations;
|
|
235
|
+
|
|
236
|
+
if (
|
|
237
|
+
specialIndexAggregation in aggregations &&
|
|
238
|
+
'specialIndexHandling' in aggregations[specialIndexAggregation]
|
|
239
|
+
) {
|
|
240
|
+
const controlType = this.runtimeControl.getMetadata().getName();
|
|
241
|
+
this.model.setProperty('/indexHandlingFlag', false);
|
|
242
|
+
this.model.setProperty('/specialIndexHandlingIcon', true);
|
|
243
|
+
this.model.setProperty(
|
|
244
|
+
'/iconTooltip',
|
|
245
|
+
`Index is defined by special logic of ${controlType} and can't be set here`
|
|
246
|
+
);
|
|
247
|
+
} else {
|
|
248
|
+
this.model.setProperty('/indexHandlingFlag', true);
|
|
249
|
+
this.model.setProperty('/specialIndexHandlingIcon', false);
|
|
250
|
+
this.model.setProperty('/specialIndexHandlingIconPressed', false);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
170
254
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
sap.ui.define(["sap/ui/core/Fragment", "sap/ui/fl/Utils", "./controllers/AddFragment.controller", "./controllers/ControllerExtension.controller", "./controllers/ExtensionPoint.controller", "../cpe/utils", "../i18n"], function (Fragment, FlUtils, __AddFragment, __ControllerExtension, __ExtensionPoint, ___cpe_utils, ___i18n) {
|
|
3
|
+
sap.ui.define(["sap/ui/core/Fragment", "sap/ui/fl/Utils", "./controllers/AddFragment.controller", "./controllers/ControllerExtension.controller", "./controllers/ExtensionPoint.controller", "../cpe/utils", "../i18n", "./controllers/AddTableColumnFragments.controller"], function (Fragment, FlUtils, __AddFragment, __ControllerExtension, __ExtensionPoint, ___cpe_utils, ___i18n, __AddTableColumnFragments) {
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
6
|
function _interopRequireDefault(obj) {
|
|
@@ -11,8 +11,10 @@ sap.ui.define(["sap/ui/core/Fragment", "sap/ui/fl/Utils", "./controllers/AddFrag
|
|
|
11
11
|
const ExtensionPoint = _interopRequireDefault(__ExtensionPoint);
|
|
12
12
|
const isReuseComponent = ___cpe_utils["isReuseComponent"];
|
|
13
13
|
const getTextBundle = ___i18n["getTextBundle"];
|
|
14
|
+
const AddTableColumnFragments = _interopRequireDefault(__AddTableColumnFragments);
|
|
14
15
|
var DialogNames = /*#__PURE__*/function (DialogNames) {
|
|
15
16
|
DialogNames["ADD_FRAGMENT"] = "AddFragment";
|
|
17
|
+
DialogNames["ADD_TABLE_COLUMN_FRAGMENTS"] = "AddTableColumnFragments";
|
|
16
18
|
DialogNames["CONTROLLER_EXTENSION"] = "ControllerExtension";
|
|
17
19
|
DialogNames["ADD_FRAGMENT_AT_EXTENSION_POINT"] = "ExtensionPoint";
|
|
18
20
|
return DialogNames;
|
|
@@ -106,6 +108,12 @@ sap.ui.define(["sap/ui/core/Fragment", "sap/ui/fl/Utils", "./controllers/AddFrag
|
|
|
106
108
|
title: resources.getText(options.title ?? 'ADP_ADD_FRAGMENT_DIALOG_TITLE')
|
|
107
109
|
});
|
|
108
110
|
break;
|
|
111
|
+
case DialogNames.ADD_TABLE_COLUMN_FRAGMENTS:
|
|
112
|
+
controller = new AddTableColumnFragments(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta, {
|
|
113
|
+
aggregation: options.aggregation,
|
|
114
|
+
title: resources.getText(options.title ?? 'ADP_ADD_FRAGMENT_DIALOG_TITLE')
|
|
115
|
+
});
|
|
116
|
+
break;
|
|
109
117
|
case DialogNames.CONTROLLER_EXTENSION:
|
|
110
118
|
controller = new ControllerExtension(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta);
|
|
111
119
|
break;
|
|
@@ -22,14 +22,16 @@ import ManagedObject from 'sap/ui/base/ManagedObject';
|
|
|
22
22
|
import { isReuseComponent } from '../cpe/utils';
|
|
23
23
|
import { Ui5VersionInfo } from '../utils/version';
|
|
24
24
|
import { getTextBundle } from '../i18n';
|
|
25
|
+
import AddTableColumnFragments from './controllers/AddTableColumnFragments.controller';
|
|
25
26
|
|
|
26
27
|
export const enum DialogNames {
|
|
27
28
|
ADD_FRAGMENT = 'AddFragment',
|
|
29
|
+
ADD_TABLE_COLUMN_FRAGMENTS = 'AddTableColumnFragments',
|
|
28
30
|
CONTROLLER_EXTENSION = 'ControllerExtension',
|
|
29
31
|
ADD_FRAGMENT_AT_EXTENSION_POINT = 'ExtensionPoint'
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
type Controller = AddFragment | ControllerExtension | ExtensionPoint;
|
|
34
|
+
type Controller = AddFragment | AddTableColumnFragments | ControllerExtension | ExtensionPoint;
|
|
33
35
|
|
|
34
36
|
/**
|
|
35
37
|
* Handler for enablement of Extend With Controller context menu entry
|
|
@@ -138,6 +140,12 @@ export async function handler(
|
|
|
138
140
|
title: resources.getText(options.title ?? 'ADP_ADD_FRAGMENT_DIALOG_TITLE')
|
|
139
141
|
});
|
|
140
142
|
break;
|
|
143
|
+
case DialogNames.ADD_TABLE_COLUMN_FRAGMENTS:
|
|
144
|
+
controller = new AddTableColumnFragments(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta, {
|
|
145
|
+
aggregation: options.aggregation,
|
|
146
|
+
title: resources.getText(options.title ?? 'ADP_ADD_FRAGMENT_DIALOG_TITLE')
|
|
147
|
+
});
|
|
148
|
+
break;
|
|
141
149
|
case DialogNames.CONTROLLER_EXTENSION:
|
|
142
150
|
controller = new ControllerExtension(`open.ux.preview.client.adp.controllers.${dialogName}`, overlay, rta);
|
|
143
151
|
break;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
sap.ui.define(["../../../cpe/feature-service", "../../../utils/core", "
|
|
3
|
+
sap.ui.define(["../../../cpe/feature-service", "../../../utils/core", "../table-quick-action-base"], function (_____cpe_feature_service, _____utils_core, ___table_quick_action_base) {
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
6
|
const FeatureService = _____cpe_feature_service["FeatureService"];
|
|
@@ -6,7 +6,7 @@ import ManagedObject from 'sap/ui/base/ManagedObject';
|
|
|
6
6
|
import { FeatureService } from '../../../cpe/feature-service';
|
|
7
7
|
import { QuickActionContext, NestedQuickActionDefinition } from '../../../cpe/quick-actions/quick-action-definition';
|
|
8
8
|
import { getControlById, isA } from '../../../utils/core';
|
|
9
|
-
import { TableQuickActionDefinitionBase } from '
|
|
9
|
+
import { TableQuickActionDefinitionBase } from '../table-quick-action-base';
|
|
10
10
|
|
|
11
11
|
export const CHANGE_TABLE_COLUMNS = 'change-table-columns';
|
|
12
12
|
const SMART_TABLE_TYPE = 'sap.ui.comp.smarttable.SmartTable';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../../utils/core", "../../init-dialogs", "../../../cpe/feature-service", "
|
|
3
|
+
sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../../utils/core", "../../init-dialogs", "../../../cpe/feature-service", "../table-quick-action-base"], function (OverlayRegistry, _____utils_core, ____init_dialogs, _____cpe_feature_service, ___table_quick_action_base) {
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
6
|
const getControlById = _____utils_core["getControlById"];
|
|
@@ -9,7 +9,7 @@ import { QuickActionContext, NestedQuickActionDefinition } from '../../../cpe/qu
|
|
|
9
9
|
import { getControlById, isA } from '../../../utils/core';
|
|
10
10
|
import { DialogNames, handler } from '../../init-dialogs';
|
|
11
11
|
import { FeatureService } from '../../../cpe/feature-service';
|
|
12
|
-
import { TableQuickActionDefinitionBase } from '
|
|
12
|
+
import { TableQuickActionDefinitionBase } from '../table-quick-action-base';
|
|
13
13
|
|
|
14
14
|
export const CREATE_TABLE_ACTION = 'create-table-action';
|
|
15
15
|
const SMART_TABLE_TYPE = 'sap.ui.comp.smarttable.SmartTable';
|