From fcf86c7ff12d9953e3a6079c33b5854378ef0d5d Mon Sep 17 00:00:00 2001 From: philipp Date: Fri, 26 Apr 2024 09:50:01 +0200 Subject: [PATCH] if user is logged in, use that user as default rower --- frontend/main.ts | 5 ++++- frontend/tests/log.spec.ts | 2 ++ templates/log.html.tera | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/main.ts b/frontend/main.ts index 69efee5..15360e6 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -5,6 +5,7 @@ export interface choiceMap { [details: string]: Choices; } +declare var loggedin_user_id: string; let choiceObjects: choiceMap = {}; let boat_in_ottensheim = true; let boat_reserved_today= true; @@ -176,7 +177,9 @@ function selectBoatChange() { /** custom code for Etsch */ choiceObjects["newrower"].setChoiceByValue("81"); } - } + }else if (typeof loggedin_user_id !== 'undefined'){ + choiceObjects["newrower"].setChoiceByValue(loggedin_user_id); + } const inputElement = document.getElementById( "departure", diff --git a/frontend/tests/log.spec.ts b/frontend/tests/log.spec.ts index b12f0cb..a5380b7 100644 --- a/frontend/tests/log.spec.ts +++ b/frontend/tests/log.spec.ts @@ -18,6 +18,7 @@ test("Cox can start and cancel trip", async ({ page }, testInfo) => { await page.getByText('2x', { exact: true }).click(); await page.getByText("Joe", { exact: true }).click(); } + await page.getByLabel('Remove item: \'6\'').click(); // remove pre-filled cox2 await page.getByPlaceholder("Ruderer auswählen").click(); await page.getByRole("option", { name: "rower2" }).click(); await page.getByRole("option", { name: "cox2" }).click(); @@ -59,6 +60,7 @@ test("Cox can start and finish trip", async ({ page }, testInfo) => { await page.getByText('2x', { exact: true }).click(); await page.getByText("Joe", { exact: true }).click(); } + await page.getByLabel('Remove item: \'6\'').click(); // remove pre-filled cox2 await page.getByPlaceholder("Ruderer auswählen").click(); await page.getByRole("option", { name: "rower2" }).click(); await page.getByRole("option", { name: "cox2" }).click(); diff --git a/templates/log.html.tera b/templates/log.html.tera index 5650da0..1bf266b 100644 --- a/templates/log.html.tera +++ b/templates/log.html.tera @@ -38,5 +38,6 @@ + {% if loggedin_user %}{% endif %} {% endblock content %} -- 2.45.2