From f1c812b436c02c46aefaded951301816845d2441 Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Sat, 8 Apr 2023 09:14:48 +0200 Subject: [PATCH] [TASK] refactor sidebar --- frontend/js/sidebar.ts | 4 - frontend/main.ts | 6 +- templates/index.html.tera | 194 ++++++++++++++++++-------------------- 3 files changed, 97 insertions(+), 107 deletions(-) diff --git a/frontend/js/sidebar.ts b/frontend/js/sidebar.ts index c2cb7f6..0a6e116 100644 --- a/frontend/js/sidebar.ts +++ b/frontend/js/sidebar.ts @@ -17,10 +17,6 @@ export class Sidebar { this.isOpen = false; } - checkStatus(): Boolean { - return this.isOpen; - } - toggle() { this.isOpen = !this.isOpen; if(this.trigger) { diff --git a/frontend/main.ts b/frontend/main.ts index 0f76e6e..be3479b 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -105,7 +105,7 @@ function initSidebar() { triggerElement.addEventListener('click', (e) => { e.preventDefault(); - if(triggerElement.dataset.trigger === 'addTrip' && !sidebar.isOpen) { + if(triggerElement.dataset.trigger === 'sidebar') { initTripSidebar(triggerElement); } @@ -117,11 +117,11 @@ function initSidebar() { } function initTripSidebar(triggerElement: HTMLElement) { - const sidebarElement = document.querySelector('#addTrip'); + 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('.form-js'); + let formContainerElement = sidebarElement.querySelector('.body-js'); if(formContainerElement) { formContainerElement.innerHTML = ''; formContainerElement.append(formElement); diff --git a/templates/index.html.tera b/templates/index.html.tera index b797e8f..bac3b71 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -34,7 +34,8 @@

{{ day.day| date(format="%d.%m.%Y") }} {{ day.day | date(format="%A", locale="de_AT") }}

- + + {# --- START Events --- #} {% if day.planned_events | length > 0 %}
{% for planned_event in day.planned_events %} @@ -43,10 +44,16 @@
{{ planned_event.planned_starting_time }} Uhr ({{ planned_event.name }})
- Details + + + Details +
+ {# --- START Row Buttons --- #} {% set_global cur_user_participates = false %} {% for rower in planned_event.rower%} {% if rower.name == loggedin_user.name %} @@ -61,47 +68,35 @@ Mitrudern {% endif %} {% endif %} + {# --- END Row Buttons --- #} + {# --- START Cox Buttons --- #} {% if loggedin_user.is_cox %} - - {% set_global cur_user_participates = false %} - {% for cox in planned_event.cox %} - {% if cox.name == loggedin_user.name %} - {% set_global cur_user_participates = true %} + {% set_global cur_user_participates = false %} + {% for cox in planned_event.cox %} + {% if cox.name == loggedin_user.name %} + {% set_global cur_user_participates = true %} + {% endif %} + {% endfor %} + {% if cur_user_participates %} + + {% include "includes/cox-icon" %} + Abmelden + + {% else %} + + {% include "includes/cox-icon" %} + Steuern + + {% endif %} {% endif %} - {% endfor %} - {% if cur_user_participates %} - - {% include "includes/cox-icon" %} - Abmelden - - {% else %} - - {% include "includes/cox-icon" %} - Steuern - - {% endif %} - {% endif %} - + {# --- END Cox Buttons --- #}
- - {% endfor %} {% endif %} + {# --- END Events --- #} - + {# --- START Trips --- #} {% if day.trips | length > 0 %}
{% for trip in day.trips %} @@ -147,78 +143,75 @@
{{ trip.planned_starting_time }} Uhr ({{ trip.cox_name }})
- Details + + Details +
+
{% set_global cur_user_participates = false %} {% for rower in trip.rower %} - {% if rower.name == loggedin_user.name %} - {% set_global cur_user_participates = true %} - {% endif %} + {% if rower.name == loggedin_user.name %} + {% set_global cur_user_participates = true %} + {% endif %} {% endfor %} {% if cur_user_participates %} - Abmelden + Abmelden {% endif %} - {% if trip.max_people > trip.rower | length and trip.cox_id != loggedin_user.id and cur_user_participates - == false%} - Mitrudern + {% if trip.max_people > trip.rower | length and trip.cox_id != loggedin_user.id and cur_user_participates == false%} + Mitrudern {% endif %}
- {% endif %} + {# --- END Trips --- #} + {# --- START Add Buttons --- #} {% if loggedin_user.is_admin or loggedin_user.is_cox %} {% endif %} - + {# --- END Add Buttons --- #} + {% endfor %} - + {# --- START Add Trip Sidebar --- #} -