Skip to content

feat(runtime): per-page default Period via daterange "default" - #37

Merged
lukaisailovic merged 1 commit into
mainfrom
feat/page-default-period
Jun 25, 2026
Merged

feat(runtime): per-page default Period via daterange "default"#37
lukaisailovic merged 1 commit into
mainfrom
feat/page-default-period

Conversation

@lukaisailovic

Copy link
Copy Markdown
Owner

What

Page-level daterange filters can now declare a default period. Until now every page opened on All time with no way to set a per-page default.

A daterange filter gains an optional default:

{ "id": "period", "type": "daterange", "label": "Period",
  "bind": { "transactions": "ts" }, "default": "last-90-days" }

One of today, last-7-days, last-30-days, last-90-days, this-month, last-month — the same set already offered by the date-range control's presets.

Behavior

  • When the URL sets no range, the page opens on the default, resolved live against today so it never goes stale (last-90-days always means the last 90 days from now).
  • An explicit ?from=&to= still wins — the default only fills the gap.
  • Omitting default keeps the current all-time behavior.
  • The header reset (X) clears the URL range, which re-resolves to the page's default (reset = back to default, by design).

How

Preset math is hoisted out of PageFilters into the shared runtime/src/client/pageFilters.ts (PERIOD_PRESETS, presetBounds, defaultRangeBounds) so the route and the control build ranges from one source — the control's UI is unchanged. The route resolves the default in PageView when from/to are absent; validateSearch (and the URL shape) is untouched.

The keystone schema change in @openislands/schema regenerates types + JSON Schema; CLI/runtime/MCP follow.

Dogfood

Finance template holdings page defaults to last-90-days (daily transaction data).

Verified

  • pnpm build, pnpm typecheck, pnpm test (389/389), pnpm lint, pnpm validate:templates — all green.
  • New unit tests for presetBounds + defaultRangeBounds.
  • SSR-checked the served finance app (today 2026-06-25): holdingsMar 28 – Jun 25, 2026; overview (no default) → All time; holdings?from=2026-01-01&to=2026-01-31Jan 1 – Jan 31, 2026.

Docs

Updated docs/data-app-model.md, apps/docs/.../reference/manifest.mdx, and concepts/manifest.mdx.

Add an optional `default` to the `daterange` page filter — one of
today / last-7-days / last-30-days / last-90-days / this-month / last-month.
When the URL sets no range, the page opens on this period, resolved live
against today (so it never goes stale); an explicit ?from=&to= still wins,
and omitting it keeps the all-time behavior.

Preset math is hoisted from PageFilters into the shared client/pageFilters
module (PERIOD_PRESETS, presetBounds, defaultRangeBounds) so the route and
the control build ranges from one source; the control's UI is unchanged.
Finance "holdings" page dogfoods last-90-days.
@lukaisailovic
lukaisailovic merged commit 1aec989 into main Jun 25, 2026
2 checks passed
@lukaisailovic
lukaisailovic deleted the feat/page-default-period branch June 25, 2026 20:40
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