mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Filter menu show all options for Bool/Choice/Choice List columns
Summary: > Toggle, Choice, and Choice List need all possible values available in filter, not just values present in current records https://grist.quip.com/cjw4A8AHx1vh/Filtering-Improvements#temp:C:PZHc42e8be8cd8547bb8ce93fdb0 Test Plan: Adds new nbrowser test Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D3436
This commit is contained in:
@@ -29,6 +29,10 @@ export class ColumnFilter extends Disposable {
|
||||
this.setState(_initialFilterJson);
|
||||
}
|
||||
|
||||
public get columnType() {
|
||||
return this._columnType;
|
||||
}
|
||||
|
||||
public setState(filterJson: string|FilterSpec) {
|
||||
const state = makeFilterState(filterJson);
|
||||
this._include = state.include;
|
||||
|
||||
@@ -22,10 +22,10 @@ export class ColumnFilterMenuModel extends Disposable {
|
||||
// computes a set of all keys that matches the search text.
|
||||
public readonly filterSet = Computed.create(this, this.searchValue, (_use, searchValue) => {
|
||||
const searchRegex = new RegExp(escapeRegExp(searchValue), 'i');
|
||||
const showAllOptions = ['Bool', 'Choice', 'ChoiceList'].includes(this.columnFilter.columnType!);
|
||||
return new Set(
|
||||
this._valueCount
|
||||
.filter(([_, {count}]) => count)
|
||||
.filter(([_, {label}]) => searchRegex.test(label))
|
||||
.filter(([_, {label, count}]) => (showAllOptions ? true : count) && searchRegex.test(label))
|
||||
.map(([key]) => key)
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user