@sap-ux/preview-middleware 0.13.72 → 0.13.73
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 +3 -2
- package/dist/client/adp/api-handler.ts +6 -4
- package/dist/client/adp/command-executor.js +10 -6
- package/dist/client/adp/command-executor.ts +9 -5
- package/dist/client/adp/controllers/AddFragment.controller.js +6 -6
- package/dist/client/adp/controllers/AddFragment.controller.ts +13 -7
- package/dist/client/adp/controllers/BaseDialog.controller.js +15 -1
- package/dist/client/adp/controllers/BaseDialog.controller.ts +22 -4
- package/dist/client/adp/controllers/ControllerExtension.controller.js +20 -23
- package/dist/client/adp/controllers/ControllerExtension.controller.ts +35 -26
- package/dist/client/adp/controllers/ExtensionPoint.controller.js +2 -3
- package/dist/client/adp/controllers/ExtensionPoint.controller.ts +7 -4
- package/dist/client/adp/init-dialogs.js +32 -32
- package/dist/client/adp/init-dialogs.ts +27 -27
- package/dist/client/adp/init.js +6 -4
- package/dist/client/adp/init.ts +4 -3
- package/dist/client/adp/ui5-version-utils.js +18 -18
- package/dist/client/adp/ui5-version-utils.ts +16 -15
- package/dist/client/cpe/changes/service.js +9 -6
- package/dist/client/cpe/changes/service.ts +13 -8
- package/dist/client/cpe/changes/validator.js +2 -2
- package/dist/client/cpe/changes/validator.ts +3 -2
- package/dist/client/cpe/control-data.ts +4 -1
- package/dist/client/cpe/documentation.ts +1 -1
- package/dist/client/cpe/error-utils.js +21 -0
- package/dist/client/cpe/error-utils.ts +9 -0
- package/dist/client/cpe/init.js +7 -5
- package/dist/client/cpe/init.ts +4 -3
- package/dist/client/cpe/outline/index.js +5 -3
- package/dist/client/cpe/outline/index.ts +2 -1
- package/dist/client/cpe/selection.js +7 -5
- package/dist/client/cpe/selection.ts +4 -3
- package/dist/client/flp/init.js +2 -3
- package/dist/client/flp/init.ts +29 -19
- package/package.json +4 -4
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
sap.ui.define([], function () {
|
|
3
|
+
sap.ui.define(["../cpe/error-utils"], function (___cpe_error_utils) {
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
|
+
const getError = ___cpe_error_utils["getError"];
|
|
6
7
|
var ApiEndpoints = /*#__PURE__*/function (ApiEndpoints) {
|
|
7
8
|
ApiEndpoints["CHANGES"] = "/preview/api/changes";
|
|
8
9
|
ApiEndpoints["FRAGMENT"] = "/adp/api/fragment";
|
|
@@ -55,7 +56,7 @@ sap.ui.define([], function () {
|
|
|
55
56
|
return response.json();
|
|
56
57
|
}
|
|
57
58
|
} catch (e) {
|
|
58
|
-
throw
|
|
59
|
+
throw getError(e);
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Layer } from 'sap/ui/fl';
|
|
2
|
+
import { getError } from '../cpe/error-utils';
|
|
2
3
|
|
|
3
4
|
export const enum ApiEndpoints {
|
|
4
5
|
CHANGES = '/preview/api/changes',
|
|
@@ -16,8 +17,9 @@ export const enum RequestMethod {
|
|
|
16
17
|
DELETE = 'DELETE'
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
type Fragments = { fragmentName: string }[];
|
|
20
|
-
type Controllers = { controllerName: string }[];
|
|
20
|
+
export type Fragments = { fragmentName: string }[];
|
|
21
|
+
export type Controllers = { controllerName: string }[];
|
|
22
|
+
type ResponseMessage = { message?: string };
|
|
21
23
|
|
|
22
24
|
export interface FragmentsResponse {
|
|
23
25
|
fragments: Fragments;
|
|
@@ -68,7 +70,7 @@ export async function request<T>(endpoint: ApiEndpoints, method: RequestMethod,
|
|
|
68
70
|
const response: Response = await fetch(endpoint, config);
|
|
69
71
|
|
|
70
72
|
if (!response.ok) {
|
|
71
|
-
const errorData = await response.json();
|
|
73
|
+
const errorData = (await response.json()) as ResponseMessage;
|
|
72
74
|
const message = errorData?.message ?? '';
|
|
73
75
|
throw new Error(`Request failed, status: ${response.status}. ${message}`.trim());
|
|
74
76
|
}
|
|
@@ -86,7 +88,7 @@ export async function request<T>(endpoint: ApiEndpoints, method: RequestMethod,
|
|
|
86
88
|
return response.json() as T;
|
|
87
89
|
}
|
|
88
90
|
} catch (e) {
|
|
89
|
-
throw
|
|
91
|
+
throw getError(e);
|
|
90
92
|
}
|
|
91
93
|
}
|
|
92
94
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
sap.ui.define(["sap/m/MessageToast", "sap/ui/rta/command/CommandFactory"], function (MessageToast, CommandFactory) {
|
|
3
|
+
sap.ui.define(["sap/m/MessageToast", "sap/ui/rta/command/CommandFactory", "../cpe/error-utils"], function (MessageToast, CommandFactory, ___cpe_error_utils) {
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
|
+
const getError = ___cpe_error_utils["getError"];
|
|
6
7
|
/**
|
|
7
8
|
* Class responsible for handling rta calls
|
|
8
9
|
*/
|
|
@@ -28,9 +29,11 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/rta/command/CommandFactory"], funct
|
|
|
28
29
|
try {
|
|
29
30
|
return await CommandFactory.getCommandFor(runtimeControl, commandName, modifiedValue, designMetadata, flexSettings);
|
|
30
31
|
} catch (e) {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const error = getError(e);
|
|
33
|
+
const msgToastErrorMsg = `Could not get command for '${commandName}'. ${error.message}`;
|
|
34
|
+
error.message = msgToastErrorMsg;
|
|
35
|
+
MessageToast.show(msgToastErrorMsg);
|
|
36
|
+
throw error;
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
39
|
|
|
@@ -46,8 +49,9 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/rta/command/CommandFactory"], funct
|
|
|
46
49
|
*/
|
|
47
50
|
await this.rta.getCommandStack().pushAndExecute(command);
|
|
48
51
|
} catch (e) {
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
const error = getError(e);
|
|
53
|
+
MessageToast.show(error.message);
|
|
54
|
+
throw error;
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
}
|
|
@@ -5,6 +5,7 @@ import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
|
|
|
5
5
|
import type { FlexSettings } from 'sap/ui/rta/RuntimeAuthoring';
|
|
6
6
|
import type DesignTimeMetadata from 'sap/ui/dt/DesignTimeMetadata';
|
|
7
7
|
import type FlexCommand from 'sap/ui/rta/command/FlexCommand';
|
|
8
|
+
import { getError } from '../cpe/error-utils';
|
|
8
9
|
|
|
9
10
|
type CommandNames = 'addXML';
|
|
10
11
|
|
|
@@ -43,9 +44,11 @@ export default class CommandExecutor {
|
|
|
43
44
|
flexSettings
|
|
44
45
|
);
|
|
45
46
|
} catch (e) {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
const error = getError(e);
|
|
48
|
+
const msgToastErrorMsg = `Could not get command for '${commandName}'. ${error.message}`;
|
|
49
|
+
error.message = msgToastErrorMsg;
|
|
50
|
+
MessageToast.show(msgToastErrorMsg);
|
|
51
|
+
throw error;
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
54
|
|
|
@@ -61,8 +64,9 @@ export default class CommandExecutor {
|
|
|
61
64
|
*/
|
|
62
65
|
await this.rta.getCommandStack().pushAndExecute(command);
|
|
63
66
|
} catch (e) {
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
const error = getError(e);
|
|
68
|
+
MessageToast.show(error.message);
|
|
69
|
+
throw error;
|
|
66
70
|
}
|
|
67
71
|
}
|
|
68
72
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
sap.ui.define(["sap/
|
|
3
|
+
sap.ui.define(["sap/ui/model/json/JSONModel", "sap/ui/dt/OverlayRegistry", "../control-utils", "../command-executor", "../api-handler", "./BaseDialog.controller", "../utils"], function (JSONModel, OverlayRegistry, __ControlUtils, __CommandExecutor, ___api_handler, __BaseDialog, ___utils) {
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
6
|
function _interopRequireDefault(obj) {
|
|
@@ -11,6 +11,7 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "sap/ui/dt/O
|
|
|
11
11
|
const getFragments = ___api_handler["getFragments"];
|
|
12
12
|
const BaseDialog = _interopRequireDefault(__BaseDialog);
|
|
13
13
|
const notifyUser = ___utils["notifyUser"];
|
|
14
|
+
const radix = 10;
|
|
14
15
|
/**
|
|
15
16
|
* @namespace open.ux.preview.client.adp.controllers
|
|
16
17
|
*/
|
|
@@ -71,7 +72,7 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "sap/ui/dt/O
|
|
|
71
72
|
this.model.setProperty('/selectedAggregation/value', selectedItemText);
|
|
72
73
|
let newSelectedControlChildren = Object.keys(ControlUtils.getControlAggregationByName(this.runtimeControl, selectedItemText));
|
|
73
74
|
newSelectedControlChildren = newSelectedControlChildren.map(key => {
|
|
74
|
-
return parseInt(key);
|
|
75
|
+
return parseInt(key, radix);
|
|
75
76
|
});
|
|
76
77
|
this.specialIndexHandling(selectedItemText);
|
|
77
78
|
const updatedIndexArray = this.fillIndexArray(newSelectedControlChildren);
|
|
@@ -87,7 +88,7 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "sap/ui/dt/O
|
|
|
87
88
|
const source = event.getSource();
|
|
88
89
|
source.setEnabled(false);
|
|
89
90
|
const fragmentName = this.model.getProperty('/newFragmentName');
|
|
90
|
-
const index =
|
|
91
|
+
const index = this.model.getProperty('/selectedIndex');
|
|
91
92
|
const targetAggregation = this.model.getProperty('/selectedAggregation/value');
|
|
92
93
|
const fragmentData = {
|
|
93
94
|
index,
|
|
@@ -123,7 +124,7 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "sap/ui/dt/O
|
|
|
123
124
|
const selectedControlName = controlMetadata.getName();
|
|
124
125
|
let selectedControlChildren = Object.keys(ControlUtils.getControlAggregationByName(this.runtimeControl, defaultAggregation));
|
|
125
126
|
selectedControlChildren = selectedControlChildren.map(key => {
|
|
126
|
-
return parseInt(key);
|
|
127
|
+
return parseInt(key, radix);
|
|
127
128
|
});
|
|
128
129
|
this.model.setProperty('/selectedControlName', selectedControlName);
|
|
129
130
|
this.model.setProperty('/selectedAggregation', {});
|
|
@@ -154,8 +155,7 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "sap/ui/dt/O
|
|
|
154
155
|
} = await getFragments();
|
|
155
156
|
this.model.setProperty('/fragmentList', fragments);
|
|
156
157
|
} catch (e) {
|
|
157
|
-
|
|
158
|
-
throw new Error(e.message);
|
|
158
|
+
this.handleError(e);
|
|
159
159
|
}
|
|
160
160
|
this.model.setProperty('/selectedIndex', indexArray.length - 1);
|
|
161
161
|
this.model.setProperty('/targetAggregation', controlAggregation);
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import Button from 'sap/m/Button';
|
|
3
3
|
import type Dialog from 'sap/m/Dialog';
|
|
4
4
|
import type ComboBox from 'sap/m/ComboBox';
|
|
5
|
-
import MessageToast from 'sap/m/MessageToast';
|
|
6
5
|
|
|
7
6
|
/** sap.ui.core */
|
|
8
7
|
import type UI5Element from 'sap/ui/core/Element';
|
|
@@ -33,10 +32,18 @@ interface CreateFragmentProps {
|
|
|
33
32
|
targetAggregation: string;
|
|
34
33
|
}
|
|
35
34
|
|
|
35
|
+
const radix = 10;
|
|
36
|
+
|
|
37
|
+
type AddFragmentModel = JSONModel & {
|
|
38
|
+
getProperty(sPath: '/newFragmentName'): string;
|
|
39
|
+
getProperty(sPath: '/selectedIndex'): number;
|
|
40
|
+
getProperty(sPath: '/selectedAggregation/value'): string;
|
|
41
|
+
};
|
|
42
|
+
|
|
36
43
|
/**
|
|
37
44
|
* @namespace open.ux.preview.client.adp.controllers
|
|
38
45
|
*/
|
|
39
|
-
export default class AddFragment extends BaseDialog {
|
|
46
|
+
export default class AddFragment extends BaseDialog<AddFragmentModel> {
|
|
40
47
|
constructor(name: string, overlays: UI5Element, rta: RuntimeAuthoring) {
|
|
41
48
|
super(name);
|
|
42
49
|
this.rta = rta;
|
|
@@ -114,7 +121,7 @@ export default class AddFragment extends BaseDialog {
|
|
|
114
121
|
);
|
|
115
122
|
|
|
116
123
|
newSelectedControlChildren = newSelectedControlChildren.map((key) => {
|
|
117
|
-
return parseInt(key);
|
|
124
|
+
return parseInt(key, radix);
|
|
118
125
|
});
|
|
119
126
|
|
|
120
127
|
this.specialIndexHandling(selectedItemText);
|
|
@@ -135,7 +142,7 @@ export default class AddFragment extends BaseDialog {
|
|
|
135
142
|
source.setEnabled(false);
|
|
136
143
|
|
|
137
144
|
const fragmentName = this.model.getProperty('/newFragmentName');
|
|
138
|
-
const index =
|
|
145
|
+
const index = this.model.getProperty('/selectedIndex');
|
|
139
146
|
const targetAggregation = this.model.getProperty('/selectedAggregation/value');
|
|
140
147
|
const fragmentData = {
|
|
141
148
|
index,
|
|
@@ -182,7 +189,7 @@ export default class AddFragment extends BaseDialog {
|
|
|
182
189
|
);
|
|
183
190
|
|
|
184
191
|
selectedControlChildren = selectedControlChildren.map((key) => {
|
|
185
|
-
return parseInt(key);
|
|
192
|
+
return parseInt(key, radix);
|
|
186
193
|
});
|
|
187
194
|
|
|
188
195
|
this.model.setProperty('/selectedControlName', selectedControlName);
|
|
@@ -216,8 +223,7 @@ export default class AddFragment extends BaseDialog {
|
|
|
216
223
|
|
|
217
224
|
this.model.setProperty('/fragmentList', fragments);
|
|
218
225
|
} catch (e) {
|
|
219
|
-
|
|
220
|
-
throw new Error(e.message);
|
|
226
|
+
this.handleError(e);
|
|
221
227
|
}
|
|
222
228
|
|
|
223
229
|
this.model.setProperty('/selectedIndex', indexArray.length - 1);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
sap.ui.define(["sap/ui/core/library", "sap/ui/core/mvc/Controller", "../utils"], function (sap_ui_core_library, Controller, ___utils) {
|
|
3
|
+
sap.ui.define(["sap/ui/core/library", "sap/ui/core/mvc/Controller", "sap/m/MessageToast", "../utils", "../../cpe/error-utils"], function (sap_ui_core_library, Controller, MessageToast, ___utils, ____cpe_error_utils) {
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
6
|
const ValueState = sap_ui_core_library["ValueState"];
|
|
7
7
|
const matchesFragmentName = ___utils["matchesFragmentName"];
|
|
8
|
+
const getError = ____cpe_error_utils["getError"];
|
|
8
9
|
/**
|
|
9
10
|
* @namespace open.ux.preview.client.adp.controllers
|
|
10
11
|
*/
|
|
@@ -86,6 +87,19 @@ sap.ui.define(["sap/ui/core/library", "sap/ui/core/mvc/Controller", "../utils"],
|
|
|
86
87
|
handleDialogClose: function _handleDialogClose() {
|
|
87
88
|
this.dialog.close();
|
|
88
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;
|
|
89
103
|
}
|
|
90
104
|
});
|
|
91
105
|
return BaseDialog;
|
|
@@ -8,14 +8,20 @@ import Controller from 'sap/ui/core/mvc/Controller';
|
|
|
8
8
|
import JSONModel from 'sap/ui/model/json/JSONModel';
|
|
9
9
|
import RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
|
|
10
10
|
import FlexCommand from 'sap/ui/rta/command/FlexCommand';
|
|
11
|
-
|
|
11
|
+
import MessageToast from 'sap/m/MessageToast';
|
|
12
12
|
import CommandExecutor from '../command-executor';
|
|
13
13
|
import { matchesFragmentName } from '../utils';
|
|
14
|
+
import type { Fragments } from '../api-handler';
|
|
15
|
+
import { getError } from '../../cpe/error-utils';
|
|
16
|
+
|
|
17
|
+
type BaseDialogModel = JSONModel & {
|
|
18
|
+
getProperty(sPath: '/fragmentList'): Fragments;
|
|
19
|
+
};
|
|
14
20
|
|
|
15
21
|
/**
|
|
16
22
|
* @namespace open.ux.preview.client.adp.controllers
|
|
17
23
|
*/
|
|
18
|
-
export default abstract class BaseDialog extends Controller {
|
|
24
|
+
export default abstract class BaseDialog<T extends BaseDialogModel = BaseDialogModel> extends Controller {
|
|
19
25
|
/**
|
|
20
26
|
* Runtime Authoring
|
|
21
27
|
*/
|
|
@@ -27,7 +33,7 @@ export default abstract class BaseDialog extends Controller {
|
|
|
27
33
|
/**
|
|
28
34
|
* JSON Model that has the data
|
|
29
35
|
*/
|
|
30
|
-
public model:
|
|
36
|
+
public model: T;
|
|
31
37
|
/**
|
|
32
38
|
* Runtime control managed object
|
|
33
39
|
*/
|
|
@@ -61,7 +67,7 @@ export default abstract class BaseDialog extends Controller {
|
|
|
61
67
|
const beginBtn = this.dialog.getBeginButton();
|
|
62
68
|
|
|
63
69
|
const fragmentName: string = input.getValue();
|
|
64
|
-
const fragmentList:
|
|
70
|
+
const fragmentList: Fragments = this.model.getProperty('/fragmentList');
|
|
65
71
|
|
|
66
72
|
const updateDialogState = (valueState: ValueState, valueStateText = '') => {
|
|
67
73
|
input.setValueState(valueState).setValueStateText(valueStateText);
|
|
@@ -149,4 +155,16 @@ export default abstract class BaseDialog extends Controller {
|
|
|
149
155
|
this.dialog.close();
|
|
150
156
|
this.dialog.destroy();
|
|
151
157
|
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Function that handles runtime thrown errors with MessageToast
|
|
161
|
+
*
|
|
162
|
+
* @param e error instance
|
|
163
|
+
* @throws {Error}.
|
|
164
|
+
*/
|
|
165
|
+
protected handleError(e: unknown): void {
|
|
166
|
+
const error = getError(e);
|
|
167
|
+
MessageToast.show(error.message, { duration: 5000 });
|
|
168
|
+
throw error;
|
|
169
|
+
}
|
|
152
170
|
}
|
|
@@ -103,17 +103,20 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/J
|
|
|
103
103
|
controllerName,
|
|
104
104
|
viewId
|
|
105
105
|
} = this.getControllerInfo(overlayControl);
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
106
|
+
const existingController = await this.getExistingController(controllerName);
|
|
107
|
+
if (existingController) {
|
|
108
|
+
const {
|
|
109
|
+
controllerExists,
|
|
110
|
+
controllerPath,
|
|
111
|
+
controllerPathFromRoot,
|
|
112
|
+
isRunningInBAS
|
|
113
|
+
} = existingController;
|
|
114
|
+
if (controllerExists) {
|
|
115
|
+
this.updateModelForExistingController(controllerExists, controllerPath, controllerPathFromRoot, isRunningInBAS);
|
|
116
|
+
} else {
|
|
117
|
+
this.updateModelForNewController(viewId);
|
|
118
|
+
await this.getControllers();
|
|
119
|
+
}
|
|
117
120
|
}
|
|
118
121
|
},
|
|
119
122
|
/**
|
|
@@ -171,15 +174,13 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/J
|
|
|
171
174
|
* @returns Returnsexisting controller data
|
|
172
175
|
*/
|
|
173
176
|
getExistingController: async function _getExistingController(controllerName) {
|
|
177
|
+
let data;
|
|
174
178
|
try {
|
|
175
|
-
|
|
176
|
-
return data;
|
|
179
|
+
data = await getExistingController(controllerName);
|
|
177
180
|
} catch (e) {
|
|
178
|
-
|
|
179
|
-
duration: 5000
|
|
180
|
-
});
|
|
181
|
-
throw new Error(e.message);
|
|
181
|
+
this.handleError(e);
|
|
182
182
|
}
|
|
183
|
+
return data;
|
|
183
184
|
},
|
|
184
185
|
/**
|
|
185
186
|
* Retrieves controller files and fills the model with data
|
|
@@ -191,10 +192,7 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/J
|
|
|
191
192
|
} = await readControllers();
|
|
192
193
|
this.model.setProperty('/controllersList', controllers);
|
|
193
194
|
} catch (e) {
|
|
194
|
-
|
|
195
|
-
duration: 5000
|
|
196
|
-
});
|
|
197
|
-
throw new Error(e.message);
|
|
195
|
+
this.handleError(e);
|
|
198
196
|
}
|
|
199
197
|
},
|
|
200
198
|
/**
|
|
@@ -223,8 +221,7 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/J
|
|
|
223
221
|
// We want to update the model incase we have already created a controller file but failed when creating a change file,
|
|
224
222
|
// 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
|
|
225
223
|
await this.getControllers();
|
|
226
|
-
|
|
227
|
-
throw new Error(e.message);
|
|
224
|
+
this.handleError(e);
|
|
228
225
|
}
|
|
229
226
|
}
|
|
230
227
|
});
|
|
@@ -45,10 +45,18 @@ interface ControllerInfo {
|
|
|
45
45
|
viewId: string;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
type ControllerModel = JSONModel & {
|
|
49
|
+
getProperty(sPath: '/controllersList'): { controllerName: string }[];
|
|
50
|
+
getProperty(sPath: '/controllerExists'): boolean;
|
|
51
|
+
getProperty(sPath: '/newControllerName'): string;
|
|
52
|
+
getProperty(sPath: '/viewId'): string;
|
|
53
|
+
getProperty(sPath: '/controllerPath'): string;
|
|
54
|
+
};
|
|
55
|
+
|
|
48
56
|
/**
|
|
49
57
|
* @namespace open.ux.preview.client.adp.controllers
|
|
50
58
|
*/
|
|
51
|
-
export default class ControllerExtension extends BaseDialog {
|
|
59
|
+
export default class ControllerExtension extends BaseDialog<ControllerModel> {
|
|
52
60
|
constructor(name: string, overlays: UI5Element, rta: RuntimeAuthoring) {
|
|
53
61
|
super(name);
|
|
54
62
|
this.rta = rta;
|
|
@@ -83,7 +91,7 @@ export default class ControllerExtension extends BaseDialog {
|
|
|
83
91
|
const beginBtn = this.dialog.getBeginButton();
|
|
84
92
|
|
|
85
93
|
const controllerName: string = input.getValue();
|
|
86
|
-
const controllerList
|
|
94
|
+
const controllerList = this.model.getProperty('/controllersList');
|
|
87
95
|
|
|
88
96
|
const updateDialogState = (valueState: ValueState, valueStateText = '') => {
|
|
89
97
|
input.setValueState(valueState).setValueStateText(valueStateText);
|
|
@@ -157,21 +165,23 @@ export default class ControllerExtension extends BaseDialog {
|
|
|
157
165
|
const overlayControl = sap.ui.getCore().byId(selectorId) as unknown as ElementOverlay;
|
|
158
166
|
|
|
159
167
|
const { controllerName, viewId } = this.getControllerInfo(overlayControl);
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
168
|
+
const existingController = await this.getExistingController(controllerName);
|
|
169
|
+
|
|
170
|
+
if (existingController) {
|
|
171
|
+
const { controllerExists, controllerPath, controllerPathFromRoot, isRunningInBAS } = existingController;
|
|
172
|
+
|
|
173
|
+
if (controllerExists) {
|
|
174
|
+
this.updateModelForExistingController(
|
|
175
|
+
controllerExists,
|
|
176
|
+
controllerPath,
|
|
177
|
+
controllerPathFromRoot,
|
|
178
|
+
isRunningInBAS
|
|
179
|
+
);
|
|
180
|
+
} else {
|
|
181
|
+
this.updateModelForNewController(viewId);
|
|
182
|
+
|
|
183
|
+
await this.getControllers();
|
|
184
|
+
}
|
|
175
185
|
}
|
|
176
186
|
}
|
|
177
187
|
|
|
@@ -238,14 +248,15 @@ export default class ControllerExtension extends BaseDialog {
|
|
|
238
248
|
* @param controllerName Controller name that exists in the view
|
|
239
249
|
* @returns Returnsexisting controller data
|
|
240
250
|
*/
|
|
241
|
-
private async getExistingController(controllerName: string): Promise<CodeExtResponse> {
|
|
251
|
+
private async getExistingController(controllerName: string): Promise<CodeExtResponse | undefined> {
|
|
252
|
+
let data: CodeExtResponse | undefined;
|
|
242
253
|
try {
|
|
243
|
-
|
|
244
|
-
return data;
|
|
254
|
+
data = await getExistingController(controllerName);
|
|
245
255
|
} catch (e) {
|
|
246
|
-
|
|
247
|
-
throw new Error(e.message);
|
|
256
|
+
this.handleError(e);
|
|
248
257
|
}
|
|
258
|
+
|
|
259
|
+
return data;
|
|
249
260
|
}
|
|
250
261
|
|
|
251
262
|
/**
|
|
@@ -256,8 +267,7 @@ export default class ControllerExtension extends BaseDialog {
|
|
|
256
267
|
const { controllers } = await readControllers<ControllersResponse>();
|
|
257
268
|
this.model.setProperty('/controllersList', controllers);
|
|
258
269
|
} catch (e) {
|
|
259
|
-
|
|
260
|
-
throw new Error(e.message);
|
|
270
|
+
this.handleError(e);
|
|
261
271
|
}
|
|
262
272
|
}
|
|
263
273
|
|
|
@@ -288,8 +298,7 @@ export default class ControllerExtension extends BaseDialog {
|
|
|
288
298
|
// We want to update the model incase we have already created a controller file but failed when creating a change file,
|
|
289
299
|
// 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
|
|
290
300
|
await this.getControllers();
|
|
291
|
-
|
|
292
|
-
throw new Error(e.message);
|
|
301
|
+
this.handleError(e);
|
|
293
302
|
}
|
|
294
303
|
}
|
|
295
304
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
sap.ui.define(["sap/
|
|
3
|
+
sap.ui.define(["sap/ui/model/json/JSONModel", "../api-handler", "./BaseDialog.controller", "../utils"], function (JSONModel, ___api_handler, __BaseDialog, ___utils) {
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
6
|
function _interopRequireDefault(obj) {
|
|
@@ -101,8 +101,7 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "../api-hand
|
|
|
101
101
|
} = await getFragments();
|
|
102
102
|
this.model.setProperty('/fragmentList', fragments);
|
|
103
103
|
} catch (e) {
|
|
104
|
-
|
|
105
|
-
throw new Error(e.message);
|
|
104
|
+
this.handleError(e);
|
|
106
105
|
}
|
|
107
106
|
},
|
|
108
107
|
/**
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import type Button from 'sap/m/Button';
|
|
3
3
|
import type Select from 'sap/m/Select';
|
|
4
4
|
import type Dialog from 'sap/m/Dialog';
|
|
5
|
-
import MessageToast from 'sap/m/MessageToast';
|
|
6
5
|
|
|
7
6
|
/** sap.ui.core */
|
|
8
7
|
import type UI5Element from 'sap/ui/core/Element';
|
|
@@ -21,10 +20,15 @@ import BaseDialog from './BaseDialog.controller';
|
|
|
21
20
|
import { ExtensionPointData, ExtensionPointInfo } from '../extension-point';
|
|
22
21
|
import { notifyUser } from '../utils';
|
|
23
22
|
|
|
23
|
+
type ExtensionPointModel = JSONModel & {
|
|
24
|
+
getProperty(sPath: '/newFragmentName'): string;
|
|
25
|
+
getProperty(sPath: '/extensionPointName'): string;
|
|
26
|
+
};
|
|
27
|
+
|
|
24
28
|
/**
|
|
25
29
|
* @namespace open.ux.preview.client.adp.controllers
|
|
26
30
|
*/
|
|
27
|
-
export default class ExtensionPoint extends BaseDialog {
|
|
31
|
+
export default class ExtensionPoint extends BaseDialog<ExtensionPointModel> {
|
|
28
32
|
public readonly data: ExtensionPointData;
|
|
29
33
|
|
|
30
34
|
constructor(name: string, _overlays: UI5Element, rta: RuntimeAuthoring, data: ExtensionPointData) {
|
|
@@ -132,8 +136,7 @@ export default class ExtensionPoint extends BaseDialog {
|
|
|
132
136
|
|
|
133
137
|
this.model.setProperty('/fragmentList', fragments);
|
|
134
138
|
} catch (e) {
|
|
135
|
-
|
|
136
|
-
throw new Error(e.message);
|
|
139
|
+
this.handleError(e);
|
|
137
140
|
}
|
|
138
141
|
}
|
|
139
142
|
|
|
@@ -16,37 +16,13 @@ sap.ui.define(["sap/ui/core/Fragment", "sap/ui/fl/Utils", "./controllers/AddFrag
|
|
|
16
16
|
return DialogNames;
|
|
17
17
|
}(DialogNames || {});
|
|
18
18
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
contextMenu.addMenuItem({
|
|
27
|
-
id: 'ADD_FRAGMENT',
|
|
28
|
-
text: getAddFragmentItemText,
|
|
29
|
-
handler: async overlays => await handler(overlays[0], rta, DialogNames.ADD_FRAGMENT),
|
|
30
|
-
enabled: isFragmentCommandEnabled,
|
|
31
|
-
icon: 'sap-icon://attachment-html'
|
|
32
|
-
});
|
|
33
|
-
contextMenu.addMenuItem({
|
|
34
|
-
id: 'EXTEND_CONTROLLER',
|
|
35
|
-
text: 'Extend With Controller',
|
|
36
|
-
handler: async overlays => await handler(overlays[0], rta, DialogNames.CONTROLLER_EXTENSION),
|
|
37
|
-
icon: 'sap-icon://create-form',
|
|
38
|
-
enabled: overlays => isControllerExtensionEnabled(overlays, syncViewsIds)
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Handler for enablement of Extend With Controller context menu entry
|
|
44
|
-
*
|
|
45
|
-
* @param overlays Control overlays
|
|
46
|
-
* @param syncViewsIds Runtime Authoring
|
|
47
|
-
*
|
|
48
|
-
* @returns boolean
|
|
49
|
-
*/
|
|
19
|
+
* Handler for enablement of Extend With Controller context menu entry
|
|
20
|
+
*
|
|
21
|
+
* @param overlays Control overlays
|
|
22
|
+
* @param syncViewsIds Runtime Authoring
|
|
23
|
+
*
|
|
24
|
+
* @returns boolean
|
|
25
|
+
*/
|
|
50
26
|
const isControllerExtensionEnabled = (overlays, syncViewsIds) => {
|
|
51
27
|
const clickedControlId = FlUtils.getViewForControl(overlays[0].getElement()).getId();
|
|
52
28
|
return overlays.length <= 1 && !syncViewsIds.includes(clickedControlId);
|
|
@@ -109,15 +85,39 @@ sap.ui.define(["sap/ui/core/Fragment", "sap/ui/fl/Utils", "./controllers/AddFrag
|
|
|
109
85
|
});
|
|
110
86
|
await controller.setup(dialog);
|
|
111
87
|
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Adds a new item to the context menu
|
|
91
|
+
*
|
|
92
|
+
* @param rta Runtime Authoring
|
|
93
|
+
* @param syncViewsIds Ids of all application sync views
|
|
94
|
+
*/
|
|
95
|
+
const initDialogs = (rta, syncViewsIds) => {
|
|
96
|
+
const contextMenu = rta.getDefaultPlugins().contextMenu;
|
|
97
|
+
contextMenu.addMenuItem({
|
|
98
|
+
id: 'ADD_FRAGMENT',
|
|
99
|
+
text: getAddFragmentItemText,
|
|
100
|
+
handler: async overlays => await handler(overlays[0], rta, DialogNames.ADD_FRAGMENT),
|
|
101
|
+
enabled: isFragmentCommandEnabled,
|
|
102
|
+
icon: 'sap-icon://attachment-html'
|
|
103
|
+
});
|
|
104
|
+
contextMenu.addMenuItem({
|
|
105
|
+
id: 'EXTEND_CONTROLLER',
|
|
106
|
+
text: 'Extend With Controller',
|
|
107
|
+
handler: async overlays => await handler(overlays[0], rta, DialogNames.CONTROLLER_EXTENSION),
|
|
108
|
+
icon: 'sap-icon://create-form',
|
|
109
|
+
enabled: overlays => isControllerExtensionEnabled(overlays, syncViewsIds)
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
112
|
var __exports = {
|
|
113
113
|
__esModule: true
|
|
114
114
|
};
|
|
115
115
|
__exports.DialogNames = DialogNames;
|
|
116
|
-
__exports.initDialogs = initDialogs;
|
|
117
116
|
__exports.isControllerExtensionEnabled = isControllerExtensionEnabled;
|
|
118
117
|
__exports.isFragmentCommandEnabled = isFragmentCommandEnabled;
|
|
119
118
|
__exports.getAddFragmentItemText = getAddFragmentItemText;
|
|
120
119
|
__exports.handler = handler;
|
|
120
|
+
__exports.initDialogs = initDialogs;
|
|
121
121
|
return __exports;
|
|
122
122
|
});
|
|
123
123
|
//# sourceMappingURL=init-dialogs.js.map
|