pre-fill time input when entering /quote/add
This commit is contained in:
@@ -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<Response, CompositeError> {
|
||||
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(PREFILL_TIME_SCRIPT))}
|
||||
div class="flex gap-4 justify-between" {
|
||||
div class="flex flex-col flex-1" {
|
||||
label class="w-full"{
|
||||
|
||||
15
src/web/pages/quotes/prefill-time.js
Normal file
15
src/web/pages/quotes/prefill-time.js
Normal 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}`;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user