From d8a13f1961046e7bb4b814de2a66ed38b446d160 Mon Sep 17 00:00:00 2001 From: ecki Date: Fri, 24 Apr 2026 09:57:25 +0200 Subject: [PATCH] Datumsfelder gefixt --- backend/public/js/modals.js | 42 +++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/backend/public/js/modals.js b/backend/public/js/modals.js index cd0144d..df880b8 100644 --- a/backend/public/js/modals.js +++ b/backend/public/js/modals.js @@ -1,6 +1,33 @@ /* ========================= RESOURCE MODAL ========================= */ +function toInputDate(value){ + if(!value) return "" + + return String(value).slice(0, 10) +} + +function formatDisplayDate(value){ + if(!value) return "" + + const date = new Date(value) + + if(Number.isNaN(date.getTime())){ + return String(value) + } + + return date.toLocaleDateString("de-DE") +} + +function formatSubdomainName(subdomain, domainName){ + if(!subdomain) return domainName || "" + if(!domainName) return subdomain + + return subdomain.endsWith("." + domainName) || subdomain === domainName + ? subdomain + : subdomain + "." + domainName +} + window.openCreate = function(){ document.getElementById("modalTitle").innerText = "Create Resource" @@ -23,7 +50,13 @@ document.getElementById("resource_id").value=resource.id Object.keys(resource).forEach(k=>{ const el=document.getElementById(k) -if(el) el.value=resource[k] || "" +if(el){ +if(el.type === "date"){ +el.value = toInputDate(resource[k]) +}else{ +el.value = resource[k] || "" +} +} }) document.getElementById("resourceModal").style.display="block" @@ -81,7 +114,7 @@ window.openServerDetail = async function(resource){ html += `
- ↳ ${s.subdomain}.${s.domain_name} + ↳ ${formatSubdomainName(s.subdomain, s.domain_name)}
` @@ -95,8 +128,9 @@ window.openServerDetail = async function(resource){ html += `
- Bestelldatum: ${resource.bestelldatum || ""}
- Kündbar ab: ${resource.kuendbar_ab || ""} + Bestelldatum: ${formatDisplayDate(resource.bestelldatum)}
+ Kündbar ab: ${formatDisplayDate(resource.kuendbar_ab)}
+ Kündigungsdatum: ${formatDisplayDate(resource.kuendigungsdatum)}