ru.coon 3.0.57 → 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 CHANGED
@@ -1,3 +1,23 @@
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
+
9
+ # Version 3.0.58, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/9f4087fb2aba17d56ea49774ac21340c1b414307)
10
+ * update: CHANGELOG.md ([fcea34], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/fcea34f891b7acc6a0b73200d9b6d7b60c383f46))
11
+
12
+ # Version 3.0.57, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/f68b5e938b5f9deaceb1b28accb4153c604cac48)
13
+ * update: CHANGELOG.md ([d72a42], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/d72a42a63d7b506db7cac423bfea512e215f64c7))
14
+
15
+ # Version 3.0.56, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/6d42b7aef8ee61964f826099feaaf68cd7299303)
16
+ * ## Features
17
+ * <span style='color:green'>feat: add forceShowHeader</span> ([7ce368], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/7ce368898a1809f08aaa8331af2bdef4f40366da))
18
+
19
+ * update: CHANGELOG.md ([8108ae], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/8108ae12826ada676cd8598e0c1ba8ce067fa32e))
20
+
1
21
  # Version 3.0.57, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/28be9d312317e10260c5d784cf2eb09e83a30140)
2
22
  * HT-14299: изменение вида несохраненных изменений в вертикальных табах ([590315], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/59031554ed302eabdc194e916e44c3a8a3c77371))
3
23
  * update: CHANGELOG.md ([62c8b4], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/62c8b40173f540191ba7eeb9aad48dae93dd5f57))
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "ru.coon"
5
5
  },
6
6
  "description": "",
7
- "version": "3.0.57",
7
+ "version": "3.0.59",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+http://gitlab-dbr.sigma-it.local/dbr/ru.coon"
@@ -2,7 +2,7 @@ Ext.define('Coon.report.util', {
2
2
  singleton: true,
3
3
 
4
4
  validateReportConfig(config) {
5
- return Coon.util.isObjectValid(config, [
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'},
@@ -173,7 +173,7 @@ Ext.define('Coon.uielement.component.UiCustomController', {
173
173
  this.getViewModel().bind(`{${context}}`, function(contextValue) {
174
174
  setupTitle(
175
175
  this.makeComponentTitle(staticText, contextValue),
176
- {silent: true}
176
+ {silent: false}
177
177
  );
178
178
  }, this);
179
179
  } else {
@@ -190,22 +190,4 @@ Ext.define('Coon.uielement.component.UiCustomController', {
190
190
  setupTitle(title);
191
191
  }
192
192
  },
193
-
194
- setupTitle(title, options = {}) {
195
- if (!typeof title === 'string') {
196
- return;
197
- }
198
- title = title || Coon.format.withHint('<span style="color:red">---</span>', 'заголовок не задан');
199
- this.getView().titleText = title;
200
- if (!options.silent) {
201
- this.getView().fireEvent('titlechange', this.getView(), title);
202
- }
203
- if (
204
- this.getView().tab &&
205
- typeof this.getView().tab.setTooltip === 'function'
206
- ) {
207
- this.getView().tab.setTooltip(title);
208
- }
209
- },
210
-
211
193
  });
@@ -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': {
@@ -69,6 +72,24 @@ Ext.define('Coon.uielement.component.UiCustomPanel', {
69
72
  this.viewModel.setData(data);
70
73
  }
71
74
  this.callParent();
75
+ if (this.componentTitle?.forceShowHeader) {
76
+ this.on('titlechange', this.forceShowHeader, this);
77
+ }
78
+ },
79
+
80
+ forceShowHeader(_, title) {
81
+ if (this.assert.is_string_required(title).invalid) {
82
+ return;
83
+ }
84
+ if (typeof title !== 'string' || !title) {
85
+ return;
86
+ }
87
+ if (this.header && typeof this.header.show === 'function') {
88
+ this.header.show();
89
+ } else {
90
+ this.header = {title};
91
+ this.updateHeader(true);
92
+ }
72
93
  },
73
94
 
74
95
  convertRowData(rowData) {
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
- // eslint-disable-next-line no-console
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
- copyToClipboard(copiedData) {
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
- if (document.queryCommandSupported && document.queryCommandSupported('copy')) {
247
- const hiddenTextArea = this.getHtaEl();
248
- hiddenTextArea.value = copiedData;
249
- hiddenTextArea.focus();
250
- hiddenTextArea.select();
251
- return document.execCommand('copy');
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
- instance.xtype ||
669
- instance.ptype ||
670
- instance.$className ||
671
- Ext.isObject(instance.initialConfig)
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
@@ -0,0 +1,4 @@
1
+ .x-window.toast-success {
2
+ border: 1px solid green !important;
3
+ border-radius: 2px !important;
4
+ }
@@ -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
@@ -1,4 +1,4 @@
1
1
  Ext.define('Coon.version', {
2
2
  singleton: true,
3
- number: '3.0.57',
3
+ number: '3.0.59',
4
4
  });