ru.coon 2.7.38 → 2.7.39

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,9 @@
1
+ # Version 2.7.39, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/ee1b57d7e50b1e21a906d29edb7d671c219c524c)
2
+ * ## Features
3
+ * <span style='color:green'>feat: HT-9216 В формирование имени файла добавлена поддержка шаблона</span> ([bbee95], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/bbee952b0dc180e47bb5a0c2afb7ff9b3a41eedc))
4
+
5
+ * update: CHANGELOG.md ([e6739a], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/e6739ad52aabed775b6e64571810e581c0d8389b))
6
+
1
7
  # Version 2.7.38, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/3e9d06de2b191d41e62cc8ecb0fa9bf29863d57f)
2
8
  * ## Fixes
3
9
  * <span style='color:red'> HT-9208 submit button disabled until file is selected</span> ([c55498], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/c55498ff17153280cfc025f435eea7acf4be8b0c))
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "ru.coon"
5
5
  },
6
6
  "description": "",
7
- "version": "2.7.38",
7
+ "version": "2.7.39",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+http://gitlab-dbr.sigma-it.local/dbr/ru.coon"
@@ -176,6 +176,25 @@ Ext.define('Coon.report.plugin.configPanel.CopyRowsFromGridConfigPanel', {
176
176
  return !isValid(value) ? 'Недопустимое имя файла' : true;
177
177
  },
178
178
  },
179
+ {
180
+ xtype: 'container',
181
+ html: `
182
+ <div style="font-size:12px;color: gray">
183
+ <li>Имя файла может быть шаблоном
184
+ <a style="color:var(--base-color);" href="https://docs.sencha.com/extjs/7.5.0/classic/Ext.XTemplate.html" target="_blank">
185
+ Ext.XTemplate
186
+ </a>
187
+ </li>
188
+ <li>
189
+ Для указания параметра введите <b>{parameters.[Название параметра]}</b>
190
+ </li>
191
+ Пример:<br>
192
+ <li>
193
+ Строка "Строка 'Файл {parameters.ADDRESS}' будет преобразована в "Файл_г_Санкт-Петербург_Невский_проспект".
194
+ </li>
195
+ </div>
196
+ `,
197
+ },
179
198
  {
180
199
  xtype: 'checkbox',
181
200
  boxLabel: 'Добавлять дату и время к имени',
@@ -204,6 +223,12 @@ Ext.define('Coon.report.plugin.configPanel.CopyRowsFromGridConfigPanel', {
204
223
  </ul>
205
224
  </div>
206
225
  `,
226
+ },
227
+ {
228
+ xtype: 'textfield',
229
+ fieldLabel: 'Символ, для замены недопустимых символов',
230
+ name: 'forbiddenSymbolReplacer',
231
+ value: '_',
207
232
  }
208
233
  ],
209
234
  };
@@ -27,6 +27,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
27
27
  return '___CRFG';
28
28
  },
29
29
  defaultDateFormat: 'Y-m-d_h-i',
30
+ forbiddenSymbolReplacer: '_',
30
31
 
31
32
  injectForm() {
32
33
  // if element already exist
@@ -388,7 +389,7 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
388
389
  execute: function() {
389
390
  const reportPanel = this.component.up('ReportPanel');
390
391
  const selected = this.getSelected()[0];
391
- const name = this.reportFileName ||
392
+ const name = this.getParameterPartName(this.reportFileName) ||
392
393
  (selected && selected.data['CM_REPORT_CD']) ||
393
394
  this.tryToGetTitle() ||
394
395
  (reportPanel && reportPanel.reportId) ||
@@ -404,6 +405,8 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
404
405
  filename += '_';
405
406
  filename += Ext.Date.format(new Date(), dateFormat);
406
407
  }
408
+ filename = this.normalizeFileName(filename);
409
+
407
410
  reportPanel && reportPanel.mask('Экспорт', 'x-mask-loading');
408
411
  if (this.format === 'xlsx') {
409
412
  const exporter = this.initExporter(filename);
@@ -419,6 +422,40 @@ Ext.define('Coon.report.plugin.grid.CopyRowsFromGrid', {
419
422
  }
420
423
  reportPanel && reportPanel.unmask();
421
424
  },
425
+
426
+ getParameterPartName: function(message) {
427
+ if (Ext.isString(message) && message.match(/{.*}/g) !== null) {
428
+ return this.getTemplatedMessage(message);
429
+ }
430
+ return message;
431
+ },
432
+
433
+ getTemplatedMessage: function(message) {
434
+ return new Ext.XTemplate(message).apply({
435
+ parameters: this.component.up('ReportPanel').currentParamList,
436
+ });
437
+ },
438
+
439
+ normalizeFileName: function(fileName) {
440
+ const regexs = [
441
+ {rg: /s|:|\\*|"|\\?|>|<|\||\\|\//g, isGlobal: true}, // запрещенные символы \ / : * ? " < > |
442
+ {rg: /nul|prn|con|lpt[0-9]|com[0-9]/}, // запрещенные имена файлов
443
+ {rg: /^\./} // не должно начинаться с точки (.)
444
+ ];
445
+ regexs.forEach((_regex) => {
446
+ if (_regex.isGlobal) {
447
+ fileName.replaceAll(_regex.rg, this.forbiddenSymbolReplacer);
448
+ } else {
449
+ fileName.replace(_regex.rg, this.forbiddenSymbolReplacer);
450
+ }
451
+ });
452
+ if (fileName.length>128) {
453
+ Coon.log.warn('Усекаем имя файла');
454
+ fileName = fileName.slice(0, 128);
455
+ }
456
+ return fileName;
457
+ },
458
+
422
459
  initExporter: function(filename) {
423
460
  const exporter = Ext.create('Ext.exporter.excel.Xlsx', {
424
461
  fileName: filename + '.xlsx',
package/src/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  Ext.define('Coon.version', {
2
2
  singleton: true,
3
- number: '2.7.38',
3
+ number: '2.7.39',
4
4
  });