ru.coon 3.0.58 → 3.0.59
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/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/src/report/util.js +1 -1
- package/src/uielement/component/UiCustomPanel.js +6 -0
- package/src/util.js +30 -113
- package/src/util.scss +4 -0
- package/src/validator.js +173 -0
- package/src/version.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
# Version 3.0.59, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/065a134b1f6c6211d56ef758b127778d5e104faa)
|
|
2
|
+
* Копирование в буфер обмена без использования дополнительного окна prompt. Related to NEVA-990 ([41cd4e], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/41cd4ed4fdb7088d10df1eac44964c5aadae4646))
|
|
3
|
+
* add Coon.validator singleton class ([a402d0], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/a402d0829e81d7f4297fba2af9b628a4528533c1))
|
|
4
|
+
* upd ([61e613], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/61e6137120af2b8a95c0d7918a85afe2aa3d0456))
|
|
5
|
+
* upd ([0258f1], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/0258f199b5928da341e6549f5589390f1fa87bcd))
|
|
6
|
+
* add validator ([0ca7d7], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/0ca7d719f4715af1845f0b4385333271db2438bb))
|
|
7
|
+
* update: CHANGELOG.md ([5969de], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/5969de159690ff30bc5194f8fe83a4d1d7507dd0))
|
|
8
|
+
|
|
1
9
|
# Version 3.0.58, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/9f4087fb2aba17d56ea49774ac21340c1b414307)
|
|
2
10
|
* update: CHANGELOG.md ([fcea34], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/fcea34f891b7acc6a0b73200d9b6d7b60c383f46))
|
|
3
11
|
|
|
@@ -8,7 +16,13 @@
|
|
|
8
16
|
* ## Features
|
|
9
17
|
* <span style='color:green'>feat: add forceShowHeader</span> ([7ce368], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/7ce368898a1809f08aaa8331af2bdef4f40366da))
|
|
10
18
|
|
|
19
|
+
* update: CHANGELOG.md ([8108ae], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/8108ae12826ada676cd8598e0c1ba8ce067fa32e))
|
|
20
|
+
|
|
21
|
+
# Version 3.0.57, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/28be9d312317e10260c5d784cf2eb09e83a30140)
|
|
11
22
|
* HT-14299: изменение вида несохраненных изменений в вертикальных табах ([590315], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/59031554ed302eabdc194e916e44c3a8a3c77371))
|
|
23
|
+
* update: CHANGELOG.md ([62c8b4], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/62c8b40173f540191ba7eeb9aad48dae93dd5f57))
|
|
24
|
+
|
|
25
|
+
# Version 3.0.56, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/74308acb16cf13c9793236b74d8fd025bd632cab)
|
|
12
26
|
* HT-14580: повторный вход при завершении сессии ([66c811], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/66c81121345e02ec436a9ec3308db087030a25ac))
|
|
13
27
|
* update: CHANGELOG.md ([0cd2cb], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/0cd2cb99bbdcdf6d8cf83c29c744dd0f02daa497))
|
|
14
28
|
|
package/package.json
CHANGED
package/src/report/util.js
CHANGED
|
@@ -2,7 +2,7 @@ Ext.define('Coon.report.util', {
|
|
|
2
2
|
singleton: true,
|
|
3
3
|
|
|
4
4
|
validateReportConfig(config) {
|
|
5
|
-
return Coon.
|
|
5
|
+
return Coon.validator.isObjectValid(config, [
|
|
6
6
|
{path: 'reportDescription', valid: 'string, required'},
|
|
7
7
|
{path: 'reportId', valid: 'string, required'},
|
|
8
8
|
{path: 'SQLText', valid: 'string, required'},
|
|
@@ -9,6 +9,9 @@ Ext.define('Coon.uielement.component.UiCustomPanel', {
|
|
|
9
9
|
'Coon.uielement.component.UiCustomPanelTraceWindow'
|
|
10
10
|
],
|
|
11
11
|
controller: 'UiCustomController',
|
|
12
|
+
mixins: [
|
|
13
|
+
'Coon.validator.mixin'
|
|
14
|
+
],
|
|
12
15
|
|
|
13
16
|
keyMap: {
|
|
14
17
|
'Ctrl+Shift+Alt+F8': {
|
|
@@ -75,6 +78,9 @@ Ext.define('Coon.uielement.component.UiCustomPanel', {
|
|
|
75
78
|
},
|
|
76
79
|
|
|
77
80
|
forceShowHeader(_, title) {
|
|
81
|
+
if (this.assert.is_string_required(title).invalid) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
78
84
|
if (typeof title !== 'string' || !title) {
|
|
79
85
|
return;
|
|
80
86
|
}
|
package/src/util.js
CHANGED
|
@@ -210,7 +210,7 @@ Ext.define('Coon.util', {
|
|
|
210
210
|
const bAcc = acc;
|
|
211
211
|
acc = this.safeCall(fn, acc);
|
|
212
212
|
if (debug) {
|
|
213
|
-
|
|
213
|
+
// eslint-disable-next-line no-console
|
|
214
214
|
console.debug(`\n \x1b[36m\x1b[4m BEFORE: \x1b[0m ${fn.toString()}`);
|
|
215
215
|
// eslint-disable-next-line no-console
|
|
216
216
|
console.dir(bAcc, {depth: debug.depth || 5});
|
|
@@ -228,7 +228,22 @@ Ext.define('Coon.util', {
|
|
|
228
228
|
return acc;
|
|
229
229
|
},
|
|
230
230
|
|
|
231
|
-
|
|
231
|
+
getHtaEl() {
|
|
232
|
+
const textArea = document.createElement('textarea');
|
|
233
|
+
textArea.style.position = 'fixed';
|
|
234
|
+
textArea.style.top = 0;
|
|
235
|
+
textArea.style.left = 0;
|
|
236
|
+
textArea.style.width = '2em';
|
|
237
|
+
textArea.style.height = '2em';
|
|
238
|
+
textArea.style.padding = 0;
|
|
239
|
+
textArea.style.border = 'none';
|
|
240
|
+
textArea.style.outline = 'none';
|
|
241
|
+
textArea.style.boxShadow = 'none';
|
|
242
|
+
textArea.style.background = 'transparent';
|
|
243
|
+
return textArea;
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
copyToClipboard(copiedData, successText = 'Скопировано успешно') {
|
|
232
247
|
try {
|
|
233
248
|
if (!Ext.browser.is.Firefox && navigator && navigator.clipboard) {
|
|
234
249
|
navigator.permissions.query({name: 'clipboard-write'}).then((result) => {
|
|
@@ -243,13 +258,14 @@ Ext.define('Coon.util', {
|
|
|
243
258
|
if (window.clipboardData && window.clipboardData.setData) {
|
|
244
259
|
window.clipboardData.setData('text', copiedData);
|
|
245
260
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
261
|
+
const hiddenTextArea = this.getHtaEl();
|
|
262
|
+
hiddenTextArea.value = copiedData;
|
|
263
|
+
document.body.appendChild(hiddenTextArea);
|
|
264
|
+
hiddenTextArea.focus();
|
|
265
|
+
hiddenTextArea.select();
|
|
266
|
+
document.execCommand('copy');
|
|
267
|
+
document.body.removeChild(hiddenTextArea);
|
|
268
|
+
Ext.toast({html: successText, cls: ['toast-success']});
|
|
253
269
|
} catch (ex) {
|
|
254
270
|
return prompt('Copy to clipboard: Ctrl+C, Enter', copiedData);
|
|
255
271
|
}
|
|
@@ -369,106 +385,6 @@ Ext.define('Coon.util', {
|
|
|
369
385
|
return acc;
|
|
370
386
|
},
|
|
371
387
|
|
|
372
|
-
/**
|
|
373
|
-
*
|
|
374
|
-
* @param {Object} obj
|
|
375
|
-
* @param {Array} rules
|
|
376
|
-
* @example
|
|
377
|
-
* rules: [
|
|
378
|
-
* {path: 'a.b.c', valid: 'string,nonempty,length.-.30,', msg: 'invalid string'}
|
|
379
|
-
* ]
|
|
380
|
-
*/
|
|
381
|
-
isObjectValid(obj, rules) {
|
|
382
|
-
const getValid = (valid) => {
|
|
383
|
-
if (typeof valid === 'string') {
|
|
384
|
-
return valid.split(',').map((el) => el.trim());
|
|
385
|
-
}
|
|
386
|
-
if (Array.isArray(valid)) {
|
|
387
|
-
return valid;
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
const checkValidity = (validProps, value) => validProps.find((prop) => {
|
|
391
|
-
const [name, ...args] = prop.split('.');
|
|
392
|
-
if (typeof validators[name] === 'function') {
|
|
393
|
-
return !(
|
|
394
|
-
validators[name](value, ...args)
|
|
395
|
-
);
|
|
396
|
-
}
|
|
397
|
-
});
|
|
398
|
-
// validators
|
|
399
|
-
const validators = {
|
|
400
|
-
empty: (v) => Ext.isEmpty(v),
|
|
401
|
-
required: (v) => !Ext.isEmpty(v),
|
|
402
|
-
uppercase: (v) => typeof v === 'string' && v.toUpperCase() === v,
|
|
403
|
-
lowercase: (v) => typeof v === 'string' && v.toLowerCase() === v,
|
|
404
|
-
true: (v) => v === true,
|
|
405
|
-
false: (v) => v === false,
|
|
406
|
-
allowblank: (v) => true,
|
|
407
|
-
type: (v, expectedType) => {
|
|
408
|
-
if (expectedType === 'null') {
|
|
409
|
-
return v === null;
|
|
410
|
-
}
|
|
411
|
-
if (expectedType === 'array') {
|
|
412
|
-
return Array.isArray(v);
|
|
413
|
-
}
|
|
414
|
-
if (expectedType === 'object') {
|
|
415
|
-
return Ext.isObject(v);
|
|
416
|
-
}
|
|
417
|
-
return typeof v === expectedType;
|
|
418
|
-
},
|
|
419
|
-
not: (name, ...args) => {
|
|
420
|
-
if (typeof validators[name] !== 'function') {
|
|
421
|
-
throw new Error(`validator [${name}] is not exist!`);
|
|
422
|
-
}
|
|
423
|
-
return (v, ...args) => validators[name](v, ...args);
|
|
424
|
-
},
|
|
425
|
-
};
|
|
426
|
-
validators['!type'] = (v, typename) => !validators.type(v, typename);
|
|
427
|
-
validators.string = (v) => validators.type(v, 'string');
|
|
428
|
-
validators.array = (v) => validators.type(v, 'array');
|
|
429
|
-
validators.boolean = (v) => validators.type(v, 'boolean');
|
|
430
|
-
validators.number = (v) => validators.type(v, 'number');
|
|
431
|
-
validators.object = (v) => validators.type(v, 'object');
|
|
432
|
-
// EOF validators
|
|
433
|
-
const getErrors = (obj, rules) => {
|
|
434
|
-
const errors = Coon.util.filterMap(rules, (rule) => {
|
|
435
|
-
if (!rule.path) {
|
|
436
|
-
return;
|
|
437
|
-
}
|
|
438
|
-
const value = Coon.util.getByPath(obj, rule.path);
|
|
439
|
-
const validTags = getValid(rule.valid) || [];
|
|
440
|
-
let subErrors;
|
|
441
|
-
let isInvalid = typeof valid === 'function' ?
|
|
442
|
-
validTags(value) :
|
|
443
|
-
checkValidity(validTags, value);
|
|
444
|
-
if (
|
|
445
|
-
!Ext.isEmpty(value) &&
|
|
446
|
-
!isInvalid &&
|
|
447
|
-
Array.isArray(rule.rules) &&
|
|
448
|
-
rule.rules.length
|
|
449
|
-
) {
|
|
450
|
-
const subResult = getErrors(value, rule.rules);
|
|
451
|
-
if (!subResult.valid) {
|
|
452
|
-
isInvalid = false;
|
|
453
|
-
subErrors = subResult.errors.join('\n');
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
if (isInvalid) {
|
|
457
|
-
rule.msg = rule.msg || `[by path: ${rule.path}], value [${value}] is invalid`;
|
|
458
|
-
if (subErrors) {
|
|
459
|
-
rule.msg = rule.msg + '\n' + subErrors;
|
|
460
|
-
}
|
|
461
|
-
return rule.msg;
|
|
462
|
-
}
|
|
463
|
-
});
|
|
464
|
-
return {
|
|
465
|
-
valid: !errors.length,
|
|
466
|
-
errors,
|
|
467
|
-
};
|
|
468
|
-
};
|
|
469
|
-
return getErrors(obj, rules);
|
|
470
|
-
},
|
|
471
|
-
|
|
472
388
|
getAllCommandsList() {
|
|
473
389
|
if (Coon.util.locals.getAllCommandsList) {
|
|
474
390
|
return Coon.util.locals.getAllCommandsList;
|
|
@@ -665,10 +581,10 @@ Ext.define('Coon.util', {
|
|
|
665
581
|
|
|
666
582
|
getInstanceIdProperties(instance) {
|
|
667
583
|
if (instance.id ||
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
584
|
+
instance.xtype ||
|
|
585
|
+
instance.ptype ||
|
|
586
|
+
instance.$className ||
|
|
587
|
+
Ext.isObject(instance.initialConfig)
|
|
672
588
|
) {
|
|
673
589
|
return Object.assign(
|
|
674
590
|
{},
|
|
@@ -756,6 +672,7 @@ Ext.define('Coon.util', {
|
|
|
756
672
|
}
|
|
757
673
|
}
|
|
758
674
|
}
|
|
675
|
+
|
|
759
676
|
return detectCycle(data);
|
|
760
677
|
},
|
|
761
678
|
|
package/src/util.scss
ADDED
package/src/validator.js
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
Ext.define('Coon.validator', {
|
|
2
|
+
singleton: true,
|
|
3
|
+
|
|
4
|
+
alternateClassName: 'Coon.v',
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
const validators = {
|
|
8
|
+
empty: (v) => Ext.isEmpty(v),
|
|
9
|
+
notempty: (v) => !Ext.isEmpty(v),
|
|
10
|
+
required: (v) => !Ext.isEmpty(v),
|
|
11
|
+
uppercase: (v) => typeof v === 'string' && v.toUpperCase() === v,
|
|
12
|
+
lowercase: (v) => typeof v === 'string' && v.toLowerCase() === v,
|
|
13
|
+
true: (v) => v === true,
|
|
14
|
+
false: (v) => v === false,
|
|
15
|
+
allowblank: (v) => true,
|
|
16
|
+
type: (v, expectedType) => {
|
|
17
|
+
if (expectedType === 'null') {
|
|
18
|
+
return v === null;
|
|
19
|
+
}
|
|
20
|
+
if (expectedType === 'array') {
|
|
21
|
+
return Array.isArray(v);
|
|
22
|
+
}
|
|
23
|
+
if (expectedType === 'object') {
|
|
24
|
+
return Ext.isObject(v);
|
|
25
|
+
}
|
|
26
|
+
return typeof v === expectedType;
|
|
27
|
+
},
|
|
28
|
+
not: (name, ...args) => {
|
|
29
|
+
if (typeof validators[name] !== 'function') {
|
|
30
|
+
throw new Error(`validator [${name}] is not exist!`);
|
|
31
|
+
}
|
|
32
|
+
return (v, ...args) => validators[name](v, ...args);
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
validators['!type'] = (v, typename) => !validators.type(v, typename);
|
|
36
|
+
validators.string = (v) => validators.type(v, 'string');
|
|
37
|
+
validators.array = (v) => validators.type(v, 'array');
|
|
38
|
+
validators.boolean = (v) => validators.type(v, 'boolean');
|
|
39
|
+
validators.number = (v) => validators.type(v, 'number');
|
|
40
|
+
validators.object = (v) => validators.type(v, 'object');
|
|
41
|
+
this.addValidator = (name, validator, override) => {
|
|
42
|
+
if (!validators[name] || override) {
|
|
43
|
+
validators[name] = validator;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
this.getValidator = (name) => validators[name];
|
|
47
|
+
this.getValidators = () => validators;
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @param {Object} obj
|
|
54
|
+
* @param {Array} rules
|
|
55
|
+
* @example
|
|
56
|
+
* rules: [
|
|
57
|
+
* {path: 'a.b.c', valid: 'string,nonempty,length.-.30,', msg: 'invalid string'}
|
|
58
|
+
* ]
|
|
59
|
+
*/
|
|
60
|
+
isObjectValid(obj, rules) {
|
|
61
|
+
const getValid = (valid) => {
|
|
62
|
+
if (typeof valid === 'string') {
|
|
63
|
+
return valid.split(',').map((el) => el.trim());
|
|
64
|
+
}
|
|
65
|
+
if (Array.isArray(valid)) {
|
|
66
|
+
return valid;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const checkValidity = (validProps, value) => validProps.find((prop) => {
|
|
70
|
+
const [name, ...args] = prop.split('.');
|
|
71
|
+
if (typeof validators[name] === 'function') {
|
|
72
|
+
return !(
|
|
73
|
+
validators[name](value, ...args)
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
const validators = this.getValidators();
|
|
78
|
+
const getErrors = (obj, rules) => {
|
|
79
|
+
const errors = Coon.util.filterMap(rules, (rule) => {
|
|
80
|
+
if (!rule.path) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const value = Coon.util.getByPath(obj, rule.path);
|
|
84
|
+
const validTags = getValid(rule.valid) || [];
|
|
85
|
+
let subErrors;
|
|
86
|
+
let isInvalid = typeof valid === 'function' ?
|
|
87
|
+
validTags(value) :
|
|
88
|
+
checkValidity(validTags, value);
|
|
89
|
+
if (
|
|
90
|
+
!Ext.isEmpty(value) &&
|
|
91
|
+
!isInvalid &&
|
|
92
|
+
Array.isArray(rule.rules) &&
|
|
93
|
+
rule.rules.length
|
|
94
|
+
) {
|
|
95
|
+
const subResult = getErrors(value, rule.rules);
|
|
96
|
+
if (!subResult.valid) {
|
|
97
|
+
isInvalid = false;
|
|
98
|
+
subErrors = subResult.errors.join('\n');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (isInvalid) {
|
|
102
|
+
rule.msg = rule.msg || `[by path: ${rule.path}], value [${value}] is invalid`;
|
|
103
|
+
if (subErrors) {
|
|
104
|
+
rule.msg = rule.msg + '\n' + subErrors;
|
|
105
|
+
}
|
|
106
|
+
return rule.msg;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
return {
|
|
110
|
+
valid: !errors.length,
|
|
111
|
+
errors,
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
return getErrors(obj, rules);
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
}, function() {
|
|
118
|
+
this.assert = new Proxy(this, {
|
|
119
|
+
get: function(target, name) {
|
|
120
|
+
if (!name.startsWith('is_')) {
|
|
121
|
+
return target[name];
|
|
122
|
+
}
|
|
123
|
+
const tokens = name.slice(3)
|
|
124
|
+
.split('_')
|
|
125
|
+
.map((name) => {
|
|
126
|
+
if (!Coon.validator.getValidator(name)) {
|
|
127
|
+
return {name};
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
fn: (tested) => {
|
|
131
|
+
if (tested.invalid) {
|
|
132
|
+
return tested;
|
|
133
|
+
}
|
|
134
|
+
const isValid = Coon.validator.getValidator(name).call(this, tested.value);
|
|
135
|
+
tested.invalid = !isValid;
|
|
136
|
+
tested.steps.push({[name]: isValid});
|
|
137
|
+
return tested;
|
|
138
|
+
},
|
|
139
|
+
name,
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
if (tokens.find(({fn}) => !fn)) {
|
|
143
|
+
return () => {
|
|
144
|
+
const tested = {steps: []};
|
|
145
|
+
tokens.filter(({fn}) => !fn)
|
|
146
|
+
.map(({name}) => name)
|
|
147
|
+
.forEach((name) => {
|
|
148
|
+
tested.steps.push({[name]: `validator not found`});
|
|
149
|
+
});
|
|
150
|
+
tested.invalid = true;
|
|
151
|
+
return tested;
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
if (tokens.length === 0) {
|
|
155
|
+
return (tested) => {
|
|
156
|
+
tested.valid = true;
|
|
157
|
+
return tested;
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
return (value) => Coon.util.chained(
|
|
161
|
+
tokens.map((el) => el.fn),
|
|
162
|
+
{value, steps: []}
|
|
163
|
+
);
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
Ext.define('Coon.validator.mixin', {
|
|
169
|
+
constructor(validator) {
|
|
170
|
+
this.assert = Coon.validator.assert;
|
|
171
|
+
this.callParent(arguments);
|
|
172
|
+
},
|
|
173
|
+
});
|
package/src/version.js
CHANGED