@sap-ux/preview-middleware 0.9.0 → 0.10.1
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/controllers/BaseDialog.controller.js +4 -0
- package/dist/client/adp/controllers/BaseDialog.controller.ts +5 -0
- package/dist/client/adp/controllers/ControllerExtension.controller.js +4 -0
- package/dist/client/adp/controllers/ControllerExtension.controller.ts +9 -0
- package/dist/client/cpe/changes/service.js +53 -27
- package/dist/client/cpe/changes/service.ts +62 -38
- package/dist/client/thirdparty/@sap-ux-private/control-property-editor-common.js +40 -2
- package/package.json +3 -3
|
@@ -33,6 +33,10 @@ sap.ui.define(["sap/ui/core/library", "sap/ui/core/mvc/Controller"], function (s
|
|
|
33
33
|
updateDialogState(ValueState.Error, 'The fragment name cannot contain white spaces or special characters.');
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
|
+
if (fragmentName.length > 64) {
|
|
37
|
+
updateDialogState(ValueState.Error, 'A fragment file name cannot contain more than 64 characters.');
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
36
40
|
updateDialogState(ValueState.Success);
|
|
37
41
|
this.model.setProperty('/newFragmentName', fragmentName);
|
|
38
42
|
},
|
|
@@ -83,6 +83,11 @@ export default abstract class BaseDialog extends Controller {
|
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
if(fragmentName.length > 64) {
|
|
87
|
+
updateDialogState(ValueState.Error, 'A fragment file name cannot contain more than 64 characters.');
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
86
91
|
updateDialogState(ValueState.Success);
|
|
87
92
|
this.model.setProperty('/newFragmentName', fragmentName);
|
|
88
93
|
}
|
|
@@ -56,6 +56,10 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/J
|
|
|
56
56
|
updateDialogState(ValueState.Error, 'The controller name cannot contain white spaces or special characters.');
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
|
+
if (controllerName.length > 64) {
|
|
60
|
+
updateDialogState(ValueState.Error, 'A controller file name cannot contain more than 64 characters.');
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
59
63
|
updateDialogState(ValueState.Success);
|
|
60
64
|
this.model.setProperty('/newControllerName', controllerName);
|
|
61
65
|
},
|
|
@@ -100,10 +100,19 @@ export default class ControllerExtension extends BaseDialog {
|
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
if(controllerName.length > 64) {
|
|
104
|
+
updateDialogState(
|
|
105
|
+
ValueState.Error,
|
|
106
|
+
'A controller file name cannot contain more than 64 characters.'
|
|
107
|
+
);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
103
111
|
updateDialogState(ValueState.Success);
|
|
104
112
|
this.model.setProperty('/newControllerName', controllerName);
|
|
105
113
|
}
|
|
106
114
|
|
|
115
|
+
|
|
107
116
|
/**
|
|
108
117
|
* Handles create button press
|
|
109
118
|
*
|
|
@@ -75,6 +75,9 @@ sap.ui.define([
|
|
|
75
75
|
].every(item => item === undefined || item === null)) {
|
|
76
76
|
throw new Error('Invalid change, missing new value in the change file');
|
|
77
77
|
}
|
|
78
|
+
if (change.changeType !== 'propertyChange' && change.changeType !== 'propertyBindingChange') {
|
|
79
|
+
throw new Error('Unknown Change Type');
|
|
80
|
+
}
|
|
78
81
|
return {
|
|
79
82
|
type: 'saved',
|
|
80
83
|
kind: 'valid',
|
|
@@ -83,14 +86,16 @@ sap.ui.define([
|
|
|
83
86
|
propertyName: change.content.property,
|
|
84
87
|
value: change.content.newValue ?? change.content.newBinding,
|
|
85
88
|
timestamp: new Date(change.creation).getTime(),
|
|
86
|
-
controlName: change.selector.type.split('.').pop()
|
|
89
|
+
controlName: change.selector.type ? change.selector.type.split('.').pop() : '',
|
|
90
|
+
changeType: change.changeType
|
|
87
91
|
};
|
|
88
92
|
} catch (error) {
|
|
89
93
|
if (change.fileName) {
|
|
90
94
|
const unknownChange = {
|
|
91
95
|
type: 'saved',
|
|
92
96
|
kind: 'unknown',
|
|
93
|
-
fileName: change.fileName
|
|
97
|
+
fileName: change.fileName,
|
|
98
|
+
controlId: change.selector?.id
|
|
94
99
|
};
|
|
95
100
|
if (change.creation) {
|
|
96
101
|
unknownChange.timestamp = new Date(change.creation).getTime();
|
|
@@ -121,41 +126,62 @@ sap.ui.define([
|
|
|
121
126
|
const allCommands = stack.getCommands();
|
|
122
127
|
const executedCommands = stack.getAllExecutedCommands();
|
|
123
128
|
const inactiveCommandCount = allCommands.length - executedCommands.length;
|
|
124
|
-
|
|
125
|
-
|
|
129
|
+
let activeChanges = [];
|
|
130
|
+
allCommands.forEach((command, i) => {
|
|
126
131
|
try {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
case 'propertyBindingChange':
|
|
135
|
-
value = command.getProperty('newBinding');
|
|
136
|
-
break;
|
|
137
|
-
default:
|
|
138
|
-
throw new Error(`Invalid changeType ${ changeType }`);
|
|
132
|
+
if (typeof command.getCommands === 'function') {
|
|
133
|
+
const subCommands = command.getCommands();
|
|
134
|
+
subCommands.forEach(command => {
|
|
135
|
+
activeChanges.push(this.prepareChangeType(command, inactiveCommandCount, i));
|
|
136
|
+
});
|
|
137
|
+
} else {
|
|
138
|
+
activeChanges.push(this.prepareChangeType(command, inactiveCommandCount, i));
|
|
139
139
|
}
|
|
140
|
-
result = {
|
|
141
|
-
type: 'pending',
|
|
142
|
-
controlId: selector.id,
|
|
143
|
-
propertyName: command.getProperty('propertyName'),
|
|
144
|
-
isActive: i >= inactiveCommandCount,
|
|
145
|
-
value,
|
|
146
|
-
controlName: command.getElement().getMetadata().getName().split('.').pop() ?? ''
|
|
147
|
-
};
|
|
148
140
|
} catch (error) {
|
|
149
|
-
Log.error('
|
|
141
|
+
Log.error('CPE: Change creation Failed', error);
|
|
150
142
|
}
|
|
151
|
-
|
|
152
|
-
|
|
143
|
+
});
|
|
144
|
+
activeChanges = activeChanges.filter(change => !!change);
|
|
153
145
|
sendAction(changeStackModified({
|
|
154
146
|
saved: this.savedChanges,
|
|
155
147
|
pending: activeChanges
|
|
156
148
|
}));
|
|
157
149
|
};
|
|
158
150
|
}
|
|
151
|
+
prepareChangeType(command, inactiveCommandCount, index) {
|
|
152
|
+
let result;
|
|
153
|
+
let value = '';
|
|
154
|
+
const selector = command.getSelector();
|
|
155
|
+
const changeType = command.getChangeType();
|
|
156
|
+
switch (changeType) {
|
|
157
|
+
case 'propertyChange':
|
|
158
|
+
value = command.getProperty('newValue');
|
|
159
|
+
break;
|
|
160
|
+
case 'propertyBindingChange':
|
|
161
|
+
value = command.getProperty('newBinding');
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
if (changeType === 'propertyChange' || changeType === 'propertyBindingChange') {
|
|
165
|
+
result = {
|
|
166
|
+
type: 'pending',
|
|
167
|
+
changeType,
|
|
168
|
+
controlId: selector.id,
|
|
169
|
+
propertyName: command.getProperty('propertyName'),
|
|
170
|
+
isActive: index >= inactiveCommandCount,
|
|
171
|
+
value,
|
|
172
|
+
controlName: command.getElement().getMetadata().getName().split('.').pop() ?? ''
|
|
173
|
+
};
|
|
174
|
+
} else {
|
|
175
|
+
result = {
|
|
176
|
+
type: 'pending',
|
|
177
|
+
controlId: selector.id,
|
|
178
|
+
changeType,
|
|
179
|
+
isActive: index >= inactiveCommandCount,
|
|
180
|
+
controlName: command.getElement().getMetadata().getName().split('.').pop() ?? ''
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
return result;
|
|
184
|
+
}
|
|
159
185
|
}
|
|
160
186
|
var __exports = { __esModule: true };
|
|
161
187
|
__exports.ChangeService = ChangeService;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
ExternalAction,
|
|
3
|
+
PendingChange,
|
|
3
4
|
SavedPropertyChange,
|
|
4
|
-
PendingPropertyChange,
|
|
5
5
|
UnknownSavedChange
|
|
6
6
|
} from '@sap-ux-private/control-property-editor-common';
|
|
7
7
|
import {
|
|
@@ -39,6 +39,7 @@ interface Change {
|
|
|
39
39
|
selector: ChangeSelector;
|
|
40
40
|
content: ChangeContent;
|
|
41
41
|
creation: string;
|
|
42
|
+
changeType: string;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
type Properties<T extends object> = { [K in keyof T]-?: K extends string ? K : never }[keyof T];
|
|
@@ -91,10 +92,7 @@ export class ChangeService {
|
|
|
91
92
|
* @param ui5 facade for ui5 framework methods.
|
|
92
93
|
* @param selectionService selection service instance.
|
|
93
94
|
*/
|
|
94
|
-
constructor(
|
|
95
|
-
private readonly options: UI5AdaptationOptions,
|
|
96
|
-
private readonly selectionService: SelectionService
|
|
97
|
-
) {}
|
|
95
|
+
constructor(private readonly options: UI5AdaptationOptions, private readonly selectionService: SelectionService) {}
|
|
98
96
|
|
|
99
97
|
/**
|
|
100
98
|
*
|
|
@@ -144,6 +142,9 @@ export class ChangeService {
|
|
|
144
142
|
) {
|
|
145
143
|
throw new Error('Invalid change, missing new value in the change file');
|
|
146
144
|
}
|
|
145
|
+
if (change.changeType !== 'propertyChange' && change.changeType !== 'propertyBindingChange') {
|
|
146
|
+
throw new Error('Unknown Change Type');
|
|
147
|
+
}
|
|
147
148
|
return {
|
|
148
149
|
type: 'saved',
|
|
149
150
|
kind: 'valid',
|
|
@@ -152,7 +153,8 @@ export class ChangeService {
|
|
|
152
153
|
propertyName: change.content.property,
|
|
153
154
|
value: change.content.newValue ?? change.content.newBinding,
|
|
154
155
|
timestamp: new Date(change.creation).getTime(),
|
|
155
|
-
controlName: change.selector.type.split('.').pop()
|
|
156
|
+
controlName: change.selector.type ? (change.selector.type.split('.').pop() as string) : '',
|
|
157
|
+
changeType: change.changeType
|
|
156
158
|
};
|
|
157
159
|
} catch (error) {
|
|
158
160
|
// Gracefully handle change files with invalid content
|
|
@@ -160,7 +162,8 @@ export class ChangeService {
|
|
|
160
162
|
const unknownChange: UnknownSavedChange = {
|
|
161
163
|
type: 'saved',
|
|
162
164
|
kind: 'unknown',
|
|
163
|
-
fileName: change.fileName
|
|
165
|
+
fileName: change.fileName,
|
|
166
|
+
controlId: change.selector?.id // some changes may not have selector
|
|
164
167
|
};
|
|
165
168
|
if (change.creation) {
|
|
166
169
|
unknownChange.timestamp = new Date(change.creation).getTime();
|
|
@@ -220,38 +223,23 @@ export class ChangeService {
|
|
|
220
223
|
const allCommands = stack.getCommands();
|
|
221
224
|
const executedCommands = stack.getAllExecutedCommands();
|
|
222
225
|
const inactiveCommandCount = allCommands.length - executedCommands.length;
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
value = command.getProperty('newValue');
|
|
234
|
-
break;
|
|
235
|
-
case 'propertyBindingChange':
|
|
236
|
-
value = command.getProperty('newBinding');
|
|
237
|
-
break;
|
|
238
|
-
default:
|
|
239
|
-
throw new Error(`Invalid changeType ${changeType}`);
|
|
240
|
-
}
|
|
241
|
-
result = {
|
|
242
|
-
type: 'pending',
|
|
243
|
-
controlId: selector.id,
|
|
244
|
-
propertyName: command.getProperty('propertyName'),
|
|
245
|
-
isActive: i >= inactiveCommandCount,
|
|
246
|
-
value,
|
|
247
|
-
controlName: command.getElement().getMetadata().getName().split('.').pop() ?? ''
|
|
248
|
-
};
|
|
249
|
-
} catch (error) {
|
|
250
|
-
Log.error('Failed: ', error);
|
|
226
|
+
let activeChanges: PendingChange[] = [];
|
|
227
|
+
allCommands.forEach((command: BaseCommand, i): void => {
|
|
228
|
+
try {
|
|
229
|
+
if (typeof command.getCommands === 'function') {
|
|
230
|
+
const subCommands = command.getCommands();
|
|
231
|
+
subCommands.forEach((command) => {
|
|
232
|
+
activeChanges.push(this.prepareChangeType(command, inactiveCommandCount, i));
|
|
233
|
+
});
|
|
234
|
+
} else {
|
|
235
|
+
activeChanges.push(this.prepareChangeType(command, inactiveCommandCount, i));
|
|
251
236
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
237
|
+
} catch (error) {
|
|
238
|
+
Log.error('CPE: Change creation Failed', error);
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
activeChanges = activeChanges.filter((change): boolean => !!change);
|
|
255
243
|
sendAction(
|
|
256
244
|
changeStackModified({
|
|
257
245
|
saved: this.savedChanges,
|
|
@@ -260,4 +248,40 @@ export class ChangeService {
|
|
|
260
248
|
);
|
|
261
249
|
};
|
|
262
250
|
}
|
|
251
|
+
|
|
252
|
+
private prepareChangeType(command: BaseCommand, inactiveCommandCount: number, index: number): PendingChange {
|
|
253
|
+
let result: PendingChange;
|
|
254
|
+
let value = '';
|
|
255
|
+
const selector = command.getSelector();
|
|
256
|
+
const changeType = command.getChangeType();
|
|
257
|
+
switch (changeType) {
|
|
258
|
+
case 'propertyChange':
|
|
259
|
+
value = command.getProperty('newValue');
|
|
260
|
+
break;
|
|
261
|
+
case 'propertyBindingChange':
|
|
262
|
+
value = command.getProperty('newBinding');
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
if (changeType === 'propertyChange' || changeType === 'propertyBindingChange') {
|
|
266
|
+
result = {
|
|
267
|
+
type: 'pending',
|
|
268
|
+
changeType,
|
|
269
|
+
controlId: selector.id,
|
|
270
|
+
propertyName: command.getProperty('propertyName'),
|
|
271
|
+
isActive: index >= inactiveCommandCount,
|
|
272
|
+
value,
|
|
273
|
+
controlName: command.getElement().getMetadata().getName().split('.').pop() ?? ''
|
|
274
|
+
};
|
|
275
|
+
} else {
|
|
276
|
+
result = {
|
|
277
|
+
type: 'pending',
|
|
278
|
+
controlId: selector.id,
|
|
279
|
+
changeType,
|
|
280
|
+
isActive: index >= inactiveCommandCount,
|
|
281
|
+
controlName: command.getElement().getMetadata().getName().split('.').pop() ?? ''
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return result;
|
|
286
|
+
}
|
|
263
287
|
}
|
|
@@ -225,9 +225,47 @@ sap.ui.define((function () { 'use strict';
|
|
|
225
225
|
(function (exports) {
|
|
226
226
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
227
227
|
exports.FlexChangesEndPoints = exports.convertCamelCaseToPascalCase = void 0;
|
|
228
|
+
const isUpperCase = (code) => code >= 65 && code <= 90;
|
|
229
|
+
const isLowerCase = (code) => code >= 97 && code <= 122;
|
|
230
|
+
const isWordDelimiter = (code) => code === 45 || code === 95 || code === 32; // - or _ or space
|
|
228
231
|
const convertCamelCaseToPascalCase = (text) => {
|
|
229
|
-
const
|
|
230
|
-
|
|
232
|
+
const words = [];
|
|
233
|
+
let word = '';
|
|
234
|
+
let lookForUpperCase = true;
|
|
235
|
+
for (let i = 0; i < text.length; i++) {
|
|
236
|
+
const character = text[i];
|
|
237
|
+
if (lookForUpperCase) {
|
|
238
|
+
// make sure that the first letter is capitalized
|
|
239
|
+
word += word.length === 0 ? character.toUpperCase() : character;
|
|
240
|
+
if (isLowerCase(text.charCodeAt(i + 1))) {
|
|
241
|
+
// First lower case character after upper case character -> switch mode to collect only lower case characters
|
|
242
|
+
lookForUpperCase = false;
|
|
243
|
+
}
|
|
244
|
+
else if (isUpperCase(text.charCodeAt(i + 1)) && isLowerCase(text.charCodeAt(i + 2))) {
|
|
245
|
+
// Next character is the last uppercase character after a sequence of upper case character -> create an abbreviated word
|
|
246
|
+
words.push(word);
|
|
247
|
+
word = '';
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
else if (isUpperCase(text.charCodeAt(i))) {
|
|
251
|
+
// Upper case character indicates the beginning of a new word -> switch mode to detect abbreviated word
|
|
252
|
+
words.push(word);
|
|
253
|
+
lookForUpperCase = true;
|
|
254
|
+
word = character;
|
|
255
|
+
}
|
|
256
|
+
else if (isWordDelimiter(text.charCodeAt(i))) {
|
|
257
|
+
words.push(word);
|
|
258
|
+
lookForUpperCase = true;
|
|
259
|
+
word = '';
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
word += character;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (word.length) {
|
|
266
|
+
words.push(word);
|
|
267
|
+
}
|
|
268
|
+
return words.join(' ');
|
|
231
269
|
};
|
|
232
270
|
exports.convertCamelCaseToPascalCase = convertCamelCaseToPascalCase;
|
|
233
271
|
(function (FlexChangesEndPoints) {
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"bugs": {
|
|
10
10
|
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Apreview-middleware"
|
|
11
11
|
},
|
|
12
|
-
"version": "0.
|
|
12
|
+
"version": "0.10.1",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"ejs": "3.1.9",
|
|
26
26
|
"@sap-ux/logger": "0.4.0",
|
|
27
27
|
"@sap-ux/adp-tooling": "0.5.3",
|
|
28
|
-
"@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.
|
|
28
|
+
"@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.4.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/ejs": "3.1.2",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"npm-run-all": "4.1.5",
|
|
37
37
|
"nock": "13.2.1",
|
|
38
38
|
"supertest": "6.3.3",
|
|
39
|
-
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.
|
|
39
|
+
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.7.1",
|
|
40
40
|
"@sap-ux/project-access": "1.14.0",
|
|
41
41
|
"@sap-ux/store": "0.4.0"
|
|
42
42
|
},
|