ru.coon 3.0.59 → 3.0.61

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.
@@ -5,7 +5,13 @@ Ext.define('Coon.report.plugin.configPanel.ControlColumnByParamPluginConfigPanel
5
5
  requires: [],
6
6
  alternateClassName: 'Sigma.common.plugins.configPanel.ControlColumnByParamPluginConfigPanel',
7
7
 
8
- description: 'Плагин отображает/скрывает колонки в зависимости от параметров',
8
+ description: [
9
+ 'Плагин отображает/скрывает колонки в зависимости от значения параметра',
10
+ 'Варианты указания параметров: ',
11
+ '- Строка (TEST_VALUE)',
12
+ '- Логический (true|false)',
13
+ '- Диапазон (1-5), числа через запятую (1,3,5), одиночное число (5)'
14
+ ].join('<br>'),
9
15
  tags: ['Поведение', 'Отображение', 'Колонки'],
10
16
 
11
17
  config: {
@@ -18,6 +24,8 @@ Ext.define('Coon.report.plugin.configPanel.ControlColumnByParamPluginConfigPanel
18
24
  },
19
25
 
20
26
  createItems: function() {
27
+ const fieldTypeStyle =
28
+ 'opacity:.8;background-color:lightgrey;font-size:.7rem;padding:2px 4px;';
21
29
  this.grid = Ext.create('Coon.report.plugin.configPanel.ControlColumnByParamPluginConfigPanelGrid', {
22
30
  flex: 1,
23
31
  columnNameEditor: this.createFieldColumns({
@@ -25,16 +33,62 @@ Ext.define('Coon.report.plugin.configPanel.ControlColumnByParamPluginConfigPanel
25
33
  name: 'columnName',
26
34
  allowBlank: false,
27
35
  hideLabel: true,
36
+ listConfig: {
37
+ tpl: Ext.create(
38
+ 'Ext.XTemplate',
39
+ '<ul class="x-list-plain"><tpl for=".">',
40
+ '<li role="option" class="x-boundlist-item">',
41
+ `<b>{[values["reportFieldCd"]]}</b> : <i style="${fieldTypeStyle}">{[values["reportFieldTypeLookup"]]}</i>`,
42
+ '<tpl if="description.length">',
43
+ '<div style="opacity:.8;font-size: 1rem;"><i>{[values["description"]]}</i></div>',
44
+ '</tpl>',
45
+ '</li>',
46
+ '</tpl></ul>'
47
+ ),
48
+ },
28
49
  }),
29
50
  paramNameEditor: this.createFieldParameteres({
30
51
  anchor: '100%',
31
52
  name: 'paramName',
32
53
  allowBlank: false,
33
54
  hideLabel: true,
55
+ listConfig: {
56
+ tpl: Ext.create(
57
+ 'Ext.XTemplate',
58
+ '<ul class="x-list-plain"><tpl for=".">',
59
+ '<li role="option" class="x-boundlist-item">',
60
+ `<b>{[values["reportParameterCd"]]}</b> : <i style="${fieldTypeStyle}">{[values["reportParameterTypeLookup"]]}</i>`,
61
+ '<tpl if="description.length">',
62
+ '<div style="opacity:.8;font-size: 1rem;"><i>{[values["description"]]}</i></div>',
63
+ '</tpl>',
64
+ '</li>',
65
+ '</tpl></ul>'
66
+ ),
67
+ },
34
68
  }),
35
69
  });
36
70
  return [
37
- this.grid
71
+ {
72
+ xtype: 'panel',
73
+ items: [
74
+ {
75
+ xtype: 'displayfield',
76
+ value: [
77
+ 'Плагин отображает/скрывает колонки в зависимости от значения параметра',
78
+ 'Варианты указания параметров: ',
79
+ '- Строка (TEST_VALUE)',
80
+ '- Логический (true|false)',
81
+ '- Диапазон (1-5), числа через запятую (1,3,5), одиночное число (5)'
82
+ ].join('\n'),
83
+ style: {
84
+ // fontWeight: 'bold',
85
+ fontSize: '1.2rem',
86
+ margin: '8px',
87
+ },
88
+ },
89
+ this.grid
90
+ ],
91
+ }
38
92
  ];
39
93
  },
40
94
 
@@ -47,7 +47,7 @@ Ext.define('Coon.report.plugin.configPanel.ControlColumnByParamPluginConfigPanel
47
47
  xtype: 'checkcolumn',
48
48
  },
49
49
  {
50
- header: 'Значение параметра',
50
+ header: 'Значение параметра: 1-5 или 1,3,5 или 5',
51
51
  dataIndex: 'paramValue',
52
52
  xtype: 'hintColumn',
53
53
  editor: {xtype: 'textfield'},
@@ -69,11 +69,11 @@ Ext.define('Coon.report.plugin.form.ReportGroupsFieldValidationPlugin', {
69
69
  valid = false;
70
70
  for (const group of groups) {
71
71
  if (this.checkValidityOfGroup(group)) {
72
- // this.fields.forEach((field) => { // Убрать все звездочки
73
- // if (field.setFlagColor && typeof field.setFlagColor === 'function') {
74
- // field.setFlagColor(this.requiredFieldColorState2);
75
- // }
76
- // });
72
+ this.fields.forEach((field) => { // Убрать все звездочки
73
+ if (field.setFlagColor && typeof field.setFlagColor === 'function') {
74
+ field.setFlagColor(this.requiredFieldColorState2);
75
+ }
76
+ });
77
77
  valid = true;
78
78
  break;
79
79
  } else {
@@ -104,7 +104,6 @@ Ext.define('Coon.report.plugin.form.ReportGroupsFieldValidationPlugin', {
104
104
  this.fields.forEach(function(field) { // Поставить все звездочки
105
105
  if (this.isPluginEnabled(field)) {
106
106
  field.setFlagColor(this.requiredFieldColorState2);
107
- field.changeFieldFlag(!valid);
108
107
  }
109
108
  }, this);
110
109
  }
@@ -133,7 +132,6 @@ Ext.define('Coon.report.plugin.form.ReportGroupsFieldValidationPlugin', {
133
132
  valid = false;
134
133
  }
135
134
  if (this.isPluginEnabled(currentField)) {
136
- currentField.changeFieldFlag(Ext.isEmpty(currentField.getValue()));
137
135
  currentField.setFlagColor(Ext.isEmpty(currentField.getValue()) ? this.requiredFieldColorState1 : this.requiredFieldColorState2);
138
136
  }
139
137
  }
@@ -151,7 +149,6 @@ Ext.define('Coon.report.plugin.form.ReportGroupsFieldValidationPlugin', {
151
149
  for (const field of group.children) {
152
150
  const currentField = this.fields.find((element) => element.name === field.reportParameterCd);
153
151
  if (this.isPluginEnabled(currentField)) {
154
- currentField.changeFieldFlag(!valid);
155
152
  currentField.setFlagColor(valid ? this.requiredFieldColorState2 : this.requiredFieldColorState1);
156
153
  }
157
154
  }
@@ -5,7 +5,7 @@ Ext.define('Coon.report.plugin.grid.ControlColumnByParamPlugin', {
5
5
  extend: 'Ext.AbstractPlugin',
6
6
  alias: 'plugin.ControlColumnByParamPlugin',
7
7
  uses: [],
8
- requires: [],
8
+ requires: ['Coon.format'],
9
9
  alternateClassName: [
10
10
  'Sigma.common.grid.plugin.ControlColumnByParamPlugin',
11
11
  'Sigma.common.plugin.grid.ControlColumnByParamPlugin'
@@ -41,45 +41,44 @@ Ext.define('Coon.report.plugin.grid.ControlColumnByParamPlugin', {
41
41
  }
42
42
  },
43
43
 
44
+ matchFilterValue: function(configValue, filterValue, shouldShow) {
45
+ if (typeof filterValue === 'undefined') {
46
+ return !shouldShow;
47
+ }
48
+ if (typeof filterValue === 'boolean') {
49
+ return Boolean(configValue) === filterValue && shouldShow;
50
+ }
51
+ if (String(configValue) === String(filterValue)) {
52
+ return shouldShow;
53
+ }
54
+ const range = Coon.format.stringToNumbersArray(String(configValue));
55
+ return range.includes(filterValue) && shouldShow;
56
+ },
57
+
44
58
  checkColumnsStatus: function() {
45
- const fields = this.grid.up('ReportPanel').filterContainer.query('field')
46
- .filter((field) => field.getValue && field.getValue())
47
- .map((field) => ({name: field.name, value: field.getValue()})) || [];
59
+ const filterValues = this.grid.up('ReportPanel').
60
+ filterContainer.
61
+ query('field').
62
+ filter((field) => field.getValue && field.getValue()).
63
+ reduce((acc, field) => {
64
+ acc[field.name] = field.getValue();
65
+ return acc;
66
+ }, {});
48
67
 
49
- const checkFn = (val, hideAction) => {
50
- return (val === 'false' || val === '0' || !val) ? (hideAction ? 1 : 0): (hideAction ? 0 : 1);
51
- };
68
+ const targetColumns = {};
52
69
 
53
- const columnsActions = this.valueConfig.reduce((acc, item) => {
54
- const columnName = item.columnName;
55
- const paramName = item.paramName;
56
- if (!Ext.isObject(acc[columnName])) {
57
- acc[columnName] = {};
58
- acc[columnName][paramName] = 0;
70
+ for (const {columnName, paramName, paramValue, show} of this.valueConfig) {
71
+ if (typeof targetColumns[columnName] === 'undefined') {
72
+ targetColumns[columnName] = [];
59
73
  }
60
- const filter = fields.filter((f) => f.name === paramName);
61
- const hideAction = item.show === true;
62
- const itemValue = (item.paramValue + '').trim();
74
+ targetColumns[columnName].push(this.matchFilterValue(paramValue, filterValues[paramName], show));
75
+ }
63
76
 
64
- if (!filter.length || !(filter[0].value + '').trim()) {
65
- acc[columnName][paramName] += checkFn(itemValue, hideAction);
66
- } else {
67
- const filterValue = (filter.pop().value + '').trim();
68
- if (itemValue === 'false' || itemValue === '0' || !itemValue) {
69
- acc[columnName][paramName] += checkFn(filterValue, hideAction);
70
- } else {
71
- acc[columnName][paramName] += (filterValue === itemValue) ? (hideAction ? 1 : 0) : (hideAction ? 0 : 1);
72
- }
73
- }
74
- return acc;
75
- }, {});
76
- const me = this;
77
- Object.keys(columnsActions).forEach((columnName) => {
78
- const column = me.grid.getColumns().find((col) => col.dataIndex === columnName);
79
- Object.keys(columnsActions[columnName]).forEach((paramName) => {
80
- column.setHidden(columnsActions[columnName][paramName] > 0);
81
- });
82
- });
77
+ for (const dataIndex in targetColumns) {
78
+ const column = this.grid.getColumns().find((col) => col.dataIndex === dataIndex);
79
+ const shouldHide = !targetColumns[dataIndex].some(Boolean);
80
+ column?.setHidden(shouldHide);
81
+ }
83
82
  },
84
83
 
85
84
  });
@@ -108,6 +108,7 @@ Ext.define('Coon.uielement.component.formchips.FilterConditionToolbarController'
108
108
  const closableFilterCondition = this.getView().getClosableFilterCondition();
109
109
  const fields = this.getAllFields();
110
110
  const cont = this.lookup('chipsContainer');
111
+ let unusableChips = 0;
111
112
  if (cont && fields.length) {
112
113
  fields
113
114
  .sort((a, b) => {
@@ -125,8 +126,11 @@ Ext.define('Coon.uielement.component.formchips.FilterConditionToolbarController'
125
126
  this.getView().fireEvent('chipdelete', field);
126
127
  }, this);
127
128
  cont.add(cmp);
129
+ (field.unusable) && (unusableChips += 1);
128
130
  this.countRemoteChips++;
129
131
  });
132
+
133
+ this.getView().fireEvent('unusableChips', unusableChips);
130
134
  }
131
135
  },
132
136
 
@@ -140,6 +144,7 @@ Ext.define('Coon.uielement.component.formchips.FilterConditionToolbarController'
140
144
  });
141
145
 
142
146
  this.lookup('chipsContainer').add(cmp);
147
+ this.getView().fireEvent('chipCountChange', 0);
143
148
  }
144
149
  },
145
150
 
@@ -169,6 +174,8 @@ Ext.define('Coon.uielement.component.formchips.FilterConditionToolbarController'
169
174
  item.unusable = true;
170
175
  }
171
176
  }
177
+ item.rawValue = found.rawValue;
178
+ item.value = found.value;
172
179
  }
173
180
  ret.push(item);
174
181
  });
package/src/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  Ext.define('Coon.version', {
2
2
  singleton: true,
3
- number: '3.0.59',
3
+ number: '3.0.61',
4
4
  });