@sap-ux/preview-middleware 0.17.48 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/adp/api-handler.js +153 -153
- package/dist/client/adp/api-handler.ts +1 -0
- package/dist/client/adp/command-executor.js +75 -75
- package/dist/client/adp/control-utils.js +44 -44
- package/dist/client/adp/controllers/BaseDialog.controller.js +187 -187
- package/dist/client/adp/controllers/ControllerExtension.controller.js +209 -213
- package/dist/client/adp/controllers/ControllerExtension.controller.ts +19 -36
- package/dist/client/adp/controllers/ExtensionPoint.controller.js +138 -138
- package/dist/client/adp/controllers/FileExistsDialog.controller.js +66 -66
- package/dist/client/adp/dialog-factory.js +125 -125
- package/dist/client/adp/init-dialogs.js +100 -100
- package/dist/client/adp/quick-actions/common/add-controller-to-page.js +55 -55
- package/dist/client/adp/quick-actions/common/create-page-action.js +51 -51
- package/dist/client/adp/quick-actions/common/op-add-custom-section.js +36 -36
- package/dist/client/adp/quick-actions/common/op-add-header-field.js +48 -48
- package/dist/client/adp/quick-actions/common/utils.js +18 -18
- package/dist/client/adp/quick-actions/control-types.js +21 -21
- package/dist/client/adp/quick-actions/dialog-enablement-validator.js +24 -24
- package/dist/client/adp/quick-actions/enablement-validator.js +4 -4
- package/dist/client/adp/quick-actions/fe-v2/change-table-columns.js +101 -101
- package/dist/client/adp/quick-actions/fe-v2/create-table-action.js +104 -104
- package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.js +96 -96
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-semantic-date-range-filter-bar.js +78 -78
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-table-filtering.js +77 -77
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-variant-management.js +69 -69
- package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.js +59 -59
- package/dist/client/adp/quick-actions/fe-v2/op-enable-empty-row-mode.js +93 -93
- package/dist/client/adp/quick-actions/fe-v2/op-enable-variant-management.js +84 -84
- package/dist/client/adp/quick-actions/fe-v2/registry.js +75 -75
- package/dist/client/adp/quick-actions/fe-v2/utils.js +116 -116
- package/dist/client/adp/quick-actions/fe-v4/change-table-columns.js +73 -73
- package/dist/client/adp/quick-actions/fe-v4/create-table-action.js +50 -50
- package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column.js +46 -46
- package/dist/client/adp/quick-actions/fe-v4/enable-variant-management.js +81 -81
- package/dist/client/adp/quick-actions/fe-v4/lr-enable-semantic-date-range-filter-bar.js +56 -56
- package/dist/client/adp/quick-actions/fe-v4/lr-enable-table-filtering.js +82 -82
- package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.js +53 -53
- package/dist/client/adp/quick-actions/fe-v4/op-enable-empty-row-mode.js +89 -89
- package/dist/client/adp/quick-actions/fe-v4/registry.js +58 -58
- package/dist/client/adp/quick-actions/fe-v4/utils.js +47 -47
- package/dist/client/adp/quick-actions/load.js +44 -44
- package/dist/client/adp/quick-actions/quick-action-base.js +53 -53
- package/dist/client/adp/ui/ControllerExtension.fragment.xml +2 -2
- package/dist/client/adp/utils.js +160 -160
- package/dist/client/cpe/changes/index.js +10 -10
- package/dist/client/cpe/changes/validator.js +39 -39
- package/dist/client/cpe/documentation.js +164 -164
- package/dist/client/cpe/feature-service.js +36 -36
- package/dist/client/cpe/logger.js +30 -30
- package/dist/client/cpe/outline/editable.js +37 -37
- package/dist/client/cpe/outline/nodes.js +222 -222
- package/dist/client/cpe/quick-actions/quick-action-definition.js +4 -4
- package/dist/client/cpe/quick-actions/registry.js +143 -143
- package/dist/client/cpe/quick-actions/utils.js +92 -92
- package/dist/client/cpe/types.js +4 -4
- package/dist/client/cpe/ui5-utils.js +33 -33
- package/dist/client/cpe/utils.js +138 -138
- package/dist/client/flp/WorkspaceConnector.js +86 -86
- package/dist/client/flp/common.js +28 -28
- package/dist/client/flp/enableFakeConnector.js +83 -83
- package/dist/client/flp/initConnectors.js +30 -30
- package/dist/client/flp/initRta.js +178 -178
- package/dist/client/i18n.js +56 -56
- package/dist/client/tsconfig.tsbuildinfo +1 -0
- package/dist/client/utils/application.js +32 -32
- package/dist/client/utils/core.js +68 -68
- package/dist/client/utils/error.js +19 -19
- package/dist/client/utils/fe-v4.js +118 -118
- package/dist/client/utils/version.js +102 -102
- package/package.json +3 -3
|
@@ -1,215 +1,211 @@
|
|
|
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
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
|
|
38
|
-
this.dialog.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-
this.
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
controllerName
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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 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) {
|
|
23
|
+
BaseDialog.prototype.constructor.call(this, name);
|
|
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}.js`);
|
|
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
|
+
const controllerExists = this.model.getProperty('/controllerExists');
|
|
85
|
+
if (!controllerExists) {
|
|
86
|
+
source.setEnabled(false);
|
|
87
|
+
const controllerName = this.model.getProperty('/newControllerName');
|
|
88
|
+
const viewId = this.model.getProperty('/viewId');
|
|
89
|
+
await this.createNewController(controllerName, viewId);
|
|
90
|
+
} else {
|
|
91
|
+
const controllerPath = this.model.getProperty('/controllerPath');
|
|
92
|
+
window.open(`vscode://file${controllerPath}`);
|
|
93
|
+
}
|
|
94
|
+
this.handleDialogClose();
|
|
95
|
+
},
|
|
96
|
+
/**
|
|
97
|
+
* Builds data that is used in the dialog.
|
|
98
|
+
*/
|
|
99
|
+
buildDialogData: async function _buildDialogData() {
|
|
100
|
+
const selectorId = this.overlays.getId();
|
|
101
|
+
const overlayControl = sap.ui.getCore().byId(selectorId);
|
|
102
|
+
const {
|
|
103
|
+
controllerName,
|
|
104
|
+
viewId
|
|
105
|
+
} = getControllerInfo(overlayControl);
|
|
106
|
+
const data = await this.getExistingController(controllerName);
|
|
107
|
+
if (data) {
|
|
108
|
+
if (data?.controllerExists) {
|
|
109
|
+
this.updateModelForExistingController(data);
|
|
110
|
+
} else {
|
|
111
|
+
this.updateModelForNewController(viewId, data.isTsSupported);
|
|
112
|
+
await this.getControllers();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
/**
|
|
117
|
+
* Updates the model properties for an existing controller.
|
|
118
|
+
*
|
|
119
|
+
* @param {CodeExtResponse} data - Existing controller data from the server.
|
|
120
|
+
*/
|
|
121
|
+
updateModelForExistingController: function _updateModelForExistingController(data) {
|
|
122
|
+
const {
|
|
123
|
+
controllerExists,
|
|
124
|
+
controllerPath,
|
|
125
|
+
controllerPathFromRoot,
|
|
126
|
+
isRunningInBAS
|
|
127
|
+
} = data;
|
|
128
|
+
this.model.setProperty('/controllerExists', controllerExists);
|
|
129
|
+
this.model.setProperty('/controllerPath', controllerPath);
|
|
130
|
+
this.model.setProperty('/controllerPathFromRoot', controllerPathFromRoot);
|
|
131
|
+
const content = this.dialog.getContent();
|
|
132
|
+
const form = content[0];
|
|
133
|
+
form.setVisible(false);
|
|
134
|
+
const messageForm = content[1];
|
|
135
|
+
messageForm.setVisible(true);
|
|
136
|
+
if (isRunningInBAS) {
|
|
137
|
+
this.dialog.getBeginButton().setVisible(false);
|
|
138
|
+
} else {
|
|
139
|
+
this.dialog.getBeginButton().setText('Open in VS Code').setEnabled(true);
|
|
140
|
+
}
|
|
141
|
+
this.dialog.getEndButton().setText('Close');
|
|
142
|
+
},
|
|
143
|
+
/**
|
|
144
|
+
* Updates the model property for a new controller.
|
|
145
|
+
*
|
|
146
|
+
* @param {string} viewId - The view ID.
|
|
147
|
+
* @param {boolean} isTsSupported - Whether TypeScript supported for the current project.
|
|
148
|
+
*/
|
|
149
|
+
updateModelForNewController: function _updateModelForNewController(viewId, isTsSupported) {
|
|
150
|
+
this.model.setProperty('/viewId', viewId);
|
|
151
|
+
this.model.setProperty('/controllerExtension', isTsSupported ? '.ts' : '.js');
|
|
152
|
+
},
|
|
153
|
+
/**
|
|
154
|
+
* Retrieves existing controller data if found in the project's workspace.
|
|
155
|
+
*
|
|
156
|
+
* @param controllerName Controller name that exists in the view.
|
|
157
|
+
* @returns Returns existing controller data.
|
|
158
|
+
*/
|
|
159
|
+
getExistingController: async function _getExistingController(controllerName) {
|
|
160
|
+
let data;
|
|
161
|
+
try {
|
|
162
|
+
data = await getExistingController(controllerName);
|
|
163
|
+
} catch (e) {
|
|
164
|
+
this.handleError(e);
|
|
165
|
+
}
|
|
166
|
+
return data;
|
|
167
|
+
},
|
|
168
|
+
/**
|
|
169
|
+
* Retrieves controller files and fills the model with data
|
|
170
|
+
*/
|
|
171
|
+
getControllers: async function _getControllers() {
|
|
172
|
+
try {
|
|
173
|
+
const {
|
|
174
|
+
controllers
|
|
175
|
+
} = await readControllers();
|
|
176
|
+
this.model.setProperty('/controllersList', controllers);
|
|
177
|
+
} catch (e) {
|
|
178
|
+
this.handleError(e);
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
/**
|
|
182
|
+
* Creates a new fragment for the specified control
|
|
183
|
+
*
|
|
184
|
+
* @param controllerName Controller Name
|
|
185
|
+
* @param viewId View Id
|
|
186
|
+
*/
|
|
187
|
+
createNewController: async function _createNewController(controllerName, viewId) {
|
|
188
|
+
try {
|
|
189
|
+
await writeController({
|
|
190
|
+
controllerName
|
|
191
|
+
});
|
|
192
|
+
const controllerRef = {
|
|
193
|
+
codeRef: `coding/${controllerName}.js`,
|
|
194
|
+
viewId
|
|
195
|
+
};
|
|
196
|
+
const service = await this.rta.getService('controllerExtension');
|
|
197
|
+
const change = await service.add(controllerRef.codeRef, controllerRef.viewId);
|
|
198
|
+
change.creation = new Date().toISOString();
|
|
199
|
+
await writeChange(change);
|
|
200
|
+
MessageToast.show(`Controller extension with name '${controllerName}' was created.`);
|
|
201
|
+
} catch (e) {
|
|
202
|
+
// We want to update the model incase we have already created a controller file but failed when creating a change file,
|
|
203
|
+
// 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
|
|
204
|
+
await this.getControllers();
|
|
205
|
+
this.handleError(e);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
return ControllerExtension;
|
|
214
210
|
});
|
|
215
211
|
//# sourceMappingURL=ControllerExtension.controller.js.map
|
|
@@ -24,13 +24,7 @@ import type SimpleForm from 'sap/ui/layout/form/SimpleForm';
|
|
|
24
24
|
import type ElementOverlay from 'sap/ui/dt/ElementOverlay';
|
|
25
25
|
|
|
26
26
|
import type { CodeExtResponse, ControllersResponse } from '../api-handler';
|
|
27
|
-
import {
|
|
28
|
-
getExistingController,
|
|
29
|
-
getManifestAppdescr,
|
|
30
|
-
readControllers,
|
|
31
|
-
writeChange,
|
|
32
|
-
writeController
|
|
33
|
-
} from '../api-handler';
|
|
27
|
+
import { getExistingController, readControllers, writeChange, writeController } from '../api-handler';
|
|
34
28
|
import BaseDialog from './BaseDialog.controller';
|
|
35
29
|
import { getControllerInfo } from '../utils';
|
|
36
30
|
|
|
@@ -44,6 +38,7 @@ type ControllerModel = JSONModel & {
|
|
|
44
38
|
getProperty(sPath: '/newControllerName'): string;
|
|
45
39
|
getProperty(sPath: '/viewId'): string;
|
|
46
40
|
getProperty(sPath: '/controllerPath'): string;
|
|
41
|
+
getProperty(sPath: '/controllerExtension'): string;
|
|
47
42
|
};
|
|
48
43
|
|
|
49
44
|
/**
|
|
@@ -158,20 +153,13 @@ export default class ControllerExtension extends BaseDialog<ControllerModel> {
|
|
|
158
153
|
const overlayControl = sap.ui.getCore().byId(selectorId) as unknown as ElementOverlay;
|
|
159
154
|
|
|
160
155
|
const { controllerName, viewId } = getControllerInfo(overlayControl);
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if (controllerExists) {
|
|
167
|
-
this.updateModelForExistingController(
|
|
168
|
-
controllerExists,
|
|
169
|
-
controllerPath,
|
|
170
|
-
controllerPathFromRoot,
|
|
171
|
-
isRunningInBAS
|
|
172
|
-
);
|
|
156
|
+
const data = await this.getExistingController(controllerName);
|
|
157
|
+
|
|
158
|
+
if (data) {
|
|
159
|
+
if (data?.controllerExists) {
|
|
160
|
+
this.updateModelForExistingController(data);
|
|
173
161
|
} else {
|
|
174
|
-
this.updateModelForNewController(viewId);
|
|
162
|
+
this.updateModelForNewController(viewId, data.isTsSupported);
|
|
175
163
|
|
|
176
164
|
await this.getControllers();
|
|
177
165
|
}
|
|
@@ -180,17 +168,11 @@ export default class ControllerExtension extends BaseDialog<ControllerModel> {
|
|
|
180
168
|
/**
|
|
181
169
|
* Updates the model properties for an existing controller.
|
|
182
170
|
*
|
|
183
|
-
* @param {
|
|
184
|
-
* @param {string} controllerPath - The controller path.
|
|
185
|
-
* @param {string} controllerPathFromRoot - The controller path from the project root.
|
|
186
|
-
* @param {boolean} isRunningInBAS - Whether the environment is BAS or VS Code.
|
|
171
|
+
* @param {CodeExtResponse} data - Existing controller data from the server.
|
|
187
172
|
*/
|
|
188
|
-
private updateModelForExistingController(
|
|
189
|
-
controllerExists
|
|
190
|
-
|
|
191
|
-
controllerPathFromRoot: string,
|
|
192
|
-
isRunningInBAS: boolean
|
|
193
|
-
): void {
|
|
173
|
+
private updateModelForExistingController(data: CodeExtResponse): void {
|
|
174
|
+
const { controllerExists, controllerPath, controllerPathFromRoot, isRunningInBAS } = data;
|
|
175
|
+
|
|
194
176
|
this.model.setProperty('/controllerExists', controllerExists);
|
|
195
177
|
this.model.setProperty('/controllerPath', controllerPath);
|
|
196
178
|
this.model.setProperty('/controllerPathFromRoot', controllerPathFromRoot);
|
|
@@ -214,17 +196,19 @@ export default class ControllerExtension extends BaseDialog<ControllerModel> {
|
|
|
214
196
|
/**
|
|
215
197
|
* Updates the model property for a new controller.
|
|
216
198
|
*
|
|
217
|
-
* @param viewId The view ID
|
|
199
|
+
* @param {string} viewId - The view ID.
|
|
200
|
+
* @param {boolean} isTsSupported - Whether TypeScript supported for the current project.
|
|
218
201
|
*/
|
|
219
|
-
private updateModelForNewController(viewId: string): void {
|
|
202
|
+
private updateModelForNewController(viewId: string, isTsSupported: boolean): void {
|
|
220
203
|
this.model.setProperty('/viewId', viewId);
|
|
204
|
+
this.model.setProperty('/controllerExtension', isTsSupported ? '.ts' : '.js');
|
|
221
205
|
}
|
|
222
206
|
|
|
223
207
|
/**
|
|
224
208
|
* Retrieves existing controller data if found in the project's workspace.
|
|
225
209
|
*
|
|
226
|
-
* @param controllerName Controller name that exists in the view
|
|
227
|
-
* @returns
|
|
210
|
+
* @param controllerName Controller name that exists in the view.
|
|
211
|
+
* @returns Returns existing controller data.
|
|
228
212
|
*/
|
|
229
213
|
private async getExistingController(controllerName: string): Promise<CodeExtResponse | undefined> {
|
|
230
214
|
let data: CodeExtResponse | undefined;
|
|
@@ -257,8 +241,7 @@ export default class ControllerExtension extends BaseDialog<ControllerModel> {
|
|
|
257
241
|
*/
|
|
258
242
|
private async createNewController(controllerName: string, viewId: string): Promise<void> {
|
|
259
243
|
try {
|
|
260
|
-
|
|
261
|
-
await writeController({ controllerName, projectId: manifest.id });
|
|
244
|
+
await writeController({ controllerName });
|
|
262
245
|
|
|
263
246
|
const controllerRef = {
|
|
264
247
|
codeRef: `coding/${controllerName}.js`,
|