@sap-ux/preview-middleware 0.16.80 → 0.16.81

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 (48) hide show
  1. package/dist/client/adp/api-handler.js +142 -142
  2. package/dist/client/adp/command-executor.js +58 -58
  3. package/dist/client/adp/control-utils.js +44 -44
  4. package/dist/client/adp/controllers/AddFragment.controller.js +5 -1
  5. package/dist/client/adp/controllers/AddFragment.controller.ts +5 -1
  6. package/dist/client/adp/controllers/BaseDialog.controller.js +105 -105
  7. package/dist/client/adp/controllers/ControllerExtension.controller.js +213 -213
  8. package/dist/client/adp/controllers/ExtensionPoint.controller.js +138 -138
  9. package/dist/client/adp/init-dialogs.js +159 -159
  10. package/dist/client/adp/quick-actions/common/add-controller-to-page.js +54 -54
  11. package/dist/client/adp/quick-actions/common/op-add-custom-section.js +35 -35
  12. package/dist/client/adp/quick-actions/common/op-add-header-field.js +47 -47
  13. package/dist/client/adp/quick-actions/fe-v2/change-table-columns.js +98 -98
  14. package/dist/client/adp/quick-actions/fe-v2/create-page-action.js +35 -35
  15. package/dist/client/adp/quick-actions/fe-v2/create-page-action.ts +2 -2
  16. package/dist/client/adp/quick-actions/fe-v2/create-table-action.js +69 -69
  17. package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.js +57 -57
  18. package/dist/client/adp/quick-actions/fe-v2/registry.js +60 -60
  19. package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.js +79 -79
  20. package/dist/client/adp/quick-actions/fe-v4/registry.js +50 -50
  21. package/dist/client/adp/quick-actions/fe-v4/utils.js +52 -52
  22. package/dist/client/adp/quick-actions/load.js +48 -48
  23. package/dist/client/adp/utils.js +160 -160
  24. package/dist/client/cpe/changes/flex-change.js +51 -51
  25. package/dist/client/cpe/changes/index.js +10 -10
  26. package/dist/client/cpe/changes/validator.js +34 -34
  27. package/dist/client/cpe/documentation.js +164 -164
  28. package/dist/client/cpe/logger.js +30 -30
  29. package/dist/client/cpe/outline/editable.js +37 -37
  30. package/dist/client/cpe/outline/nodes.js +187 -187
  31. package/dist/client/cpe/quick-actions/quick-action-definition.js +4 -4
  32. package/dist/client/cpe/quick-actions/registry.js +143 -143
  33. package/dist/client/cpe/quick-actions/utils.js +92 -92
  34. package/dist/client/cpe/types.js +4 -4
  35. package/dist/client/cpe/ui5-utils.js +33 -33
  36. package/dist/client/cpe/utils.js +97 -97
  37. package/dist/client/flp/WorkspaceConnector.js +87 -87
  38. package/dist/client/flp/common.js +28 -28
  39. package/dist/client/flp/enableFakeConnector.js +84 -84
  40. package/dist/client/flp/initConnectors.js +30 -30
  41. package/dist/client/flp/initRta.js +178 -178
  42. package/dist/client/i18n.js +56 -56
  43. package/dist/client/tsconfig.tsbuildinfo +1 -1
  44. package/dist/client/utils/application.js +32 -32
  45. package/dist/client/utils/core.js +68 -68
  46. package/dist/client/utils/error.js +19 -19
  47. package/dist/client/utils/version.js +68 -68
  48. package/package.json +4 -4
@@ -1,107 +1,107 @@
1
- "use strict";
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) {
4
- "use strict";
5
-
6
- const ValueState = sap_ui_core_library["ValueState"];
7
- const matchesFragmentName = ___utils["matchesFragmentName"];
8
- const getError = ____utils_error["getError"];
9
- /**
10
- * @namespace open.ux.preview.client.adp.controllers
11
- */
12
- const BaseDialog = Controller.extend("open.ux.preview.client.adp.controllers.BaseDialog", {
13
- /**
14
- * Handles fragment name input change
15
- *
16
- * @param event Event
17
- */
18
- onFragmentNameInputChange: function _onFragmentNameInputChange(event) {
19
- const input = event.getSource();
20
- const beginBtn = this.dialog.getBeginButton();
21
- const fragmentName = input.getValue();
22
- const fragmentList = this.model.getProperty('/fragmentList');
23
- const updateDialogState = function (valueState) {
24
- let valueStateText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
25
- input.setValueState(valueState).setValueStateText(valueStateText);
26
- beginBtn.setEnabled(valueState === ValueState.Success);
27
- };
28
- if (fragmentName.length <= 0) {
29
- updateDialogState(ValueState.None);
30
- this.model.setProperty('/newFragmentName', null);
31
- return;
32
- }
33
- const fileExists = fragmentList.some(f => f.fragmentName === `${fragmentName}.fragment.xml`);
34
- if (fileExists) {
35
- updateDialogState(ValueState.Error, 'Enter a different name. The fragment name that you entered already exists in your project.');
36
- return;
37
- }
38
- const isValidName = /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(fragmentName);
39
- if (!isValidName) {
40
- updateDialogState(ValueState.Error, 'The fragment name cannot contain white spaces or special characters.');
41
- return;
42
- }
43
- if (fragmentName.length > 64) {
44
- updateDialogState(ValueState.Error, 'A fragment file name cannot contain more than 64 characters.');
45
- return;
46
- }
47
- const changeExists = this.checkForExistingChange(fragmentName);
48
- if (changeExists) {
49
- updateDialogState(ValueState.Error, 'Enter a different name. The fragment name entered matches the name of an unsaved fragment.');
50
- return;
51
- }
52
- updateDialogState(ValueState.Success);
53
- this.model.setProperty('/newFragmentName', fragmentName);
54
- },
55
- /**
56
- * Checks for the existence of a change associated with a specific fragment name in the RTA command stack.
57
- *
58
- * @param {string} fragmentName - The name of the fragment to check for existing changes.
59
- * @returns {Promise<boolean>} A promise that resolves to `true` if a matching change is found, otherwise `false`.
60
- */
61
- checkForExistingChange: function _checkForExistingChange(fragmentName) {
62
- const allCommands = this.rta.getCommandStack().getCommands();
63
- return allCommands.some(command => {
64
- if (typeof command.getCommands === 'function') {
65
- const addXmlCommand = command.getCommands().find(c => c?.getProperty('name') === 'addXMLAtExtensionPoint');
66
- return addXmlCommand && matchesFragmentName(addXmlCommand, fragmentName);
67
- } else {
68
- return matchesFragmentName(command, fragmentName);
69
- }
70
- });
71
- },
72
- /**
73
- * Sets custom function that fires when user presses escape key.
74
- */
75
- setEscapeHandler: function _setEscapeHandler() {
76
- this.dialog.setEscapeHandler(_ref => {
77
- let {
78
- resolve
79
- } = _ref;
80
- this.handleDialogClose();
81
- resolve();
82
- });
83
- },
84
- /**
85
- * Handles the dialog closing and destruction of it.
86
- */
87
- handleDialogClose: function _handleDialogClose() {
88
- this.dialog.close();
89
- this.dialog.destroy();
90
- },
91
- /**
92
- * Function that handles runtime thrown errors with MessageToast
93
- *
94
- * @param e error instance
95
- * @throws {Error}.
96
- */
97
- handleError: function _handleError(e) {
98
- const error = getError(e);
99
- MessageToast.show(error.message, {
100
- duration: 5000
101
- });
102
- throw error;
103
- }
104
- });
105
- return BaseDialog;
1
+ "use strict";
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) {
4
+ "use strict";
5
+
6
+ const ValueState = sap_ui_core_library["ValueState"];
7
+ const matchesFragmentName = ___utils["matchesFragmentName"];
8
+ const getError = ____utils_error["getError"];
9
+ /**
10
+ * @namespace open.ux.preview.client.adp.controllers
11
+ */
12
+ const BaseDialog = Controller.extend("open.ux.preview.client.adp.controllers.BaseDialog", {
13
+ /**
14
+ * Handles fragment name input change
15
+ *
16
+ * @param event Event
17
+ */
18
+ onFragmentNameInputChange: function _onFragmentNameInputChange(event) {
19
+ const input = event.getSource();
20
+ const beginBtn = this.dialog.getBeginButton();
21
+ const fragmentName = input.getValue();
22
+ const fragmentList = this.model.getProperty('/fragmentList');
23
+ const updateDialogState = function (valueState) {
24
+ let valueStateText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
25
+ input.setValueState(valueState).setValueStateText(valueStateText);
26
+ beginBtn.setEnabled(valueState === ValueState.Success);
27
+ };
28
+ if (fragmentName.length <= 0) {
29
+ updateDialogState(ValueState.None);
30
+ this.model.setProperty('/newFragmentName', null);
31
+ return;
32
+ }
33
+ const fileExists = fragmentList.some(f => f.fragmentName === `${fragmentName}.fragment.xml`);
34
+ if (fileExists) {
35
+ updateDialogState(ValueState.Error, 'Enter a different name. The fragment name that you entered already exists in your project.');
36
+ return;
37
+ }
38
+ const isValidName = /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(fragmentName);
39
+ if (!isValidName) {
40
+ updateDialogState(ValueState.Error, 'The fragment name cannot contain white spaces or special characters.');
41
+ return;
42
+ }
43
+ if (fragmentName.length > 64) {
44
+ updateDialogState(ValueState.Error, 'A fragment file name cannot contain more than 64 characters.');
45
+ return;
46
+ }
47
+ const changeExists = this.checkForExistingChange(fragmentName);
48
+ if (changeExists) {
49
+ updateDialogState(ValueState.Error, 'Enter a different name. The fragment name entered matches the name of an unsaved fragment.');
50
+ return;
51
+ }
52
+ updateDialogState(ValueState.Success);
53
+ this.model.setProperty('/newFragmentName', fragmentName);
54
+ },
55
+ /**
56
+ * Checks for the existence of a change associated with a specific fragment name in the RTA command stack.
57
+ *
58
+ * @param {string} fragmentName - The name of the fragment to check for existing changes.
59
+ * @returns {Promise<boolean>} A promise that resolves to `true` if a matching change is found, otherwise `false`.
60
+ */
61
+ checkForExistingChange: function _checkForExistingChange(fragmentName) {
62
+ const allCommands = this.rta.getCommandStack().getCommands();
63
+ return allCommands.some(command => {
64
+ if (typeof command.getCommands === 'function') {
65
+ const addXmlCommand = command.getCommands().find(c => c?.getProperty('name') === 'addXMLAtExtensionPoint');
66
+ return addXmlCommand && matchesFragmentName(addXmlCommand, fragmentName);
67
+ } else {
68
+ return matchesFragmentName(command, fragmentName);
69
+ }
70
+ });
71
+ },
72
+ /**
73
+ * Sets custom function that fires when user presses escape key.
74
+ */
75
+ setEscapeHandler: function _setEscapeHandler() {
76
+ this.dialog.setEscapeHandler(_ref => {
77
+ let {
78
+ resolve
79
+ } = _ref;
80
+ this.handleDialogClose();
81
+ resolve();
82
+ });
83
+ },
84
+ /**
85
+ * Handles the dialog closing and destruction of it.
86
+ */
87
+ handleDialogClose: function _handleDialogClose() {
88
+ this.dialog.close();
89
+ this.dialog.destroy();
90
+ },
91
+ /**
92
+ * Function that handles runtime thrown errors with MessageToast
93
+ *
94
+ * @param e error instance
95
+ * @throws {Error}.
96
+ */
97
+ handleError: function _handleError(e) {
98
+ const error = getError(e);
99
+ MessageToast.show(error.message, {
100
+ duration: 5000
101
+ });
102
+ throw error;
103
+ }
104
+ });
105
+ return BaseDialog;
106
106
  });
107
107
  //# sourceMappingURL=BaseDialog.controller.js.map
@@ -1,215 +1,215 @@
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 getManifestAppdescr = ___api_handler["getManifestAppdescr"];
14
- const readControllers = ___api_handler["readControllers"];
15
- const writeChange = ___api_handler["writeChange"];
16
- const writeController = ___api_handler["writeController"];
17
- const BaseDialog = _interopRequireDefault(__BaseDialog);
18
- const getControllerInfo = ___utils["getControllerInfo"];
19
- /**
20
- * @namespace open.ux.preview.client.adp.controllers
21
- */
22
- const ControllerExtension = BaseDialog.extend("open.ux.preview.client.adp.controllers.ControllerExtension", {
23
- constructor: function _constructor(name, overlays, rta) {
24
- BaseDialog.prototype.constructor.call(this, name);
25
- this.rta = rta;
26
- this.overlays = overlays;
27
- this.model = new JSONModel();
28
- },
29
- /**
30
- * Setups the Dialog and the JSON Model
31
- *
32
- * @param {Dialog} dialog - Dialog instance
33
- */
34
- setup: async function _setup(dialog) {
35
- this.dialog = dialog;
36
- this.setEscapeHandler();
37
- await this.buildDialogData();
38
- this.dialog.setModel(this.model);
39
- this.dialog.open();
40
- },
41
- /**
42
- * Handles fragment name input change
43
- *
44
- * @param event Event
45
- */
46
- onControllerNameInputChange: function _onControllerNameInputChange(event) {
47
- const input = event.getSource();
48
- const beginBtn = this.dialog.getBeginButton();
49
- const controllerName = input.getValue();
50
- const controllerList = this.model.getProperty('/controllersList');
51
- const updateDialogState = function (valueState) {
52
- let valueStateText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
53
- input.setValueState(valueState).setValueStateText(valueStateText);
54
- beginBtn.setEnabled(valueState === ValueState.Success);
55
- };
56
- if (controllerName.length <= 0) {
57
- updateDialogState(ValueState.None);
58
- this.model.setProperty('/newControllerName', null);
59
- return;
60
- }
61
- const fileExists = controllerList.some(f => f.controllerName === `${controllerName}.js`);
62
- if (fileExists) {
63
- updateDialogState(ValueState.Error, 'Enter a different name. The controller name that you entered already exists in your project.');
64
- return;
65
- }
66
- const isValidName = /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(controllerName);
67
- if (!isValidName) {
68
- updateDialogState(ValueState.Error, 'The controller name cannot contain white spaces or special characters.');
69
- return;
70
- }
71
- if (controllerName.length > 64) {
72
- updateDialogState(ValueState.Error, 'A controller file name cannot contain more than 64 characters.');
73
- return;
74
- }
75
- updateDialogState(ValueState.Success);
76
- this.model.setProperty('/newControllerName', controllerName);
77
- },
78
- /**
79
- * Handles create button press
80
- *
81
- * @param event Event
82
- */
83
- onCreateBtnPress: async function _onCreateBtnPress(event) {
84
- const source = event.getSource();
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 existingController = await this.getExistingController(controllerName);
108
- if (existingController) {
109
- const {
110
- controllerExists,
111
- controllerPath,
112
- controllerPathFromRoot,
113
- isRunningInBAS
114
- } = existingController;
115
- if (controllerExists) {
116
- this.updateModelForExistingController(controllerExists, controllerPath, controllerPathFromRoot, isRunningInBAS);
117
- } else {
118
- this.updateModelForNewController(viewId);
119
- await this.getControllers();
120
- }
121
- }
122
- },
123
- /**
124
- * Updates the model properties for an existing controller.
125
- *
126
- * @param {boolean} controllerExists - Whether the controller exists.
127
- * @param {string} controllerPath - The controller path.
128
- * @param {string} controllerPathFromRoot - The controller path from the project root.
129
- * @param {boolean} isRunningInBAS - Whether the environment is BAS or VS Code.
130
- */
131
- updateModelForExistingController: function _updateModelForExistingController(controllerExists, controllerPath, controllerPathFromRoot, isRunningInBAS) {
132
- this.model.setProperty('/controllerExists', controllerExists);
133
- this.model.setProperty('/controllerPath', controllerPath);
134
- this.model.setProperty('/controllerPathFromRoot', controllerPathFromRoot);
135
- const content = this.dialog.getContent();
136
- const form = content[0];
137
- form.setVisible(false);
138
- const messageForm = content[1];
139
- messageForm.setVisible(true);
140
- if (isRunningInBAS) {
141
- this.dialog.getBeginButton().setVisible(false);
142
- } else {
143
- this.dialog.getBeginButton().setText('Open in VS Code').setEnabled(true);
144
- }
145
- this.dialog.getEndButton().setText('Close');
146
- },
147
- /**
148
- * Updates the model property for a new controller.
149
- *
150
- * @param viewId The view ID
151
- */
152
- updateModelForNewController: function _updateModelForNewController(viewId) {
153
- this.model.setProperty('/viewId', viewId);
154
- },
155
- /**
156
- * Retrieves existing controller data if found in the project's workspace.
157
- *
158
- * @param controllerName Controller name that exists in the view
159
- * @returns Returnsexisting controller data
160
- */
161
- getExistingController: async function _getExistingController(controllerName) {
162
- let data;
163
- try {
164
- data = await getExistingController(controllerName);
165
- } catch (e) {
166
- this.handleError(e);
167
- }
168
- return data;
169
- },
170
- /**
171
- * Retrieves controller files and fills the model with data
172
- */
173
- getControllers: async function _getControllers() {
174
- try {
175
- const {
176
- controllers
177
- } = await readControllers();
178
- this.model.setProperty('/controllersList', controllers);
179
- } catch (e) {
180
- this.handleError(e);
181
- }
182
- },
183
- /**
184
- * Creates a new fragment for the specified control
185
- *
186
- * @param controllerName Controller Name
187
- * @param viewId View Id
188
- */
189
- createNewController: async function _createNewController(controllerName, viewId) {
190
- try {
191
- const manifest = await getManifestAppdescr();
192
- await writeController({
193
- controllerName,
194
- projectId: manifest.id
195
- });
196
- const controllerRef = {
197
- codeRef: `coding/${controllerName}.js`,
198
- viewId
199
- };
200
- const service = await this.rta.getService('controllerExtension');
201
- const change = await service.add(controllerRef.codeRef, controllerRef.viewId);
202
- change.creation = new Date().toISOString();
203
- await writeChange(change);
204
- MessageToast.show(`Controller extension with name '${controllerName}' was created.`);
205
- } catch (e) {
206
- // We want to update the model incase we have already created a controller file but failed when creating a change file,
207
- // 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
208
- await this.getControllers();
209
- this.handleError(e);
210
- }
211
- }
212
- });
213
- 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 getManifestAppdescr = ___api_handler["getManifestAppdescr"];
14
+ const readControllers = ___api_handler["readControllers"];
15
+ const writeChange = ___api_handler["writeChange"];
16
+ const writeController = ___api_handler["writeController"];
17
+ const BaseDialog = _interopRequireDefault(__BaseDialog);
18
+ const getControllerInfo = ___utils["getControllerInfo"];
19
+ /**
20
+ * @namespace open.ux.preview.client.adp.controllers
21
+ */
22
+ const ControllerExtension = BaseDialog.extend("open.ux.preview.client.adp.controllers.ControllerExtension", {
23
+ constructor: function _constructor(name, overlays, rta) {
24
+ BaseDialog.prototype.constructor.call(this, name);
25
+ this.rta = rta;
26
+ this.overlays = overlays;
27
+ this.model = new JSONModel();
28
+ },
29
+ /**
30
+ * Setups the Dialog and the JSON Model
31
+ *
32
+ * @param {Dialog} dialog - Dialog instance
33
+ */
34
+ setup: async function _setup(dialog) {
35
+ this.dialog = dialog;
36
+ this.setEscapeHandler();
37
+ await this.buildDialogData();
38
+ this.dialog.setModel(this.model);
39
+ this.dialog.open();
40
+ },
41
+ /**
42
+ * Handles fragment name input change
43
+ *
44
+ * @param event Event
45
+ */
46
+ onControllerNameInputChange: function _onControllerNameInputChange(event) {
47
+ const input = event.getSource();
48
+ const beginBtn = this.dialog.getBeginButton();
49
+ const controllerName = input.getValue();
50
+ const controllerList = this.model.getProperty('/controllersList');
51
+ const updateDialogState = function (valueState) {
52
+ let valueStateText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
53
+ input.setValueState(valueState).setValueStateText(valueStateText);
54
+ beginBtn.setEnabled(valueState === ValueState.Success);
55
+ };
56
+ if (controllerName.length <= 0) {
57
+ updateDialogState(ValueState.None);
58
+ this.model.setProperty('/newControllerName', null);
59
+ return;
60
+ }
61
+ const fileExists = controllerList.some(f => f.controllerName === `${controllerName}.js`);
62
+ if (fileExists) {
63
+ updateDialogState(ValueState.Error, 'Enter a different name. The controller name that you entered already exists in your project.');
64
+ return;
65
+ }
66
+ const isValidName = /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(controllerName);
67
+ if (!isValidName) {
68
+ updateDialogState(ValueState.Error, 'The controller name cannot contain white spaces or special characters.');
69
+ return;
70
+ }
71
+ if (controllerName.length > 64) {
72
+ updateDialogState(ValueState.Error, 'A controller file name cannot contain more than 64 characters.');
73
+ return;
74
+ }
75
+ updateDialogState(ValueState.Success);
76
+ this.model.setProperty('/newControllerName', controllerName);
77
+ },
78
+ /**
79
+ * Handles create button press
80
+ *
81
+ * @param event Event
82
+ */
83
+ onCreateBtnPress: async function _onCreateBtnPress(event) {
84
+ const source = event.getSource();
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 existingController = await this.getExistingController(controllerName);
108
+ if (existingController) {
109
+ const {
110
+ controllerExists,
111
+ controllerPath,
112
+ controllerPathFromRoot,
113
+ isRunningInBAS
114
+ } = existingController;
115
+ if (controllerExists) {
116
+ this.updateModelForExistingController(controllerExists, controllerPath, controllerPathFromRoot, isRunningInBAS);
117
+ } else {
118
+ this.updateModelForNewController(viewId);
119
+ await this.getControllers();
120
+ }
121
+ }
122
+ },
123
+ /**
124
+ * Updates the model properties for an existing controller.
125
+ *
126
+ * @param {boolean} controllerExists - Whether the controller exists.
127
+ * @param {string} controllerPath - The controller path.
128
+ * @param {string} controllerPathFromRoot - The controller path from the project root.
129
+ * @param {boolean} isRunningInBAS - Whether the environment is BAS or VS Code.
130
+ */
131
+ updateModelForExistingController: function _updateModelForExistingController(controllerExists, controllerPath, controllerPathFromRoot, isRunningInBAS) {
132
+ this.model.setProperty('/controllerExists', controllerExists);
133
+ this.model.setProperty('/controllerPath', controllerPath);
134
+ this.model.setProperty('/controllerPathFromRoot', controllerPathFromRoot);
135
+ const content = this.dialog.getContent();
136
+ const form = content[0];
137
+ form.setVisible(false);
138
+ const messageForm = content[1];
139
+ messageForm.setVisible(true);
140
+ if (isRunningInBAS) {
141
+ this.dialog.getBeginButton().setVisible(false);
142
+ } else {
143
+ this.dialog.getBeginButton().setText('Open in VS Code').setEnabled(true);
144
+ }
145
+ this.dialog.getEndButton().setText('Close');
146
+ },
147
+ /**
148
+ * Updates the model property for a new controller.
149
+ *
150
+ * @param viewId The view ID
151
+ */
152
+ updateModelForNewController: function _updateModelForNewController(viewId) {
153
+ this.model.setProperty('/viewId', viewId);
154
+ },
155
+ /**
156
+ * Retrieves existing controller data if found in the project's workspace.
157
+ *
158
+ * @param controllerName Controller name that exists in the view
159
+ * @returns Returnsexisting controller data
160
+ */
161
+ getExistingController: async function _getExistingController(controllerName) {
162
+ let data;
163
+ try {
164
+ data = await getExistingController(controllerName);
165
+ } catch (e) {
166
+ this.handleError(e);
167
+ }
168
+ return data;
169
+ },
170
+ /**
171
+ * Retrieves controller files and fills the model with data
172
+ */
173
+ getControllers: async function _getControllers() {
174
+ try {
175
+ const {
176
+ controllers
177
+ } = await readControllers();
178
+ this.model.setProperty('/controllersList', controllers);
179
+ } catch (e) {
180
+ this.handleError(e);
181
+ }
182
+ },
183
+ /**
184
+ * Creates a new fragment for the specified control
185
+ *
186
+ * @param controllerName Controller Name
187
+ * @param viewId View Id
188
+ */
189
+ createNewController: async function _createNewController(controllerName, viewId) {
190
+ try {
191
+ const manifest = await getManifestAppdescr();
192
+ await writeController({
193
+ controllerName,
194
+ projectId: manifest.id
195
+ });
196
+ const controllerRef = {
197
+ codeRef: `coding/${controllerName}.js`,
198
+ viewId
199
+ };
200
+ const service = await this.rta.getService('controllerExtension');
201
+ const change = await service.add(controllerRef.codeRef, controllerRef.viewId);
202
+ change.creation = new Date().toISOString();
203
+ await writeChange(change);
204
+ MessageToast.show(`Controller extension with name '${controllerName}' was created.`);
205
+ } catch (e) {
206
+ // We want to update the model incase we have already created a controller file but failed when creating a change file,
207
+ // 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
208
+ await this.getControllers();
209
+ this.handleError(e);
210
+ }
211
+ }
212
+ });
213
+ return ControllerExtension;
214
214
  });
215
215
  //# sourceMappingURL=ControllerExtension.controller.js.map