Skip to content

feat(list): config-driven filters + working date range on any doctype - #10

Closed
jcfrei wants to merge 1 commit into
masterfrom
feat/list-filters
Closed

feat(list): config-driven filters + working date range on any doctype#10
jcfrei wants to merge 1 commit into
masterfrom
feat/list-filters

Conversation

@jcfrei

@jcfrei jcfrei commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Why

Surfaced by the internal CRM's Lead list, where the generic document list's filter bar was wrong in two ways:

  1. The status dropdown made no sense. It's hardcoded to Draft / Submitted / Cancelled (docstatus labels). Leads aren't submittable — Lead.status is a business field (New / Contacted / Responded / …), so picking "Draft" matched zero rows.
  2. The date pickers did nothing. from_date/to_date filter against a hardcoded server-side DATE_FIELDS map that only knows the built-in core doctypes. "Lead" isn't in it, so the range was silently dropped.

Both live in core because the Lead list is the generic DocumentList + generic list endpoint.

What

  • listFilters — a doctype config may declare listFilters: string[]: select fields rendered as dropdowns above the list, each selection sent as a plain column filter (status=Contacted, fit=A) via the ad-hoc column-filter path added in 0.6.0. When set, these replace the default status dropdown; omit it and every existing doctype is unchanged. No backend change.
  • date_field — the frontend now passes its declared dateField as a date_field query param. The backend honors it when it names a real column (falling back to the DATE_FIELDS map otherwise, and degrading to no date filter — never a 400 — for a synthetic dateField). Validated against live columns before it touches SQL. Applies to list, count, and prev/next (DocPager) alike, so a filtered list and its DocPager stay in sync.

Tests

tests/test_adjacent.py gains date_field coverage: list + count + adjacent honor an explicit date column, the unmapped-doctype case is ignored, and a bogus date_field degrades gracefully instead of 400-ing. Full suite green on SQLite; CI runs it on Postgres too.

🤖 Generated with Claude Code

Two fixes to the generic document list, both surfaced by the internal CRM's
Lead list — where the built-in Draft/Submitted/Cancelled status dropdown is
meaningless (Lead.status is a business field, not a docstatus) and the date
pickers did nothing.

- listFilters: a doctype config may declare `listFilters: string[]` — select
  fields rendered as dropdowns whose selection is sent as a plain column
  filter (status=Contacted, fit=A), via the ad-hoc filter path from 0.6.0.
  When set they replace the default status dropdown; omit to keep it. No
  backend change; existing doctypes unchanged.

- date_field: from_date/to_date filtered against a hardcoded server DATE_FIELDS
  map that only knew core doctypes, so a plugin doctype's date pickers were
  silently dropped. The frontend now passes its declared dateField as a
  `date_field` param; the backend honors it when it's a real column (map
  fallback otherwise; degrades to no date filter, never a 400, for a synthetic
  field). Validated against live columns before touching SQL. Applies to list,
  count, and prev/next (DocPager) alike.

tests/test_adjacent.py gains date_field coverage (list/count/adjacent + the
graceful-degrade path). Full suite green on SQLite; CI covers Postgres.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
jcfrei added a commit that referenced this pull request Jul 29, 2026
feat(list): config-driven filters + working date range on any doctype (#10)

- listFilters config option → dropdowns from a field's select options, sent as
  column filters; replaces the default Draft/Submitted/Cancelled status dropdown
  where opted in. No backend change; existing doctypes unchanged.
- date_field: frontend passes its declared dateField so from_date/to_date filter
  the right column on any doctype (list, count, and DocPager prev/next), instead
  of only the hardcoded core DATE_FIELDS map. Validated against live columns;
  degrades to no date filter for a synthetic field rather than 400-ing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jcfrei

jcfrei commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Squash-merged into master as e231076 and released as v0.6.6.

@jcfrei jcfrei closed this Jul 29, 2026
@jcfrei
jcfrei deleted the feat/list-filters branch July 29, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant