//! The Askama entry point for the described publish-at field. //! //! One field, and it is the last site of `data-config` — a private per-app //! attribute vocabulary that existed for exactly one behaviour: a //! `datetime-local` box submits the characters a reader typed, and //! `PUT /api/items/{id}` stores a moment. Something had to convert, and the //! conversion was four lines in `frontend/src/core/dispatch.ts` keyed on an //! attribute only this app understood. //! //! `makeover_layout::Field::as_instant` is the described version of the same //! request: the value is submitted as the moment it names, and how is the //! renderer's, because the browser is the only party that knows what "your //! computer's time zone" means. `quasi-webview` ships the script; //! `makeover-webview` marks the input; this file is the site that asks. //! //! # What is described here and what stays the host's //! //! Described: the kind, the name, the label, the standing hint, that it is //! required, and that the value is submitted as an instant. //! //! Host: the form around it. `item_details.html` keeps the `
` with its //! `hx-put` and its `data-after`, the same division `upload_field` makes — the //! wrapper is the app's and the group inside it is the renderer's. Converting //! the whole item-details tab is a screen conversion and not this. //! //! No wire contract moves. The route was already receiving an instant; what //! changed is who computed it. use makeover_layout::FieldKind; use quasi_router::{Field, Node}; /// The publish-at field for an item's schedule form. /// /// The hint is the one the template carried, and it is still true for the same /// reason it was: the reader types a time in their own zone. What is no longer /// true is that nothing said so to the renderer. #[must_use] pub fn publish_at() -> String { use quasi_axum::Serves as _; let field = Field::new(FieldKind::DateTime, "publish_at", "Publish at") .required() .hint("Uses your computer's time zone.") .submits_instant(); // No shell: a fragment landing inside a document Askama already built. quasi_webview::Webview::new().fragment(&Node::field(field)) } #[cfg(test)] mod tests { /// The assertion the whole change is for. Without the mark the form /// submits `2026-09-01T14:30` and the route stores whatever it makes of /// that, which is the bug `data-config` was patching. #[test] fn the_field_asks_to_be_submitted_as_a_moment() { let html = super::publish_at(); assert!(html.contains(r#"type="datetime-local""#), "{html}"); assert!(html.contains(r#"name="publish_at""#), "{html}"); assert!(html.contains(r#"data-instant="true""#), "{html}"); assert!(html.contains(" required"), "{html}"); } /// The private vocabulary does not come back in through the renderer. #[test] fn nothing_here_emits_data_config() { assert!(!super::publish_at().contains("data-config"), "gone"); } /// The label and the hint are the template's, moved rather than rewritten. #[test] fn the_question_and_its_standing_help_survived_the_move() { let html = super::publish_at(); assert!(html.contains("Publish at"), "{html}"); assert!( html.contains("Uses your computer's time zone."), "{html}" ); } }