From 562f5989e10b263bf06d1f5e3b17a7fc425176f8 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 9 Jan 2025 15:17:34 +0100 Subject: [PATCH] Solved identifier bug --- app/static/js/modal.js | 61 +++++++++++++++++++++++------- app/templates/moduls/modal.html.j2 | 18 +++++++-- 2 files changed, 63 insertions(+), 16 deletions(-) diff --git a/app/static/js/modal.js b/app/static/js/modal.js index c12914e..ef77f74 100644 --- a/app/static/js/modal.js +++ b/app/static/js/modal.js @@ -1,18 +1,53 @@ function openDynamicPopup(subitem) { - // Set modal title and content - document.getElementById('dynamicModalLabel').innerText = subitem.description; - const modalContent = document.getElementById('dynamicModalContent'); - modalContent.value = subitem.identifier; + // Setze den Titel + document.getElementById('dynamicModalLabel').innerText = subitem.description; - // Add copy functionality - document.getElementById('dynamicCopyButton').addEventListener('click', function () { + // Setze den Identifier, falls vorhanden + const modalContent = document.getElementById('dynamicModalContent'); + if (subitem.identifier) { + modalContent.value = subitem.identifier; + } else { + modalContent.value = ''; + } + + // Konfiguriere die Warnbox + const warningBox = document.getElementById('dynamicModalWarning'); + if (subitem.warning) { + warningBox.classList.remove('d-none'); + document.getElementById('dynamicModalWarningText').innerText = subitem.warning; + } else { + warningBox.classList.add('d-none'); + } + + // Konfiguriere die Infobox + const infoBox = document.getElementById('dynamicModalInfo'); + if (subitem.info) { + infoBox.classList.remove('d-none'); + document.getElementById('dynamicModalInfoText').innerText = subitem.info; + } else { + infoBox.classList.add('d-none'); + } + + // Konfiguriere den Link + const linkBox = document.getElementById('dynamicModalLink'); + const linkHref = document.getElementById('dynamicModalLinkHref'); + if (subitem.url) { + linkBox.classList.remove('d-none'); + linkHref.href = subitem.url; + } else { + linkBox.classList.add('d-none'); + linkHref.href = '#'; + } + + // Kopierfunktion für den Identifier + document.getElementById('dynamicCopyButton').addEventListener('click', function () { modalContent.select(); navigator.clipboard.writeText(modalContent.value) - .then(() => alert('Content copied to clipboard!')) - .catch(() => alert('Failed to copy content.')); - }); + .then(() => alert('Content copied to clipboard!')) + .catch(() => alert('Failed to copy content.')); + }); - // Show the modal - const modal = new bootstrap.Modal(document.getElementById('dynamicModal')); - modal.show(); - } \ No newline at end of file + // Modal anzeigen + const modal = new bootstrap.Modal(document.getElementById('dynamicModal')); + modal.show(); +} diff --git a/app/templates/moduls/modal.html.j2 b/app/templates/moduls/modal.html.j2 index 4314f7f..37f966c 100644 --- a/app/templates/moduls/modal.html.j2 +++ b/app/templates/moduls/modal.html.j2 @@ -1,4 +1,3 @@ - \ No newline at end of file +