diff --git a/src/endpoints/index.css b/src/endpoints/index.css index 1306dad..299b067 100644 --- a/src/endpoints/index.css +++ b/src/endpoints/index.css @@ -27,9 +27,7 @@ label { grid-column: 2; text-align: center; } -#i-name, -#i-department, -#mhhr { +.twocol { grid-column: 2 / 4; } #gfub { @@ -57,6 +55,12 @@ label { justify-content: end; align-items: baseline; } +#check { + grid-column: 2; +} +#validate { + text-align: right; +} #table { display: grid; grid: auto-flow / 3fr 1fr 1fr 1fr 1fr 1fr; diff --git a/src/endpoints/index.rs b/src/endpoints/index.rs index a391580..90f3492 100644 --- a/src/endpoints/index.rs +++ b/src/endpoints/index.rs @@ -47,7 +47,7 @@ pub async fn get() -> Markup { 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" {} + input #i-name .twocol name="name" type="text" placeholder="McStudentface, Student" {} label #l-staffid for="i-staffid" { "Personalnummer:" } input #i-staffid name="staff_id" type="text" placeholder="1337420" {} @@ -63,10 +63,10 @@ pub async fn get() -> Markup { } label #l-department for="i-department" title="Organisationseinheit" { "OE:" } - input #i-department name="department" type="text" placeholder="Institut für Informatik" value="Institut für Informatik" {} + input #i-department .twocol name="department" type="text" placeholder="Institut für Informatik" value="Institut für Informatik" {} label #l-monthlyhours for="i-monthlyhours" { "Vertraglich vereinbarte Arbeitszeit:" } - div #mhhr { + div #mhhr .twocol { span { input #i-monthlyhours name="monthly_hours" type="number" value="40" min="0" {} " Std." @@ -78,12 +78,22 @@ pub async fn get() -> Markup { } } - div #carry { + div #carry .twocol { span { label #l-carry for="i-carry" { "Übertrag vom Vormonat: " } input #i-carry .i-dur name="carry_prev_month" type="text" placeholder="00:00" {} } } + + label #check title="Die Tabelleneinträge werden chronologisch sortiert, anstatt dass ihre Reihenfolge beibehalten wird." { + "Einträge sortieren " + input name="sort" type="checkbox" value="true" checked {} + } + + label #validate title="Die Tabelleneinträge werden auf Konsistenz und Korrektheit überprüft, bevor das Dokument generiert wird." { + "Einträge validieren " + input name="validate" type="checkbox" value="true" checked {} + } } div #table { @@ -133,6 +143,10 @@ pub struct PostForm { monthly_hours: u32, hourly_wage: String, carry_prev_month: String, + #[serde(default)] + sort: bool, + #[serde(default)] + validate: bool, task: Vec, day: Vec>, start: Vec, @@ -229,7 +243,8 @@ pub async fn post(form: Form) -> Response { working_area, monthly_hours: form.monthly_hours, hourly_wage: form.hourly_wage, - validate: true, + validate: form.validate, + sort: form.sort, carry_prev_month, year, month, diff --git a/src/endpoints/tsg.css b/src/endpoints/tsg.css index 88c09eb..44cebc3 100644 --- a/src/endpoints/tsg.css +++ b/src/endpoints/tsg.css @@ -18,7 +18,6 @@ h1 { label { display: block; font-weight: bold; - margin-top: 4mm; } textarea { display: block; diff --git a/src/endpoints/tsg.js b/src/endpoints/tsg.js index e3bfbfd..41de787 100644 --- a/src/endpoints/tsg.js +++ b/src/endpoints/tsg.js @@ -44,7 +44,14 @@ submit.addEventListener("click", async () => { return; } - const dataJson = JSON.stringify({ global, month }); + let sort = data.get("sort") !== null; + let validate = data.get("validate") !== null; + + console.log("data", data) + console.log("sort", sort) + console.log("validate", validate) + + const dataJson = JSON.stringify({ global, month, sort, validate }); try { const response = await fetch(".", { diff --git a/src/endpoints/tsg.rs b/src/endpoints/tsg.rs index 2156d65..3eb4afe 100644 --- a/src/endpoints/tsg.rs +++ b/src/endpoints/tsg.rs @@ -30,11 +30,27 @@ pub async fn get() -> Markup { " eingeben." } - label for="i-global" { "Global.json" } - textarea #i-global name="global" placeholder="{}" {} + p { + label for="i-global" { "Global.json" } + textarea #i-global name="global" placeholder="{}" {} + } - label for="i-month" { "Month.json" } - textarea #i-month name="month" placeholder="{}" {} + p { + label for="i-month" { "Month.json" } + textarea #i-month name="month" placeholder="{}" {} + } + + p { + label title="Die Einträge werden chronologisch sortiert, anstatt dass ihre Reihenfolge beibehalten wird." { + input name="sort" type="checkbox" checked {} + " Einträge sortieren" + } + + label title="Die Einträge werden auf Konsistenz und Korrektheit überprüft, bevor das Dokument generiert wird." { + input name="validate" type="checkbox" checked {} + " Einträge validieren" + } + } button #submit type="button" { "Arbeitszeitdokumentation generieren" } @@ -82,6 +98,8 @@ pub struct MonthJson { pub struct PostJson { global: GlobalJson, month: MonthJson, + sort: bool, + validate: bool, } fn error_response(msg: S) -> Response { @@ -149,7 +167,8 @@ pub async fn post(json: Json) -> Response { working_area, monthly_hours, hourly_wage: json.global.wage.to_string(), - validate: true, + validate: json.validate, + sort: json.sort, carry_prev_month: json.month.pred_transfer, year: json.month.year, month: json.month.month, diff --git a/src/render.rs b/src/render.rs index 4395c14..2d196c5 100644 --- a/src/render.rs +++ b/src/render.rs @@ -51,6 +51,7 @@ pub struct Timesheet { pub monthly_hours: u32, pub hourly_wage: String, pub validate: bool, + pub sort: bool, pub carry_prev_month: Option, pub year: u32, pub month: u32, @@ -137,6 +138,7 @@ fn fmt_timesheet(ts: Timesheet) -> String { lines.push(format!(" monthly_hours: {},", fmt_int(ts.monthly_hours))); lines.push(format!(" hourly_wage: {},", fmt_str(&ts.hourly_wage))); lines.push(format!(" validate: {},", fmt_bool(ts.validate))); + lines.push(format!(" sort: {},", fmt_bool(ts.sort))); if let Some(carry) = ts.carry_prev_month { lines.push(format!(" carry_prev_month: {},", fmt_str(&carry))); }