ru.coon 3.0.5 → 3.0.6

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.6, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/d51e8e77fbd516f0652723c1dde07e684d3f0da9)
2
+ * ## Features
3
+ * <span style='color:green'>feat: HT-12083 change ReportFilterForm logic, add xtype: 'coontabpanel</span> ([3cbf03], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/3cbf03a68e6934fc10430705d1c73ac99bd834d7))
4
+
5
+ * update: CHANGELOG.md ([00de7c], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/00de7c83a272fdf985d3627c192c05c1be1e8953))
6
+
1
7
  # Version 3.0.5, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/e0c4d5ae7335ab5af50f01462f36c1de26edf311)
2
8
  * up ([57408c], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/57408cd0e2e46ae1fb908ac0d93623681b4fcff4))
3
9
  * up ([65fcec], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/65fcecf6226bad1b6d533e7b555f23975eb8f0c2))
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "ru.coon"
5
5
  },
6
6
  "description": "",
7
- "version": "3.0.5",
7
+ "version": "3.0.6",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+http://gitlab-dbr.sigma-it.local/dbr/ru.coon"
@@ -0,0 +1,79 @@
1
+ /**
2
+ * @class Coon.TabPanel
3
+ *
4
+ * Добавлен функционал:
5
+ * - Подписка на событие 'tabchange':
6
+ * - установка id активного компонента в activeComponentId и публикация 'activeComponentId' в viewModel (publishState)
7
+ * - установка активного компонент в activeComponent
8
+ * - Подписка на событие 'dirtychange' на все items в coontabpanel,
9
+ * добавляющий/удаляющий дополнительный класс 'tabDirtyCls' у tab.
10
+ *
11
+ * Стилизация вертикальных табов осуществлена добавлением "tabStyle: 'vertical'" в конфигурацию coontabpanel.
12
+ */
13
+ Ext.define('Coon.TabPanel', {
14
+ extend: 'Ext.tab.Panel',
15
+ xtype: 'coontabpanel',
16
+
17
+ config: {
18
+ tabStyle: undefined,
19
+ activeComponent: undefined,
20
+ activeComponentId: undefined,
21
+ },
22
+
23
+ tabDirtyCls: 'tab-dirty',
24
+
25
+ initComponent() {
26
+ this.callParent();
27
+
28
+ if (this.tabStyle === 'vertical') {
29
+ this.setTabPosition('left');
30
+ this.setTabRotation(0);
31
+ this.addCls('coonVerticalTabpanel');
32
+ }
33
+
34
+ this.setCurrentActiveTab();
35
+
36
+ this.on('tabchange', function(panel, newPanel) {
37
+ this.setActiveComponent(newPanel);
38
+ }, this);
39
+
40
+ this.getLayout().getLayoutItems().forEach((tab) => {
41
+ tab.on('dirtychange', this.onCardDirtyChange.bind(this));
42
+ });
43
+ },
44
+
45
+ setCurrentActiveTab() {
46
+ const activeTab = this.getActiveTab();
47
+ this.setActiveComponent(activeTab);
48
+ },
49
+
50
+ /**
51
+ * Установка активного компонента в activeComponent и его id в activeComponentId.
52
+ * Публикация значения activeComponentId в viewModel.
53
+ * @param component
54
+ */
55
+ setActiveComponent(component) {
56
+ if (!component) {
57
+ return;
58
+ }
59
+ this.activeComponent = component;
60
+ this.activeComponentId = component.id;
61
+ this.publishState('activeComponentId', this.activeComponentId);
62
+ },
63
+
64
+ /**
65
+ * Ставит/убирает CSS класс "tabDirtyCls" в зависимости от флага "isDirty" соответствующей табе
66
+ * @param { component: Component, isDirty: boolean }
67
+ */
68
+ onCardDirtyChange(component, isDirty) {
69
+ if (!component.tab) {
70
+ return;
71
+ }
72
+ if (isDirty) {
73
+ component.tab.addCls(this.tabDirtyCls);
74
+ } else {
75
+ component.tab.removeCls(this.tabDirtyCls);
76
+ }
77
+ },
78
+
79
+ });
@@ -1,5 +1,33 @@
1
1
  /**
2
- * Форма динамического отчета
2
+ * Компонент фильтров репорта для разделения ReportPanel на отдельные табы с предустановленными filterDefaults.
3
+ * Начитывает репорт с полученными из фильтр панели параметрами в репорте с id = remoteReportPanelId, учитывая их filterDefaults.
4
+ *
5
+ * Пример использования с xtype = 'coontabpanel':
6
+ * {
7
+ * xtype: 'ReportFilterForm',
8
+ * reportID: 'REPORT_DOC_REG_CREDIT',
9
+ * bind: {
10
+ * remoteReportPanelId: '{remoteReportPanelId}',
11
+ * },
12
+ * },
13
+ * {
14
+ * xtype: 'coontabpanel',
15
+ * bind: {
16
+ * activeComponentId: '{remoteReportPanelId}',
17
+ * },
18
+ * items: [
19
+ * {
20
+ * xtype: 'ReportPanel',
21
+ * reportId: 'REPORT_DOC_REG_CREDIT',
22
+ * filterDefaults: {
23
+ * REG_TYPE: 'HEAT',
24
+ * },
25
+ * ...
26
+ * }
27
+ * ]
28
+ * }
29
+ *
30
+ * Пример кастомной панели с данным функционалом DAA_REPORT_DOC_REG_CREDIT_PANEL
3
31
  **/
4
32
  Ext.define('Coon.report.component.ReportFilterForm', {
5
33
  extend: 'Ext.panel.Panel',
@@ -47,6 +75,7 @@ Ext.define('Coon.report.component.ReportFilterForm', {
47
75
  enableHighlightingRequiredFields: false,
48
76
  enableChipToolbar: false,
49
77
  filtered: false,
78
+ remoteReportPanelId: undefined,
50
79
  },
51
80
  defaults: {
52
81
  split: true,
@@ -56,52 +85,39 @@ Ext.define('Coon.report.component.ReportFilterForm', {
56
85
  items: [],
57
86
  locals: {
58
87
  plugins: new Map(),
88
+ reportCurrentParams: new Map(),
59
89
  },
60
90
 
61
-
62
- getValue() {
63
- return this.value;
64
- },
65
- setValue(values) {
66
- this.value = values;
67
- this.updateFilterDefaults(this.value);
68
- },
69
-
70
- updateReportId() {
71
- if (!Ext.isEmpty(this.reportId)) {
72
- this.configureReport();
91
+ setRemoteReportPanelId(remoteReportPanelId) {
92
+ this.remoteReportPanelId = remoteReportPanelId;
93
+ if (this.filtered) {
94
+ this.filterHandler();
73
95
  } else {
74
- this.clear();
96
+ this.clearData();
75
97
  }
76
98
  },
77
99
 
78
- applyFilterDefaults: function(filterDefaults) {
79
- return Ext.apply({}, filterDefaults || {}, this.getFilterDefaults());
80
- },
81
-
82
- updateFilterDefaults: function(filterDefaults) {
83
- this.applyFilter(filterDefaults);
84
- },
85
-
86
- getWikiContext: function() {
87
- return this.reportId;
88
- },
89
-
90
- beforeDoInitCommand: function() {
91
- let command = undefined;
92
- if (!Ext.isEmpty(this['GET_DATA_COMMAND'])) {
93
- command = Ext.create('command.' + this['GET_DATA_COMMAND']);
94
- }
95
- return command;
96
- },
97
-
98
- beforeApplyFilterCommand: function() {
99
- return undefined;
100
- },
101
-
102
-
103
100
  initComponent: function() {
104
- this.centerProperties = this.centerProperties || {};
101
+ this.reportCurrentParams = new Map();
102
+
103
+ Coon.util.bindMethods([
104
+ 'beforeApplyFilterCommand',
105
+ 'beforeDoInitCommand',
106
+ 'getWikiContext',
107
+ 'updateFilterDefaults',
108
+ 'applyFilterDefaults',
109
+ 'updateReportId',
110
+ 'doInit',
111
+ 'beforeCommandExecuter',
112
+ 'init',
113
+ 'inputParameters',
114
+ 'clearFilter',
115
+ 'reset',
116
+ 'configureNorthPanel',
117
+ 'getPluginConfigByType',
118
+ 'filter',
119
+ 'applyFilter'
120
+ ], Ext.create('Coon.report.component.ReportPanel'), this, this);
105
121
 
106
122
  this.setFilterDefaults(this.getFilterDefaults() || {});
107
123
  this.northPanel = Ext.widget('NorthPanel', {
@@ -150,51 +166,6 @@ Ext.define('Coon.report.component.ReportFilterForm', {
150
166
  this.on('invalidateCache', this.filterHandler.bind(this, true));
151
167
  },
152
168
 
153
-
154
- /**
155
- * Инициализация
156
- * @param reportId - ID отчета
157
- * @param params - дефолтные параметры фильтра поиска в формате {ИМЯ: ЗНАЧЕНИЕ}
158
- * @param autoFilter do Filter immediately after report are configured
159
- */
160
- doInit: function(reportId, params, autoFilter) {
161
- this.beforeCommandExecuter(this.beforeDoInitCommand(this), [reportId || this.reportId, params, autoFilter], function() {
162
- this.init(reportId, params, autoFilter);
163
- });
164
- },
165
-
166
- beforeCommandExecuter: function(beforeCommand, beforeCommandParameters, callback) {
167
- if (beforeCommand && beforeCommand instanceof Coon.command.BaseCommand) {
168
- beforeCommand.on('complete', callback, this);
169
- beforeCommand.execute.apply(beforeCommand, beforeCommandParameters);
170
- } else {
171
- callback.call(this);
172
- }
173
- },
174
-
175
- init: function(reportId, params, autoFilter) {
176
- this.setAutoFilter(Ext.isDefined(autoFilter) ? autoFilter : this.autoFilter);
177
- if (reportId) {
178
- this.reportId = reportId;
179
- this.configureReport();
180
- }
181
- this.updateFilterDefaults(Ext.apply({}, params, this.getFilterDefaults()));
182
-
183
- // hack
184
- if (this.ownerCt && this.ownerCt.isXType && this.ownerCt.isXType('tabpanel')) {
185
- this.updateLayout();
186
- }
187
- },
188
-
189
- inputParameters: function() {
190
- return [
191
- {name: 'reportId'},
192
- {name: 'params'},
193
- {name: 'autoFilter'}
194
- ];
195
- },
196
-
197
-
198
169
  preprocessPlugins(plugins) {
199
170
  return plugins.reduce((acc, plugin) => {
200
171
  if (typeof this.preprocessPluginConfig === 'function') {
@@ -217,34 +188,20 @@ Ext.define('Coon.report.component.ReportFilterForm', {
217
188
  command.execute(this.reportId);
218
189
  },
219
190
 
220
-
221
191
  clear: function() {
222
192
  this.northPanel.clear();
223
193
  this.fireEvent('clear');
224
194
  },
225
195
 
226
-
227
196
  clearForm: function() {
228
197
  this.setFilterDefaults({});
229
198
  this.clearFilter();
230
199
  },
231
200
 
232
- clearFilter: function() {
233
- this.northPanel.clearFilter();
234
- this.fireEvent('clearFilter');
235
- },
236
-
237
-
238
- reset: function() {
239
- this.clearForm();
240
- },
241
-
242
-
243
201
  fillFilter: function(useURIParameters, params) {
244
202
  this.northPanel.fillFilter(useURIParameters, params, this.getFilterDefaults());
245
203
  },
246
204
 
247
-
248
205
  build: function(reportFormBean) {
249
206
  const ns = Coon.report.model.ReportBeanFields;
250
207
 
@@ -264,6 +221,7 @@ Ext.define('Coon.report.component.ReportFilterForm', {
264
221
  this.configurePluginsByAcceptedPTypes(reportFormBean);
265
222
  this.applyFilter();
266
223
  },
224
+
267
225
  configurePluginsByAcceptedPTypes(reportFormBean) {
268
226
  const ns = Coon.report.model.ReportPluginBeanFields;
269
227
  const types = this.getAcceptedPTypes();
@@ -288,81 +246,53 @@ Ext.define('Coon.report.component.ReportFilterForm', {
288
246
  });
289
247
  }
290
248
  },
291
- configureNorthPanel: function(reportFormBean) {
292
- this.northPanel.filterPlugins = this.getPluginConfigByType('FILTER_PLUGIN', 'p');
293
- this.northPanel.configureFilterPanel(reportFormBean);
294
- },
295
249
 
296
- getPluginConfigByType: function(type, prefix, pluginList) {
297
- if (!this.locals.plugins.has(type)) {
298
- return [];
250
+ getRemoteReportPanel(remoteReportPanelId) {
251
+ const id = remoteReportPanelId || this.getRemoteReportPanelId();
252
+ const reportPanel = id && this.up('UiCustomPanel').down(`#${id}`);
253
+ if (!reportPanel || reportPanel.xtype !== 'ReportPanel') {
254
+ return;
299
255
  }
300
- const ns = Coon.report.model.ReportPluginBeanFields;
301
- return this.locals.plugins.get(type).map((plugin) => {
302
- const config = {pluginId: plugin[ns.$uiElement] && plugin[ns.$uiElement].id};
303
- if (plugin[ns.$uiElement].propertyData) {
304
- Ext.apply(config, Coon.Function.convertAdvancedProperties(Ext.decode(plugin[ns.$uiElement].propertyData)));
305
- } else {
306
- Ext.apply(config, Coon.Function.convertAdvancedProperties(plugin[ns.$uiElement].properties || plugin[ns.$properties]));
307
- }
308
- config[prefix + 'type'] = plugin[ns.$uiElement].xtype || plugin[ns.$xtype];
309
- config[ns.$sortSequence] = plugin[ns.$sortSequence] || null;
310
- return config;
311
- });
256
+ return reportPanel;
312
257
  },
313
258
 
314
- applyFilter: function(params) {
315
- if (!this.items.length) {
259
+ filterHandler: function() {
260
+ const remoteReportPanelId = this.getRemoteReportPanelId();
261
+ const reportPanel = this.getRemoteReportPanel(remoteReportPanelId);
262
+ if (!reportPanel || !this.northPanel.isValid()) {
316
263
  return;
317
264
  }
318
- params = params || {};
319
- const parameters = Ext.apply({}, params, this.getFilterDefaults());
320
- const filterPanel = this.down('FilterPanel');
321
- if (filterPanel) {
322
- filterPanel.markFilterFields(this.getFilterDefaults() || {});
323
- }
324
265
 
325
- this.fillFilter(!params.__doNotDecode, parameters);
326
- // Если задано - фильтрация без ожидания ввода параметров
327
- const doFilter = (parameters ? parameters.doFilter : undefined) ||
328
- (Coon.MessageResources.getURIParameter('reportID', false) === this.reportID ?
329
- (Coon.MessageResources.getURIParameter('doFilter', false)) : undefined);
330
- if (this.getAutoFilter() || doFilter === 'true' || doFilter === true) {
331
- this.filterHandler();
332
- }
266
+ const currentParams = Object.fromEntries(this.northPanel.getFields().reduce((acc, field) => {
267
+ if (!field.hidden) {
268
+ acc.push([field.name, field.value || '']);
269
+ }
270
+ return acc;
271
+ }, []));
272
+ const reportParams = this.reportCurrentParams.get(remoteReportPanelId);
333
273
 
334
- const hideFilterPanel = (parameters ? parameters.hideFilterPanel : undefined) ||
335
- (Coon.MessageResources.getURIParameter('reportID', false) === this.reportID ?
336
- Coon.MessageResources.getURIParameter('hideFilterPanel', false) : undefined);
337
- if (hideFilterPanel === 'true') {
338
- this.hideFilterPanel = true;
339
- }
340
- if (this.hideFilterPanel === false) {
341
- this.northPanel.show();
342
- } else if (this.hideFilterPanel === true || this.hideFilterPanel === 'hide') {
343
- const visibleFields = this.query('[validate][isReportFilterField][hidden=false]');
344
- visibleFields.forEach((field) => {
345
- this._visibleFieldsMap.set(field, field.hidden);
346
- field.setHidden(true);
347
- });
348
- this.northPanel.hide();
349
- } else if (this.hideFilterPanel === 'collapse') {
350
- this.northPanel.collapse(false);
274
+ const currentParamsHash = Coon.util.generateHashFromObj(currentParams);
275
+ const reportParamsHash = Coon.util.generateHashFromObj(reportParams);
276
+ if (Ext.isObject(reportParams) && (currentParamsHash === reportParamsHash)) {
277
+ return;
351
278
  }
352
- },
353
279
 
354
- filter: function() {
355
- this.filterHandler();
280
+ this.reportCurrentParams.set(remoteReportPanelId, currentParams);
281
+ this.filtered = true;
282
+
283
+ reportPanel.northPanel.fillFilter(false, currentParams, reportPanel.getFilterDefaults());
284
+ reportPanel.filterHandler();
356
285
  },
357
286
 
358
- filterHandler: function() {
359
- if (this.northPanel.isValid()) {
360
- this.currentParamList = this.northPanel.collectParams();
361
- this.filtered = true;
362
- this.northPanel.fireEvent('filterhandlerevent', this.currentParamList);
363
- this.setValue(this.currentParamList);
364
- this.publishState('value', this.value);
287
+ clearData() {
288
+ this.filtered = false;
289
+ const remoteReportPanelId = this.getRemoteReportPanelId();
290
+ const reportPanel = this.getRemoteReportPanel(remoteReportPanelId);
291
+ if (!reportPanel || !reportPanel.grid) {
292
+ return;
365
293
  }
294
+ reportPanel.grid.clear();
295
+ this.reportCurrentParams.set(remoteReportPanelId, {});
366
296
  },
367
297
 
368
298
  });
package/src/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  Ext.define('Coon.version', {
2
2
  singleton: true,
3
- number: '3.0.5',
3
+ number: '3.0.6',
4
4
  });
@@ -1,36 +0,0 @@
1
- /**
2
- * Override класса 'Ext.tab.Panel'.
3
- * Добавлен функционал:
4
- * - Подписка на событие 'dirtychange' на все items в tabpanel,
5
- * добавляющий/удаляющий дополнительный класс tabDirtyCls у tab.
6
- *
7
- * Стилизация вертикальных табов осуществлена добавлением "cls: 'coonVerticalTabpanel'" в конфигурацию tabpanel.
8
- */
9
- Ext.define('Coon.overrides.panel.TabPanelOverride', {
10
- override: 'Ext.tab.Panel',
11
-
12
- tabDirtyCls: 'tab-dirty',
13
-
14
- initComponent() {
15
- this.callParent();
16
- this.getLayout().getLayoutItems().forEach((tab) => {
17
- tab.on('dirtychange', this.onCardDirtyChange.bind(this));
18
- });
19
- },
20
-
21
- /**
22
- * @param { component: Component, isDirty: boolean }
23
- * Ставит/убирает CSS класс "tabDirtyCls" в зависимости от флага "isDirty" соответствующей табе
24
- */
25
- onCardDirtyChange(component, isDirty) {
26
- if (!component.tab) {
27
- return;
28
- }
29
- if (isDirty) {
30
- component.tab.addCls(this.tabDirtyCls);
31
- } else {
32
- component.tab.removeCls(this.tabDirtyCls);
33
- }
34
- },
35
- });
36
-