diff --git a/frontend/js/sidebar.ts b/frontend/js/sidebar.ts index 6dad1b0..c2cb7f6 100644 --- a/frontend/js/sidebar.ts +++ b/frontend/js/sidebar.ts @@ -17,7 +17,7 @@ export class Sidebar { this.isOpen = false; } - checkStatus() { + checkStatus(): Boolean { return this.isOpen; } diff --git a/frontend/main.ts b/frontend/main.ts index e09f22a..58268db 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -51,10 +51,36 @@ function initSidebar() { const sidebar = new Sidebar(triggerElement.dataset.trigger); triggerElement.addEventListener('click', () => { + if(triggerElement.dataset.trigger === 'addTrip') { + initTripSidebar(triggerElement); + } + sidebar.toggle(); }); - } }); } } + +function initTripSidebar(triggerElement: HTMLElement) { + const sidebarElement = document.querySelector('#addTrip'); + if(sidebarElement && triggerElement.dataset.form && triggerElement.dataset.header) { + let formElement = document.querySelector(triggerElement.dataset.form); + let formContainerElement = sidebarElement.querySelector('.form-js'); + if(formContainerElement) { + formContainerElement.innerHTML = ''; + formContainerElement.append(formElement); + } + if(triggerElement.dataset.day) { + let hiddenElement = formElement.querySelector('.day-js'); + if(hiddenElement) { + hiddenElement.value = triggerElement.dataset.day; + } + } + + let headerElement = sidebarElement.querySelector('.header-js'); + if(headerElement) { + headerElement.innerHTML = triggerElement.dataset.header; + } + } +} diff --git a/templates/index.html.tera b/templates/index.html.tera index a3211e7..befde40 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -188,75 +188,67 @@
{% if loggedin_user.is_admin %} - Event hinzufügen - - - - - {% endif %} {% if loggedin_user.is_cox%} - Ausfahrt hinzufügen - - - {% endif %}
{% endfor %} + +{# --- START Add Trip Sidebar --- #} + + +{# --- END Add Trip Sidebar --- #} + +{# --- START Form Add Trip --- #} +
+ + {{ macros::input(label='Startzeit', name='planned_starting_time', type='input', required=true) }} + {{ macros::input(label='Anzahl Ruderer', name='max_people', type='number', required=true) }} + {{ macros::input(label='Anmerkungen', name='notes', type='input') }} + +
+{# --- END Form Add Trip --- #} + +{# --- START Form Add Event --- #} +
+ + {{ macros::input(label='Titel (z.B. Firmenrudern)', name='name', type='text', required=true) }} + {{ macros::input(label='Startzeit', name='planned_starting_time', type='text', required=true) }} + {{ macros::input(label='Anzahl Steuerleute', name='planned_amount_cox', type='number', required=true) }} + {{ macros::input(label='Anzahl Ruderer', name='max_people', type='number', required=true) }} + {{ macros::checkbox(label='Gäste erlauben', name='max_allow_guestspeople') }} + {{ macros::input(label='Anmerkungen', name='notes', type='text') }} + +
+{# --- END Form Add Event --- #} + {% endblock content %} \ No newline at end of file