From b759cbb50549900b4795109dafcc79f592845670 Mon Sep 17 00:00:00 2001 From: EiSiMo Date: Thu, 23 Apr 2026 13:50:15 +0200 Subject: [PATCH] feat(settings): hide push-channel fields when "Nur Dashboard" is picked MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Channel-dependent fields (Telegram bot token, chat id, event checkboxes, "Test senden" button) now hide when the user switches the Kanal select to "Nur Dashboard". Implemented as data-channel-only="telegram" markers that a tiny syncChannelOnlyFields() in app.js toggles via inline display:none. Initial state is set in Jinja so there's no flash on load. Hidden inputs stay in the form, so the values survive the round-trip: switch to Dashboard → save → switch back to Telegram and the bot token / chat id are still there. Co-Authored-By: Claude Opus 4.7 (1M context) --- web/static/app.js | 20 ++++++++++++++++++++ web/templates/_settings_notifications.html | 15 +++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) 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.

-
+
-
+