mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Ref columns weren't filtered on csv/excel export for sections.
Summary: Ref columns weren't filtred on section export. Filters were applied to a display helper columns instead of the actual columns. Test Plan: Updated tests Reviewers: alexmojaki Reviewed By: alexmojaki Subscribers: alexmojaki Differential Revision: https://phab.getgrist.com/D3644
This commit is contained in:
parent
792565976a
commit
198beaab2a
@ -273,10 +273,7 @@ export async function exportSection(
|
||||
const displayCol = tableColsById[field?.displayCol || col.displayCol || col.id];
|
||||
const colWidgetOptions = gutil.safeJsonParse(col.widgetOptions, {});
|
||||
const fieldWidgetOptions = field ? gutil.safeJsonParse(field.widgetOptions, {}) : {};
|
||||
const filterString = unsavedFiltersByColRef[col.id]?.filter || savedFiltersByColRef[col.id]?.filter;
|
||||
const filterFunc = buildColFilter(filterString, col.type);
|
||||
return {
|
||||
filterFunc,
|
||||
id: displayCol.id,
|
||||
colId: displayCol.colId,
|
||||
label: col.label,
|
||||
@ -285,9 +282,19 @@ export async function exportSection(
|
||||
widgetOptions: Object.assign(colWidgetOptions, fieldWidgetOptions),
|
||||
};
|
||||
};
|
||||
const tableColumns = columns
|
||||
const buildFilters = (col: GristTablesColumn, field?: GristViewsSectionField) => {
|
||||
const filterString = unsavedFiltersByColRef[col.id]?.filter || savedFiltersByColRef[col.id]?.filter;
|
||||
const filterFunc = buildColFilter(filterString, col.type);
|
||||
return {
|
||||
filterFunc,
|
||||
id: col.id,
|
||||
colId: col.colId,
|
||||
type: col.type,
|
||||
};
|
||||
};
|
||||
const columnsForFilters = columns
|
||||
.filter(column => !gristTypes.isHiddenCol(column.colId))
|
||||
.map(column => viewify(column, fieldsByColRef[column.id]));
|
||||
.map(column => buildFilters(column, fieldsByColRef[column.id]));
|
||||
const viewColumns = _.sortBy(fields, 'parentPos')
|
||||
.map((field) => viewify(tableColsById[field.colRef], field));
|
||||
|
||||
@ -313,9 +320,9 @@ export async function exportSection(
|
||||
sorter.updateSpec(sortSpec);
|
||||
rowIds.sort((a, b) => sorter.compare(a, b));
|
||||
// create cell accessors
|
||||
const tableAccess = tableColumns.map(col => getters.getColGetter(col.id)!);
|
||||
const tableAccess = columnsForFilters.map(col => getters.getColGetter(col.id)!);
|
||||
// create row filter based on all columns filter
|
||||
const rowFilter = tableColumns
|
||||
const rowFilter = columnsForFilters
|
||||
.map((col, c) => buildRowFilter(tableAccess[c], col.filterFunc))
|
||||
.reduce((prevFilter, curFilter) => (id) => prevFilter(id) && curFilter(id), () => true);
|
||||
// filter rows numbers
|
||||
|
Loading…
Reference in New Issue
Block a user