From d45c73cac94bf3de3c7af1be2bfd25972a67b31f Mon Sep 17 00:00:00 2001
From: philipp <philipp@hofer.link>
Date: Thu, 8 Jun 2023 15:00:15 +0200
Subject: [PATCH 1/2] show proper state of checkbox

---
 templates/index.html.tera | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/templates/index.html.tera b/templates/index.html.tera
index f6f4250..d312a28 100644
--- a/templates/index.html.tera
+++ b/templates/index.html.tera
@@ -130,7 +130,7 @@
                 <input type="hidden" name="id" value="{{ planned_event.id }}" />
                 {{ macros::input(label='Anzahl Ruderer', name='max_people', type='number', required=true, value=planned_event.max_people, min='0') }}
                 {{ macros::input(label='Anzahl Steuerleute', name='planned_amount_cox', type='number', value=planned_event.planned_amount_cox, required=true, min='0') }}
-    		{{ macros::checkbox(label='Immer anzeigen', name='always_show') }}
+    		{{ macros::checkbox(label='Immer anzeigen', name='always_show', checked=planned_event.always_show) }}
                 {{ macros::input(label='Anmerkungen', name='notes', type='input', value=planned_event.notes) }}
 
                 <input value="Bearbeiten" class="btn btn-primary" type="submit" />

From 6f2071df3721492d03cc0bc316898af2bf20780c Mon Sep 17 00:00:00 2001
From: Marie Birner <mb@studiomitte.com>
Date: Thu, 8 Jun 2023 15:28:08 +0200
Subject: [PATCH 2/2] [BUGFIX] duplicate ids checkboxes in sidebar form

---
 frontend/main.ts          | 11 +++++++++++
 templates/index.html.tera |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/frontend/main.ts b/frontend/main.ts
index dcea3f5..9d9bd2d 100644
--- a/frontend/main.ts
+++ b/frontend/main.ts
@@ -189,6 +189,17 @@ function initTripSidebar(triggerElement: HTMLElement) {
     let body = <HTMLElement>document.querySelector(triggerElement.dataset.body);
     let bodyElement = <HTMLElement>body.cloneNode(true);
     let bodyContainerElement = <HTMLElement>sidebarElement.querySelector('.body-js');
+    
+    /* Quickfix duplicate ids checkboxes */
+    const checkboxes = <NodeListOf<HTMLElement>>bodyElement.querySelectorAll('input[type="checkbox"]');
+
+    Array.prototype.forEach.call(checkboxes, (checkbox: HTMLElement) => {
+      if(checkbox) {
+        checkbox.parentElement?.setAttribute('for', checkbox.id + 'js');
+        checkbox.id += 'js';
+      }
+    });
+
     if(bodyContainerElement) {
       bodyContainerElement.innerHTML = '';
       bodyContainerElement.append(bodyElement);
diff --git a/templates/index.html.tera b/templates/index.html.tera
index 78882f1..75648d9 100644
--- a/templates/index.html.tera
+++ b/templates/index.html.tera
@@ -131,7 +131,7 @@
                 <input type="hidden" name="id" value="{{ planned_event.id }}" />
                 {{ macros::input(label='Anzahl Ruderer', name='max_people', type='number', required=true, value=planned_event.max_people, min='0') }}
                 {{ macros::input(label='Anzahl Steuerleute', name='planned_amount_cox', type='number', value=planned_event.planned_amount_cox, required=true, min='0') }}
-    		{{ macros::checkbox(label='Immer anzeigen', name='always_show', checked=planned_event.always_show) }}
+    		        {{ macros::checkbox(label='Immer anzeigen', name='always_show', id=planned_event.id,checked=planned_event.always_show) }}
                 {{ macros::input(label='Anmerkungen', name='notes', type='input', value=planned_event.notes) }}
 
                 <input value="Bearbeiten" class="btn btn-primary" type="submit" />