mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Linking summary tables grouped by list columns
Summary:
Prefix keys of `LinkingState.filterColValues` with `_contains:` when the source column is a ChoiceList or ReferenceList.
This is parsed out to make a boolean `isContainsFilter` which is kept in each value of `QueryRefs.filterTuples` (previously `filterPairs`).
Then when converting back in `convertQueryFromRefs` we construct `Query.contains: {[colId: string]: boolean}`.
Finally `getFilterFunc` uses `Query.contains` to decide what kind of filtering to do.
This is not pretty, but the existing code is already very complex and it was hard to find something that wouldn't require touching loads of code just to make things compile.
Test Plan: Added a new nbrowser test and fixture, tests that selecting a source table by summary tables grouped by a choicelist column, non-list column, and both all filter the correct data.
Reviewers: dsagal
Reviewed By: dsagal
Differential Revision: https://phab.getgrist.com/D2940
This commit is contained in:
@@ -62,16 +62,33 @@ export interface ImportTableResult {
|
||||
* {tableId: "Projects", filters: {}}
|
||||
* {tableId: "Employees", filters: {Status: ["Active"], Dept: ["Sales", "HR"]}}
|
||||
*/
|
||||
export interface Query {
|
||||
interface BaseQuery {
|
||||
tableId: string;
|
||||
filters: {
|
||||
[colId: string]: any[];
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Query that can only be used on the client side.
|
||||
* Allows filtering with more complex operations.
|
||||
*/
|
||||
export interface ClientQuery extends BaseQuery {
|
||||
operations?: {
|
||||
[colId: string]: QueryOperation;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Query intended to be sent to a server.
|
||||
*/
|
||||
export interface ServerQuery extends BaseQuery {
|
||||
// Queries to server for onDemand tables will set a limit to avoid bringing down the browser.
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
export type QueryOperation = "in" | "intersects";
|
||||
|
||||
/**
|
||||
* Response from useQuerySet(). A query returns data AND creates a subscription to receive
|
||||
* DocActions that affect this data. The querySubId field identifies this subscription, and must
|
||||
@@ -113,7 +130,7 @@ export interface ActiveDocAPI {
|
||||
* docActions that affect this query's results. The subscription remains functional even when
|
||||
* tables or columns get renamed.
|
||||
*/
|
||||
useQuerySet(query: Query): Promise<QueryResult>;
|
||||
useQuerySet(query: ServerQuery): Promise<QueryResult>;
|
||||
|
||||
/**
|
||||
* Removes the subscription to a Query, identified by QueryResult.querySubId, so that the
|
||||
|
||||
Reference in New Issue
Block a user