[TASK] refactor sidebar forms (reduced size dramatically)
This commit is contained in:
parent
5e4df13289
commit
2d75e7696d
@ -17,7 +17,7 @@ export class Sidebar {
|
||||
this.isOpen = false;
|
||||
}
|
||||
|
||||
checkStatus() {
|
||||
checkStatus(): Boolean {
|
||||
return this.isOpen;
|
||||
}
|
||||
|
||||
|
@ -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 = <HTMLElement>document.querySelector('#addTrip');
|
||||
if(sidebarElement && triggerElement.dataset.form && triggerElement.dataset.header) {
|
||||
let formElement = <HTMLElement>document.querySelector(triggerElement.dataset.form);
|
||||
let formContainerElement = <HTMLElement>sidebarElement.querySelector('.form-js');
|
||||
if(formContainerElement) {
|
||||
formContainerElement.innerHTML = '';
|
||||
formContainerElement.append(formElement);
|
||||
}
|
||||
if(triggerElement.dataset.day) {
|
||||
let hiddenElement = <HTMLInputElement>formElement.querySelector('.day-js');
|
||||
if(hiddenElement) {
|
||||
hiddenElement.value = triggerElement.dataset.day;
|
||||
}
|
||||
}
|
||||
|
||||
let headerElement = sidebarElement.querySelector('.header-js');
|
||||
if(headerElement) {
|
||||
headerElement.innerHTML = triggerElement.dataset.header;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -188,75 +188,67 @@
|
||||
|
||||
<div>
|
||||
{% if loggedin_user.is_admin %}
|
||||
<a href="#" data-sidebar="true" data-trigger="plannedTrip{{ loop.index }}"
|
||||
<a href="#" data-sidebar="true" data-trigger="addTrip"
|
||||
data-header="<strong>Event</strong> am {{ day.day| date(format='%d.%m.%Y') }} erstellen"
|
||||
data-day="{{ day.day }}"
|
||||
data-form="#addEventForm"
|
||||
class="inline-block link-dark mr-3">Event hinzufügen</a>
|
||||
|
||||
<!-- START Sidebar plannedTrip -->
|
||||
<div class="sidebar slide-in from-right" id="plannedTrip{{ loop.index }}" aria-modal="false">
|
||||
<div class="bg-primary-900 text-white px-2 py-3 flex justify-between sidebar-header">
|
||||
<div>
|
||||
<span class="ps-1">
|
||||
<strong>Event</strong> am {{ day.day| date(format="%d.%m.%Y") }} erstellen
|
||||
</span>
|
||||
</div>
|
||||
<button type="button" title="Add planned event schließen"
|
||||
class="sidebar-close border-0 bg-primary-600 text-black" data-trigger="plannedTrip{{ loop.index }}">
|
||||
x
|
||||
</button>
|
||||
</div>
|
||||
<div class="px-2 pt-2" style="margin-top: 63px; margin-bottom: 157px">
|
||||
<form action="/admin/planned-event" method="post" class="grid gap-3">
|
||||
<input type="hidden" name="day" value="{{ day.day }}" />
|
||||
{{ 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') }}
|
||||
<input value="Erstellen"
|
||||
class="w-full rounded-md bg-primary-600 px-3 py-2 text-sm font-semibold text-white hover:bg-primary-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 cursor-pointer"
|
||||
type="submit" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sidebar-overlay" data-trigger="plannedTrip{{ loop.index }}"></div>
|
||||
<!-- END Sidebar plannedTrip -->
|
||||
{% endif %}
|
||||
|
||||
{% if loggedin_user.is_cox%}
|
||||
<a href="#" data-sidebar="true" data-trigger="trip{{ loop.index }}"
|
||||
<a href="#" data-sidebar="true" data-trigger="addTrip"
|
||||
data-header="<strong>Ausfahrt</strong> am {{ day.day| date(format='%d.%m.%Y') }} erstellen"
|
||||
data-day="{{ day.day }}"
|
||||
data-form="#addTripForm"
|
||||
class="inline-block link-primary">Ausfahrt hinzufügen</a>
|
||||
|
||||
<div class="sidebar slide-in from-right" id="trip{{ loop.index }}" aria-modal="false">
|
||||
<div class="bg-primary-900 text-white px-2 py-3 flex justify-between sidebar-header">
|
||||
<div>
|
||||
<span class="ps-1">
|
||||
<strong>Ausfahrt</strong> am {{ day.day| date(format="%d.%m.%Y") }} erstellen
|
||||
</span>
|
||||
</div>
|
||||
<button type="button" title="Add trip schließen" class="sidebar-close border-0 bg-primary-600 text-black"
|
||||
data-trigger="trip{{ loop.index }}">
|
||||
x
|
||||
</button>
|
||||
</div>
|
||||
<div class="px-2 pt-2" style="margin-top: 63px; margin-bottom: 157px">
|
||||
<form action="/cox/trip" method="post" class="grid gap-3">
|
||||
<input type="hidden" name="day" value="{{ day.day }}" />
|
||||
{{ macros::input(label='Startzeit', name='planned_starting_time', type='text', required=true) }}
|
||||
{{ macros::input(label='Anzahl Ruderer', name='max_people', type='number', required=true) }}
|
||||
{{ macros::input(label='Anmerkungen', name='notes', type='text') }}
|
||||
|
||||
<input value="Erstellen"
|
||||
class="w-full rounded-md bg-primary-600 px-3 py-2 text-sm font-semibold text-white hover:bg-primary-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 cursor-pointer"
|
||||
type="submit" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sidebar-overlay" data-trigger="trip{{ loop.index }}"></div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# --- START Add Trip Sidebar --- #}
|
||||
<div class="sidebar slide-in from-right" id="addTrip" aria-modal="false">
|
||||
<div class="bg-primary-900 text-white px-2 py-3 flex justify-between sidebar-header">
|
||||
<div>
|
||||
<span class="ps-1 header-js">
|
||||
Überschrift (wird ersetzt)
|
||||
</span>
|
||||
</div>
|
||||
<button type="button" title="Ausfahrt erstellen schließen" class="sidebar-close border-0 bg-primary-600 text-black"
|
||||
data-trigger="addTrip">
|
||||
x
|
||||
</button>
|
||||
</div>
|
||||
<div class="form-js px-2 pt-2" style="margin-top: 63px; margin-bottom: 157px">
|
||||
Formular wird ersetzt
|
||||
</div>
|
||||
</div>
|
||||
<div class="sidebar-overlay" data-trigger="addTrip"></div>
|
||||
{# --- END Add Trip Sidebar --- #}
|
||||
|
||||
{# --- START Form Add Trip --- #}
|
||||
<form action="/cox/trip" method="post" class="grid gap-3" id="addTripForm">
|
||||
<input class="day-js" type="hidden" name="day" value="" />
|
||||
{{ 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') }}
|
||||
<input value="Erstellen" class="w-full btn btn-primary" type="submit" />
|
||||
</form>
|
||||
{# --- END Form Add Trip --- #}
|
||||
|
||||
{# --- START Form Add Event --- #}
|
||||
<form action="/admin/planned-event" method="post" class="grid gap-3" id="addEventForm">
|
||||
<input class="day-js" type="hidden" name="day" value="" />
|
||||
{{ 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') }}
|
||||
<input value="Erstellen" class="w-full btn btn-primary" type="submit" />
|
||||
</form>
|
||||
{# --- END Form Add Event --- #}
|
||||
|
||||
{% endblock content %}
|
Loading…
Reference in New Issue
Block a user