From d8049dd1e67090c28b1da27675cb40bb9910ac72 Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Sat, 8 Apr 2023 09:17:46 +0200 Subject: [PATCH] [TASK] refactor sidebar --- frontend/main.ts | 16 ++++++++-------- templates/index.html.tera | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/frontend/main.ts b/frontend/main.ts index be3479b..678ce29 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -118,16 +118,16 @@ function initSidebar() { function initTripSidebar(triggerElement: HTMLElement) { const sidebarElement = document.querySelector('#sidebar'); - if(sidebarElement && triggerElement.dataset.form && triggerElement.dataset.header) { - let form = document.querySelector(triggerElement.dataset.form); - let formElement = form.cloneNode(true); - let formContainerElement = sidebarElement.querySelector('.body-js'); - if(formContainerElement) { - formContainerElement.innerHTML = ''; - formContainerElement.append(formElement); + if(sidebarElement && triggerElement.dataset.body && triggerElement.dataset.header) { + let body = document.querySelector(triggerElement.dataset.body); + let bodyElement = body.cloneNode(true); + let bodyContainerElement = sidebarElement.querySelector('.body-js'); + if(bodyContainerElement) { + bodyContainerElement.innerHTML = ''; + bodyContainerElement.append(bodyElement); } if(triggerElement.dataset.day) { - let hiddenElement = formElement.querySelector('.day-js'); + let hiddenElement = bodyElement.querySelector('.day-js'); if(hiddenElement) { hiddenElement.value = triggerElement.dataset.day; } diff --git a/templates/index.html.tera b/templates/index.html.tera index bac3b71..e1e6e9d 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -47,7 +47,7 @@ Details @@ -145,7 +145,7 @@ class="text-gray-600">({{ trip.cox_name }})
Details @@ -214,7 +214,7 @@ {% include "includes/plus-icon" %} @@ -227,7 +227,7 @@ {% include "includes/plus-icon" %}