mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Allows range filter for Date, DateTime columns
Summary: This diff is first of a series of 3 commits to enable range filering for Date and DateTime columns. Diff only enable setting date's min/max throw typing dates, Date picker and relative ranges are left for follow-up commits. - Exposes columns value formatter to the range input - Fixes column filter func to work with dates Test Plan: Adds Date to projects range filter test Adds Date/DateTime to nbrowser ColumnFilterMenu tests Reviewers: alexmojaki Reviewed By: alexmojaki Subscribers: alexmojaki Differential Revision: https://phab.getgrist.com/D3455
This commit is contained in:
@@ -37,7 +37,7 @@ export class SectionFilter extends Disposable {
|
||||
const columnFilterFunc = Computed.create(this, this._openFilterOverride, (use, openFilter) => {
|
||||
const openFilterFilterFunc = openFilter && use(openFilter.colFilter.filterFunc);
|
||||
function getFilterFunc(fieldOrColumn: ViewFieldRec|ColumnRec, colFilter: ColumnFilterFunc|null) {
|
||||
if (openFilter?.colRef === fieldOrColumn.getRowId()) {
|
||||
if (openFilter?.colRef === fieldOrColumn.origCol().getRowId()) {
|
||||
return openFilterFilterFunc;
|
||||
}
|
||||
return colFilter;
|
||||
|
||||
@@ -221,12 +221,8 @@ export interface CustomViewSectionDef {
|
||||
}
|
||||
|
||||
// Information about filters for a field or hidden column.
|
||||
// TODO: It looks like that it is not needed for FilterInfo to support ViewFieldRec anymore (db
|
||||
// _grist_Filters explicitely maintain a reference to _grist_Tables_column, not
|
||||
// _grist_Views_section_field). And it has caused a bug (due to mismatching a viewField id against a
|
||||
// column id).
|
||||
export interface FilterInfo {
|
||||
// The field or column associated with this filter info.
|
||||
// The field or column associated with this filter info (field if column is visible, else column).
|
||||
fieldOrColumn: ViewFieldRec|ColumnRec;
|
||||
// Filter that applies to this field/column, if any.
|
||||
filter: modelUtil.CustomComputed<string>;
|
||||
@@ -337,6 +333,7 @@ export function createViewSectionRec(this: ViewSectionRec, docModel: DocModel):
|
||||
*/
|
||||
this.filters = this.autoDispose(ko.computed(() => {
|
||||
const savedFiltersByColRef = new Map(this._savedFilters().all().map(f => [f.colRef(), f]));
|
||||
const viewFieldsByColRef = new Map(this.viewFields().all().map(f => [f.origCol().getRowId(), f]));
|
||||
|
||||
return this.columns().map(column => {
|
||||
const savedFilter = savedFiltersByColRef.get(column.origColRef());
|
||||
@@ -351,9 +348,9 @@ export function createViewSectionRec(this: ViewSectionRec, docModel: DocModel):
|
||||
|
||||
return {
|
||||
filter,
|
||||
fieldOrColumn: column,
|
||||
fieldOrColumn: viewFieldsByColRef.get(column.origColRef()) ?? column,
|
||||
isFiltered: ko.pureComputed(() => filter() !== '')
|
||||
} as FilterInfo;
|
||||
};
|
||||
});
|
||||
}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user