diff --git a/web/static/app.js b/web/static/app.js index d41f866..fe87d11 100644 --- a/web/static/app.js +++ b/web/static/app.js @@ -144,6 +144,26 @@ function openDeepLinkedFlat() { document.addEventListener("DOMContentLoaded", openDeepLinkedFlat); +// Notification-channel toggle — show fields tagged data-channel-only="" +// only while that channel is selected. Hidden inputs stay in the form so +// values survive a round-trip (e.g. switch to "ui", save, switch back to +// "telegram" and the bot token is still there). +function syncChannelOnlyFields() { + const sel = document.querySelector('select[name="channel"]'); + if (!sel) return; + const channel = sel.value; + document.querySelectorAll("[data-channel-only]").forEach((el) => { + el.style.display = el.dataset.channelOnly === channel ? "" : "none"; + }); +} +document.addEventListener("change", (ev) => { + if (ev.target && ev.target.matches && ev.target.matches('select[name="channel"]')) { + syncChannelOnlyFields(); + } +}); +document.addEventListener("DOMContentLoaded", syncChannelOnlyFields); +document.body && document.body.addEventListener("htmx:afterSwap", syncChannelOnlyFields); + // Image lightbox — single global modal in base.html, opened by clicking any // .flat-gallery-tile. Click handler is delegated so it survives HTMX swaps. // Visibility is driven by inline style.display rather than a `hidden` class diff --git a/web/templates/_settings_notifications.html b/web/templates/_settings_notifications.html index b6721be..1de5b05 100644 --- a/web/templates/_settings_notifications.html +++ b/web/templates/_settings_notifications.html @@ -19,6 +19,11 @@ autocomplete="off" data-lpignore="true" data-1p-ignore data-bwignore data-form-type="other"> + {# Channel-dependent fields are wrapped in data-channel-only="telegram" so a + small JS handler in app.js can hide them when "Nur Dashboard" is picked. + Inputs stay in the form (display:none doesn't strip them), so values are + preserved when you switch back to Telegram. #} + {% set hide_telegram = notifications.channel != 'telegram' %}
-
+

Bot bei @BotFather anlegen, Token hier eintragen.

-
+
-
+