Datumsfelder gefixt
This commit is contained in:
@@ -1,6 +1,33 @@
|
|||||||
/* =========================
|
/* =========================
|
||||||
RESOURCE MODAL
|
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(){
|
window.openCreate = function(){
|
||||||
|
|
||||||
document.getElementById("modalTitle").innerText = "Create Resource"
|
document.getElementById("modalTitle").innerText = "Create Resource"
|
||||||
@@ -23,7 +50,13 @@ document.getElementById("resource_id").value=resource.id
|
|||||||
|
|
||||||
Object.keys(resource).forEach(k=>{
|
Object.keys(resource).forEach(k=>{
|
||||||
const el=document.getElementById(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"
|
document.getElementById("resourceModal").style.display="block"
|
||||||
@@ -81,7 +114,7 @@ window.openServerDetail = async function(resource){
|
|||||||
|
|
||||||
html += `
|
html += `
|
||||||
<div class="subdomain-detail">
|
<div class="subdomain-detail">
|
||||||
↳ ${s.subdomain}.${s.domain_name}
|
↳ ${formatSubdomainName(s.subdomain, s.domain_name)}
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
|
|
||||||
@@ -95,8 +128,9 @@ window.openServerDetail = async function(resource){
|
|||||||
html += `
|
html += `
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<b>Bestelldatum:</b> ${resource.bestelldatum || ""}<br>
|
<b>Bestelldatum:</b> ${formatDisplayDate(resource.bestelldatum)}<br>
|
||||||
<b>Kündbar ab:</b> ${resource.kuendbar_ab || ""}
|
<b>Kündbar ab:</b> ${formatDisplayDate(resource.kuendbar_ab)}<br>
|
||||||
|
<b>Kündigungsdatum:</b> ${formatDisplayDate(resource.kuendigungsdatum)}
|
||||||
|
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user