feat(settings): hide push-channel fields when "Nur Dashboard" is picked
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) <noreply@anthropic.com>
This commit is contained in:
parent
6ad6565cf2
commit
b759cbb505
2 changed files with 31 additions and 4 deletions
|
|
@ -144,6 +144,26 @@ function openDeepLinkedFlat() {
|
|||
|
||||
document.addEventListener("DOMContentLoaded", openDeepLinkedFlat);
|
||||
|
||||
// Notification-channel toggle — show fields tagged data-channel-only="<value>"
|
||||
// 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue