Pre-fill month field with previous month

This commit is contained in:
Joscha 2024-05-04 22:35:23 +02:00
parent 738509edab
commit 6507276488
3 changed files with 19 additions and 1 deletions

12
Cargo.lock generated
View file

@ -1092,6 +1092,7 @@ dependencies = [
"comemo",
"fontdb",
"maud",
"time",
"tokio",
"typst",
"typst-pdf",
@ -1288,6 +1289,15 @@ dependencies = [
"libc",
]
[[package]]
name = "num_threads"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9"
dependencies = [
"libc",
]
[[package]]
name = "numerals"
version = "0.1.4"
@ -2059,7 +2069,9 @@ checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885"
dependencies = [
"deranged",
"itoa",
"libc",
"num-conv",
"num_threads",
"powerfmt",
"serde",
"time-core",

View file

@ -10,6 +10,7 @@ clap = { version = "4.5.4", features = ["derive", "deprecated"] }
comemo = "0.4.0"
fontdb = "0.16.2"
maud = { version = "0.26.0", features = ["axum"] }
time = { version = "0.3.36", features = ["macros", "formatting", "local-offset"] }
tokio = { version = "1.37.0", features = ["full"] }
typst = "0.11.0"
typst-pdf = "0.11.0"

View file

@ -1,8 +1,13 @@
use maud::{html, Markup};
use time::{macros::format_description, Date, OffsetDateTime};
use crate::endpoints::page;
pub async fn get() -> Markup {
let now = OffsetDateTime::now_local().unwrap_or_else(|_| OffsetDateTime::now_utc());
let month = now.date().replace_day(1).unwrap().previous_day().unwrap();
let month = month.format(format_description!("[year]-[month]")).unwrap();
page(
html! {
style { (include_str!("base.css")) }
@ -13,7 +18,7 @@ pub async fn get() -> Markup {
div #header {
label #l-month for="i-month" { "Monat / Jahr:" }
input #i-month name="month" type="month" placeholder="2024-04" {} // TODO Fill in previous month by default
input #i-month name="month" type="month" placeholder=(month) value=(month) {}
label #l-name for="i-name" { "Name, Vorname des/r Beschäftigten:" }
input #i-name name="name" type="text" placeholder="McStudentface, Student" {}