@sap-ux/preview-middleware 0.19.37 → 0.19.39

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 (79) hide show
  1. package/dist/client/adp/add-fragment.js +46 -46
  2. package/dist/client/adp/api-handler.js +159 -159
  3. package/dist/client/adp/command-executor.js +75 -75
  4. package/dist/client/adp/control-utils.js +44 -44
  5. package/dist/client/adp/controllers/AddTableColumnFragments.controller.js +5 -10
  6. package/dist/client/adp/controllers/AddTableColumnFragments.controller.ts +3 -9
  7. package/dist/client/adp/controllers/ControllerExtension.controller.js +210 -210
  8. package/dist/client/adp/controllers/ExtensionPoint.controller.js +139 -139
  9. package/dist/client/adp/controllers/FileExistsDialog.controller.js +66 -66
  10. package/dist/client/adp/dialog-factory.js +135 -135
  11. package/dist/client/adp/init-dialogs.js +163 -163
  12. package/dist/client/adp/quick-actions/add-new-subpage-quick-action-base.js +96 -96
  13. package/dist/client/adp/quick-actions/common/add-controller-to-page.js +60 -60
  14. package/dist/client/adp/quick-actions/common/create-page-action.js +54 -54
  15. package/dist/client/adp/quick-actions/common/op-add-custom-section.js +39 -39
  16. package/dist/client/adp/quick-actions/common/op-add-header-field.js +67 -67
  17. package/dist/client/adp/quick-actions/common/utils.js +18 -18
  18. package/dist/client/adp/quick-actions/control-types.js +23 -23
  19. package/dist/client/adp/quick-actions/dialog-enablement-validator.js +24 -24
  20. package/dist/client/adp/quick-actions/enablement-validator.js +4 -4
  21. package/dist/client/adp/quick-actions/fe-v2/add-new-subpage.js +81 -81
  22. package/dist/client/adp/quick-actions/fe-v2/change-table-actions.js +67 -67
  23. package/dist/client/adp/quick-actions/fe-v2/change-table-columns.js +101 -101
  24. package/dist/client/adp/quick-actions/fe-v2/create-table-action.js +107 -107
  25. package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.js +99 -99
  26. package/dist/client/adp/quick-actions/fe-v2/lr-enable-semantic-date-range-filter-bar.js +78 -78
  27. package/dist/client/adp/quick-actions/fe-v2/lr-enable-table-filtering.js +77 -77
  28. package/dist/client/adp/quick-actions/fe-v2/lr-enable-variant-management.js +69 -69
  29. package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.js +59 -59
  30. package/dist/client/adp/quick-actions/fe-v2/op-enable-empty-row-mode.js +93 -93
  31. package/dist/client/adp/quick-actions/fe-v2/op-enable-variant-management.js +84 -84
  32. package/dist/client/adp/quick-actions/fe-v2/registry.js +77 -77
  33. package/dist/client/adp/quick-actions/fe-v2/utils.js +116 -116
  34. package/dist/client/adp/quick-actions/fe-v4/add-new-subpage.js +138 -138
  35. package/dist/client/adp/quick-actions/fe-v4/change-table-actions.js +79 -79
  36. package/dist/client/adp/quick-actions/fe-v4/change-table-columns.js +75 -75
  37. package/dist/client/adp/quick-actions/fe-v4/create-table-action.js +53 -53
  38. package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column.js +49 -49
  39. package/dist/client/adp/quick-actions/fe-v4/enable-variant-management.js +81 -81
  40. package/dist/client/adp/quick-actions/fe-v4/lr-enable-semantic-date-range-filter-bar.js +56 -56
  41. package/dist/client/adp/quick-actions/fe-v4/lr-enable-table-filtering.js +84 -84
  42. package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.js +53 -53
  43. package/dist/client/adp/quick-actions/fe-v4/op-enable-empty-row-mode.js +89 -89
  44. package/dist/client/adp/quick-actions/fe-v4/registry.js +60 -60
  45. package/dist/client/adp/quick-actions/fe-v4/utils.js +72 -72
  46. package/dist/client/adp/quick-actions/load.js +44 -44
  47. package/dist/client/adp/quick-actions/quick-action-base.js +64 -64
  48. package/dist/client/adp/utils.js +218 -218
  49. package/dist/client/cpe/additional-change-info/add-xml-additional-info.js +75 -75
  50. package/dist/client/cpe/changes/index.js +10 -10
  51. package/dist/client/cpe/changes/validator.js +39 -39
  52. package/dist/client/cpe/documentation.js +164 -164
  53. package/dist/client/cpe/feature-service.js +36 -36
  54. package/dist/client/cpe/logger.js +30 -30
  55. package/dist/client/cpe/outline/editable.js +37 -37
  56. package/dist/client/cpe/outline/nodes.js +203 -203
  57. package/dist/client/cpe/quick-actions/quick-action-definition.js +4 -4
  58. package/dist/client/cpe/quick-actions/registry.js +143 -143
  59. package/dist/client/cpe/quick-actions/utils.js +92 -92
  60. package/dist/client/cpe/types.js +4 -4
  61. package/dist/client/cpe/ui5-utils.js +33 -33
  62. package/dist/client/cpe/utils.js +111 -111
  63. package/dist/client/flp/WorkspaceConnector.js +92 -92
  64. package/dist/client/flp/common.js +28 -28
  65. package/dist/client/flp/enableFakeConnector.js +89 -89
  66. package/dist/client/flp/homepage/Component.js +14 -14
  67. package/dist/client/flp/initCdm.js +117 -117
  68. package/dist/client/flp/initConnectors.js +28 -28
  69. package/dist/client/flp/initRta.js +178 -178
  70. package/dist/client/i18n.js +56 -56
  71. package/dist/client/utils/additional-change-info.js +54 -41
  72. package/dist/client/utils/additional-change-info.ts +22 -8
  73. package/dist/client/utils/application.js +32 -32
  74. package/dist/client/utils/core.js +84 -84
  75. package/dist/client/utils/error.js +19 -19
  76. package/dist/client/utils/fe-v2.js +56 -56
  77. package/dist/client/utils/fe-v4.js +140 -140
  78. package/dist/client/utils/version.js +104 -104
  79. package/package.json +4 -4
@@ -10,8 +10,9 @@ sap.ui.define([
10
10
  '../api-handler',
11
11
  './BaseDialog.controller',
12
12
  '../utils',
13
- 'sap/ui/core/library'
14
- ], function (JSONModel, OverlayRegistry, ___sap_ux_private_control_property_editor_common, ____i18n, ____cpe_communication_service, __ControlUtils, __CommandExecutor, ___api_handler, __BaseDialog, ___utils, sap_ui_core_library) {
13
+ 'sap/ui/core/library',
14
+ '../../utils/additional-change-info'
15
+ ], function (JSONModel, OverlayRegistry, ___sap_ux_private_control_property_editor_common, ____i18n, ____cpe_communication_service, __ControlUtils, __CommandExecutor, ___api_handler, __BaseDialog, ___utils, sap_ui_core_library, ____utils_additional_change_info) {
15
16
  'use strict';
16
17
  function _interopRequireDefault(obj) {
17
18
  return obj && obj.__esModule && typeof obj.default !== 'undefined' ? obj.default : obj;
@@ -26,6 +27,7 @@ sap.ui.define([
26
27
  const BaseDialog = _interopRequireDefault(__BaseDialog);
27
28
  const notifyUser = ___utils['notifyUser'];
28
29
  const ValueState = sap_ui_core_library['ValueState'];
30
+ const setAdditionalChangeInfoForChangeFile = ____utils_additional_change_info['setAdditionalChangeInfoForChangeFile'];
29
31
  const radix = 10;
30
32
  const COLUMNS_AGGREGATION = 'columns';
31
33
  const ITEMS_AGGREGATION = 'items';
@@ -149,7 +151,6 @@ sap.ui.define([
149
151
  const flexSettings = this.rta.getFlexSettings();
150
152
  const overlay = OverlayRegistry.getOverlay(this.runtimeControl);
151
153
  const designMetadata = overlay.getDesignTimeMetadata();
152
- const result = [];
153
154
  const compositeCommand = await this.commandExecutor.createCompositeCommand(this.runtimeControl);
154
155
  for (const fragment of fragments) {
155
156
  const modifiedValue = {
@@ -162,17 +163,11 @@ sap.ui.define([
162
163
  const command = await this.commandExecutor.getCommand(targetObject, 'addXML', modifiedValue, designMetadata, flexSettings);
163
164
  const templateName = fragment.targetAggregation === COLUMNS_AGGREGATION ? `V2_SMART_TABLE_COLUMN` : 'V2_SMART_TABLE_CELL';
164
165
  const preparedChange = command.getPreparedChange();
165
- const content = {
166
- ...preparedChange.getContent(),
167
- templateName
168
- };
169
- preparedChange.setContent(content);
166
+ setAdditionalChangeInfoForChangeFile(preparedChange.getDefinition().fileName, { templateName });
170
167
  compositeCommand.addCommand(command, false);
171
- result.push(templateName);
172
168
  }
173
169
  await this.commandExecutor.pushAndExecuteCommand(compositeCommand);
174
170
  CommunicationService.sendAction(setApplicationRequiresReload(true));
175
- return result;
176
171
  }
177
172
  });
178
173
  return AddTableColumnFragments;
@@ -39,6 +39,7 @@ import Input from 'sap/m/Input';
39
39
  import Control from 'sap/ui/core/Control';
40
40
  import ManagedObject from 'sap/ui/base/ManagedObject';
41
41
  import { QuickActionTelemetryData } from '../../cpe/quick-actions/quick-action-definition';
42
+ import { setAdditionalChangeInfoForChangeFile } from '../../utils/additional-change-info';
42
43
 
43
44
  const radix = 10;
44
45
 
@@ -60,7 +61,6 @@ interface CreateFragmentProps {
60
61
  * @namespace open.ux.preview.client.adp.controllers
61
62
  */
62
63
  export default class AddTableColumnFragments extends BaseDialog<AddTableColumnsFragmentsModel> {
63
-
64
64
  constructor(
65
65
  name: string,
66
66
  overlays: UI5Element,
@@ -255,7 +255,7 @@ export default class AddTableColumnFragments extends BaseDialog<AddTableColumnsF
255
255
  *
256
256
  * @param fragmentData Fragment Data
257
257
  */
258
- private async createFragmentChange(fragmentData: CreateFragmentProps): Promise<string[] | undefined> {
258
+ private async createFragmentChange(fragmentData: CreateFragmentProps): Promise<void> {
259
259
  const { fragments, index } = fragmentData;
260
260
 
261
261
  const flexSettings = this.rta.getFlexSettings();
@@ -263,8 +263,6 @@ export default class AddTableColumnFragments extends BaseDialog<AddTableColumnsF
263
263
  const overlay = OverlayRegistry.getOverlay(this.runtimeControl as UI5Element);
264
264
  const designMetadata = overlay.getDesignTimeMetadata();
265
265
 
266
- const result: string[] = [];
267
-
268
266
  const compositeCommand = await this.commandExecutor.createCompositeCommand(this.runtimeControl);
269
267
 
270
268
  for (const fragment of fragments) {
@@ -292,15 +290,11 @@ export default class AddTableColumnFragments extends BaseDialog<AddTableColumnsF
292
290
  const templateName =
293
291
  fragment.targetAggregation === COLUMNS_AGGREGATION ? `V2_SMART_TABLE_COLUMN` : 'V2_SMART_TABLE_CELL';
294
292
  const preparedChange = command.getPreparedChange();
295
- const content = { ...preparedChange.getContent(), templateName };
296
- preparedChange.setContent(content);
293
+ setAdditionalChangeInfoForChangeFile(preparedChange.getDefinition().fileName, { templateName });
297
294
  compositeCommand.addCommand(command, false);
298
- result.push(templateName);
299
295
  }
300
296
 
301
297
  await this.commandExecutor.pushAndExecuteCommand(compositeCommand);
302
298
  CommunicationService.sendAction(setApplicationRequiresReload(true));
303
-
304
- return result;
305
299
  }
306
300
  }
@@ -1,212 +1,212 @@
1
- "use strict";
2
-
3
- sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/JSONModel", "../api-handler", "./BaseDialog.controller", "../utils"], function (MessageToast, sap_ui_core_library, JSONModel, ___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
- /** sap.ui.core */
10
- const ValueState = sap_ui_core_library["ValueState"];
11
- /** sap.ui.base */
12
- const getExistingController = ___api_handler["getExistingController"];
13
- const readControllers = ___api_handler["readControllers"];
14
- const writeChange = ___api_handler["writeChange"];
15
- const writeController = ___api_handler["writeController"];
16
- const BaseDialog = _interopRequireDefault(__BaseDialog);
17
- const getControllerInfo = ___utils["getControllerInfo"];
18
- /**
19
- * @namespace open.ux.preview.client.adp.controllers
20
- */
21
- const ControllerExtension = BaseDialog.extend("open.ux.preview.client.adp.controllers.ControllerExtension", {
22
- constructor: function _constructor(name, overlays, rta, telemetryData) {
23
- BaseDialog.prototype.constructor.call(this, name, telemetryData);
24
- this.rta = rta;
25
- this.overlays = overlays;
26
- this.model = new JSONModel();
27
- },
28
- /**
29
- * Setups the Dialog and the JSON Model
30
- *
31
- * @param {Dialog} dialog - Dialog instance
32
- */
33
- setup: async function _setup(dialog) {
34
- this.dialog = dialog;
35
- this.setEscapeHandler();
36
- await this.buildDialogData();
37
- this.dialog.setModel(this.model);
38
- this.dialog.open();
39
- },
40
- /**
41
- * Handles fragment name input change
42
- *
43
- * @param event Event
44
- */
45
- onControllerNameInputChange: function _onControllerNameInputChange(event) {
46
- const input = event.getSource();
47
- const beginBtn = this.dialog.getBeginButton();
48
- const controllerName = input.getValue();
49
- const controllerList = this.model.getProperty('/controllersList');
50
- const updateDialogState = function (valueState) {
51
- let valueStateText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
52
- input.setValueState(valueState).setValueStateText(valueStateText);
53
- beginBtn.setEnabled(valueState === ValueState.Success);
54
- };
55
- if (controllerName.length <= 0) {
56
- updateDialogState(ValueState.None);
57
- this.model.setProperty('/newControllerName', null);
58
- return;
59
- }
60
- const fileExists = controllerList.some(f => f.controllerName === controllerName);
61
- if (fileExists) {
62
- updateDialogState(ValueState.Error, 'Enter a different name. The controller name that you entered already exists in your project.');
63
- return;
64
- }
65
- const isValidName = /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(controllerName);
66
- if (!isValidName) {
67
- updateDialogState(ValueState.Error, 'The controller name cannot contain white spaces or special characters.');
68
- return;
69
- }
70
- if (controllerName.length > 64) {
71
- updateDialogState(ValueState.Error, 'A controller file name cannot contain more than 64 characters.');
72
- return;
73
- }
74
- updateDialogState(ValueState.Success);
75
- this.model.setProperty('/newControllerName', controllerName);
76
- },
77
- /**
78
- * Handles create button press
79
- *
80
- * @param event Event
81
- */
82
- onCreateBtnPress: async function _onCreateBtnPress(event) {
83
- const source = event.getSource();
84
- await BaseDialog.prototype.onCreateBtnPressHandler.call(this);
85
- const controllerExists = this.model.getProperty('/controllerExists');
86
- if (!controllerExists) {
87
- source.setEnabled(false);
88
- const controllerName = this.model.getProperty('/newControllerName');
89
- const viewId = this.model.getProperty('/viewId');
90
- await this.createNewController(controllerName, viewId);
91
- } else {
92
- const controllerPath = this.model.getProperty('/controllerPath');
93
- window.open(`vscode://file${controllerPath}`);
94
- }
95
- this.handleDialogClose();
96
- },
97
- /**
98
- * Builds data that is used in the dialog.
99
- */
100
- buildDialogData: async function _buildDialogData() {
101
- const selectorId = this.overlays.getId();
102
- const overlayControl = sap.ui.getCore().byId(selectorId);
103
- const {
104
- controllerName,
105
- viewId
106
- } = getControllerInfo(overlayControl);
107
- const data = await this.getExistingController(controllerName);
108
- if (data) {
109
- if (data?.controllerExists) {
110
- this.updateModelForExistingController(data);
111
- } else {
112
- this.updateModelForNewController(viewId, data.isTsSupported);
113
- await this.getControllers();
114
- }
115
- }
116
- },
117
- /**
118
- * Updates the model properties for an existing controller.
119
- *
120
- * @param {CodeExtResponse} data - Existing controller data from the server.
121
- */
122
- updateModelForExistingController: function _updateModelForExistingController(data) {
123
- const {
124
- controllerExists,
125
- controllerPath,
126
- controllerPathFromRoot,
127
- isRunningInBAS
128
- } = data;
129
- this.model.setProperty('/controllerExists', controllerExists);
130
- this.model.setProperty('/controllerPath', controllerPath);
131
- this.model.setProperty('/controllerPathFromRoot', controllerPathFromRoot);
132
- const content = this.dialog.getContent();
133
- const form = content[0];
134
- form.setVisible(false);
135
- const messageForm = content[1];
136
- messageForm.setVisible(true);
137
- if (isRunningInBAS) {
138
- this.dialog.getBeginButton().setVisible(false);
139
- } else {
140
- this.dialog.getBeginButton().setText('Open in VS Code').setEnabled(true);
141
- }
142
- this.dialog.getEndButton().setText('Close');
143
- },
144
- /**
145
- * Updates the model property for a new controller.
146
- *
147
- * @param {string} viewId - The view ID.
148
- * @param {boolean} isTsSupported - Whether TypeScript supported for the current project.
149
- */
150
- updateModelForNewController: function _updateModelForNewController(viewId, isTsSupported) {
151
- this.model.setProperty('/viewId', viewId);
152
- this.model.setProperty('/controllerExtension', isTsSupported ? '.ts' : '.js');
153
- },
154
- /**
155
- * Retrieves existing controller data if found in the project's workspace.
156
- *
157
- * @param controllerName Controller name that exists in the view.
158
- * @returns Returns existing controller data.
159
- */
160
- getExistingController: async function _getExistingController(controllerName) {
161
- let data;
162
- try {
163
- data = await getExistingController(controllerName);
164
- } catch (e) {
165
- this.handleError(e);
166
- }
167
- return data;
168
- },
169
- /**
170
- * Retrieves controller files and fills the model with data
171
- */
172
- getControllers: async function _getControllers() {
173
- try {
174
- const {
175
- controllers
176
- } = await readControllers();
177
- this.model.setProperty('/controllersList', controllers);
178
- } catch (e) {
179
- this.handleError(e);
180
- }
181
- },
182
- /**
183
- * Creates a new fragment for the specified control
184
- *
185
- * @param controllerName Controller Name
186
- * @param viewId View Id
187
- */
188
- createNewController: async function _createNewController(controllerName, viewId) {
189
- try {
190
- await writeController({
191
- controllerName
192
- });
193
- const controllerRef = {
194
- codeRef: `coding/${controllerName}.js`,
195
- viewId
196
- };
197
- const service = await this.rta.getService('controllerExtension');
198
- const change = await service.add(controllerRef.codeRef, controllerRef.viewId);
199
- change.creation = new Date().toISOString();
200
- await writeChange(change);
201
- MessageToast.show(`Controller extension with name '${controllerName}' was created.`);
202
- } catch (e) {
203
- // We want to update the model incase we have already created a controller file but failed when creating a change file,
204
- // 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
205
- await this.getControllers();
206
- this.handleError(e);
207
- }
208
- }
209
- });
210
- return ControllerExtension;
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/JSONModel", "../api-handler", "./BaseDialog.controller", "../utils"], function (MessageToast, sap_ui_core_library, JSONModel, ___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
+ /** sap.ui.core */
10
+ const ValueState = sap_ui_core_library["ValueState"];
11
+ /** sap.ui.base */
12
+ const getExistingController = ___api_handler["getExistingController"];
13
+ const readControllers = ___api_handler["readControllers"];
14
+ const writeChange = ___api_handler["writeChange"];
15
+ const writeController = ___api_handler["writeController"];
16
+ const BaseDialog = _interopRequireDefault(__BaseDialog);
17
+ const getControllerInfo = ___utils["getControllerInfo"];
18
+ /**
19
+ * @namespace open.ux.preview.client.adp.controllers
20
+ */
21
+ const ControllerExtension = BaseDialog.extend("open.ux.preview.client.adp.controllers.ControllerExtension", {
22
+ constructor: function _constructor(name, overlays, rta, telemetryData) {
23
+ BaseDialog.prototype.constructor.call(this, name, telemetryData);
24
+ this.rta = rta;
25
+ this.overlays = overlays;
26
+ this.model = new JSONModel();
27
+ },
28
+ /**
29
+ * Setups the Dialog and the JSON Model
30
+ *
31
+ * @param {Dialog} dialog - Dialog instance
32
+ */
33
+ setup: async function _setup(dialog) {
34
+ this.dialog = dialog;
35
+ this.setEscapeHandler();
36
+ await this.buildDialogData();
37
+ this.dialog.setModel(this.model);
38
+ this.dialog.open();
39
+ },
40
+ /**
41
+ * Handles fragment name input change
42
+ *
43
+ * @param event Event
44
+ */
45
+ onControllerNameInputChange: function _onControllerNameInputChange(event) {
46
+ const input = event.getSource();
47
+ const beginBtn = this.dialog.getBeginButton();
48
+ const controllerName = input.getValue();
49
+ const controllerList = this.model.getProperty('/controllersList');
50
+ const updateDialogState = function (valueState) {
51
+ let valueStateText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
52
+ input.setValueState(valueState).setValueStateText(valueStateText);
53
+ beginBtn.setEnabled(valueState === ValueState.Success);
54
+ };
55
+ if (controllerName.length <= 0) {
56
+ updateDialogState(ValueState.None);
57
+ this.model.setProperty('/newControllerName', null);
58
+ return;
59
+ }
60
+ const fileExists = controllerList.some(f => f.controllerName === controllerName);
61
+ if (fileExists) {
62
+ updateDialogState(ValueState.Error, 'Enter a different name. The controller name that you entered already exists in your project.');
63
+ return;
64
+ }
65
+ const isValidName = /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(controllerName);
66
+ if (!isValidName) {
67
+ updateDialogState(ValueState.Error, 'The controller name cannot contain white spaces or special characters.');
68
+ return;
69
+ }
70
+ if (controllerName.length > 64) {
71
+ updateDialogState(ValueState.Error, 'A controller file name cannot contain more than 64 characters.');
72
+ return;
73
+ }
74
+ updateDialogState(ValueState.Success);
75
+ this.model.setProperty('/newControllerName', controllerName);
76
+ },
77
+ /**
78
+ * Handles create button press
79
+ *
80
+ * @param event Event
81
+ */
82
+ onCreateBtnPress: async function _onCreateBtnPress(event) {
83
+ const source = event.getSource();
84
+ await BaseDialog.prototype.onCreateBtnPressHandler.call(this);
85
+ const controllerExists = this.model.getProperty('/controllerExists');
86
+ if (!controllerExists) {
87
+ source.setEnabled(false);
88
+ const controllerName = this.model.getProperty('/newControllerName');
89
+ const viewId = this.model.getProperty('/viewId');
90
+ await this.createNewController(controllerName, viewId);
91
+ } else {
92
+ const controllerPath = this.model.getProperty('/controllerPath');
93
+ window.open(`vscode://file${controllerPath}`);
94
+ }
95
+ this.handleDialogClose();
96
+ },
97
+ /**
98
+ * Builds data that is used in the dialog.
99
+ */
100
+ buildDialogData: async function _buildDialogData() {
101
+ const selectorId = this.overlays.getId();
102
+ const overlayControl = sap.ui.getCore().byId(selectorId);
103
+ const {
104
+ controllerName,
105
+ viewId
106
+ } = getControllerInfo(overlayControl);
107
+ const data = await this.getExistingController(controllerName);
108
+ if (data) {
109
+ if (data?.controllerExists) {
110
+ this.updateModelForExistingController(data);
111
+ } else {
112
+ this.updateModelForNewController(viewId, data.isTsSupported);
113
+ await this.getControllers();
114
+ }
115
+ }
116
+ },
117
+ /**
118
+ * Updates the model properties for an existing controller.
119
+ *
120
+ * @param {CodeExtResponse} data - Existing controller data from the server.
121
+ */
122
+ updateModelForExistingController: function _updateModelForExistingController(data) {
123
+ const {
124
+ controllerExists,
125
+ controllerPath,
126
+ controllerPathFromRoot,
127
+ isRunningInBAS
128
+ } = data;
129
+ this.model.setProperty('/controllerExists', controllerExists);
130
+ this.model.setProperty('/controllerPath', controllerPath);
131
+ this.model.setProperty('/controllerPathFromRoot', controllerPathFromRoot);
132
+ const content = this.dialog.getContent();
133
+ const form = content[0];
134
+ form.setVisible(false);
135
+ const messageForm = content[1];
136
+ messageForm.setVisible(true);
137
+ if (isRunningInBAS) {
138
+ this.dialog.getBeginButton().setVisible(false);
139
+ } else {
140
+ this.dialog.getBeginButton().setText('Open in VS Code').setEnabled(true);
141
+ }
142
+ this.dialog.getEndButton().setText('Close');
143
+ },
144
+ /**
145
+ * Updates the model property for a new controller.
146
+ *
147
+ * @param {string} viewId - The view ID.
148
+ * @param {boolean} isTsSupported - Whether TypeScript supported for the current project.
149
+ */
150
+ updateModelForNewController: function _updateModelForNewController(viewId, isTsSupported) {
151
+ this.model.setProperty('/viewId', viewId);
152
+ this.model.setProperty('/controllerExtension', isTsSupported ? '.ts' : '.js');
153
+ },
154
+ /**
155
+ * Retrieves existing controller data if found in the project's workspace.
156
+ *
157
+ * @param controllerName Controller name that exists in the view.
158
+ * @returns Returns existing controller data.
159
+ */
160
+ getExistingController: async function _getExistingController(controllerName) {
161
+ let data;
162
+ try {
163
+ data = await getExistingController(controllerName);
164
+ } catch (e) {
165
+ this.handleError(e);
166
+ }
167
+ return data;
168
+ },
169
+ /**
170
+ * Retrieves controller files and fills the model with data
171
+ */
172
+ getControllers: async function _getControllers() {
173
+ try {
174
+ const {
175
+ controllers
176
+ } = await readControllers();
177
+ this.model.setProperty('/controllersList', controllers);
178
+ } catch (e) {
179
+ this.handleError(e);
180
+ }
181
+ },
182
+ /**
183
+ * Creates a new fragment for the specified control
184
+ *
185
+ * @param controllerName Controller Name
186
+ * @param viewId View Id
187
+ */
188
+ createNewController: async function _createNewController(controllerName, viewId) {
189
+ try {
190
+ await writeController({
191
+ controllerName
192
+ });
193
+ const controllerRef = {
194
+ codeRef: `coding/${controllerName}.js`,
195
+ viewId
196
+ };
197
+ const service = await this.rta.getService('controllerExtension');
198
+ const change = await service.add(controllerRef.codeRef, controllerRef.viewId);
199
+ change.creation = new Date().toISOString();
200
+ await writeChange(change);
201
+ MessageToast.show(`Controller extension with name '${controllerName}' was created.`);
202
+ } catch (e) {
203
+ // We want to update the model incase we have already created a controller file but failed when creating a change file,
204
+ // 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
205
+ await this.getControllers();
206
+ this.handleError(e);
207
+ }
208
+ }
209
+ });
210
+ return ControllerExtension;
211
211
  });
212
212
  //# sourceMappingURL=ControllerExtension.controller.js.map