refactor: use hyperscript instead of javascript
This commit is contained in:
parent
653dbb4233
commit
1d493b85b1
@ -30,7 +30,12 @@ snapshot_kind: text
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<div class="dropdown-trigger">
|
<div class="dropdown-trigger"
|
||||||
|
_="on click[.dropdown does not contain target] from elsewhere
|
||||||
|
or keyup[key is 'Escape'] from elsewhere
|
||||||
|
or click[parentElement of me does not match .is-active]
|
||||||
|
remove .is-active from .dropdown end
|
||||||
|
on click toggle .is-active on the parentElement of me">
|
||||||
<button class="button" aria-haspopup="true" aria-controls="dropdown-menu">
|
<button class="button" aria-haspopup="true" aria-controls="dropdown-menu">
|
||||||
|
|
||||||
<span>als Posten geplant</span>
|
<span>als Posten geplant</span>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use askama::Template;
|
use askama::Template;
|
||||||
|
|
||||||
use crate::filters;
|
use crate::filters;
|
||||||
|
use crate::utils::DateTimeFormat::{DayMonthYearHourMinute, HourMinute};
|
||||||
|
|
||||||
use brass_db::models::{Availability, AvailabilityAssignmentState, Event};
|
use brass_db::models::{Availability, AvailabilityAssignmentState, Event};
|
||||||
pub mod delete;
|
pub mod delete;
|
||||||
|
@ -11,30 +11,6 @@ document.addEventListener("htmx:afterSwap", () => {
|
|||||||
document.querySelectorAll("button[hx-trigger='confirmed']").forEach((value) => value.addEventListener("click", fireConfirmModal));
|
document.querySelectorAll("button[hx-trigger='confirmed']").forEach((value) => value.addEventListener("click", fireConfirmModal));
|
||||||
});
|
});
|
||||||
|
|
||||||
// dropdown activation / deactivation
|
|
||||||
const toggleDropdown = (event) => {
|
|
||||||
const classList = event.target.closest('.dropdown').classList
|
|
||||||
if (!classList.contains('is-active')) {
|
|
||||||
Array.from(document.querySelectorAll('.dropdown')).forEach((d) => d.classList.remove('is-active'));
|
|
||||||
}
|
|
||||||
classList.toggle('is-active');
|
|
||||||
};
|
|
||||||
|
|
||||||
const closeDropdownsIfClickedOutside = (event) => {
|
|
||||||
const dropdowns = Array.from(document.querySelectorAll('.dropdown'));
|
|
||||||
if (dropdowns.every((v) => !v.contains(event.target))) {
|
|
||||||
dropdowns.forEach((d) => d.classList.remove('is-active'))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
document.querySelectorAll(".dropdown-trigger .button").forEach((value) => value.addEventListener("click", toggleDropdown));
|
|
||||||
document.addEventListener("click", closeDropdownsIfClickedOutside);
|
|
||||||
|
|
||||||
document.addEventListener("htmx:afterSwap", () => {
|
|
||||||
document.querySelectorAll(".dropdown-trigger .button").forEach((value) => value.addEventListener("click", toggleDropdown));
|
|
||||||
document.addEventListener("click", closeDropdownsIfClickedOutside);
|
|
||||||
});
|
|
||||||
|
|
||||||
// light / dark mode interpretation for first load and switch behaviour respecting localStorage and CSS prefers-color-scheme
|
// light / dark mode interpretation for first load and switch behaviour respecting localStorage and CSS prefers-color-scheme
|
||||||
const getCurrentTheme = () => {
|
const getCurrentTheme = () => {
|
||||||
let current = localStorage.getItem("theme");
|
let current = localStorage.getItem("theme");
|
||||||
|
@ -27,14 +27,20 @@
|
|||||||
{{ u.function|show_tree|safe }}
|
{{ u.function|show_tree|safe }}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ availability.start.format("%R") }} bis {{ availability.end.format("%d.%m.%Y %R") }}
|
{{ availability.start|fmt_datetime(HourMinute) }} bis {{ availability.end|fmt_datetime(DayMonthYearHourMinute)
|
||||||
|
}}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ availability.comment.as_deref().unwrap_or("") }}
|
{{ availability.comment.as_deref().unwrap_or_default() }}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<div class="dropdown-trigger">
|
<div class="dropdown-trigger"
|
||||||
|
_="on click[.dropdown does not contain target] from elsewhere
|
||||||
|
or keyup[key is 'Escape'] from elsewhere
|
||||||
|
or click[parentElement of me does not match .is-active]
|
||||||
|
remove .is-active from .dropdown end
|
||||||
|
on click toggle .is-active on the parentElement of me">
|
||||||
<button class="button" aria-haspopup="true" aria-controls="dropdown-menu">
|
<button class="button" aria-haspopup="true" aria-controls="dropdown-menu">
|
||||||
{% match status %}
|
{% match status %}
|
||||||
{% when AvailabilityAssignmentState::AssignedPosten(_) %}
|
{% when AvailabilityAssignmentState::AssignedPosten(_) %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user