mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
75d979abdb
Summary: In a selector table, when a selected row is filtered out of view, linked widgets should update based on the newly selected row. There were a few bugs that contributed to this wrong behavior: - Gridview wasn't subscribing to the current row id, and the row with id 'new' was being converted to the first row - Cursor was keeping track of the currently selected row id, it was hiding a problem behind the proper rowIndex - Undo/redo somehow leveraged the wrong rowId from the cursor during the position restore. The `No data` text was also changed to be more meaningful. Test Plan: Added and updated. Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D3937
28 lines
1.2 KiB
TypeScript
28 lines
1.2 KiB
TypeScript
import {TableData, UIRowId} from 'app/common/TableData';
|
|
|
|
/**
|
|
* Return whether a table (identified by the rowId of its metadata record) should
|
|
* normally be hidden from the user (e.g. as an option in the page-widget picker).
|
|
*/
|
|
export function isHiddenTable(tablesData: TableData, tableRef: UIRowId): boolean {
|
|
const tableId = tablesData.getValue(tableRef, 'tableId') as string|undefined;
|
|
// The `!tableId` check covers the case of censored tables (see isTableCensored() below).
|
|
return !tableId || isSummaryTable(tablesData, tableRef) || tableId.startsWith('GristHidden_');
|
|
}
|
|
|
|
/**
|
|
* Return whether a table (identified by the rowId of its metadata record) is a
|
|
* summary table.
|
|
*/
|
|
export function isSummaryTable(tablesData: TableData, tableRef: UIRowId): boolean {
|
|
return tablesData.getValue(tableRef, 'summarySourceTable') !== 0;
|
|
}
|
|
|
|
// Check if a table record (from _grist_Tables) is censored.
|
|
// Metadata records get censored by clearing certain of their fields, so it's expected that a
|
|
// record may exist even though various code should consider it as hidden.
|
|
export function isTableCensored(tablesData: TableData, tableRef: UIRowId): boolean {
|
|
const tableId = tablesData.getValue(tableRef, 'tableId');
|
|
return !tableId;
|
|
}
|