@sap-ux/preview-middleware 0.20.0 → 0.20.2
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/add-fragment.js +46 -46
- package/dist/client/adp/api-handler.js +159 -159
- package/dist/client/adp/command-executor.js +75 -75
- package/dist/client/adp/command-executor.ts +4 -4
- package/dist/client/adp/control-utils.js +44 -44
- package/dist/client/adp/controllers/AddFragment.controller.js +1 -1
- package/dist/client/adp/controllers/AddFragment.controller.ts +2 -2
- package/dist/client/adp/controllers/AddTableColumnFragments.controller.js +1 -1
- package/dist/client/adp/controllers/AddTableColumnFragments.controller.ts +2 -2
- package/dist/client/adp/controllers/BaseDialog.controller.js +2 -13
- package/dist/client/adp/controllers/BaseDialog.controller.ts +7 -25
- package/dist/client/adp/controllers/ControllerExtension.controller.js +268 -210
- package/dist/client/adp/controllers/ControllerExtension.controller.ts +110 -22
- package/dist/client/adp/controllers/ExtensionPoint.controller.js +139 -139
- package/dist/client/adp/controllers/FileExistsDialog.controller.js +66 -66
- package/dist/client/adp/dialog-factory.js +135 -135
- package/dist/client/adp/dialog-factory.ts +3 -1
- package/dist/client/adp/extend-controller.js +48 -0
- package/dist/client/adp/extend-controller.ts +49 -0
- package/dist/client/adp/init-dialogs.js +143 -163
- package/dist/client/adp/init-dialogs.ts +42 -20
- package/dist/client/adp/init.js +9 -1
- package/dist/client/adp/init.ts +6 -1
- package/dist/client/adp/quick-actions/add-new-subpage-quick-action-base.js +96 -96
- package/dist/client/adp/quick-actions/common/add-controller-to-page.js +74 -60
- package/dist/client/adp/quick-actions/common/add-controller-to-page.ts +25 -3
- package/dist/client/adp/quick-actions/common/create-page-action.js +54 -54
- package/dist/client/adp/quick-actions/common/op-add-custom-section.js +39 -39
- package/dist/client/adp/quick-actions/common/op-add-header-field.js +67 -67
- package/dist/client/adp/quick-actions/common/utils.js +18 -18
- package/dist/client/adp/quick-actions/control-types.js +23 -23
- 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/add-new-subpage.js +81 -81
- package/dist/client/adp/quick-actions/fe-v2/change-table-actions.js +67 -67
- 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 +107 -107
- package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.js +99 -99
- 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 +77 -77
- package/dist/client/adp/quick-actions/fe-v2/utils.js +116 -116
- package/dist/client/adp/quick-actions/fe-v4/add-new-subpage.js +138 -138
- package/dist/client/adp/quick-actions/fe-v4/change-table-actions.js +79 -79
- package/dist/client/adp/quick-actions/fe-v4/change-table-columns.js +75 -75
- package/dist/client/adp/quick-actions/fe-v4/create-table-action.js +53 -53
- package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column.js +49 -49
- 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 +84 -84
- 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 +60 -60
- package/dist/client/adp/quick-actions/fe-v4/utils.js +72 -72
- package/dist/client/adp/quick-actions/load.js +44 -44
- package/dist/client/adp/quick-actions/quick-action-base.js +64 -64
- package/dist/client/adp/ui/ControllerExtension.fragment.xml +14 -3
- package/dist/client/adp/utils.js +259 -218
- package/dist/client/adp/utils.ts +55 -7
- package/dist/client/cpe/additional-change-info/add-xml-additional-info.js +75 -75
- package/dist/client/cpe/changes/generic-change.js +326 -326
- package/dist/client/cpe/changes/index.js +10 -10
- package/dist/client/cpe/changes/validator.js +39 -39
- package/dist/client/cpe/connector-service.ts +1 -0
- 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 +203 -203
- 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 +111 -111
- package/dist/client/flp/WorkspaceConnector.js +92 -92
- package/dist/client/flp/common.js +28 -28
- package/dist/client/flp/enableFakeConnector.js +89 -89
- package/dist/client/flp/homepage/Component.js +14 -14
- package/dist/client/flp/initCdm.js +117 -117
- package/dist/client/flp/initConnectors.js +28 -28
- package/dist/client/flp/initRta.js +178 -178
- package/dist/client/i18n.js +56 -56
- package/dist/client/messagebundle.properties +5 -0
- package/dist/client/utils/additional-change-info.js +54 -54
- package/dist/client/utils/application.js +32 -32
- package/dist/client/utils/core.js +84 -84
- package/dist/client/utils/error.js +19 -19
- package/dist/client/utils/fe-v2.js +56 -56
- package/dist/client/utils/fe-v4.js +140 -140
- package/dist/client/utils/version.js +104 -104
- package/package.json +4 -4
|
@@ -17,17 +17,19 @@ import JSONModel from 'sap/ui/model/json/JSONModel';
|
|
|
17
17
|
/** sap.ui.rta */
|
|
18
18
|
import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
|
|
19
19
|
|
|
20
|
-
/** sap.ui.layout */
|
|
21
|
-
import type SimpleForm from 'sap/ui/layout/form/SimpleForm';
|
|
22
|
-
|
|
23
20
|
/** sap.ui.dt */
|
|
24
21
|
import type ElementOverlay from 'sap/ui/dt/ElementOverlay';
|
|
25
22
|
|
|
26
23
|
import type { CodeExtResponse, ControllersResponse } from '../api-handler';
|
|
27
24
|
import { getExistingController, readControllers, writeChange, writeController } from '../api-handler';
|
|
28
25
|
import BaseDialog from './BaseDialog.controller';
|
|
29
|
-
import {
|
|
26
|
+
import type { ExtendControllerData, DeferredExtendControllerData } from '../extend-controller';
|
|
30
27
|
import { QuickActionTelemetryData } from '../../cpe/quick-actions/quick-action-definition';
|
|
28
|
+
import { getResourceModel, getTextBundle, TextBundle } from '../../i18n';
|
|
29
|
+
import { notifyUser, checkForExistingChange, getControllerInfo } from '../utils';
|
|
30
|
+
import { getUi5Version, isLowerThanMinimalUi5Version } from '../../utils/version';
|
|
31
|
+
import CommandExecutor from '../command-executor';
|
|
32
|
+
import { getControlById } from '../../utils/core';
|
|
31
33
|
|
|
32
34
|
interface ControllerExtensionService {
|
|
33
35
|
add: (codeRef: string, viewId: string) => Promise<{ creation: string }>;
|
|
@@ -53,11 +55,21 @@ type ControllerModel = JSONModel & {
|
|
|
53
55
|
* @namespace open.ux.preview.client.adp.controllers
|
|
54
56
|
*/
|
|
55
57
|
export default class ControllerExtension extends BaseDialog<ControllerModel> {
|
|
56
|
-
|
|
58
|
+
public readonly data?: ExtendControllerData;
|
|
59
|
+
private bundle: TextBundle;
|
|
60
|
+
|
|
61
|
+
constructor(
|
|
62
|
+
name: string,
|
|
63
|
+
overlays: UI5Element,
|
|
64
|
+
rta: RuntimeAuthoring,
|
|
65
|
+
data?: ExtendControllerData,
|
|
66
|
+
telemetryData?: QuickActionTelemetryData
|
|
67
|
+
) {
|
|
57
68
|
super(name, telemetryData);
|
|
58
69
|
this.rta = rta;
|
|
59
70
|
this.overlays = overlays;
|
|
60
71
|
this.model = new JSONModel();
|
|
72
|
+
this.data = data;
|
|
61
73
|
}
|
|
62
74
|
|
|
63
75
|
/**
|
|
@@ -70,8 +82,12 @@ export default class ControllerExtension extends BaseDialog<ControllerModel> {
|
|
|
70
82
|
|
|
71
83
|
this.setEscapeHandler();
|
|
72
84
|
|
|
85
|
+
const resourceModel = await getResourceModel('open.ux.preview.client');
|
|
86
|
+
this.bundle = await getTextBundle();
|
|
87
|
+
|
|
73
88
|
await this.buildDialogData();
|
|
74
89
|
|
|
90
|
+
this.dialog.setModel(resourceModel, 'i18n');
|
|
75
91
|
this.dialog.setModel(this.model);
|
|
76
92
|
|
|
77
93
|
this.dialog.open();
|
|
@@ -102,6 +118,13 @@ export default class ControllerExtension extends BaseDialog<ControllerModel> {
|
|
|
102
118
|
|
|
103
119
|
const fileExists = controllerList.some((f) => f.controllerName === controllerName);
|
|
104
120
|
|
|
121
|
+
const pendingChangeExists = checkForExistingChange(
|
|
122
|
+
this.rta,
|
|
123
|
+
'codeExt',
|
|
124
|
+
'content.codeRef',
|
|
125
|
+
`${controllerName}.js`
|
|
126
|
+
);
|
|
127
|
+
|
|
105
128
|
if (fileExists) {
|
|
106
129
|
updateDialogState(
|
|
107
130
|
ValueState.Error,
|
|
@@ -110,6 +133,14 @@ export default class ControllerExtension extends BaseDialog<ControllerModel> {
|
|
|
110
133
|
return;
|
|
111
134
|
}
|
|
112
135
|
|
|
136
|
+
if (pendingChangeExists) {
|
|
137
|
+
updateDialogState(
|
|
138
|
+
ValueState.Error,
|
|
139
|
+
'Enter a different name. The controller name that you entered already exists as a pending change.'
|
|
140
|
+
);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
113
144
|
const isValidName = /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(controllerName);
|
|
114
145
|
|
|
115
146
|
if (!isValidName) {
|
|
@@ -147,7 +178,16 @@ export default class ControllerExtension extends BaseDialog<ControllerModel> {
|
|
|
147
178
|
const controllerName = this.model.getProperty('/newControllerName');
|
|
148
179
|
const viewId = this.model.getProperty('/viewId');
|
|
149
180
|
|
|
150
|
-
|
|
181
|
+
const controllerRef = {
|
|
182
|
+
codeRef: `coding/${controllerName}.js`,
|
|
183
|
+
viewId
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
if (this.data) {
|
|
187
|
+
this.data.deferred.resolve(controllerRef);
|
|
188
|
+
} else {
|
|
189
|
+
await this.createNewController(controllerName, controllerRef);
|
|
190
|
+
}
|
|
151
191
|
} else {
|
|
152
192
|
const controllerPath = this.model.getProperty('/controllerPath');
|
|
153
193
|
window.open(`vscode://file${controllerPath}`);
|
|
@@ -166,8 +206,17 @@ export default class ControllerExtension extends BaseDialog<ControllerModel> {
|
|
|
166
206
|
const { controllerName, viewId } = getControllerInfo(overlayControl);
|
|
167
207
|
const data = await this.getExistingController(controllerName);
|
|
168
208
|
|
|
209
|
+
const hasPendingChangeForView = checkForExistingChange(
|
|
210
|
+
this.rta,
|
|
211
|
+
'codeExt',
|
|
212
|
+
'selector.controllerName',
|
|
213
|
+
controllerName
|
|
214
|
+
);
|
|
215
|
+
|
|
169
216
|
if (data) {
|
|
170
|
-
if (
|
|
217
|
+
if (hasPendingChangeForView) {
|
|
218
|
+
this.updateModelForExistingPendingChange();
|
|
219
|
+
} else if (data?.controllerExists) {
|
|
171
220
|
this.updateModelForExistingController(data);
|
|
172
221
|
} else {
|
|
173
222
|
this.updateModelForNewController(viewId, data.isTsSupported);
|
|
@@ -187,14 +236,9 @@ export default class ControllerExtension extends BaseDialog<ControllerModel> {
|
|
|
187
236
|
this.model.setProperty('/controllerExists', controllerExists);
|
|
188
237
|
this.model.setProperty('/controllerPath', controllerPath);
|
|
189
238
|
this.model.setProperty('/controllerPathFromRoot', controllerPathFromRoot);
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const form = content[0] as SimpleForm;
|
|
194
|
-
form.setVisible(false);
|
|
195
|
-
|
|
196
|
-
const messageForm = content[1] as SimpleForm;
|
|
197
|
-
messageForm.setVisible(true);
|
|
239
|
+
this.model.setProperty('/inputFormVisibility', false);
|
|
240
|
+
this.model.setProperty('/pendingChangeFormVisibility', false);
|
|
241
|
+
this.model.setProperty('/existingControllerFormVisibility', true);
|
|
198
242
|
|
|
199
243
|
if (isRunningInBAS) {
|
|
200
244
|
this.dialog.getBeginButton().setVisible(false);
|
|
@@ -204,6 +248,18 @@ export default class ControllerExtension extends BaseDialog<ControllerModel> {
|
|
|
204
248
|
this.dialog.getEndButton().setText('Close');
|
|
205
249
|
}
|
|
206
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Updates the model properties for an existing controller in a pending change.
|
|
253
|
+
*/
|
|
254
|
+
private updateModelForExistingPendingChange(): void {
|
|
255
|
+
this.model.setProperty('/inputFormVisibility', false);
|
|
256
|
+
this.model.setProperty('/existingControllerFormVisibility', false);
|
|
257
|
+
this.model.setProperty('/pendingChangeFormVisibility', true);
|
|
258
|
+
|
|
259
|
+
this.dialog.getBeginButton().setVisible(false);
|
|
260
|
+
this.dialog.getEndButton().setText('Close');
|
|
261
|
+
}
|
|
262
|
+
|
|
207
263
|
/**
|
|
208
264
|
* Updates the model property for a new controller.
|
|
209
265
|
*
|
|
@@ -213,6 +269,9 @@ export default class ControllerExtension extends BaseDialog<ControllerModel> {
|
|
|
213
269
|
private updateModelForNewController(viewId: string, isTsSupported: boolean): void {
|
|
214
270
|
this.model.setProperty('/viewId', viewId);
|
|
215
271
|
this.model.setProperty('/controllerExtension', isTsSupported ? '.ts' : '.js');
|
|
272
|
+
this.model.setProperty('/existingControllerFormVisibility', false);
|
|
273
|
+
this.model.setProperty('/pendingChangeFormVisibility', false);
|
|
274
|
+
this.model.setProperty('/inputFormVisibility', true);
|
|
216
275
|
}
|
|
217
276
|
|
|
218
277
|
/**
|
|
@@ -248,17 +307,20 @@ export default class ControllerExtension extends BaseDialog<ControllerModel> {
|
|
|
248
307
|
* Creates a new fragment for the specified control
|
|
249
308
|
*
|
|
250
309
|
* @param controllerName Controller Name
|
|
251
|
-
* @param
|
|
310
|
+
* @param controllerRef Controller reference
|
|
252
311
|
*/
|
|
253
|
-
private async createNewController(
|
|
312
|
+
private async createNewController(
|
|
313
|
+
controllerName: string,
|
|
314
|
+
controllerRef: DeferredExtendControllerData
|
|
315
|
+
): Promise<void> {
|
|
316
|
+
const ui5Version = await getUi5Version();
|
|
317
|
+
if (!isLowerThanMinimalUi5Version(ui5Version, { major: 1, minor: 135 })) {
|
|
318
|
+
await this.createControllerCommand(controllerName, controllerRef);
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
254
321
|
try {
|
|
255
322
|
await writeController({ controllerName });
|
|
256
323
|
|
|
257
|
-
const controllerRef = {
|
|
258
|
-
codeRef: `coding/${controllerName}.js`,
|
|
259
|
-
viewId
|
|
260
|
-
};
|
|
261
|
-
|
|
262
324
|
const service = await this.rta.getService<ControllerExtensionService>('controllerExtension');
|
|
263
325
|
|
|
264
326
|
const change = await service.add(controllerRef.codeRef, controllerRef.viewId);
|
|
@@ -273,4 +335,30 @@ export default class ControllerExtension extends BaseDialog<ControllerModel> {
|
|
|
273
335
|
this.handleError(e);
|
|
274
336
|
}
|
|
275
337
|
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Creates a controller command and executes it.
|
|
341
|
+
*
|
|
342
|
+
* @param controllerName Controller name
|
|
343
|
+
* @param controllerRef Controller reference
|
|
344
|
+
*/
|
|
345
|
+
private async createControllerCommand(
|
|
346
|
+
controllerName: string,
|
|
347
|
+
controllerRef: DeferredExtendControllerData
|
|
348
|
+
): Promise<void> {
|
|
349
|
+
const flexSettings = this.rta.getFlexSettings();
|
|
350
|
+
const commandExecutor = new CommandExecutor(this.rta);
|
|
351
|
+
const view = getControlById(controllerRef.viewId) as UI5Element;
|
|
352
|
+
const command = await commandExecutor.getCommand<DeferredExtendControllerData>(
|
|
353
|
+
view,
|
|
354
|
+
'codeExt',
|
|
355
|
+
controllerRef,
|
|
356
|
+
flexSettings
|
|
357
|
+
);
|
|
358
|
+
|
|
359
|
+
await commandExecutor.pushAndExecuteCommand(command);
|
|
360
|
+
|
|
361
|
+
const bundle = await getTextBundle();
|
|
362
|
+
notifyUser(bundle.getText('ADP_CREATE_CONTROLLER_EXTENSION', [controllerName]), 8000);
|
|
363
|
+
}
|
|
276
364
|
}
|
|
@@ -1,141 +1,141 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
sap.ui.define(["sap/ui/model/json/JSONModel", "../api-handler", "./BaseDialog.controller", "../utils"], function (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
|
-
const getFragments = ___api_handler["getFragments"];
|
|
10
|
-
const BaseDialog = _interopRequireDefault(__BaseDialog);
|
|
11
|
-
const notifyUser = ___utils["notifyUser"];
|
|
12
|
-
/**
|
|
13
|
-
* @namespace open.ux.preview.client.adp.controllers
|
|
14
|
-
*/
|
|
15
|
-
const ExtensionPoint = BaseDialog.extend("open.ux.preview.client.adp.controllers.ExtensionPoint", {
|
|
16
|
-
constructor: function _constructor(name, _overlays, rta, data) {
|
|
17
|
-
BaseDialog.prototype.constructor.call(this, name);
|
|
18
|
-
this.model = new JSONModel();
|
|
19
|
-
this.data = data;
|
|
20
|
-
this.rta = rta;
|
|
21
|
-
},
|
|
22
|
-
/**
|
|
23
|
-
* Setups the Dialog and the JSON Model
|
|
24
|
-
*
|
|
25
|
-
* @param {Dialog} dialog - Dialog instance
|
|
26
|
-
*/
|
|
27
|
-
setup: async function _setup(dialog) {
|
|
28
|
-
this.dialog = dialog;
|
|
29
|
-
this.setEscapeHandler();
|
|
30
|
-
await this.buildDialogData();
|
|
31
|
-
this.dialog.setModel(this.model);
|
|
32
|
-
this.dialog.open();
|
|
33
|
-
},
|
|
34
|
-
/**
|
|
35
|
-
* Handles create button press
|
|
36
|
-
*
|
|
37
|
-
* @param event Event
|
|
38
|
-
*/
|
|
39
|
-
onCreateBtnPress: async function _onCreateBtnPress(event) {
|
|
40
|
-
const source = event.getSource();
|
|
41
|
-
source.setEnabled(false);
|
|
42
|
-
await BaseDialog.prototype.onCreateBtnPressHandler.call(this);
|
|
43
|
-
const fragmentName = this.model.getProperty('/newFragmentName');
|
|
44
|
-
this.createExtensionPointFragmentChange(fragmentName);
|
|
45
|
-
notifyUser(`Note: The '${fragmentName}.fragment.xml' fragment will be created once you save the change.`, 8000);
|
|
46
|
-
this.handleDialogClose();
|
|
47
|
-
},
|
|
48
|
-
/**
|
|
49
|
-
* Handler for extension point select control
|
|
50
|
-
*
|
|
51
|
-
* @param event Select control change event
|
|
52
|
-
*/
|
|
53
|
-
onExtensionPointHandler: function _onExtensionPointHandler(event) {
|
|
54
|
-
const source = event.getSource();
|
|
55
|
-
const selectedItem = source.getSelectedItem();
|
|
56
|
-
let extensionPointName = '';
|
|
57
|
-
if (selectedItem) {
|
|
58
|
-
extensionPointName = selectedItem.getText();
|
|
59
|
-
}
|
|
60
|
-
this.model.setProperty('/extensionPointName', extensionPointName);
|
|
61
|
-
const hasDefaultContent = this.hasDefaultContentForName(extensionPointName);
|
|
62
|
-
this.model.setProperty('/hasDefaultContent', hasDefaultContent);
|
|
63
|
-
},
|
|
64
|
-
/**
|
|
65
|
-
* Determines whether there is default content associated with the given name.
|
|
66
|
-
*
|
|
67
|
-
* @param {string} name - The name to check for associated default content.
|
|
68
|
-
* @returns {boolean} - True if there is non-empty default content associated with the name, false otherwise.
|
|
69
|
-
*/
|
|
70
|
-
hasDefaultContentForName: function _hasDefaultContentForName(name) {
|
|
71
|
-
const defaultContent = this.data?.info.find(v => v.name === name)?.defaultContent;
|
|
72
|
-
return defaultContent ? defaultContent.length > 0 : false;
|
|
73
|
-
},
|
|
74
|
-
/**
|
|
75
|
-
* Builds data that is used in the dialog
|
|
76
|
-
*/
|
|
77
|
-
buildDialogData: async function _buildDialogData() {
|
|
78
|
-
const name = this.data?.name;
|
|
79
|
-
if (name) {
|
|
80
|
-
const hasDefaultContent = this.hasDefaultContentForName(name);
|
|
81
|
-
const extensionPointList = [{
|
|
82
|
-
key: 0,
|
|
83
|
-
value: name
|
|
84
|
-
}];
|
|
85
|
-
this.updateModel(name, 0, extensionPointList, false, hasDefaultContent);
|
|
86
|
-
} else {
|
|
87
|
-
// In this case we are selecting from the application. There can be many extension points under one control.
|
|
88
|
-
const extensionPointList = this.data.info.map((v, idx) => {
|
|
89
|
-
return {
|
|
90
|
-
key: idx,
|
|
91
|
-
value: v.name
|
|
92
|
-
};
|
|
93
|
-
});
|
|
94
|
-
const firstElName = extensionPointList[0].value;
|
|
95
|
-
const enabled = extensionPointList.length > 1;
|
|
96
|
-
const hasDefaultContent = this.hasDefaultContentForName(firstElName);
|
|
97
|
-
this.updateModel(firstElName, 0, extensionPointList, enabled, hasDefaultContent);
|
|
98
|
-
}
|
|
99
|
-
try {
|
|
100
|
-
const {
|
|
101
|
-
fragments
|
|
102
|
-
} = await getFragments();
|
|
103
|
-
this.model.setProperty('/fragmentList', fragments);
|
|
104
|
-
} catch (e) {
|
|
105
|
-
this.handleError(e);
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
/**
|
|
109
|
-
* Updates the Select control according to provided values
|
|
110
|
-
*
|
|
111
|
-
* @param name Extension point name
|
|
112
|
-
* @param key Selected extension point key
|
|
113
|
-
* @param list All of the extension points that are under a view
|
|
114
|
-
* @param enabled Enables the select control
|
|
115
|
-
* @param hasDefaultContent Whether there is default content associated with the extension name
|
|
116
|
-
*/
|
|
117
|
-
updateModel: function _updateModel(name, key, list, enabled, hasDefaultContent) {
|
|
118
|
-
this.model.setProperty('/extensionPointName', name);
|
|
119
|
-
this.model.setProperty('/extensionPointKey', key);
|
|
120
|
-
this.model.setProperty('/extensionPointList', list);
|
|
121
|
-
this.model.setProperty('/extensionListEnabled', enabled);
|
|
122
|
-
this.model.setProperty('/hasDefaultContent', hasDefaultContent);
|
|
123
|
-
},
|
|
124
|
-
/**
|
|
125
|
-
* Creates add xml at extension point changes
|
|
126
|
-
*
|
|
127
|
-
* @param fragmentName Fragment name
|
|
128
|
-
*/
|
|
129
|
-
createExtensionPointFragmentChange: function _createExtensionPointFragmentChange(fragmentName) {
|
|
130
|
-
const extensionPointName = this.model.getProperty('/extensionPointName');
|
|
131
|
-
const modifiedValue = {
|
|
132
|
-
fragment: `<core:FragmentDefinition xmlns:core='sap.ui.core'></core:FragmentDefinition>`,
|
|
133
|
-
fragmentPath: `fragments/${fragmentName}.fragment.xml`,
|
|
134
|
-
extensionPointName
|
|
135
|
-
};
|
|
136
|
-
this.data.deferred.resolve(modifiedValue);
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
return ExtensionPoint;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
sap.ui.define(["sap/ui/model/json/JSONModel", "../api-handler", "./BaseDialog.controller", "../utils"], function (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
|
+
const getFragments = ___api_handler["getFragments"];
|
|
10
|
+
const BaseDialog = _interopRequireDefault(__BaseDialog);
|
|
11
|
+
const notifyUser = ___utils["notifyUser"];
|
|
12
|
+
/**
|
|
13
|
+
* @namespace open.ux.preview.client.adp.controllers
|
|
14
|
+
*/
|
|
15
|
+
const ExtensionPoint = BaseDialog.extend("open.ux.preview.client.adp.controllers.ExtensionPoint", {
|
|
16
|
+
constructor: function _constructor(name, _overlays, rta, data) {
|
|
17
|
+
BaseDialog.prototype.constructor.call(this, name);
|
|
18
|
+
this.model = new JSONModel();
|
|
19
|
+
this.data = data;
|
|
20
|
+
this.rta = rta;
|
|
21
|
+
},
|
|
22
|
+
/**
|
|
23
|
+
* Setups the Dialog and the JSON Model
|
|
24
|
+
*
|
|
25
|
+
* @param {Dialog} dialog - Dialog instance
|
|
26
|
+
*/
|
|
27
|
+
setup: async function _setup(dialog) {
|
|
28
|
+
this.dialog = dialog;
|
|
29
|
+
this.setEscapeHandler();
|
|
30
|
+
await this.buildDialogData();
|
|
31
|
+
this.dialog.setModel(this.model);
|
|
32
|
+
this.dialog.open();
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* Handles create button press
|
|
36
|
+
*
|
|
37
|
+
* @param event Event
|
|
38
|
+
*/
|
|
39
|
+
onCreateBtnPress: async function _onCreateBtnPress(event) {
|
|
40
|
+
const source = event.getSource();
|
|
41
|
+
source.setEnabled(false);
|
|
42
|
+
await BaseDialog.prototype.onCreateBtnPressHandler.call(this);
|
|
43
|
+
const fragmentName = this.model.getProperty('/newFragmentName');
|
|
44
|
+
this.createExtensionPointFragmentChange(fragmentName);
|
|
45
|
+
notifyUser(`Note: The '${fragmentName}.fragment.xml' fragment will be created once you save the change.`, 8000);
|
|
46
|
+
this.handleDialogClose();
|
|
47
|
+
},
|
|
48
|
+
/**
|
|
49
|
+
* Handler for extension point select control
|
|
50
|
+
*
|
|
51
|
+
* @param event Select control change event
|
|
52
|
+
*/
|
|
53
|
+
onExtensionPointHandler: function _onExtensionPointHandler(event) {
|
|
54
|
+
const source = event.getSource();
|
|
55
|
+
const selectedItem = source.getSelectedItem();
|
|
56
|
+
let extensionPointName = '';
|
|
57
|
+
if (selectedItem) {
|
|
58
|
+
extensionPointName = selectedItem.getText();
|
|
59
|
+
}
|
|
60
|
+
this.model.setProperty('/extensionPointName', extensionPointName);
|
|
61
|
+
const hasDefaultContent = this.hasDefaultContentForName(extensionPointName);
|
|
62
|
+
this.model.setProperty('/hasDefaultContent', hasDefaultContent);
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* Determines whether there is default content associated with the given name.
|
|
66
|
+
*
|
|
67
|
+
* @param {string} name - The name to check for associated default content.
|
|
68
|
+
* @returns {boolean} - True if there is non-empty default content associated with the name, false otherwise.
|
|
69
|
+
*/
|
|
70
|
+
hasDefaultContentForName: function _hasDefaultContentForName(name) {
|
|
71
|
+
const defaultContent = this.data?.info.find(v => v.name === name)?.defaultContent;
|
|
72
|
+
return defaultContent ? defaultContent.length > 0 : false;
|
|
73
|
+
},
|
|
74
|
+
/**
|
|
75
|
+
* Builds data that is used in the dialog
|
|
76
|
+
*/
|
|
77
|
+
buildDialogData: async function _buildDialogData() {
|
|
78
|
+
const name = this.data?.name;
|
|
79
|
+
if (name) {
|
|
80
|
+
const hasDefaultContent = this.hasDefaultContentForName(name);
|
|
81
|
+
const extensionPointList = [{
|
|
82
|
+
key: 0,
|
|
83
|
+
value: name
|
|
84
|
+
}];
|
|
85
|
+
this.updateModel(name, 0, extensionPointList, false, hasDefaultContent);
|
|
86
|
+
} else {
|
|
87
|
+
// In this case we are selecting from the application. There can be many extension points under one control.
|
|
88
|
+
const extensionPointList = this.data.info.map((v, idx) => {
|
|
89
|
+
return {
|
|
90
|
+
key: idx,
|
|
91
|
+
value: v.name
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
const firstElName = extensionPointList[0].value;
|
|
95
|
+
const enabled = extensionPointList.length > 1;
|
|
96
|
+
const hasDefaultContent = this.hasDefaultContentForName(firstElName);
|
|
97
|
+
this.updateModel(firstElName, 0, extensionPointList, enabled, hasDefaultContent);
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
const {
|
|
101
|
+
fragments
|
|
102
|
+
} = await getFragments();
|
|
103
|
+
this.model.setProperty('/fragmentList', fragments);
|
|
104
|
+
} catch (e) {
|
|
105
|
+
this.handleError(e);
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
/**
|
|
109
|
+
* Updates the Select control according to provided values
|
|
110
|
+
*
|
|
111
|
+
* @param name Extension point name
|
|
112
|
+
* @param key Selected extension point key
|
|
113
|
+
* @param list All of the extension points that are under a view
|
|
114
|
+
* @param enabled Enables the select control
|
|
115
|
+
* @param hasDefaultContent Whether there is default content associated with the extension name
|
|
116
|
+
*/
|
|
117
|
+
updateModel: function _updateModel(name, key, list, enabled, hasDefaultContent) {
|
|
118
|
+
this.model.setProperty('/extensionPointName', name);
|
|
119
|
+
this.model.setProperty('/extensionPointKey', key);
|
|
120
|
+
this.model.setProperty('/extensionPointList', list);
|
|
121
|
+
this.model.setProperty('/extensionListEnabled', enabled);
|
|
122
|
+
this.model.setProperty('/hasDefaultContent', hasDefaultContent);
|
|
123
|
+
},
|
|
124
|
+
/**
|
|
125
|
+
* Creates add xml at extension point changes
|
|
126
|
+
*
|
|
127
|
+
* @param fragmentName Fragment name
|
|
128
|
+
*/
|
|
129
|
+
createExtensionPointFragmentChange: function _createExtensionPointFragmentChange(fragmentName) {
|
|
130
|
+
const extensionPointName = this.model.getProperty('/extensionPointName');
|
|
131
|
+
const modifiedValue = {
|
|
132
|
+
fragment: `<core:FragmentDefinition xmlns:core='sap.ui.core'></core:FragmentDefinition>`,
|
|
133
|
+
fragmentPath: `fragments/${fragmentName}.fragment.xml`,
|
|
134
|
+
extensionPointName
|
|
135
|
+
};
|
|
136
|
+
this.data.deferred.resolve(modifiedValue);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
return ExtensionPoint;
|
|
140
140
|
});
|
|
141
141
|
//# sourceMappingURL=ExtensionPoint.controller.js.map
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
sap.ui.define(["sap/ui/model/json/JSONModel", "./BaseDialog.controller", "../../i18n"], function (JSONModel, __BaseDialog, ____i18n) {
|
|
4
|
-
"use strict";
|
|
5
|
-
|
|
6
|
-
function _interopRequireDefault(obj) {
|
|
7
|
-
return obj && obj.__esModule && typeof obj.default !== "undefined" ? obj.default : obj;
|
|
8
|
-
}
|
|
9
|
-
const BaseDialog = _interopRequireDefault(__BaseDialog);
|
|
10
|
-
const getResourceModel = ____i18n["getResourceModel"];
|
|
11
|
-
/**
|
|
12
|
-
* @namespace open.ux.preview.client.adp.controllers
|
|
13
|
-
*/
|
|
14
|
-
const FileExistsDialog = BaseDialog.extend("open.ux.preview.client.adp.controllers.FileExistsDialog", {
|
|
15
|
-
constructor: function _constructor(name, options) {
|
|
16
|
-
BaseDialog.prototype.constructor.call(this, name);
|
|
17
|
-
this.model = new JSONModel();
|
|
18
|
-
this.options = options;
|
|
19
|
-
},
|
|
20
|
-
/**
|
|
21
|
-
* Setups the Dialog and the JSON Model
|
|
22
|
-
*
|
|
23
|
-
* @param {Dialog} dialog - Dialog instance
|
|
24
|
-
*/
|
|
25
|
-
setup: async function _setup(dialog) {
|
|
26
|
-
this.dialog = dialog;
|
|
27
|
-
this.setEscapeHandler();
|
|
28
|
-
this.model.setProperty('/filePath', this.options.filePath);
|
|
29
|
-
this.model.setProperty('/filePathFromRoot', this.options.fileName);
|
|
30
|
-
this.model.setProperty('/isRunningInBAS', this.options.isRunningInBAS);
|
|
31
|
-
this.buildDialogData();
|
|
32
|
-
const resourceModel = await getResourceModel();
|
|
33
|
-
this.dialog.setModel(this.model);
|
|
34
|
-
this.dialog.setModel(resourceModel, 'i18n');
|
|
35
|
-
this.dialog.open();
|
|
36
|
-
},
|
|
37
|
-
/**
|
|
38
|
-
* Handles create button press
|
|
39
|
-
*
|
|
40
|
-
* @param _event Event
|
|
41
|
-
*/
|
|
42
|
-
onShowFileInVscodeBtn: function _onShowFileInVscodeBtn(_event) {
|
|
43
|
-
const annotationPath = this.model.getProperty('/filePath');
|
|
44
|
-
window.open(`vscode://file${annotationPath}`);
|
|
45
|
-
this.handleDialogClose();
|
|
46
|
-
},
|
|
47
|
-
/**
|
|
48
|
-
* Builds data that is used in the dialog.
|
|
49
|
-
*/
|
|
50
|
-
buildDialogData: function _buildDialogData() {
|
|
51
|
-
const content = this.dialog.getContent();
|
|
52
|
-
const messageForm = content[0];
|
|
53
|
-
messageForm.setVisible(true);
|
|
54
|
-
const isRunningInBAS = this.model.getProperty('/isRunningInBAS');
|
|
55
|
-
if (isRunningInBAS) {
|
|
56
|
-
this.dialog.getBeginButton().setVisible(false);
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
/**
|
|
60
|
-
* Handles create button press
|
|
61
|
-
*
|
|
62
|
-
* @param _event Event
|
|
63
|
-
*/
|
|
64
|
-
onCreateBtnPress: function _onCreateBtnPress(_event) {}
|
|
65
|
-
});
|
|
66
|
-
return FileExistsDialog;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
sap.ui.define(["sap/ui/model/json/JSONModel", "./BaseDialog.controller", "../../i18n"], function (JSONModel, __BaseDialog, ____i18n) {
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
function _interopRequireDefault(obj) {
|
|
7
|
+
return obj && obj.__esModule && typeof obj.default !== "undefined" ? obj.default : obj;
|
|
8
|
+
}
|
|
9
|
+
const BaseDialog = _interopRequireDefault(__BaseDialog);
|
|
10
|
+
const getResourceModel = ____i18n["getResourceModel"];
|
|
11
|
+
/**
|
|
12
|
+
* @namespace open.ux.preview.client.adp.controllers
|
|
13
|
+
*/
|
|
14
|
+
const FileExistsDialog = BaseDialog.extend("open.ux.preview.client.adp.controllers.FileExistsDialog", {
|
|
15
|
+
constructor: function _constructor(name, options) {
|
|
16
|
+
BaseDialog.prototype.constructor.call(this, name);
|
|
17
|
+
this.model = new JSONModel();
|
|
18
|
+
this.options = options;
|
|
19
|
+
},
|
|
20
|
+
/**
|
|
21
|
+
* Setups the Dialog and the JSON Model
|
|
22
|
+
*
|
|
23
|
+
* @param {Dialog} dialog - Dialog instance
|
|
24
|
+
*/
|
|
25
|
+
setup: async function _setup(dialog) {
|
|
26
|
+
this.dialog = dialog;
|
|
27
|
+
this.setEscapeHandler();
|
|
28
|
+
this.model.setProperty('/filePath', this.options.filePath);
|
|
29
|
+
this.model.setProperty('/filePathFromRoot', this.options.fileName);
|
|
30
|
+
this.model.setProperty('/isRunningInBAS', this.options.isRunningInBAS);
|
|
31
|
+
this.buildDialogData();
|
|
32
|
+
const resourceModel = await getResourceModel();
|
|
33
|
+
this.dialog.setModel(this.model);
|
|
34
|
+
this.dialog.setModel(resourceModel, 'i18n');
|
|
35
|
+
this.dialog.open();
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* Handles create button press
|
|
39
|
+
*
|
|
40
|
+
* @param _event Event
|
|
41
|
+
*/
|
|
42
|
+
onShowFileInVscodeBtn: function _onShowFileInVscodeBtn(_event) {
|
|
43
|
+
const annotationPath = this.model.getProperty('/filePath');
|
|
44
|
+
window.open(`vscode://file${annotationPath}`);
|
|
45
|
+
this.handleDialogClose();
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* Builds data that is used in the dialog.
|
|
49
|
+
*/
|
|
50
|
+
buildDialogData: function _buildDialogData() {
|
|
51
|
+
const content = this.dialog.getContent();
|
|
52
|
+
const messageForm = content[0];
|
|
53
|
+
messageForm.setVisible(true);
|
|
54
|
+
const isRunningInBAS = this.model.getProperty('/isRunningInBAS');
|
|
55
|
+
if (isRunningInBAS) {
|
|
56
|
+
this.dialog.getBeginButton().setVisible(false);
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
/**
|
|
60
|
+
* Handles create button press
|
|
61
|
+
*
|
|
62
|
+
* @param _event Event
|
|
63
|
+
*/
|
|
64
|
+
onCreateBtnPress: function _onCreateBtnPress(_event) {}
|
|
65
|
+
});
|
|
66
|
+
return FileExistsDialog;
|
|
67
67
|
});
|
|
68
68
|
//# sourceMappingURL=FileExistsDialog.controller.js.map
|