Skip to content

feat(apps): render native date/time pickers for schema format fields - #3187

Merged
vpetersson merged 2 commits into
masterfrom
feat/app-form-datetime-inputs
Jul 14, 2026
Merged

feat(apps): render native date/time pickers for schema format fields#3187
vpetersson merged 2 commits into
masterfrom
feat/app-form-datetime-inputs

Conversation

@vpetersson

Copy link
Copy Markdown
Contributor

Issues Fixed

The Timer signage app's "Target date & time" field — a JSON Schema string with format: date-time — rendered as a plain text input in the Add → Apps config form, so operators had to hand-type or paste an ISO 8601 string. Same gap for any app field using a date / time / date-time format.

Description

widgetFor() (the manifest-form control picker) only keyed off the schema type / enum / x-widget, so a string with format: date-time fell through to a bare <input type="text">. It now maps the standard JSON Schema string formats to native HTML5 pickers:

  • date-time<input type="datetime-local">
  • date<input type="date">
  • time<input type="time">

The datetime value stays a naive wall-clock time (YYYY-MM-DDTHH:mm), which apps like Timer resolve against their separate time-zone field — matching the app's own documented behaviour ("read in the time zone below"). An explicit x-widget still overrides format, and unknown formats degrade to text as before.

Also extracts widgetFor into its own module (widget-for.ts) so the mapping is unit-testable without importing the browser-only location-map / Leaflet chain that manifest-form.ts pulls in.

The plain-text date-time field was confirmed live in the Add → Apps modal on a device (it also looked out of place next to the Time zone field, which already renders as a dropdown). After this change it's a native date/time picker.

Checklist

  • I have performed a self-review of my own code.
  • New and existing unit tests pass locally and on CI with my changes. (New widget-for tests + the existing apps suite: 18/18 green.)
  • I have done an end-to-end test for Raspberry Pi devices. (N/A — this is the browser-side management UI form renderer; the rendered picker is board-agnostic. The current text-input behaviour was verified in a device's live Add → Apps modal.)
  • I have tested my changes for x86 devices. (N/A — same board-agnostic management UI.)
  • I added documentation for the changes I have made. (Updated the manifest-form module doc comment; new module is self-documented.)

- widgetFor maps a JSON Schema string `format` of date-time/date/time to
  a datetime-local/date/time input instead of a bare text box
- extract widgetFor into its own leaflet-free module so the mapping is
  unit-testable without pulling in the browser-only location-map chain
- add SettingSchema.format; add widget-for tests

Fixes the Timer app's "Target date & time" (format: date-time) rendering
as a plain text input the operator had to hand-type an ISO string into.
The value stays a naive wall-clock time, resolved against the app's
time-zone field — matching the Timer's documented behaviour.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01XrDBimoWjmEyF3A4Eo9sbh
@vpetersson
vpetersson requested a review from a team as a code owner July 14, 2026 10:13
@vpetersson vpetersson self-assigned this Jul 14, 2026
@vpetersson
vpetersson requested a review from Copilot July 14, 2026 10:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds native HTML5 date/time pickers to the manifest-driven “Add → Apps” configuration form by teaching the widget selector to consider JSON Schema string format values (while still honoring explicit x-widget overrides). This improves operator UX for settings like Timer’s target date/time, and refactors the widget selection logic into a pure module so it can be unit-tested without browser-only dependencies.

Changes:

  • Extracts widgetFor() into a new pure module and adds unit tests for widget selection behavior.
  • Extends the schema typing to include JSON Schema format and maps date-time / date / time formats to new widget keys.
  • Updates manifest-form rendering to produce datetime-local, date, and time native inputs for those widget keys.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/anthias_server/app/static/src/apps/widget-for.ts New pure widget-selection helper that maps schema to widget keys (now including string format).
src/anthias_server/app/static/src/apps/widget-for.test.ts New Bun unit tests pinning format→widget mapping and precedence rules.
src/anthias_server/app/static/src/apps/types.ts Extends SettingSchema with format?: string for JSON Schema string formats.
src/anthias_server/app/static/src/apps/manifest-form.ts Imports extracted widgetFor and renders native date/time inputs for the new widget keys.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/anthias_server/app/static/src/apps/types.ts
The renderer now also keys off a string `format` (date-time/date/time)
for native pickers; say so in the interface comment.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01XrDBimoWjmEyF3A4Eo9sbh
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@vpetersson
vpetersson merged commit d24ca4e into master Jul 14, 2026
9 checks passed
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.

2 participants