(core) Duplicate page should copy filters.

Summary: Duplicate page also copies filters for all sections.

Test Plan: nbrowser tests

Reviewers: cyprien, alexmojaki

Reviewed By: cyprien, alexmojaki

Subscribers: alexmojaki

Differential Revision: https://phab.getgrist.com/D3203
This commit is contained in:
Jarosław Sadziński
2022-01-04 12:54:06 +01:00
parent 52d3f63203
commit 50821f655d
3 changed files with 61 additions and 35 deletions

View File

@@ -3,7 +3,7 @@
*/
// Some definitions have moved to be part of plugin API.
import { CellValue } from 'app/plugin/GristData';
import { CellValue, RowRecord } from 'app/plugin/GristData';
export { CellValue, RowRecord } from 'app/plugin/GristData';
// Part of a special CellValue used for comparisons, embedding several versions of a CellValue.
@@ -182,3 +182,23 @@ export function fromTableDataAction(tableData: TableDataAction): TableColValues
const colValues: BulkColValues = tableData[3];
return {id: rowIds, ...colValues};
}
/**
* Convert a list of rows into an object with columns of values, used for
* BulkAddRecord/BulkUpdateRecord actions.
*/
export function getColValues(records: RowRecord[]): BulkColValues {
const colIdSet = new Set<string>();
for (const r of records) {
for (const c of Object.keys(r)) {
if (c !== 'id') {
colIdSet.add(c);
}
}
}
const result: BulkColValues = {};
for (const colId of colIdSet) {
result[colId] = records.map(r => r[colId]);
}
return result;
}