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..890decb 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -51,10 +51,37 @@ 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 form = document.querySelector(triggerElement.dataset.form); + let formElement = form.cloneNode(true); + 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/src/rest/mod.rs b/src/rest/mod.rs index ee9215c..85777ae 100644 --- a/src/rest/mod.rs +++ b/src/rest/mod.rs @@ -31,7 +31,6 @@ async fn index(db: &State, user: User, flash: Option {% if trip.cox_id == loggedin_user.id %} {% if trip.rower | length == 0 %} - LÖSCHEN + {% endif %}

Edit trip

@@ -201,75 +206,71 @@
{% 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 --- #} + +{# --- END Form Add Trip --- #} + +{# --- START Form Add Event --- #} + +{# --- END Form Add Event --- #} + {% endblock content %}