ru.coon 2.5.39 → 2.5.40

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/.husky/pre-commit CHANGED
File without changes
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # Version 2.5.40, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/5b5d783b6007d6cf16d9f3fb48e203818a0b9c47)
2
+ * ## Fixes
3
+ * <span style='color:red'>fix</span> ([5400c1], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/5400c17b624f78acfa1dbe8c27742e7a1f4b1cc1))
4
+ * <span style='color:red'> Переделан механизм добавления меню в кнопку "Поиск"</span> ([0437f3], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/0437f3f77c410d545f65d75516091db6ba41ad80))
5
+
6
+ * revert to bf9339051130805e551f48ce07bd5bac3d49d140 ([80394d], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/80394d8e7b64a12c3e137d74661c529d6162004c))
7
+ * update: CHANGELOG.md ([14b820], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/14b8208316d9994deafbbd54ccab2fdae4900e74))
8
+
1
9
  # Version 2.5.39, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/197e1a48c71c978b75397d971309a8df6c4eae59)
2
10
  * hotfix ExportReportDataToFilePlugin ([ccdd78], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/ccdd78c5e826fc1c93493e9336bdfb3124b58f44))
3
11
  * update: CHANGELOG.md ([35314e], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/35314ed753380fa21254cf133f068f812e6b5031))
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "ru.coon"
5
5
  },
6
6
  "description": "",
7
- "version": "2.5.39",
7
+ "version": "2.5.40",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+http://gitlab-dbr.sigma-it.local/dbr/ru.coon"
File without changes
File without changes
@@ -26,6 +26,12 @@ Ext.define('Coon.report.component.report.NorthPanel', {
26
26
  text: 'Поиск',
27
27
  }, this.findButtonConfig || {}));
28
28
 
29
+ // arrowVisible is not working, so we need this hack
30
+ this.searchButton['_splitCls'] = this.searchButton.getSplitCls();
31
+ this.searchButton.getSplitCls = function() {
32
+ return this.menu && this.menu.items.length ? this['_splitCls'] : '';
33
+ };
34
+
29
35
  this.clearButton = Ext.widget('button', Ext.apply({
30
36
  ui: 'green-button',
31
37
  text: 'Очистить',
@@ -64,7 +70,7 @@ Ext.define('Coon.report.component.report.NorthPanel', {
64
70
  */
65
71
  this.on('added', function() {
66
72
  this.reportPanel = this.findParentByType('ReportPanel');
67
- this.searchButton.handler = this.reportPanel ? Ext.bind(this.reportPanel.filterHandler, this.reportPanel): Ext.emptyFn;
73
+ this.searchButton.handler = this.reportPanel ? Ext.bind(this.reportPanel.filterHandler, this.reportPanel) : Ext.emptyFn;
68
74
  this.clearButton.handler = Ext.bind(function() {
69
75
  this.clearFilter();
70
76
  this.clearData();
@@ -93,7 +99,7 @@ Ext.define('Coon.report.component.report.NorthPanel', {
93
99
  Ext.merge(this, properties);
94
100
  this.filterPlugins.push({
95
101
  ptype: 'EnterConfirmFormPlugin',
96
- confirmHandler: this.reportPanel ? Ext.bind(this.reportPanel.filterHandler, this.reportPanel): Ext.emptyFn,
102
+ confirmHandler: this.reportPanel ? Ext.bind(this.reportPanel.filterHandler, this.reportPanel) : Ext.emptyFn,
97
103
  });
98
104
 
99
105
  const [enableHighlightingRequiredFields, hiddenLegend] = this.hasPropertiesFilterPanel(reportFormBean.plugins, properties);
@@ -107,7 +113,7 @@ Ext.define('Coon.report.component.report.NorthPanel', {
107
113
  });
108
114
  filterPanel.on('searchbuttontoggle', function(isValid, errorMessage) {
109
115
  this.searchButton.setDisabled(!isValid);
110
- this.searchButton.setTooltip(!isValid ? errorMessage: '');
116
+ this.searchButton.setTooltip(!isValid ? errorMessage : '');
111
117
  }, this);
112
118
  this.filterContainer.removeAll();
113
119
  this.filterContainer.add(filterPanel);
@@ -196,39 +202,19 @@ Ext.define('Coon.report.component.report.NorthPanel', {
196
202
  if (!menuItems.length) {
197
203
  return;
198
204
  }
199
- const btn = this.searchButton;
200
- btn.setMenu(menuItems);
201
- btn.setArrowVisible(true);
202
- return;
203
- // if (this.splitSearchButton) {
204
- // menuItems.forEach((c) => {
205
- // this.splitSearchButton.menu.insert(0,
206
- // c.$className && c.isMenuItem ?
207
- // c :
208
- // Ext.create(Object.assign(c, {xtype: 'menuitem'}))
209
- // );
210
- // });
211
- // } else {
212
- // const btn = this.searchButton;
213
- // if (btn) {
214
- // this.splitSearchButton = Ext.create(
215
- // Object.assign(
216
- // {
217
- // xtype: 'splitbutton',
218
- // handler: btn.handler.bind(btn),
219
- // menu: menuItems,
220
- // },
221
- // btn.initialConfig || {},
222
- // {margin: btn.margin}
223
- // )
224
- // );
225
- // btn.hide();
226
- // btn.ownerCt.items.items.splice(
227
- // btn.ownerCt.items.items.indexOf(btn),
228
- // 0,
229
- // this.splitSearchButton
230
- // );
231
- // }
232
- // }
205
+ const existingMenu = this.searchButton.getMenu();
206
+ if (existingMenu && existingMenu.items.length) {
207
+ for (const menuItem of menuItems) {
208
+ existingMenu.insert(
209
+ 0,
210
+ menuItem.$className && menuItem.isMenuItem ?
211
+ menuItem :
212
+ Ext.create(Object.assign(menuItem, {xtype: 'menuitem'}))
213
+ );
214
+ }
215
+ } else {
216
+ this.searchButton.setMenu(menuItems);
217
+ this.searchButton.btnWrap.addCls(this.searchButton.getSplitCls());
218
+ }
233
219
  },
234
220
  });
@@ -14,39 +14,26 @@ Ext.define('Coon.report.plugin.grid.ExportReportDataToFilePlugin', {
14
14
  },
15
15
 
16
16
  constructor(config) {
17
- // config.invisibleByDefault = config.addToSearchButton === true;
17
+ config.invisibleByDefault = config.addToSearchButton === true;
18
18
  this.callParent(arguments);
19
19
  },
20
20
 
21
-
22
21
  init(grid) {
23
22
  this.callParent([grid]);
24
23
  const format = this.config.exportFileFormat;
25
24
  this.buttonText = this.buttonText || (format && 'Экспорт в ' + format);
26
- // grid.on(
27
- // 'render',
28
- // function() {
29
- // this.report = grid.findParentByType('ReportPanel');
30
- // if (this.getConfig('addToSearchButton') === true) {
31
- // this.report.northPanel.addToSearchButtonMenu({
32
- // text: this.buttonText,
33
- // iconCls: this.buttonIconCls,
34
- // handler: Ext.bind(this.handler, this),
35
- // });
36
- // }
37
- // this.grid = grid;
38
- // }, this,
39
- // {single: true}
40
- // );
41
- this.getDataCommand = Ext.create(
42
- `command.${
43
- format === 'pdf' ?
44
- 'GetPdfReportDataCommand' :
45
- 'GetExcelFromRowsOrReportData'
46
- }`,
47
- {useRawFilterParams: this.getConfig('addToSearchButton') || true}
48
- );
49
- debugger;
25
+ grid.on('render', function() {
26
+ this.report = grid.findParentByType('ReportPanel');
27
+ if (this.getConfig('addToSearchButton') === true) {
28
+ this.report.northPanel.addToSearchButtonMenu({
29
+ text: this.buttonText,
30
+ iconCls: this.buttonIconCls,
31
+ handler: Ext.bind(this.handler, this),
32
+ });
33
+ }
34
+ this.grid = grid;
35
+ }, this);
36
+ this.printPdfCommand = Ext.create('command.GetPdfReportDataCommand', {useRawFilterParams: this.getConfig('addToSearchButton')});
50
37
  },
51
38
 
52
39
  handler: function() {
@@ -54,8 +41,10 @@ Ext.define('Coon.report.plugin.grid.ExportReportDataToFilePlugin', {
54
41
  this.showPanel();
55
42
  } else {
56
43
  this.config.columns = this.config.columnList.map((record) => record.reportField);
57
- this.getSelections();
58
- this.getDataCommand.execute(this.report, this.config);
44
+ this.getRecordsToPrint();
45
+ this.config.exportFileFormat === 'pdf' ?
46
+ this.printPdfCommand.execute(this.report, this.config) :
47
+ this.printExcelFile();
59
48
  }
60
49
  },
61
50
 
@@ -121,8 +110,10 @@ Ext.define('Coon.report.plugin.grid.ExportReportDataToFilePlugin', {
121
110
  title: 'Выводить колонки',
122
111
  });
123
112
  this.win.on('setColumns', function() {
124
- this.getSelections();
125
- this.getDataCommand.execute(this.report, this.config);
113
+ this.getRecordsToPrint();
114
+ this.config.exportFileFormat === 'pdf' ?
115
+ this.printPdfCommand.execute(this.report, this.config) :
116
+ this.printExcelFile();
126
117
  this.win.close();
127
118
  }, this);
128
119
  this.win.show();
@@ -133,24 +124,60 @@ Ext.define('Coon.report.plugin.grid.ExportReportDataToFilePlugin', {
133
124
  },
134
125
 
135
126
  setColumns: function() {
136
- const selectedColumns = this.columnsGrid.getStore().queryRecords('checkbox', true);
137
- if (!selectedColumns.length) {
127
+ const checkedRecords = this.columnsGrid.getStore().queryRecords('checkbox', true);
128
+ if (!checkedRecords.length) {
138
129
  return;
139
130
  }
140
- this.config.columns = selectedColumns.map((record) => record.get('reportField'));
131
+ this.config.columns = checkedRecords.map((record) => record.get('reportField'));
141
132
  this.win.fireEvent('setColumns');
142
133
  },
143
134
 
144
- getSelections: function() {
145
- const rows = this.grid.getSelectionModel().getSelection();
146
- if (rows.length > 0) {
147
- this.config.toExcel = [];
148
- for (const row of rows.length) {
149
- const rowData = Object.assign({}, row.getData());
150
- delete rowData['id'];
151
- this.config.toExcel.push(rowData);
135
+ getSelectedRecords() {
136
+ return this.grid.getSelectionModel().getSelection();
137
+ },
138
+
139
+ getRecordsToPrint: function() {
140
+ this.config.toExcel = [];
141
+ const selectedRecords = this.getSelectedRecords();
142
+ const records = selectedRecords.length ? selectedRecords : this.grid.getStore().getRange();
143
+
144
+ records.forEach((rec) => {
145
+ const recData = rec.getData();
146
+ delete recData['id'];
147
+ this.config.toExcel.push(recData);
148
+ });
149
+ },
150
+
151
+ printExcelFile: async function() {
152
+ const fileName = this.config.reportFileName || this.report.reportId || 'defaultReportName';
153
+ const currentParamList = this.report.currentParamList;
154
+ const parameterList = [];
155
+
156
+ for (const key in currentParamList) {
157
+ if (currentParamList.hasOwnProperty(key) && !Ext.isEmpty(currentParamList[key])) {
158
+ parameterList.push({type: key, value: currentParamList[key]});
152
159
  }
153
160
  }
161
+
162
+ const hasSelected = !!(this.getSelectedRecords() || []).length;
163
+ const url = hasSelected && !this.getConfig('addToSearchButton') ?
164
+ '/ReportFormData/getExcelFromRowsOrReport' :
165
+ '/ReportFormData/getExcelReport';
166
+
167
+ Ext.Ajax.request({
168
+ url,
169
+ method: 'POST',
170
+ binary: true,
171
+ params: {
172
+ reportId: this.report.reportId,
173
+ fileName: fileName,
174
+ appendDateToFileName: Ext.isBoolean(this.config.appendDateToFileName) ? this.config.appendDateToFileName : true,
175
+ parameterList: JSON.stringify(parameterList),
176
+ columnList: JSON.stringify(this.config.columns),
177
+ toExcel: JSON.stringify(this.config.toExcel),
178
+ },
179
+ success: (responce) => Coon.util.downloadFileFromBlob(new Blob([responce.responseBytes]), `${fileName}.xlsx`),
180
+ });
154
181
  },
155
182
 
156
183
  });
package/src/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  Ext.define('Coon.version', {
2
2
  singleton: true,
3
- number: '2.5.39',
3
+ number: '2.5.40',
4
4
  });