From d56fcc3f4c4a35f35435902b89fbeea3adde658f Mon Sep 17 00:00:00 2001 From: jmanczak Date: Wed, 8 Apr 2026 02:34:54 +0200 Subject: [PATCH] pre-fill time input when entering /quote/add --- src/web/pages/quotes/add.rs | 2 ++ src/web/pages/quotes/prefill-time.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 src/web/pages/quotes/prefill-time.js diff --git a/src/web/pages/quotes/add.rs b/src/web/pages/quotes/add.rs index 7a9b630..aa6a780 100644 --- a/src/web/pages/quotes/add.rs +++ b/src/web/pages/quotes/add.rs @@ -24,6 +24,7 @@ use crate::{ }; const LINE_ADD_RM_SCRIPT: &str = include_str!("line-add-rm.js"); +const PREFILL_TIME_SCRIPT: &str = include_str!("prefill-time.js"); pub async fn page(req: Request) -> Result { let u = User::authenticate(req.headers())?; @@ -58,6 +59,7 @@ pub async fn page(req: Request) -> Result { } } script {(PreEscaped(LINE_ADD_RM_SCRIPT))} + script {(PreEscaped(PREFILL_TIME_SCRIPT))} div class="flex gap-4 justify-between" { div class="flex flex-col flex-1" { label class="w-full"{ diff --git a/src/web/pages/quotes/prefill-time.js b/src/web/pages/quotes/prefill-time.js new file mode 100644 index 0000000..ee3c6df --- /dev/null +++ b/src/web/pages/quotes/prefill-time.js @@ -0,0 +1,15 @@ +document.addEventListener("DOMContentLoaded", () => { + const timeInput = document.querySelector( + 'input[type="datetime-local"][name="time"]', + ); + if (timeInput && !timeInput.value) { + const now = new Date(); + const year = now.getFullYear(); + const month = String(now.getMonth() + 1).padStart(2, "0"); + const day = String(now.getDate()).padStart(2, "0"); + const hours = String(now.getHours()).padStart(2, "0"); + const minutes = String(now.getMinutes()).padStart(2, "0"); + + timeInput.value = `${year}-${month}-${day}T${hours}:${minutes}`; + } +});