@sap-ux/preview-middleware 0.13.18 → 0.13.19
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/flex.d.ts +5 -15
- package/dist/base/flex.js +4 -32
- package/dist/base/flp.d.ts +12 -2
- package/dist/base/flp.js +27 -5
- package/dist/client/adp/api-handler.js +141 -141
- package/dist/client/adp/command-executor.js +54 -54
- package/dist/client/adp/control-utils.js +44 -44
- package/dist/client/adp/controllers/AddFragment.controller.js +185 -206
- package/dist/client/adp/controllers/AddFragment.controller.ts +5 -24
- package/dist/client/adp/controllers/BaseDialog.controller.js +74 -57
- package/dist/client/adp/controllers/BaseDialog.controller.ts +36 -2
- package/dist/client/adp/controllers/ControllerExtension.controller.js +179 -179
- package/dist/client/adp/controllers/ExtensionPoint.controller.js +90 -100
- package/dist/client/adp/controllers/ExtensionPoint.controller.ts +9 -22
- package/dist/client/adp/init-dialogs.js +74 -74
- package/dist/client/adp/ui5-version-utils.js +63 -63
- package/dist/client/adp/utils.js +61 -33
- package/dist/client/adp/utils.ts +34 -0
- package/dist/client/cpe/changes/flex-change.js +51 -51
- package/dist/client/cpe/changes/index.js +10 -10
- package/dist/client/cpe/changes/validator.js +35 -35
- package/dist/client/cpe/documentation.js +164 -164
- package/dist/client/cpe/logger.js +30 -30
- package/dist/client/cpe/outline/nodes.js +84 -84
- package/dist/client/cpe/outline/utils.js +37 -37
- package/dist/client/cpe/types.js +4 -4
- package/dist/client/cpe/ui5-utils.js +49 -49
- package/dist/client/cpe/utils.js +48 -48
- package/dist/client/flp/WorkspaceConnector.js +84 -84
- package/dist/client/flp/common.js +28 -28
- package/dist/client/flp/enableFakeConnector.js +77 -77
- package/dist/client/flp/init.js +220 -220
- package/dist/client/flp/initConnectors.js +33 -33
- package/dist/client/flp/initRta.js +178 -178
- package/package.json +7 -3
|
@@ -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
|
|
@@ -1,208 +1,187 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "sap/ui/dt/OverlayRegistry", "../control-utils", "../command-executor", "../api-handler", "./BaseDialog.controller"], function (MessageToast, JSONModel, OverlayRegistry, __ControlUtils, __CommandExecutor, ___api_handler, __BaseDialog) {
|
|
4
|
-
"use strict";
|
|
5
|
-
|
|
6
|
-
function _interopRequireDefault(obj) {
|
|
7
|
-
return obj && obj.__esModule && typeof obj.default !== "undefined" ? obj.default : obj;
|
|
8
|
-
}
|
|
9
|
-
const ControlUtils = _interopRequireDefault(__ControlUtils);
|
|
10
|
-
const CommandExecutor = _interopRequireDefault(__CommandExecutor);
|
|
11
|
-
const getFragments = ___api_handler["getFragments"];
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
/**
|
|
15
|
-
* @namespace open.ux.preview.client.adp.controllers
|
|
16
|
-
*/
|
|
17
|
-
const AddFragment = BaseDialog.extend("open.ux.preview.client.adp.controllers.AddFragment", {
|
|
18
|
-
constructor: function _constructor(name, overlays, rta) {
|
|
19
|
-
BaseDialog.prototype.constructor.call(this, name);
|
|
20
|
-
this.rta = rta;
|
|
21
|
-
this.overlays = overlays;
|
|
22
|
-
this.model = new JSONModel();
|
|
23
|
-
this.ui5Version = sap.ui.version;
|
|
24
|
-
this.commandExecutor = new CommandExecutor(this.rta);
|
|
25
|
-
},
|
|
26
|
-
setup: async function _setup(dialog) {
|
|
27
|
-
this.dialog = dialog;
|
|
28
|
-
this.setEscapeHandler();
|
|
29
|
-
await this.buildDialogData();
|
|
30
|
-
this.dialog.setModel(this.model);
|
|
31
|
-
this.dialog.open();
|
|
32
|
-
},
|
|
33
|
-
specialIndexHandling: function _specialIndexHandling(specialIndexAggregation) {
|
|
34
|
-
const overlay = OverlayRegistry.getOverlay(this.runtimeControl);
|
|
35
|
-
const aggregations = overlay.getDesignTimeMetadata().getData().aggregations;
|
|
36
|
-
if (specialIndexAggregation in aggregations && 'specialIndexHandling' in aggregations[specialIndexAggregation]) {
|
|
37
|
-
const controlType = this.runtimeControl.getMetadata().getName();
|
|
38
|
-
this.model.setProperty('/indexHandlingFlag', false);
|
|
39
|
-
this.model.setProperty('/specialIndexHandlingIcon', true);
|
|
40
|
-
this.model.setProperty('/iconTooltip', `Index is defined by special logic of ${controlType} and can't be set here`);
|
|
41
|
-
} else {
|
|
42
|
-
this.model.setProperty('/indexHandlingFlag', true);
|
|
43
|
-
this.model.setProperty('/specialIndexHandlingIcon', false);
|
|
44
|
-
this.model.setProperty('/specialIndexHandlingIconPressed', false);
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
onAggregationChanged: function _onAggregationChanged(event) {
|
|
48
|
-
const source = event.getSource();
|
|
49
|
-
const selectedKey = source.getSelectedKey();
|
|
50
|
-
const selectedItem = source.getSelectedItem();
|
|
51
|
-
let selectedItemText = '';
|
|
52
|
-
if (selectedItem) {
|
|
53
|
-
selectedItemText = selectedItem.getText();
|
|
54
|
-
}
|
|
55
|
-
this.model.setProperty('/selectedAggregation/key', selectedKey);
|
|
56
|
-
this.model.setProperty('/selectedAggregation/value', selectedItemText);
|
|
57
|
-
let newSelectedControlChildren = Object.keys(ControlUtils.getControlAggregationByName(this.runtimeControl, selectedItemText));
|
|
58
|
-
newSelectedControlChildren = newSelectedControlChildren.map(key => {
|
|
59
|
-
return parseInt(key);
|
|
60
|
-
});
|
|
61
|
-
this.specialIndexHandling(selectedItemText);
|
|
62
|
-
const updatedIndexArray = this.fillIndexArray(newSelectedControlChildren);
|
|
63
|
-
this.model.setProperty('/index', updatedIndexArray);
|
|
64
|
-
this.model.setProperty('/selectedIndex', updatedIndexArray.length - 1);
|
|
65
|
-
},
|
|
66
|
-
onCreateBtnPress: async function _onCreateBtnPress(event) {
|
|
67
|
-
const source = event.getSource();
|
|
68
|
-
source.setEnabled(false);
|
|
69
|
-
const fragmentName = this.model.getProperty('/newFragmentName');
|
|
70
|
-
const index = parseInt(this.model.getProperty('/selectedIndex'));
|
|
71
|
-
const targetAggregation = this.model.getProperty('/selectedAggregation/value');
|
|
72
|
-
const fragmentData = {
|
|
73
|
-
index,
|
|
74
|
-
fragmentName,
|
|
75
|
-
targetAggregation
|
|
76
|
-
};
|
|
77
|
-
await this.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
selectedControlChildren =
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
this.model.setProperty('/
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
this.model.setProperty('/selectedAggregation/
|
|
119
|
-
this.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
this.model.setProperty('/selectedAggregation/
|
|
125
|
-
this.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
this.model.setProperty('/
|
|
138
|
-
this.model.setProperty('/
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
await this.
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
},
|
|
187
|
-
createFragmentChange: async function _createFragmentChange(fragmentData) {
|
|
188
|
-
const {
|
|
189
|
-
fragmentName,
|
|
190
|
-
index,
|
|
191
|
-
targetAggregation
|
|
192
|
-
} = fragmentData;
|
|
193
|
-
const flexSettings = this.rta.getFlexSettings();
|
|
194
|
-
const overlay = OverlayRegistry.getOverlay(this.runtimeControl);
|
|
195
|
-
const designMetadata = overlay.getDesignTimeMetadata();
|
|
196
|
-
const modifiedValue = {
|
|
197
|
-
fragment: `<core:FragmentDefinition xmlns:core='sap.ui.core'></core:FragmentDefinition>`,
|
|
198
|
-
fragmentPath: `fragments/${fragmentName}.fragment.xml`,
|
|
199
|
-
index: index ?? 0,
|
|
200
|
-
targetAggregation: targetAggregation ?? 'content'
|
|
201
|
-
};
|
|
202
|
-
const command = await this.commandExecutor.getCommand(this.runtimeControl, 'addXML', modifiedValue, designMetadata, flexSettings);
|
|
203
|
-
await this.commandExecutor.pushAndExecuteCommand(command);
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
return AddFragment;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "sap/ui/dt/OverlayRegistry", "../control-utils", "../command-executor", "../api-handler", "./BaseDialog.controller", "../utils"], function (MessageToast, JSONModel, OverlayRegistry, __ControlUtils, __CommandExecutor, ___api_handler, __BaseDialog, ___utils) {
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
function _interopRequireDefault(obj) {
|
|
7
|
+
return obj && obj.__esModule && typeof obj.default !== "undefined" ? obj.default : obj;
|
|
8
|
+
}
|
|
9
|
+
const ControlUtils = _interopRequireDefault(__ControlUtils);
|
|
10
|
+
const CommandExecutor = _interopRequireDefault(__CommandExecutor);
|
|
11
|
+
const getFragments = ___api_handler["getFragments"];
|
|
12
|
+
const BaseDialog = _interopRequireDefault(__BaseDialog);
|
|
13
|
+
const notifyUser = ___utils["notifyUser"];
|
|
14
|
+
/**
|
|
15
|
+
* @namespace open.ux.preview.client.adp.controllers
|
|
16
|
+
*/
|
|
17
|
+
const AddFragment = BaseDialog.extend("open.ux.preview.client.adp.controllers.AddFragment", {
|
|
18
|
+
constructor: function _constructor(name, overlays, rta) {
|
|
19
|
+
BaseDialog.prototype.constructor.call(this, name);
|
|
20
|
+
this.rta = rta;
|
|
21
|
+
this.overlays = overlays;
|
|
22
|
+
this.model = new JSONModel();
|
|
23
|
+
this.ui5Version = sap.ui.version;
|
|
24
|
+
this.commandExecutor = new CommandExecutor(this.rta);
|
|
25
|
+
},
|
|
26
|
+
setup: async function _setup(dialog) {
|
|
27
|
+
this.dialog = dialog;
|
|
28
|
+
this.setEscapeHandler();
|
|
29
|
+
await this.buildDialogData();
|
|
30
|
+
this.dialog.setModel(this.model);
|
|
31
|
+
this.dialog.open();
|
|
32
|
+
},
|
|
33
|
+
specialIndexHandling: function _specialIndexHandling(specialIndexAggregation) {
|
|
34
|
+
const overlay = OverlayRegistry.getOverlay(this.runtimeControl);
|
|
35
|
+
const aggregations = overlay.getDesignTimeMetadata().getData().aggregations;
|
|
36
|
+
if (specialIndexAggregation in aggregations && 'specialIndexHandling' in aggregations[specialIndexAggregation]) {
|
|
37
|
+
const controlType = this.runtimeControl.getMetadata().getName();
|
|
38
|
+
this.model.setProperty('/indexHandlingFlag', false);
|
|
39
|
+
this.model.setProperty('/specialIndexHandlingIcon', true);
|
|
40
|
+
this.model.setProperty('/iconTooltip', `Index is defined by special logic of ${controlType} and can't be set here`);
|
|
41
|
+
} else {
|
|
42
|
+
this.model.setProperty('/indexHandlingFlag', true);
|
|
43
|
+
this.model.setProperty('/specialIndexHandlingIcon', false);
|
|
44
|
+
this.model.setProperty('/specialIndexHandlingIconPressed', false);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
onAggregationChanged: function _onAggregationChanged(event) {
|
|
48
|
+
const source = event.getSource();
|
|
49
|
+
const selectedKey = source.getSelectedKey();
|
|
50
|
+
const selectedItem = source.getSelectedItem();
|
|
51
|
+
let selectedItemText = '';
|
|
52
|
+
if (selectedItem) {
|
|
53
|
+
selectedItemText = selectedItem.getText();
|
|
54
|
+
}
|
|
55
|
+
this.model.setProperty('/selectedAggregation/key', selectedKey);
|
|
56
|
+
this.model.setProperty('/selectedAggregation/value', selectedItemText);
|
|
57
|
+
let newSelectedControlChildren = Object.keys(ControlUtils.getControlAggregationByName(this.runtimeControl, selectedItemText));
|
|
58
|
+
newSelectedControlChildren = newSelectedControlChildren.map(key => {
|
|
59
|
+
return parseInt(key);
|
|
60
|
+
});
|
|
61
|
+
this.specialIndexHandling(selectedItemText);
|
|
62
|
+
const updatedIndexArray = this.fillIndexArray(newSelectedControlChildren);
|
|
63
|
+
this.model.setProperty('/index', updatedIndexArray);
|
|
64
|
+
this.model.setProperty('/selectedIndex', updatedIndexArray.length - 1);
|
|
65
|
+
},
|
|
66
|
+
onCreateBtnPress: async function _onCreateBtnPress(event) {
|
|
67
|
+
const source = event.getSource();
|
|
68
|
+
source.setEnabled(false);
|
|
69
|
+
const fragmentName = this.model.getProperty('/newFragmentName');
|
|
70
|
+
const index = parseInt(this.model.getProperty('/selectedIndex'));
|
|
71
|
+
const targetAggregation = this.model.getProperty('/selectedAggregation/value');
|
|
72
|
+
const fragmentData = {
|
|
73
|
+
index,
|
|
74
|
+
fragmentName,
|
|
75
|
+
targetAggregation
|
|
76
|
+
};
|
|
77
|
+
await this.createFragmentChange(fragmentData);
|
|
78
|
+
notifyUser(`Note: The '${fragmentName}.fragment.xml' fragment will be created once you save the change.`, 8000);
|
|
79
|
+
this.handleDialogClose();
|
|
80
|
+
},
|
|
81
|
+
buildDialogData: async function _buildDialogData() {
|
|
82
|
+
const selectorId = this.overlays.getId();
|
|
83
|
+
let controlMetadata;
|
|
84
|
+
const overlayControl = sap.ui.getCore().byId(selectorId);
|
|
85
|
+
if (overlayControl) {
|
|
86
|
+
this.runtimeControl = ControlUtils.getRuntimeControl(overlayControl);
|
|
87
|
+
controlMetadata = this.runtimeControl.getMetadata();
|
|
88
|
+
} else {
|
|
89
|
+
throw new Error('Cannot get overlay control');
|
|
90
|
+
}
|
|
91
|
+
const allAggregations = Object.keys(controlMetadata.getAllAggregations());
|
|
92
|
+
const hiddenAggregations = ['customData', 'layoutData', 'dependents'];
|
|
93
|
+
const targetAggregation = allAggregations.filter(item => {
|
|
94
|
+
if (hiddenAggregations.indexOf(item) === -1) {
|
|
95
|
+
return item;
|
|
96
|
+
}
|
|
97
|
+
return false;
|
|
98
|
+
});
|
|
99
|
+
const defaultAggregation = controlMetadata.getDefaultAggregationName();
|
|
100
|
+
const selectedControlName = controlMetadata.getName();
|
|
101
|
+
let selectedControlChildren = Object.keys(ControlUtils.getControlAggregationByName(this.runtimeControl, defaultAggregation));
|
|
102
|
+
selectedControlChildren = selectedControlChildren.map(key => {
|
|
103
|
+
return parseInt(key);
|
|
104
|
+
});
|
|
105
|
+
this.model.setProperty('/selectedControlName', selectedControlName);
|
|
106
|
+
this.model.setProperty('/selectedAggregation', {});
|
|
107
|
+
const indexArray = this.fillIndexArray(selectedControlChildren);
|
|
108
|
+
const controlAggregation = targetAggregation.map((elem, index) => {
|
|
109
|
+
return {
|
|
110
|
+
key: index,
|
|
111
|
+
value: elem
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
if (defaultAggregation !== null) {
|
|
115
|
+
controlAggregation.forEach(obj => {
|
|
116
|
+
if (obj.value === defaultAggregation) {
|
|
117
|
+
obj.key = 'default';
|
|
118
|
+
this.model.setProperty('/selectedAggregation/key', obj.key);
|
|
119
|
+
this.model.setProperty('/selectedAggregation/value', obj.value);
|
|
120
|
+
this.specialIndexHandling(obj.value);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
} else {
|
|
124
|
+
this.model.setProperty('/selectedAggregation/key', controlAggregation[0].key);
|
|
125
|
+
this.model.setProperty('/selectedAggregation/value', controlAggregation[0].value);
|
|
126
|
+
this.specialIndexHandling(controlAggregation[0].value);
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
const {
|
|
130
|
+
fragments
|
|
131
|
+
} = await getFragments();
|
|
132
|
+
this.model.setProperty('/fragmentList', fragments);
|
|
133
|
+
} catch (e) {
|
|
134
|
+
MessageToast.show(e.message);
|
|
135
|
+
throw new Error(e.message);
|
|
136
|
+
}
|
|
137
|
+
this.model.setProperty('/selectedIndex', indexArray.length - 1);
|
|
138
|
+
this.model.setProperty('/targetAggregation', controlAggregation);
|
|
139
|
+
this.model.setProperty('/index', indexArray);
|
|
140
|
+
},
|
|
141
|
+
fillIndexArray: function _fillIndexArray(selectedControlChildren) {
|
|
142
|
+
let indexArray = [];
|
|
143
|
+
if (selectedControlChildren.length === 0) {
|
|
144
|
+
indexArray.push({
|
|
145
|
+
key: 0,
|
|
146
|
+
value: 0
|
|
147
|
+
});
|
|
148
|
+
} else {
|
|
149
|
+
indexArray = selectedControlChildren.map((elem, index) => {
|
|
150
|
+
return {
|
|
151
|
+
key: index + 1,
|
|
152
|
+
value: elem + 1
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
indexArray.unshift({
|
|
156
|
+
key: 0,
|
|
157
|
+
value: 0
|
|
158
|
+
});
|
|
159
|
+
indexArray.push({
|
|
160
|
+
key: selectedControlChildren.length + 1,
|
|
161
|
+
value: selectedControlChildren.length + 1
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
return indexArray;
|
|
165
|
+
},
|
|
166
|
+
createFragmentChange: async function _createFragmentChange(fragmentData) {
|
|
167
|
+
const {
|
|
168
|
+
fragmentName,
|
|
169
|
+
index,
|
|
170
|
+
targetAggregation
|
|
171
|
+
} = fragmentData;
|
|
172
|
+
const flexSettings = this.rta.getFlexSettings();
|
|
173
|
+
const overlay = OverlayRegistry.getOverlay(this.runtimeControl);
|
|
174
|
+
const designMetadata = overlay.getDesignTimeMetadata();
|
|
175
|
+
const modifiedValue = {
|
|
176
|
+
fragment: `<core:FragmentDefinition xmlns:core='sap.ui.core'></core:FragmentDefinition>`,
|
|
177
|
+
fragmentPath: `fragments/${fragmentName}.fragment.xml`,
|
|
178
|
+
index: index ?? 0,
|
|
179
|
+
targetAggregation: targetAggregation ?? 'content'
|
|
180
|
+
};
|
|
181
|
+
const command = await this.commandExecutor.getCommand(this.runtimeControl, 'addXML', modifiedValue, designMetadata, flexSettings);
|
|
182
|
+
await this.commandExecutor.pushAndExecuteCommand(command);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
return AddFragment;
|
|
207
186
|
});
|
|
208
187
|
//# sourceMappingURL=AddFragment.controller.js.map
|
|
@@ -23,8 +23,9 @@ import type ElementOverlay from 'sap/ui/dt/ElementOverlay';
|
|
|
23
23
|
|
|
24
24
|
import ControlUtils from '../control-utils';
|
|
25
25
|
import CommandExecutor from '../command-executor';
|
|
26
|
-
import { getFragments
|
|
26
|
+
import { getFragments } from '../api-handler';
|
|
27
27
|
import BaseDialog from './BaseDialog.controller';
|
|
28
|
+
import { notifyUser } from '../utils';
|
|
28
29
|
|
|
29
30
|
interface CreateFragmentProps {
|
|
30
31
|
fragmentName: string;
|
|
@@ -142,7 +143,9 @@ export default class AddFragment extends BaseDialog {
|
|
|
142
143
|
targetAggregation
|
|
143
144
|
};
|
|
144
145
|
|
|
145
|
-
await this.
|
|
146
|
+
await this.createFragmentChange(fragmentData);
|
|
147
|
+
|
|
148
|
+
notifyUser(`Note: The '${fragmentName}.fragment.xml' fragment will be created once you save the change.`, 8000);
|
|
146
149
|
|
|
147
150
|
this.handleDialogClose();
|
|
148
151
|
}
|
|
@@ -245,28 +248,6 @@ export default class AddFragment extends BaseDialog {
|
|
|
245
248
|
return indexArray;
|
|
246
249
|
}
|
|
247
250
|
|
|
248
|
-
/**
|
|
249
|
-
* Creates a new fragment for the specified control
|
|
250
|
-
*
|
|
251
|
-
* @param fragmentData Fragment Data
|
|
252
|
-
* @param fragmentData.index Index for XML Fragment placement
|
|
253
|
-
* @param fragmentData.fragmentName Fragment name
|
|
254
|
-
* @param fragmentData.targetAggregation Target aggregation for control
|
|
255
|
-
*/
|
|
256
|
-
private async createNewFragment(fragmentData: CreateFragmentProps): Promise<void> {
|
|
257
|
-
const { fragmentName, index, targetAggregation } = fragmentData;
|
|
258
|
-
try {
|
|
259
|
-
await writeFragment<unknown>({ fragmentName });
|
|
260
|
-
MessageToast.show(`Fragment with name '${fragmentName}' was created.`);
|
|
261
|
-
} catch (e) {
|
|
262
|
-
// In case of error when creating a new fragment, we should not create a change file
|
|
263
|
-
MessageToast.show(e.message);
|
|
264
|
-
throw new Error(e.message);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
await this.createFragmentChange({ fragmentName, index, targetAggregation });
|
|
268
|
-
}
|
|
269
|
-
|
|
270
251
|
/**
|
|
271
252
|
* Creates an addXML fragment command and pushes it to the command stack
|
|
272
253
|
*
|