@sap-ux/preview-middleware 0.23.48 → 0.23.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/client/adp/command-executor.js +99 -66
  2. package/dist/client/adp/controllers/AddCustomFragment.controller.js +120 -102
  3. package/dist/client/adp/controllers/AddFragment.controller.js +189 -163
  4. package/dist/client/adp/controllers/AddSubpage.controller.js +146 -137
  5. package/dist/client/adp/controllers/AddTableColumnFragments.controller.js +230 -188
  6. package/dist/client/adp/controllers/BaseDialog.controller.js +187 -164
  7. package/dist/client/adp/controllers/ControllerExtension.controller.js +329 -253
  8. package/dist/client/adp/controllers/ExtensionPoint.controller.js +158 -114
  9. package/dist/client/adp/extension-point.js +81 -60
  10. package/dist/client/adp/init.js +100 -99
  11. package/dist/client/adp/quick-actions/common/add-new-annotation-file.js +165 -147
  12. package/dist/client/adp/quick-actions/enablement-validator.js +0 -4
  13. package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.js +105 -100
  14. package/dist/client/adp/quick-actions/simple-quick-action-base.js +44 -40
  15. package/dist/client/adp/quick-actions/table-quick-action-base.js +309 -266
  16. package/dist/client/adp/sync-views-utils.js +119 -83
  17. package/dist/client/cpe/changes/flex-change.js +64 -48
  18. package/dist/client/cpe/changes/service.js +492 -367
  19. package/dist/client/cpe/communication-service.js +41 -29
  20. package/dist/client/cpe/connector-service.js +87 -64
  21. package/dist/client/cpe/context-menu-service.js +87 -74
  22. package/dist/client/cpe/control-data.js +353 -263
  23. package/dist/client/cpe/documentation.js +183 -126
  24. package/dist/client/cpe/init.js +69 -75
  25. package/dist/client/cpe/outline/service.js +60 -45
  26. package/dist/client/cpe/quick-actions/quick-action-definition.js +0 -4
  27. package/dist/client/cpe/quick-actions/quick-action-service.js +154 -129
  28. package/dist/client/cpe/rta-service.js +91 -69
  29. package/dist/client/cpe/selection.js +239 -187
  30. package/dist/client/cpe/types.js +0 -4
  31. package/dist/client/flp/init.js +403 -296
  32. package/dist/client/manifest.json +7 -4
  33. package/dist/client/thirdparty/@sap-ux-private/control-property-editor-common.js +444 -370
  34. package/dist/client/utils/info-center-message.js +59 -31
  35. package/dist/client/utils/version.js +128 -72
  36. package/package.json +4 -4
@@ -1,255 +1,331 @@
1
- 'use strict';
2
- sap.ui.define([
3
- 'sap/ui/core/library',
4
- 'sap/ui/model/json/JSONModel',
5
- 'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
6
- '../../i18n',
7
- '../../utils/core',
8
- '../../utils/error',
9
- '../../utils/info-center-message',
10
- '../../utils/version',
11
- '../api-handler',
12
- '../command-executor',
13
- '../utils',
14
- './BaseDialog.controller'
15
- ], function (sap_ui_core_library, JSONModel, ___sap_ux_private_control_property_editor_common, ____i18n, ____utils_core, ____utils_error, ____utils_info_center_message, ____utils_version, ___api_handler, __CommandExecutor, ___utils, __BaseDialog) {
16
- 'use strict';
17
- function _interopRequireDefault(obj) {
18
- return obj && obj.__esModule && typeof obj.default !== 'undefined' ? obj.default : obj;
19
- }
20
- const ValueState = sap_ui_core_library['ValueState'];
21
- const MessageBarType = ___sap_ux_private_control_property_editor_common['MessageBarType'];
22
- const getResourceModel = ____i18n['getResourceModel'];
23
- const getTextBundle = ____i18n['getTextBundle'];
24
- const getControlById = ____utils_core['getControlById'];
25
- const getError = ____utils_error['getError'];
26
- const sendInfoCenterMessage = ____utils_info_center_message['sendInfoCenterMessage'];
27
- const getUi5Version = ____utils_version['getUi5Version'];
28
- const isLowerThanMinimalUi5Version = ____utils_version['isLowerThanMinimalUi5Version'];
29
- const getExistingController = ___api_handler['getExistingController'];
30
- const readControllers = ___api_handler['readControllers'];
31
- const writeChange = ___api_handler['writeChange'];
32
- const writeController = ___api_handler['writeController'];
33
- const CommandExecutor = _interopRequireDefault(__CommandExecutor);
34
- const checkForExistingChange = ___utils['checkForExistingChange'];
35
- const getControllerInfo = ___utils['getControllerInfo'];
36
- const BaseDialog = _interopRequireDefault(__BaseDialog);
37
- const ControllerExtension = BaseDialog.extend('open.ux.preview.client.adp.controllers.ControllerExtension', {
38
- constructor: function _constructor(name, overlays, rta, data, telemetryData) {
39
- BaseDialog.prototype.constructor.call(this, name, telemetryData);
40
- this.rta = rta;
41
- this.overlays = overlays;
42
- this.model = new JSONModel();
43
- this.data = data;
44
- },
45
- setup: async function _setup(dialog) {
46
- this.dialog = dialog;
47
- this.setEscapeHandler();
48
- const resourceModel = await getResourceModel('open.ux.preview.client');
49
- this.bundle = await getTextBundle();
50
- await this.buildDialogData();
51
- this.dialog.setModel(resourceModel, 'i18n');
52
- this.dialog.setModel(this.model);
53
- this.dialog.open();
54
- },
55
- onControllerNameInputChange: function _onControllerNameInputChange(event) {
56
- const input = event.getSource();
57
- const beginBtn = this.dialog.getBeginButton();
58
- const controllerName = input.getValue();
59
- const controllerList = this.model.getProperty('/controllersList');
60
- const updateDialogState = function (valueState) {
61
- let valueStateText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
62
- input.setValueState(valueState).setValueStateText(valueStateText);
63
- beginBtn.setEnabled(valueState === ValueState.Success);
64
- };
65
- if (controllerName.length <= 0) {
66
- updateDialogState(ValueState.None);
67
- this.model.setProperty('/newControllerName', null);
68
- return;
69
- }
70
- const fileExists = controllerList.some(f => f.controllerName === controllerName);
71
- const pendingChangeExists = checkForExistingChange(this.rta, 'codeExt', 'content.codeRef', `${ controllerName }.js`);
72
- if (fileExists) {
73
- updateDialogState(ValueState.Error, 'Enter a different name. The controller name that you entered already exists in your project.');
74
- return;
75
- }
76
- if (pendingChangeExists) {
77
- updateDialogState(ValueState.Error, 'Enter a different name. The controller name that you entered already exists as a pending change.');
78
- return;
79
- }
80
- const isValidName = /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(controllerName);
81
- if (!isValidName) {
82
- updateDialogState(ValueState.Error, 'The controller name cannot contain white spaces or special characters.');
83
- return;
84
- }
85
- if (controllerName.length > 64) {
86
- updateDialogState(ValueState.Error, 'A controller file name cannot contain more than 64 characters.');
87
- return;
88
- }
89
- updateDialogState(ValueState.Success);
90
- this.model.setProperty('/newControllerName', controllerName);
91
- },
92
- onCreateBtnPress: async function _onCreateBtnPress(event) {
93
- const source = event.getSource();
94
- await BaseDialog.prototype.onCreateBtnPressHandler.call(this);
95
- const controllerExists = this.model.getProperty('/controllerExists');
96
- if (!controllerExists) {
97
- source.setEnabled(false);
98
- const controllerName = this.model.getProperty('/newControllerName');
99
- const viewId = this.model.getProperty('/viewId');
100
- const controllerRef = {
101
- codeRef: `coding/${ controllerName }.js`,
102
- viewId
103
- };
104
- if (this.data) {
105
- this.data.deferred.resolve(controllerRef);
106
- } else {
107
- await this.createNewController(controllerName, controllerRef);
108
- }
109
- if (this.data && await this.isControllerExtensionSupported()) {
110
- await sendInfoCenterMessage({
111
- title: { key: 'ADP_CREATE_CONTROLLER_EXTENSION_TITLE' },
112
- description: {
113
- key: 'ADP_CREATE_CONTROLLER_EXTENSION',
114
- params: [controllerName]
115
- },
116
- type: MessageBarType.info
117
- });
118
- }
119
- } else {
120
- const controllerPath = this.model.getProperty('/controllerPath');
121
- window.open(`vscode://file${ controllerPath }`);
122
- }
123
- this.handleDialogClose();
124
- },
125
- buildDialogData: async function _buildDialogData() {
126
- const selectorId = this.overlays.getId();
127
- const overlayControl = sap.ui.getCore().byId(selectorId);
128
- const {controllerName, viewId} = getControllerInfo(overlayControl);
129
- const data = await this.getExistingController(controllerName);
130
- const hasPendingChangeForView = checkForExistingChange(this.rta, 'codeExt', 'selector.controllerName', controllerName);
131
- if (data) {
132
- if (hasPendingChangeForView) {
133
- this.updateModelForExistingPendingChange();
134
- } else if (data?.controllerExists) {
135
- this.updateModelForExistingController(data);
136
- } else {
137
- this.updateModelForNewController(viewId, data.isTsSupported);
138
- await this.getControllers();
139
- }
140
- }
141
- },
142
- updateModelForExistingController: function _updateModelForExistingController(data) {
143
- const {controllerExists, controllerPath, controllerPathFromRoot, isRunningInBAS} = data;
144
- this.model.setProperty('/controllerExists', controllerExists);
145
- this.model.setProperty('/controllerPath', controllerPath);
146
- this.model.setProperty('/controllerPathFromRoot', controllerPathFromRoot);
147
- this.model.setProperty('/inputFormVisibility', false);
148
- this.model.setProperty('/pendingChangeFormVisibility', false);
149
- this.model.setProperty('/existingControllerFormVisibility', true);
150
- if (isRunningInBAS) {
151
- this.dialog.getBeginButton().setVisible(false);
152
- } else {
153
- this.dialog.getBeginButton().setText('Open in VS Code').setEnabled(true);
154
- }
155
- this.dialog.getEndButton().setText('Close');
156
- },
157
- updateModelForExistingPendingChange: function _updateModelForExistingPendingChange() {
158
- this.model.setProperty('/inputFormVisibility', false);
159
- this.model.setProperty('/existingControllerFormVisibility', false);
160
- this.model.setProperty('/pendingChangeFormVisibility', true);
161
- this.dialog.getBeginButton().setVisible(false);
162
- this.dialog.getEndButton().setText('Close');
163
- },
164
- updateModelForNewController: function _updateModelForNewController(viewId, isTsSupported) {
165
- this.model.setProperty('/viewId', viewId);
166
- this.model.setProperty('/controllerExtension', isTsSupported ? '.ts' : '.js');
167
- this.model.setProperty('/existingControllerFormVisibility', false);
168
- this.model.setProperty('/pendingChangeFormVisibility', false);
169
- this.model.setProperty('/inputFormVisibility', true);
170
- },
171
- getExistingController: async function _getExistingController(controllerName) {
172
- let data;
173
- try {
174
- data = await getExistingController(controllerName);
175
- } catch (e) {
176
- const error = getError(e);
177
- await sendInfoCenterMessage({
178
- title: { key: 'ADP_CONTROLLER_ERROR_TITLE' },
179
- description: error.message,
180
- type: MessageBarType.error
181
- });
182
- throw error;
183
- }
184
- return data;
185
- },
186
- getControllers: async function _getControllers() {
187
- try {
188
- const {controllers} = await readControllers();
189
- this.model.setProperty('/controllersList', controllers);
190
- } catch (e) {
191
- const error = getError(e);
192
- await sendInfoCenterMessage({
193
- title: { key: 'ADP_CONTROLLER_ERROR_TITLE' },
194
- description: error.message,
195
- type: MessageBarType.error
196
- });
197
- throw error;
198
- }
199
- },
200
- createNewController: async function _createNewController(controllerName, controllerRef) {
201
- if (await this.isControllerExtensionSupported()) {
202
- await this.createControllerCommand(controllerName, controllerRef);
203
- return;
204
- }
205
- try {
206
- await writeController({ controllerName });
207
- const service = await this.rta.getService('controllerExtension');
208
- const change = await service.add(controllerRef.codeRef, controllerRef.viewId);
209
- change.creation = new Date().toISOString();
210
- await writeChange(change);
211
- await sendInfoCenterMessage({
212
- title: { key: 'ADP_CREATE_CONTROLLER_EXTENSION_TITLE' },
213
- description: {
214
- key: 'ADP_CREATE_CONTROLLER_EXTENSION_DESCRIPTION',
215
- params: [controllerName]
216
- },
217
- type: MessageBarType.info
218
- });
219
- } catch (e) {
220
- const error = getError(e);
221
- await sendInfoCenterMessage({
222
- title: { key: 'ADP_CONTROLLER_ERROR_TITLE' },
223
- description: error.message,
224
- type: MessageBarType.error
225
- });
226
- await this.getControllers();
227
- throw error;
228
- }
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/ui/core/library", "sap/ui/model/json/JSONModel", "open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common", "../../i18n", "../../utils/core", "../../utils/error", "../../utils/info-center-message", "../../utils/version", "../api-handler", "../command-executor", "../utils", "./BaseDialog.controller"], function (sap_ui_core_library, JSONModel, ___sap_ux_private_control_property_editor_common, ____i18n, ____utils_core, ____utils_error, ____utils_info_center_message, ____utils_version, ___api_handler, __CommandExecutor, ___utils, __BaseDialog) {
4
+ "use strict";
5
+
6
+ function _interopRequireDefault(obj) {
7
+ return obj && obj.__esModule && typeof obj.default !== "undefined" ? obj.default : obj;
8
+ }
9
+ /** sap.m */
10
+ /** sap.ui.core */
11
+ const ValueState = sap_ui_core_library["ValueState"];
12
+ /** sap.ui.base */
13
+ const MessageBarType = ___sap_ux_private_control_property_editor_common["MessageBarType"];
14
+ const getResourceModel = ____i18n["getResourceModel"];
15
+ const getTextBundle = ____i18n["getTextBundle"];
16
+ const getControlById = ____utils_core["getControlById"];
17
+ const getError = ____utils_error["getError"];
18
+ const sendInfoCenterMessage = ____utils_info_center_message["sendInfoCenterMessage"];
19
+ const getUi5Version = ____utils_version["getUi5Version"];
20
+ const isLowerThanMinimalUi5Version = ____utils_version["isLowerThanMinimalUi5Version"];
21
+ const getExistingController = ___api_handler["getExistingController"];
22
+ const readControllers = ___api_handler["readControllers"];
23
+ const writeChange = ___api_handler["writeChange"];
24
+ const writeController = ___api_handler["writeController"];
25
+ const CommandExecutor = _interopRequireDefault(__CommandExecutor);
26
+ const checkForExistingChange = ___utils["checkForExistingChange"];
27
+ const getControllerInfo = ___utils["getControllerInfo"];
28
+ const BaseDialog = _interopRequireDefault(__BaseDialog);
29
+ /**
30
+ * @namespace open.ux.preview.client.adp.controllers
31
+ */
32
+ const ControllerExtension = BaseDialog.extend("open.ux.preview.client.adp.controllers.ControllerExtension", {
33
+ constructor: function _constructor(name, overlays, rta, data, telemetryData) {
34
+ BaseDialog.prototype.constructor.call(this, name, telemetryData);
35
+ this.rta = rta;
36
+ this.overlays = overlays;
37
+ this.model = new JSONModel();
38
+ this.data = data;
39
+ },
40
+ /**
41
+ * Setups the Dialog and the JSON Model
42
+ *
43
+ * @param {Dialog} dialog - Dialog instance
44
+ */
45
+ setup: async function _setup(dialog) {
46
+ this.dialog = dialog;
47
+ this.setEscapeHandler();
48
+ const resourceModel = await getResourceModel('open.ux.preview.client');
49
+ this.bundle = await getTextBundle();
50
+ await this.buildDialogData();
51
+ this.dialog.setModel(resourceModel, 'i18n');
52
+ this.dialog.setModel(this.model);
53
+ this.dialog.open();
54
+ },
55
+ /**
56
+ * Handles fragment name input change
57
+ *
58
+ * @param event Event
59
+ */
60
+ onControllerNameInputChange: function _onControllerNameInputChange(event) {
61
+ const input = event.getSource();
62
+ const beginBtn = this.dialog.getBeginButton();
63
+ const controllerName = input.getValue();
64
+ const controllerList = this.model.getProperty('/controllersList');
65
+ const updateDialogState = function (valueState) {
66
+ let valueStateText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
67
+ input.setValueState(valueState).setValueStateText(valueStateText);
68
+ beginBtn.setEnabled(valueState === ValueState.Success);
69
+ };
70
+ if (controllerName.length <= 0) {
71
+ updateDialogState(ValueState.None);
72
+ this.model.setProperty('/newControllerName', null);
73
+ return;
74
+ }
75
+ const fileExists = controllerList.some(f => f.controllerName === controllerName);
76
+ const pendingChangeExists = checkForExistingChange(this.rta, 'codeExt', 'content.codeRef', `${controllerName}.js`);
77
+ if (fileExists) {
78
+ updateDialogState(ValueState.Error, 'Enter a different name. The controller name that you entered already exists in your project.');
79
+ return;
80
+ }
81
+ if (pendingChangeExists) {
82
+ updateDialogState(ValueState.Error, 'Enter a different name. The controller name that you entered already exists as a pending change.');
83
+ return;
84
+ }
85
+ const isValidName = /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(controllerName);
86
+ if (!isValidName) {
87
+ updateDialogState(ValueState.Error, 'The controller name cannot contain white spaces or special characters.');
88
+ return;
89
+ }
90
+ if (controllerName.length > 64) {
91
+ updateDialogState(ValueState.Error, 'A controller file name cannot contain more than 64 characters.');
92
+ return;
93
+ }
94
+ updateDialogState(ValueState.Success);
95
+ this.model.setProperty('/newControllerName', controllerName);
96
+ },
97
+ /**
98
+ * Handles create button press
99
+ *
100
+ * @param event Event
101
+ */
102
+ onCreateBtnPress: async function _onCreateBtnPress(event) {
103
+ const source = event.getSource();
104
+ await BaseDialog.prototype.onCreateBtnPressHandler.call(this);
105
+ const controllerExists = this.model.getProperty('/controllerExists');
106
+ if (!controllerExists) {
107
+ source.setEnabled(false);
108
+ const controllerName = this.model.getProperty('/newControllerName');
109
+ const viewId = this.model.getProperty('/viewId');
110
+ const controllerRef = {
111
+ codeRef: `coding/${controllerName}.js`,
112
+ viewId
113
+ };
114
+ if (this.data) {
115
+ this.data.deferred.resolve(controllerRef);
116
+ } else {
117
+ await this.createNewController(controllerName, controllerRef);
118
+ }
119
+ if (this.data && (await this.isControllerExtensionSupported())) {
120
+ await sendInfoCenterMessage({
121
+ title: {
122
+ key: 'ADP_CREATE_CONTROLLER_EXTENSION_TITLE'
123
+ },
124
+ description: {
125
+ key: 'ADP_CREATE_CONTROLLER_EXTENSION',
126
+ params: [controllerName]
127
+ },
128
+ type: MessageBarType.info
129
+ });
130
+ }
131
+ } else {
132
+ const controllerPath = this.model.getProperty('/controllerPath');
133
+ window.open(`vscode://file${controllerPath}`);
134
+ }
135
+ this.handleDialogClose();
136
+ },
137
+ /**
138
+ * Builds data that is used in the dialog.
139
+ */
140
+ buildDialogData: async function _buildDialogData() {
141
+ const selectorId = this.overlays.getId();
142
+ const overlayControl = sap.ui.getCore().byId(selectorId);
143
+ const {
144
+ controllerName,
145
+ viewId
146
+ } = getControllerInfo(overlayControl);
147
+ const data = await this.getExistingController(controllerName);
148
+ const hasPendingChangeForView = checkForExistingChange(this.rta, 'codeExt', 'selector.controllerName', controllerName);
149
+ if (data) {
150
+ if (hasPendingChangeForView) {
151
+ this.updateModelForExistingPendingChange();
152
+ } else if (data?.controllerExists) {
153
+ this.updateModelForExistingController(data);
154
+ } else {
155
+ this.updateModelForNewController(viewId, data.isTsSupported);
156
+ await this.getControllers();
157
+ }
158
+ }
159
+ },
160
+ /**
161
+ * Updates the model properties for an existing controller.
162
+ *
163
+ * @param {CodeExtResponse} data - Existing controller data from the server.
164
+ */
165
+ updateModelForExistingController: function _updateModelForExistingController(data) {
166
+ const {
167
+ controllerExists,
168
+ controllerPath,
169
+ controllerPathFromRoot,
170
+ isRunningInBAS
171
+ } = data;
172
+ this.model.setProperty('/controllerExists', controllerExists);
173
+ this.model.setProperty('/controllerPath', controllerPath);
174
+ this.model.setProperty('/controllerPathFromRoot', controllerPathFromRoot);
175
+ this.model.setProperty('/inputFormVisibility', false);
176
+ this.model.setProperty('/pendingChangeFormVisibility', false);
177
+ this.model.setProperty('/existingControllerFormVisibility', true);
178
+ if (isRunningInBAS) {
179
+ this.dialog.getBeginButton().setVisible(false);
180
+ } else {
181
+ this.dialog.getBeginButton().setText('Open in VS Code').setEnabled(true);
182
+ }
183
+ this.dialog.getEndButton().setText('Close');
184
+ },
185
+ /**
186
+ * Updates the model properties for an existing controller in a pending change.
187
+ */
188
+ updateModelForExistingPendingChange: function _updateModelForExistingPendingChange() {
189
+ this.model.setProperty('/inputFormVisibility', false);
190
+ this.model.setProperty('/existingControllerFormVisibility', false);
191
+ this.model.setProperty('/pendingChangeFormVisibility', true);
192
+ this.dialog.getBeginButton().setVisible(false);
193
+ this.dialog.getEndButton().setText('Close');
194
+ },
195
+ /**
196
+ * Updates the model property for a new controller.
197
+ *
198
+ * @param {string} viewId - The view ID.
199
+ * @param {boolean} isTsSupported - Whether TypeScript supported for the current project.
200
+ */
201
+ updateModelForNewController: function _updateModelForNewController(viewId, isTsSupported) {
202
+ this.model.setProperty('/viewId', viewId);
203
+ this.model.setProperty('/controllerExtension', isTsSupported ? '.ts' : '.js');
204
+ this.model.setProperty('/existingControllerFormVisibility', false);
205
+ this.model.setProperty('/pendingChangeFormVisibility', false);
206
+ this.model.setProperty('/inputFormVisibility', true);
207
+ },
208
+ /**
209
+ * Retrieves existing controller data if found in the project's workspace.
210
+ *
211
+ * @param controllerName Controller name that exists in the view.
212
+ * @returns Returns existing controller data.
213
+ */
214
+ getExistingController: async function _getExistingController(controllerName) {
215
+ let data;
216
+ try {
217
+ data = await getExistingController(controllerName);
218
+ } catch (e) {
219
+ const error = getError(e);
220
+ await sendInfoCenterMessage({
221
+ title: {
222
+ key: 'ADP_CONTROLLER_ERROR_TITLE'
223
+ },
224
+ description: error.message,
225
+ type: MessageBarType.error
226
+ });
227
+ throw error;
228
+ }
229
+ return data;
230
+ },
231
+ /**
232
+ * Retrieves controller files and fills the model with data
233
+ */
234
+ getControllers: async function _getControllers() {
235
+ try {
236
+ const {
237
+ controllers
238
+ } = await readControllers();
239
+ this.model.setProperty('/controllersList', controllers);
240
+ } catch (e) {
241
+ const error = getError(e);
242
+ await sendInfoCenterMessage({
243
+ title: {
244
+ key: 'ADP_CONTROLLER_ERROR_TITLE'
245
+ },
246
+ description: error.message,
247
+ type: MessageBarType.error
248
+ });
249
+ throw error;
250
+ }
251
+ },
252
+ /**
253
+ * Creates a new fragment for the specified control
254
+ *
255
+ * @param controllerName Controller Name
256
+ * @param controllerRef Controller reference
257
+ */
258
+ createNewController: async function _createNewController(controllerName, controllerRef) {
259
+ if (await this.isControllerExtensionSupported()) {
260
+ await this.createControllerCommand(controllerName, controllerRef);
261
+ return;
262
+ }
263
+ try {
264
+ await writeController({
265
+ controllerName
266
+ });
267
+ const service = await this.rta.getService('controllerExtension');
268
+ const change = await service.add(controllerRef.codeRef, controllerRef.viewId);
269
+ change.creation = new Date().toISOString();
270
+ await writeChange(change);
271
+ await sendInfoCenterMessage({
272
+ title: {
273
+ key: 'ADP_CREATE_CONTROLLER_EXTENSION_TITLE'
274
+ },
275
+ description: {
276
+ key: 'ADP_CREATE_CONTROLLER_EXTENSION_DESCRIPTION',
277
+ params: [controllerName]
278
+ },
279
+ type: MessageBarType.info
280
+ });
281
+ } catch (e) {
282
+ const error = getError(e);
283
+ await sendInfoCenterMessage({
284
+ title: {
285
+ key: 'ADP_CONTROLLER_ERROR_TITLE'
286
+ },
287
+ description: error.message,
288
+ type: MessageBarType.error
289
+ });
290
+ // We want to update the model incase we have already created a controller file but failed when creating a change file,
291
+ // so when the user types the same controller name again he does not get 409 from the server, instead an error is shown in the UI
292
+ await this.getControllers();
293
+ throw error;
294
+ }
295
+ },
296
+ /**
297
+ * Creates a controller command and executes it.
298
+ *
299
+ * @param controllerName Controller name
300
+ * @param controllerRef Controller reference
301
+ */
302
+ createControllerCommand: async function _createControllerCommand(controllerName, controllerRef) {
303
+ const flexSettings = this.rta.getFlexSettings();
304
+ const commandExecutor = new CommandExecutor(this.rta);
305
+ const view = getControlById(controllerRef.viewId);
306
+ const command = await commandExecutor.getCommand(view, 'codeExt', controllerRef, flexSettings);
307
+ await commandExecutor.pushAndExecuteCommand(command);
308
+ await sendInfoCenterMessage({
309
+ title: {
310
+ key: 'ADP_CREATE_CONTROLLER_EXTENSION_TITLE'
229
311
  },
230
- createControllerCommand: async function _createControllerCommand(controllerName, controllerRef) {
231
- const flexSettings = this.rta.getFlexSettings();
232
- const commandExecutor = new CommandExecutor(this.rta);
233
- const view = getControlById(controllerRef.viewId);
234
- const command = await commandExecutor.getCommand(view, 'codeExt', controllerRef, flexSettings);
235
- await commandExecutor.pushAndExecuteCommand(command);
236
- await sendInfoCenterMessage({
237
- title: { key: 'ADP_CREATE_CONTROLLER_EXTENSION_TITLE' },
238
- description: {
239
- key: 'ADP_CREATE_CONTROLLER_EXTENSION',
240
- params: [controllerName]
241
- },
242
- type: MessageBarType.info
243
- });
312
+ description: {
313
+ key: 'ADP_CREATE_CONTROLLER_EXTENSION',
314
+ params: [controllerName]
244
315
  },
245
- isControllerExtensionSupported: async function _isControllerExtensionSupported() {
246
- const ui5Version = await getUi5Version();
247
- return !isLowerThanMinimalUi5Version(ui5Version, ControllerExtension.CONTROLLER_EXT_MIN_UI5_VERSION);
248
- }
249
- });
250
- ControllerExtension.CONTROLLER_EXT_MIN_UI5_VERSION = {
251
- major: 1,
252
- minor: 135
253
- };
254
- return ControllerExtension;
255
- });
316
+ type: MessageBarType.info
317
+ });
318
+ },
319
+ isControllerExtensionSupported: async function _isControllerExtensionSupported() {
320
+ const ui5Version = await getUi5Version();
321
+ return !isLowerThanMinimalUi5Version(ui5Version, ControllerExtension.CONTROLLER_EXT_MIN_UI5_VERSION);
322
+ }
323
+ });
324
+ /* The minimum version of UI5 framework which supports controller extensions. */
325
+ ControllerExtension.CONTROLLER_EXT_MIN_UI5_VERSION = {
326
+ major: 1,
327
+ minor: 135
328
+ };
329
+ return ControllerExtension;
330
+ });
331
+ //# sourceMappingURL=ControllerExtension.controller.js.map