flameresttable 1.0.44 → 1.0.46

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flameresttable",
3
- "version": "1.0.44",
3
+ "version": "1.0.46",
4
4
  "main": "./src/plugin.ts",
5
5
  "repository": {
6
6
  "type": "git",
@@ -205,15 +205,16 @@ export default class FlameTable<T> {
205
205
  /**
206
206
  * Обновить результаты от RESTа
207
207
  * @param CustomLoadParams Применить кастомные параметры загрузки
208
+ * @param exportFilename имя файла для экспорта, если указано, данные будут выгружены
208
209
  */
209
- public async update(CustomLoadParams: ITableLoadParams = {}, isFile = false) {
210
+ public async update(CustomLoadParams: ITableLoadParams = {}, exportFilename: string | null = null) {
210
211
 
211
212
  // Дополняем загрузочные параметры фильтрами
212
213
  const filters = merge(this.applyFiltersParams(), CustomLoadParams);
213
214
 
214
215
  const rows: Rows<T> = await (this.model as any).constructor.all(merge({}, this.opts.LoadParams, filters, { page: this.Pager.page, perPage: this.Pager.perPage }));
215
216
 
216
- if (!isFile)
217
+ if (exportFilename === null)
217
218
 
218
219
  // Строки: загружаем
219
220
  this.load(rows);
@@ -223,7 +224,7 @@ export default class FlameTable<T> {
223
224
  const url = window.URL.createObjectURL((rows as any).data);
224
225
  const a = document.createElement('a');
225
226
  a.href = url;
226
- a.download = 'file.xlsx';
227
+ a.download = exportFilename;
227
228
  document.body.appendChild(a);
228
229
  a.click();
229
230
  window.URL.revokeObjectURL(url);
@@ -415,7 +416,13 @@ export default class FlameTable<T> {
415
416
  * @returns
416
417
  */
417
418
  public getSelectedRows() {
418
- return this.Rows.rows.filter((r: any) => r.selected).map((r: any) => r.item);
419
+ const res = [];
420
+ for (const key in this.RowsParams) {
421
+ const el = this.RowsParams[key];
422
+ if (el.selected)
423
+ res.push(el.item)
424
+ }
425
+ return res;
419
426
  }
420
427
 
421
428
  /**
@@ -490,7 +497,7 @@ export default class FlameTable<T> {
490
497
  }
491
498
 
492
499
  // Делаем запрос на отдачу
493
- this.update(customFilter, true);
500
+ this.update(customFilter, customFilter.export.filename ?? null);
494
501
 
495
502
  }
496
503
 
@@ -115,7 +115,7 @@ const selectAction = () => {
115
115
  case 0:
116
116
  break;
117
117
  case 1:
118
- state.Table.exportToXLS();
118
+ state.Table.exportToXLS(true);
119
119
  break;
120
120
  case 2:
121
121
  state.Table.exportToXLS();