(core) Add cell selection summary

Summary:
Adds a cell selection summary to grid view that shows either a count or
sum of all the selected values. Implementation was done by Dmitry.

Test Plan: Browser tests.

Reviewers: jarek

Reviewed By: jarek

Subscribers: paulfitz, dsagal, jarek

Differential Revision: https://phab.getgrist.com/D3630
This commit is contained in:
George Gevoian
2022-09-29 09:32:54 -07:00
parent 433e1ecfc2
commit 364610c69d
12 changed files with 814 additions and 371 deletions

View File

@@ -169,18 +169,24 @@ export class TableData extends ActionDispatcher implements SkippableRows {
return this._rowMap.has(rowId);
}
/**
* Returns the index of the given rowId, if it exists, in the same unstable order that's
* returned by getRowIds() and getColValues().
*/
public getRowIdIndex(rowId: UIRowId): number|undefined {
return this._rowMap.get(rowId as number);
}
/**
* Given a column name, returns a function that takes a rowId and returns the value for that
* column of that row. The returned function is faster than getValue() calls.
*/
public getRowPropFunc(colId: string): UIRowFunc<CellValue|undefined> {
const colData = this._columns.get(colId);
if (!colData) { return () => undefined; }
const values = colData.values;
const rowMap = this._rowMap;
return (rowId: UIRowId) => {
const colData = this._columns.get(colId);
if (!colData) { return undefined; }
const values = colData.values;
return values[rowMap.get(rowId as number)!];
};
return (rowId: UIRowId) => values[rowMap.get(rowId as number)!];
}
// By default, no rows are skippable, all are kept.