pre-fill time input when entering /quote/add

This commit is contained in:
2026-04-08 02:34:54 +02:00
parent 6906cec2c3
commit d56fcc3f4c
2 changed files with 17 additions and 0 deletions

View File

@@ -24,6 +24,7 @@ use crate::{
}; };
const LINE_ADD_RM_SCRIPT: &str = include_str!("line-add-rm.js"); 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<Response, CompositeError> { pub async fn page(req: Request) -> Result<Response, CompositeError> {
let u = User::authenticate(req.headers())?; let u = User::authenticate(req.headers())?;
@@ -58,6 +59,7 @@ pub async fn page(req: Request) -> Result<Response, CompositeError> {
} }
} }
script {(PreEscaped(LINE_ADD_RM_SCRIPT))} script {(PreEscaped(LINE_ADD_RM_SCRIPT))}
script {(PreEscaped(PREFILL_TIME_SCRIPT))}
div class="flex gap-4 justify-between" { div class="flex gap-4 justify-between" {
div class="flex flex-col flex-1" { div class="flex flex-col flex-1" {
label class="w-full"{ label class="w-full"{

View File

@@ -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}`;
}
});