ru.coon 3.0.31 → 3.0.32

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 3.0.32, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/54a1adc38f21829b195830d3eced818bf79b9ae8)
2
+ * HT-13143 feat: Доработка функционала тулбара ([143359], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/14335922547e88e2da04be44ecd90b62b10ba9bb))
3
+ * upd ([bfda87], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/bfda878d1063c5c85d7e606457e925186fe99c02))
4
+ * upd ([567480], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/567480f225764cfdfce2ffc5ab2e132d23d7c80f))
5
+ * update: CHANGELOG.md ([aec290], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/aec29006235ca1d8f82e3dc1eaa594c797f1a14c))
6
+
1
7
  # Version 3.0.31, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/9665b81ba1d0a4cded52d8755f915381c0753074)
2
8
  * ## Fixes
3
9
  * <span style='color:red'>fix OCPB</span> ([d9f750], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/d9f7501828ec8437a029d6eb0ef7582e43bac2ba))
package/core-uls.d2 ADDED
@@ -0,0 +1,12 @@
1
+ login phase: {
2
+ /info
3
+ /revision\.json
4
+ /login
5
+ /generateCSRFToken
6
+ }
7
+
8
+ read navigation menu: {|`
9
+ - /ReportFormData/get -> reportId.MENU_ALLITEMS
10
+ - /ReportFormData/get -> reportId.MENU_PROFILE
11
+ `|
12
+ }
package/core-urls.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "loginPhase": [
3
+ "/info",
4
+ "/revision.json",
5
+ "/login",
6
+ "/generateCSRFToken"
7
+ ],
8
+ "readNavMenu": [
9
+ { "url": "/ReportFormData/get", "params": "reportId:MENU_ALLITEMS" },
10
+ { "url": "/ReportFormData/get", "params": "reportId.MENU_PROFILE" }
11
+ ],
12
+ "uiElement": [
13
+ "/UIElement/get",
14
+ "/UIElement/copy",
15
+ "/UIElement/delete",
16
+ "/UIElement/version/revision/get",
17
+ "/UIElement/version/get",
18
+ "/UIElement/save",
19
+ "/UIElement/import",
20
+ "/UIElement/editor/import",
21
+ "/UIElement/getNameProperties"
22
+ ],
23
+ "report": [
24
+ "/ReportConfiguration/get",
25
+ "/ReportConfiguration/delete",
26
+ "/ReportFormData/get",
27
+ "/ReportFormData/getCSVReport",
28
+ "/ReportFormData/getExcelFromRowsOrReport",
29
+ "/ReportFormData/getExcelReport",
30
+ "/ReportFormData/getPdfReport",
31
+ "/ReportFormData/getReportSqlText",
32
+ "/ReportField/get",
33
+ "/Report/version/get",
34
+ "/Report/version/revision/get",
35
+ "/ReportFormMaintenance/save"
36
+ ],
37
+ "common": [
38
+ "/personification/personify",
39
+ "/configurationProperty/get",
40
+ "/configurationProperty/getAllPropertiesWithDefault",
41
+ "/configurationProperty/save"
42
+ ],
43
+ "entities": [
44
+ "/externalSystem/proxy/SWE/LookUpService/getLookUpList.do",
45
+ "/externalSystem/proxy/SWE/AlgoritmChainBind/get.do",
46
+ "/externalSystem/proxy/SWE/CharacteristicList/get.do",
47
+ "/externalSystem/proxy/SWE/CharacteristicList/getAll.do",
48
+ "externalSystem/proxy/SWE/Entity/getWithAllCharacteristicsByGroups.do",
49
+ "/externalSystem/proxy/SWE/Entity/save.do",
50
+ "/externalSystem/proxy/SWE/EntityGroup/saveCharacters.do",
51
+ "/externalSystem/proxy/SWE/CharacteristicList/save.do",
52
+ "externalSystem/proxy/SWE/AlgoritmChainBind/save.do"
53
+ ]
54
+ }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "ru.coon"
5
5
  },
6
6
  "description": "",
7
- "version": "3.0.31",
7
+ "version": "3.0.32",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+http://gitlab-dbr.sigma-it.local/dbr/ru.coon"
@@ -56,8 +56,6 @@ Ext.define('Coon.common.ComponentFactory', {
56
56
  }
57
57
  const config = route.uiElement;
58
58
  const paramsObject = this.paramsToObject(params);
59
- const filterDefaults =
60
- (paramsObject && Object.assign(paramsObject, {doFilter: true})) || {};
61
59
 
62
60
  if (!Ext.isObject(config)) {
63
61
  throw new Error('неверный формат элемента пункта меню');
@@ -76,6 +74,16 @@ Ext.define('Coon.common.ComponentFactory', {
76
74
  }
77
75
  );
78
76
  }
77
+
78
+ if (Ext.isObject(paramsObject)) {
79
+ paramsObject.doFilter = 'doFilter' in paramsObject ? paramsObject.doFilter : true;
80
+ }
81
+
82
+ const filterDefaults = Object.assign(
83
+ paramsObject || {},
84
+ config.propertyData?.filterDefaults || {}
85
+ );
86
+
79
87
  Object.assign(
80
88
  config,
81
89
  {xtype: config.xtype, itemId: uiElementCd},
@@ -68,6 +68,13 @@ Ext.define('Coon.report.component.ReportPanel', {
68
68
  enableChipToolbar: false,
69
69
  filtered: false,
70
70
  customButtons: false,
71
+ locals: {
72
+ /**
73
+ * Точка монтирования api плагинов репорта
74
+ */
75
+ api: new Map(),
76
+ plugins: new Map(),
77
+ },
71
78
  },
72
79
  defaults: {
73
80
  split: true,
@@ -77,9 +84,6 @@ Ext.define('Coon.report.component.ReportPanel', {
77
84
 
78
85
  lazyConfigLoading: Coon.setup.get('lazyConfigLoading'),
79
86
 
80
- locals: {
81
- plugins: new Map(),
82
- },
83
87
  /**
84
88
  * @property {Coon.report.component.ReportFieldMap}
85
89
  */
@@ -353,6 +357,11 @@ Ext.define('Coon.report.component.ReportPanel', {
353
357
  return 'complete loadFakeData';
354
358
  },
355
359
 
360
+ constructor(config) {
361
+ this.callParent(arguments);
362
+ this.getLocals().api = new Map();
363
+ },
364
+
356
365
  initComponent: function() {
357
366
  this.gridProperties = this.gridProperties || {};
358
367
  this.centerProperties = this.centerProperties || {};
@@ -603,12 +612,23 @@ Ext.define('Coon.report.component.ReportPanel', {
603
612
  this.addPlugin(config);
604
613
  },
605
614
 
615
+ preprocessPluginConfig(config, xtype) {
616
+ return ![
617
+ 'GridQuickSearchPlugin',
618
+ 'GridFiltersPlugin', // Исключается, т.к. есть альтернатива - плагин по умолчанию AddFilterConditionPlugin
619
+ 'ReportToolbarPlugin',
620
+ 'ToolbarSeparatorPlugin' // Не совместим с ReportToolbarPlugin
621
+ ].includes(xtype) && config;
622
+ },
623
+
606
624
  preprocessPlugins(plugins) {
625
+ const isReportToolbarPlugin = plugins.find((item) => item.uiElement.xtype === 'ReportToolbarPlugin');
626
+ this.isReportToolbarPlugin = isReportToolbarPlugin;
627
+ const defaultConfig = Coon.report.plugin.form.ReportToolbarPlugin.getDefaultConfig();
628
+ this.addToolbarPlugin(isReportToolbarPlugin ?
629
+ Object.assign({}, isReportToolbarPlugin) : defaultConfig
630
+ );
607
631
  return plugins.reduce((acc, plugin) => {
608
- if (plugin.uiElement.xtype === 'ReportToolbarPlugin') {
609
- this.addToolbarPlugin(Object.assign({}, plugin));
610
- plugin = false;
611
- }
612
632
  if (typeof this.preprocessPluginConfig === 'function') {
613
633
  plugin = this.preprocessPluginConfig(plugin, plugin.uiElement && plugin.uiElement.xtype);
614
634
  }
@@ -715,7 +735,10 @@ Ext.define('Coon.report.component.ReportPanel', {
715
735
  },
716
736
 
717
737
  clearData: function() {
718
- this.grid && this.grid.clear();
738
+ if (this.grid) {
739
+ this.grid.getStore().clearFilter();
740
+ this.grid.clear();
741
+ }
719
742
  this.fireEvent('clearData');
720
743
  },
721
744
 
@@ -1138,6 +1161,7 @@ Ext.define('Coon.report.component.ReportPanel', {
1138
1161
  },
1139
1162
 
1140
1163
  loadDataByStore(parameterList, invalidateCache) {
1164
+ const stop = Coon.perf.start(`Report.load: ${this.reportId}`);
1141
1165
  const store = this.grid.getStore();
1142
1166
  store.getProxy().abort();
1143
1167
  return new Promise((resolve) => {
@@ -1148,15 +1172,17 @@ Ext.define('Coon.report.component.ReportPanel', {
1148
1172
  invalidateCache,
1149
1173
  },
1150
1174
  callback: function(records, operation, success) {
1175
+ Coon.log.debug(Coon.perf.getLog(stop()));
1151
1176
  resolve(records);
1152
1177
  },
1178
+ scope: this,
1153
1179
  });
1154
1180
  });
1155
1181
  },
1156
1182
 
1157
1183
  loadDataByCommand(command, parameterList, invalidateCache) {
1158
1184
  const store = this.grid.getStore();
1159
- return new Promise((resolve) => {
1185
+ return new Promise(function(resolve) {
1160
1186
  command.on('complete', function(response) {
1161
1187
  if (!store.lastOptions) {
1162
1188
  store.lastOptions = {};
@@ -1169,6 +1195,9 @@ Ext.define('Coon.report.component.ReportPanel', {
1169
1195
  store.fireEvent('load', store);
1170
1196
  resolve(response && response.list);
1171
1197
  }, this);
1198
+ command.on('failure', function(exception) {
1199
+ }, this);
1200
+
1172
1201
 
1173
1202
  this.executeStoreDataCommand(command, {
1174
1203
  reportID: this.reportID,
@@ -1200,4 +1229,22 @@ Ext.define('Coon.report.component.ReportPanel', {
1200
1229
  const selectedRecords = this.grid.getSelection();
1201
1230
  return selectedRecords && selectedRecords.length > 0 && firstSelectedOnly ? selectedRecords[0] : selectedRecords;
1202
1231
  },
1232
+
1233
+ registerApi(apiKey, api) {
1234
+ if (this.getLocals().api.has(apiKey)) {
1235
+ Coon.log.warn('Дублирование api ' + apiKey);
1236
+ }
1237
+ this.getLocals().api.set(apiKey, api);
1238
+ },
1239
+
1240
+ getApi(apiKey) {
1241
+ return this.getLocals().api.get(apiKey);
1242
+ },
1243
+
1244
+ isStoreEmpty() {
1245
+ if (!this.grid) {
1246
+ return true;
1247
+ }
1248
+ return this.grid.getStore().getDataSource().getCount() === 0;
1249
+ },
1203
1250
  });
@@ -17,12 +17,81 @@ Ext.define('Coon.report.plugin.grid.AddFilterConditionPlugin', {
17
17
  this.grid = grid;
18
18
  this.columnFilterTypes = this.getColumnFilterTypes();
19
19
  grid.on('clearAllFilters', this.clearAllFilters, this);
20
- grid.on('added', this.addMenuItems, this);
20
+ grid.on('added', this.onReportReady, this);
21
21
  grid.on('load', this.clearAllFilters, this);
22
22
  grid.contextMenu.on('requestMenuItems', this.onShowMenu, this);
23
+ grid.getStore().on({
24
+ load: function(_, records, success) {
25
+ if (success && !records.length) {
26
+ this.clearColumnContext();
27
+ }
28
+ },
29
+ clear: function() {
30
+ this.clearAllFilters();
31
+ this.clearColumnContext();
32
+ },
33
+ scope: this,
34
+ });
35
+ const headerContainer = grid.getHeaderContainer();
36
+ if (headerContainer) {
37
+ headerContainer.on('boxready', function() {
38
+ this.addHeaderMenuItems();
39
+
40
+ headerContainer.getMenu().on({
41
+ beforeshow: this.beforeHeaderMenuShow,
42
+ close: function() {
43
+ this.inHeaderContext = false;
44
+ },
45
+ scope: this,
46
+ });
47
+ }, this);
48
+ }
23
49
  },
24
- addMenuItems(grid) {
25
- const contextMenu = grid.contextMenu;
50
+
51
+ onReportReady(grid) {
52
+ this.addMenuItems(grid);
53
+ this.registerApi();
54
+ },
55
+
56
+ registerApi() {
57
+ this.grid.up('ReportPanel').registerApi('advancedSearch', {
58
+ menuItemText: 'Расширенный поиск',
59
+ showAdvancedSearchHandler: this.advancedSearch,
60
+ scope: this,
61
+ });
62
+ },
63
+
64
+ addHeaderMenuItems() {
65
+ if (!this.grid.getHeaderContainer()) {
66
+ return;
67
+ }
68
+ const headerMenu = this.getHeaderMenu();
69
+ const filterMenu = Ext.widget('FilterMenu');
70
+ filterMenu.on('beforeshow', this.createMenuItem, this);
71
+ headerMenu.add({xtype: 'menuseparator'});
72
+ const columnHeaderInfoMenuItem = this.getInfoMenuItem();
73
+ headerMenu.add(columnHeaderInfoMenuItem);
74
+ headerMenu.add({
75
+ xtype: 'menuitem',
76
+ text: 'Фильтр по значению',
77
+ itemId: 'filterByCellValue',
78
+ handler: this.filterByCellValue.bind(this),
79
+ });
80
+ headerMenu.add({
81
+ text: 'Поиск',
82
+ iconCls: 'svg-icon svg-icon-magnifying-glass',
83
+ itemId: 'searchByValueHeaderMenuItem',
84
+ menu: filterMenu,
85
+ });
86
+ headerMenu.add({
87
+ xtype: 'menuitem',
88
+ text: 'Очистить все фильтры',
89
+ itemId: 'cancelAllFilters',
90
+ handler: this.clearAllFilters.bind(this),
91
+ });
92
+ },
93
+
94
+ getInfoMenuItem() {
26
95
  const infoMenuItem = Ext.widget('InfoMenuItem', {
27
96
  itemId: 'infoMenuItem',
28
97
  originalText: '', // 'Фильтр не задан',
@@ -32,8 +101,15 @@ Ext.define('Coon.report.plugin.grid.AddFilterConditionPlugin', {
32
101
  });
33
102
  infoMenuItem.on('removefilter', function() {
34
103
  this.clearCurrentColumnFilter();
35
- contextMenu.hide();
104
+ const menu = this.getActiveMenu();
105
+ menu && menu.hide();
36
106
  }, this);
107
+ return infoMenuItem;
108
+ },
109
+
110
+ addMenuItems(grid) {
111
+ const contextMenu = grid.contextMenu;
112
+ const infoMenuItem = this.getInfoMenuItem();
37
113
  contextMenu.addToAdvancedSearch(infoMenuItem);
38
114
  contextMenu.addToAdvancedSearch(new Ext.menu.Item({
39
115
  text: 'Фильтр по значению',
@@ -44,7 +120,7 @@ Ext.define('Coon.report.plugin.grid.AddFilterConditionPlugin', {
44
120
  }));
45
121
  const filterMenu = Ext.widget('FilterMenu', {
46
122
  listeners: {
47
- beforeshow: this.createSearchMenuItem.bind(this),
123
+ beforeshow: this.createMenuItem.bind(this),
48
124
  resize: this.onResizeSearchSubMenu.bind(this),
49
125
  },
50
126
  });
@@ -57,13 +133,6 @@ Ext.define('Coon.report.plugin.grid.AddFilterConditionPlugin', {
57
133
  isItemHidden: this.isSearchByValueItemHidden.bind(this),
58
134
  isItemDisabled: this.isSearchByValueItemDisabled.bind(this),
59
135
  });
60
- // contextMenu.addToAdvancedSearch(new Ext.menu.Item({
61
- // text: 'Расширенный поиск',
62
- // itemId: 'advancedSearch',
63
- // handler: this.advancedSearch.bind(this),
64
- // isItemHidden: () => false,
65
- // isItemDisabled: () => false,
66
- // }));
67
136
  contextMenu.addToAdvancedSearch(new Ext.menu.Item({
68
137
  text: 'Очистить все фильтры',
69
138
  itemId: 'cancelAllFilters',
@@ -105,7 +174,41 @@ Ext.define('Coon.report.plugin.grid.AddFilterConditionPlugin', {
105
174
  const column = columns.length && columns[cellIndex];
106
175
  this.column = column;
107
176
  this.columnValue = record && record.get(column.dataIndex);
108
- this.setMenuText();
177
+ const contextMenu = this.grid.contextMenu;
178
+ const infoMenuItem = contextMenu.down('#infoMenuItem');
179
+ const foundMenuItem = contextMenu.down('#filterByCellValue');
180
+ this.setMenuText(infoMenuItem, foundMenuItem);
181
+ },
182
+
183
+ beforeHeaderMenuShow(menu) {
184
+ this.column = menu.ownerCmp;
185
+ const record = this.getCmp().getContextManager().context.record;
186
+ this.columnValue = record && record.get(this.column.dataIndex);
187
+ this.inHeaderContext = true;
188
+ this.onShowHeaderMenu();
189
+ },
190
+
191
+ onShowHeaderMenu() {
192
+ const headerMenu = this.getHeaderMenu();
193
+ const infoMenuItem = headerMenu.down('#infoMenuItem');
194
+ const foundMenuItem = headerMenu.down('#filterByCellValue');
195
+ this.setMenuText(infoMenuItem, foundMenuItem);
196
+ this.setVisibilityMenuItems();
197
+ },
198
+
199
+ setVisibilityMenuItems() {
200
+ const headerMenu = this.getHeaderMenu();
201
+ const searchByValueItem = headerMenu.down('#searchByValueHeaderMenuItem');
202
+ const filterByCellValue = headerMenu.down('#filterByCellValue');
203
+ const infoMenuItem = headerMenu.down('#infoMenuItem');
204
+ const cancelAllFiltersItem = headerMenu.down('#cancelAllFilters');
205
+
206
+ const menuItemsStatus = !this.getCmp().reportPanel.isStoreEmpty();
207
+
208
+ infoMenuItem.setVisible(menuItemsStatus);
209
+ searchByValueItem.setVisible(menuItemsStatus);
210
+ filterByCellValue.setVisible(menuItemsStatus);
211
+ cancelAllFiltersItem.setVisible(menuItemsStatus);
109
212
  },
110
213
 
111
214
  filterByCellValue: function() {
@@ -439,7 +542,9 @@ Ext.define('Coon.report.plugin.grid.AddFilterConditionPlugin', {
439
542
  return value;
440
543
  }
441
544
  if (typeof value === 'boolean') {
442
- const booleanLabels = this.column ? {trueText: this.column.trueText, falseText: this.column.falseText}: {};
545
+ const booleanLabels = this.column ?
546
+ {trueText: this.column.trueText, falseText: this.column.falseText} :
547
+ {};
443
548
  return value ? booleanLabels.trueText || 'да' : booleanLabels.falseText || 'нет';
444
549
  }
445
550
  if (value === null || value === undefined || value === '') {
@@ -447,22 +552,83 @@ Ext.define('Coon.report.plugin.grid.AddFilterConditionPlugin', {
447
552
  }
448
553
  },
449
554
 
450
- setMenuText() {
451
- const contextMenu = this.grid.contextMenu;
555
+ createInfoMenuText(currentColumnFilter) {
556
+ const operators = {
557
+ 'ne': 'не равно',
558
+ 'gt': 'больше',
559
+ 'ge': 'больше или равно',
560
+ 'lt': 'меньше',
561
+ 'le': 'меньше или равно',
562
+ 'notfilled': 'не заполнено',
563
+ 'like': 'Содержит',
564
+ 'in': 'Список',
565
+ };
566
+ let itemText; let itemPrefix;
567
+ switch (currentColumnFilter.operator) {
568
+ case 'between':
569
+ // Фильтр between может быть задан без одной из границ. Тогда информацию о фильтрации не корректно отображать как диапазон.
570
+ const operator = currentColumnFilter.operator !== 'between' ?
571
+ currentColumnFilter.operator:
572
+ Ext.isEmpty(currentColumnFilter.value[0]) ?
573
+ 'le':
574
+ Ext.isEmpty(currentColumnFilter.value[1]) ? 'ge' : 'between';
575
+ const valueStart = this.formatFilterValue(currentColumnFilter.value[0]);
576
+ const valueEnd = this.formatFilterValue(currentColumnFilter.value[1]);
577
+ if (operator === 'between') {
578
+ itemPrefix = 'по диапазону';
579
+ itemText = ` &laquo;${valueStart} - ${valueEnd}&raquo;`;
580
+ } else {
581
+ const value = Ext.isEmpty(currentColumnFilter.value[0]) ?
582
+ currentColumnFilter.value[1] :
583
+ currentColumnFilter.value[0];
584
+ itemPrefix = operators[operator];
585
+ itemText = ` &laquo;${this.getValueText(value)}&raquo;`;
586
+ }
587
+
588
+ break;
589
+ case 'ge':
590
+ case 'gt':
591
+ case 'le':
592
+ case 'lt':
593
+ case 'ne':
594
+ itemPrefix = operators[currentColumnFilter.operator];
595
+ itemText = `&laquo;${this.getValueText(currentColumnFilter.value)}&raquo;`;
596
+ break;
597
+ case 'eq':
598
+ itemPrefix = ' равно ';
599
+ itemText = `&laquo;${this.getValueText(currentColumnFilter.value)}&raquo;`;
600
+ break;
601
+ case 'like':
602
+ itemPrefix = ' по подстроке ';
603
+ itemText = `&laquo;${currentColumnFilter.value}&raquo;`;
604
+ break;
605
+ case 'in':
606
+ itemPrefix = 'по списку';
607
+ itemText = ' ';
608
+ break;
609
+ case 'notfilled':
610
+ itemPrefix = ' не заполнено ';
611
+ itemText = ' ';
612
+ break;
613
+ }
614
+ return {itemPrefix, itemText};
615
+ },
616
+
617
+ formatFilterValue(value) {
618
+ return Ext.isDate(value) ? Ext.Date.format(value, this.column.format || Coon.format.dateTime) : value;
619
+ },
620
+
621
+ setMenuText(infoMenuItem, foundMenuItem) {
452
622
  if (!this.column) {
453
623
  return;
454
624
  }
455
- const infoMenuItem = contextMenu.down('#infoMenuItem');
625
+
456
626
  infoMenuItem.removeQTip();
457
627
  infoMenuItem.setFilterText(infoMenuItem.originalText);
458
628
  infoMenuItem.setFilterPrefix('');
459
629
 
460
630
  const currentColumnFilter = this.filters.get(this.getColumnKey());
461
- const formatFilterValue = (value) => {
462
- return Ext.isDate(value) ? Ext.Date.format(value, this.column.format || Coon.format.dateTime): value;
463
- };
464
631
 
465
- const foundMenuItem = contextMenu.down('#filterByCellValue');
466
632
  if (!this.isFilterable()) {
467
633
  infoMenuItem.buttonSetHidden(true);
468
634
  infoMenuItem.setFilterText(infoMenuItem.forbiddenText);
@@ -478,64 +644,10 @@ Ext.define('Coon.report.plugin.grid.AddFilterConditionPlugin', {
478
644
  </div>`);
479
645
  }
480
646
  }
647
+
481
648
  if (currentColumnFilter) {
482
649
  infoMenuItem.buttonSetHidden(false);
483
- const operators = {
484
- 'ne': 'не равно',
485
- 'gt': 'больше',
486
- 'ge': 'больше или равно',
487
- 'lt': 'меньше',
488
- 'le': 'меньше или равно',
489
- 'notfilled': 'не заполнено',
490
- 'like': 'Содержит',
491
- 'in': 'Список',
492
- };
493
- let itemText; let itemPrefix;
494
- switch (currentColumnFilter.operator) {
495
- case 'between':
496
- // Фильтр between может быть задан без одной из границ. Тогда информацию о фильтрации не корректно отображать как диапазон.
497
- const operator = currentColumnFilter.operator !== 'between' ?
498
- currentColumnFilter.operator:
499
- Ext.isEmpty(currentColumnFilter.value[0]) ?
500
- 'le':
501
- Ext.isEmpty(currentColumnFilter.value[1]) ? 'ge': 'between';
502
- const valueStart = formatFilterValue(currentColumnFilter.value[0]);
503
- const valueEnd = formatFilterValue(currentColumnFilter.value[1]);
504
- if (operator === 'between') {
505
- itemPrefix = 'по диапазону';
506
- itemText = ` &laquo;${valueStart} - ${valueEnd}&raquo;`;
507
- } else {
508
- const value = Ext.isEmpty(currentColumnFilter.value[0]) ? currentColumnFilter.value[1] :currentColumnFilter.value[0];
509
- itemPrefix = operators[operator];
510
- itemText = ` &laquo;${this.getValueText(value)}&raquo;`;
511
- }
512
-
513
- break;
514
- case 'ge':
515
- case 'gt':
516
- case 'le':
517
- case 'lt':
518
- case 'ne':
519
- itemPrefix = operators[currentColumnFilter.operator];
520
- itemText = `&laquo;${this.getValueText(currentColumnFilter.value)}&raquo;`;
521
- break;
522
- case 'eq':
523
- itemPrefix = ' равно ';
524
- itemText = `&laquo;${this.getValueText(currentColumnFilter.value)}&raquo;`;
525
- break;
526
- case 'like':
527
- itemPrefix = ' по подстроке ';
528
- itemText = `&laquo;${currentColumnFilter.value}&raquo;`;
529
- break;
530
- case 'in':
531
- itemPrefix = 'по списку';
532
- itemText = ' ';
533
- break;
534
- case 'notfilled':
535
- itemPrefix = ' не заполнено ';
536
- itemText = ' ';
537
- break;
538
- }
650
+ const {itemPrefix, itemText} = this.createInfoMenuText(currentColumnFilter);
539
651
  infoMenuItem.setColumnName(this.column.config.text);
540
652
  infoMenuItem.setFilterText(itemText);
541
653
  infoMenuItem.setFilterPrefix(itemPrefix);
@@ -548,15 +660,26 @@ Ext.define('Coon.report.plugin.grid.AddFilterConditionPlugin', {
548
660
 
549
661
  getColumnGroup() {
550
662
  let columnGroup = this.column && this.column.columnGroup;
551
- columnGroup = Ext.isString(columnGroup) ? columnGroup.replaceAll(';', ' / ') + ' / ': '';
663
+ columnGroup = Ext.isString(columnGroup) ? columnGroup.replaceAll(';', ' / ') + ' / ' : '';
552
664
  return columnGroup;
553
665
  },
554
666
 
667
+ getDefaultOperator(filterType) {
668
+ const selectedRecord = this.getCmp().getContextManager().context.record;
669
+ const headerOperator = !selectedRecord && filterType === 'string' ? 'like' : 'eq';
670
+ if (filterType === 'list') {
671
+ return 'in';
672
+ }
673
+ return this.inHeaderContext ?
674
+ headerOperator :
675
+ !Ext.isEmpty(this.columnValue) ? 'eq' : 'notfilled';
676
+ },
677
+
555
678
  /**
556
679
  * Создать подменю простого фильтра
557
680
  * @param menu
558
681
  */
559
- createSearchMenuItem(menu) {
682
+ createMenuItem(menu) {
560
683
  const currentColumnFilter = this.filters.get(this.getColumnKey());
561
684
  const dataIndex = this.column && this.column.dataIndex;
562
685
  const filterType = this.columnFilterTypes[dataIndex];
@@ -571,13 +694,12 @@ Ext.define('Coon.report.plugin.grid.AddFilterConditionPlugin', {
571
694
  filter.value = currentColumnFilter.value;
572
695
  filter.operator = currentColumnFilter.operator;
573
696
  } else {
574
- filter.value = filterType === 'list' ? [this.columnValue]: this.columnValue;
575
- filter.operator = filterType === 'list' ?
576
- 'in':
577
- Ext.isEmpty(this.columnValue) ? 'notfilled': 'eq';
697
+ filter.value = filterType === 'list' ? [this.columnValue] : this.columnValue;
698
+ filter.operator = this.getDefaultOperator(filterType);
578
699
  }
700
+ filter.inHeaderContext = this.inHeaderContext;
579
701
  if (filterType === 'string') {
580
- filter.useCombo = /* this.filters.size === 0 &&*/ this.canUseCombo();
702
+ filter.useCombo = this.canUseCombo();
581
703
  }
582
704
  const filterWrapPanelCfg = {
583
705
  filterType,
@@ -597,7 +719,10 @@ Ext.define('Coon.report.plugin.grid.AddFilterConditionPlugin', {
597
719
  this.addFilter(dataIndex, condition, value);
598
720
  this.doFilter();
599
721
  this.changeColumnsStyle();
600
- this.grid.contextMenu.hide();
722
+ menuItem.hide();
723
+ if (this.getActiveMenu()) {
724
+ this.getActiveMenu().hide();
725
+ }
601
726
  }, this);
602
727
  menuItem.on('advancedsearch', this.advancedSearch, this);
603
728
  menu.removeAll();
@@ -605,6 +730,19 @@ Ext.define('Coon.report.plugin.grid.AddFilterConditionPlugin', {
605
730
  }
606
731
  },
607
732
 
733
+ /**
734
+ * Возвращает открытое меню (контекстное или меню колонки)
735
+ * @returns {Ext.menu.Menu}
736
+ */
737
+ getActiveMenu() {
738
+ const headerContainer = this.grid.getHeaderContainer();
739
+ if (this.grid.contextMenu.isVisible()) {
740
+ return this.grid.contextMenu;
741
+ } else if (headerContainer && headerContainer.getMenu().isVisible()) {
742
+ return headerContainer.getMenu();
743
+ }
744
+ },
745
+
608
746
  isCancelAllFiltersHidden() {
609
747
  return false;
610
748
  },
@@ -629,5 +767,12 @@ Ext.define('Coon.report.plugin.grid.AddFilterConditionPlugin', {
629
767
  isFilterByCellValueDisabled() {
630
768
  return false;
631
769
  },
770
+ clearColumnContext() {
771
+ this.column = undefined;
772
+ this.columnValue = undefined;
773
+ },
774
+ getHeaderMenu() {
775
+ return this.grid.getHeaderContainer().getMenu();
776
+ },
632
777
  });
633
778