ru.coon 2.7.3 → 2.7.4

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.
@@ -1,6 +1,3 @@
1
- /**
2
- * Для правильного инстанцирования компонента в кастомной панели нужно чтобы панель, содержащая поля формы поиска, имела itemId searchFormItemId.
3
- */
4
1
  Ext.define('Coon.uielement.component.formchips.FilterConditionToolbarController', {
5
2
  extend: 'Ext.app.ViewController',
6
3
  alias: 'controller.filterconditiontoolbarcontroller',
@@ -9,18 +6,12 @@ Ext.define('Coon.uielement.component.formchips.FilterConditionToolbarController'
9
6
  * Поля формы, используемые для поиска
10
7
  */
11
8
  lastSearchFields: [],
12
- /**
13
- * По этому itemId тулбар будет управлять сворачиванием формы Поиска
14
- */
15
- searchFormItemId: 'searchFormItemId',
16
-
17
9
  initToolbar: function() {
18
- const reportPanel = this.getView().findParentByType('ReportPanel');
19
-
10
+ const reportPanel = this.getView().up('ReportPanel');
20
11
  if (reportPanel) { // В репорте
21
12
  this.searchForm = reportPanel.northPanel;
22
13
  this.getView().on('rememberconditions', function() {
23
- this.setLastSearchFields(this.getCompletedFields(this.getFilterPanel()));
14
+ this.setLastSearchFields(this.getCompletedFields(reportPanel.down('FilterPanel')));
24
15
  this.onReloadChipsHandler();
25
16
  }, this);
26
17
 
@@ -39,41 +30,28 @@ Ext.define('Coon.uielement.component.formchips.FilterConditionToolbarController'
39
30
 
40
31
  reportPanel.on('clearFilter', this.onReportFilterClear, this);
41
32
  } else { // Реализация в кастомной панели
42
- const mainPanel = this.getView().up();
43
- this.searchForm = mainPanel ? mainPanel.query(`#${this.searchFormItemId}`)[0]: undefined;
44
- this.getView().show();
45
- if (mainPanel) {
46
- mainPanel.addTool(this.getTool());
47
- } else {
48
- Coon.log.error('Для инициализации чип панели не найден контейнер формы или родительский контейнер');
49
- }
50
- // Слушаем событие, чтобы запомнить критерии поиска.
51
- this.getView().on('rememberconditions', function() {
52
- this.setLastSearchFields(this.getCompletedFields(this.searchForm));
53
- this.onReloadChipsHandler();
54
- }, this);
55
-
56
- this.addChangeReaction();
33
+ Coon.log.warn('Вне репорта компонент пока не используется');
57
34
  }
58
35
 
59
- this.searchForm.on('hide', function() {
60
- this.toggleButtons(false);
61
- }, this);
36
+ if (this.searchForm) {
37
+ this.searchForm.on('hide', function() {
38
+ this.toggleButtons(false);
39
+ }, this);
62
40
 
63
- this.searchForm.on('show', function() {
64
- this.toggleButtons(true);
65
- }, this);
41
+ this.searchForm.on('show', function() {
42
+ this.toggleButtons(true);
43
+ }, this);
44
+ }
66
45
  },
67
46
 
68
47
  addChangeReaction: function() {
48
+ if (!this.searchForm) {
49
+ return;
50
+ }
69
51
  let fields = this.searchForm.query('field');
70
52
  fields = (fields || []).concat(this.searchForm.query('fieldcontainer'));
71
53
  fields.forEach(function(field) {
72
- field.on('change', function(field) {
73
- if (!this.usedForLastSearch(field)) {
74
- this.onReloadChipsHandler();
75
- }
76
- }, this);
54
+ field.on('change', this.onReloadChipsHandler, this, {buffer: 1000});
77
55
  }, this);
78
56
  },
79
57
 
@@ -85,13 +63,6 @@ Ext.define('Coon.uielement.component.formchips.FilterConditionToolbarController'
85
63
  this.lastSearchFields = fields;
86
64
  },
87
65
 
88
- usedForLastSearch: function(field) {
89
- const id = field.id;
90
- const value = field.value;
91
- const found = (this.lastSearchFields || []).find((f) => f.fieldLink.id === id && f.value === value);
92
- return !!found;
93
- },
94
-
95
66
  /**
96
67
  * Добавляем иконку-кнопку в хедер для коллапсирования панели поиска
97
68
  */
@@ -120,28 +91,24 @@ Ext.define('Coon.uielement.component.formchips.FilterConditionToolbarController'
120
91
  return eyeTool;
121
92
  },
122
93
 
123
- getFilterPanel() {
124
- if (!this.filterPanel) {
125
- const reportPanel = this.getView().findParentByType('ReportPanel');
126
- this.filterPanel = reportPanel && reportPanel.down('FilterPanel');
127
- }
128
-
129
- return this.filterPanel;
130
- },
131
-
132
94
  /**
133
95
  * Работает только когда компонент встроен в UI панель.
134
96
  * @param tool
135
97
  */
136
98
  toggleFilterPanel: function(tool) {
137
- const newState = !this.searchForm.isHidden();
138
- if (this.searchForm.isHidden()) {
99
+ if (!this.searchForm) {
100
+ return;
101
+ }
102
+ const isHiddenState = this.searchForm.isHidden();
103
+ const newState = !isHiddenState;
104
+ if (isHiddenState) {
139
105
  tool.setIconCls('x-fa fa-eye-slash');
140
106
  tool.setTooltip(tool.tooltipTexts.show);
141
107
  } else {
142
108
  tool.setIconCls('x-fa fa-eye');
143
109
  tool.setTooltip(tool.tooltipTexts.hide);
144
110
  }
111
+
145
112
  this.searchForm.setHidden(newState);
146
113
  },
147
114
 
@@ -185,7 +152,7 @@ Ext.define('Coon.uielement.component.formchips.FilterConditionToolbarController'
185
152
  const cmp = new Coon.uielement.component.formchips.Chip({
186
153
  service: true,
187
154
  data: {
188
- value: 'Нет критериев поиска',
155
+ rawValue: 'Нет критериев поиска',
189
156
  },
190
157
  });
191
158
 
@@ -211,8 +178,14 @@ Ext.define('Coon.uielement.component.formchips.FilterConditionToolbarController'
211
178
  // очистили поле
212
179
  item.unusable = true;
213
180
  } else {
214
- if (item.value !== found.value) {
215
- item.unusable = true;
181
+ if (Array.isArray(found.fieldLink.value)) {
182
+ if (JSON.stringify(item.value.sort()) !== JSON.stringify(found.fieldLink.value.sort())) {
183
+ item.unusable = true;
184
+ }
185
+ } else {
186
+ if (item.rawValue !== found.rawValue) {
187
+ item.unusable = true;
188
+ }
216
189
  }
217
190
  }
218
191
  ret.push(item);
@@ -252,14 +225,18 @@ Ext.define('Coon.uielement.component.formchips.FilterConditionToolbarController'
252
225
  return {
253
226
  fieldLink: f,
254
227
  label: f.fieldLabel,
255
- value: value,
228
+ rawValue: value,
229
+ value: f.getValue(),
256
230
  };
257
231
  });
258
232
 
259
- return retFields.filter((f) => !!f.value);
233
+ return retFields.filter((f) => !!f.rawValue);
260
234
  },
261
235
 
262
236
  onReloadChipsHandler() {
237
+ if (!this.searchForm) {
238
+ return;
239
+ }
263
240
  this.removeAllChips();
264
241
  this.fillChipsHandler();
265
242
  },
package/src/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  Ext.define('Coon.version', {
2
2
  singleton: true,
3
- number: '2.7.3',
3
+ number: '2.7.4',
4
4
  });