From 48f0eb0e7e016f632362600f7fc39f55d85a332a Mon Sep 17 00:00:00 2001 From: LD-Reborn Date: Sun, 23 Nov 2025 21:47:03 +0100 Subject: [PATCH] Improved toast accessibility, improved batch accessibility --- src/Resources/Views.Shared._Batch.de.resx | 3 +++ src/Resources/Views.Shared._BatchButton.resx | 20 +++++++++++++++++++ src/Views/Shared/_Batch.cshtml | 18 +++++++++++++---- src/Views/Shared/_BatchButton.cshtml | 5 ++++- src/wwwroot/js/site.js | 21 ++++++++++++++++++-- 5 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 src/Resources/Views.Shared._BatchButton.resx diff --git a/src/Resources/Views.Shared._Batch.de.resx b/src/Resources/Views.Shared._Batch.de.resx index 23cc857..4898375 100644 --- a/src/Resources/Views.Shared._Batch.de.resx +++ b/src/Resources/Views.Shared._Batch.de.resx @@ -73,4 +73,7 @@ Seriennummer + + Eintrag löschen + diff --git a/src/Resources/Views.Shared._BatchButton.resx b/src/Resources/Views.Shared._BatchButton.resx new file mode 100644 index 0000000..ec9967a --- /dev/null +++ b/src/Resources/Views.Shared._BatchButton.resx @@ -0,0 +1,20 @@ + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, ... + + + System.Resources.ResXResourceWriter, System.Windows.Forms, ... + + + + Druckseite öffnen + + + diff --git a/src/Views/Shared/_Batch.cshtml b/src/Views/Shared/_Batch.cshtml index 2c8fc05..c6adfc6 100644 --- a/src/Views/Shared/_Batch.cshtml +++ b/src/Views/Shared/_Batch.cshtml @@ -67,7 +67,10 @@ const asset = json.assetsModel; assetCard.innerHTML = `
-

Asset ${i + 1}: ${asset.Name}

+ +

Asset ${i + 1}: ${asset.Name}

+ +

@T["Asset ID"]: ${asset.Cn}

@@ -87,7 +90,10 @@ } else { assetCard.innerHTML = `
-

Asset ${i + 1}: @T["Empty"]

+ +

Asset ${i + 1}: @T["Empty"]

+ +
@@ -236,10 +242,14 @@ let cardAtIndex = document.querySelector(`[data-card-index="${index}"]`) let cardBodyAtIndex = cardAtIndex.children[0]; - cardBodyAtIndex.children[0].children[1].textContent = `Asset ${newIndex + 1}`; + cardBodyAtIndex.children[1].children[0].children[0].children[0].nextSibling.textContent = ` ${newIndex + 1}`; + cardBodyAtIndex.children[0].children[0].children[0].textContent = `Asset ${newIndex + 1}:`; + cardBodyAtIndex.children[0].children[0].children[0].ariaLabel = cardBodyAtIndex.children[0].children[0].children[0].ariaLabel.replace(/\s\d+\:/, ` ${newIndex + 1}:`); let cardAtTarget = document.querySelector(`[data-card-index="${newIndex}"]`) let cardBodyAtTarget = cardAtTarget.children[0]; - cardBodyAtTarget.children[0].children[1].textContent = `Asset ${index - 0 + 1}`; + cardBodyAtTarget.children[1].children[0].children[0].children[0].nextSibling.textContent = ` ${index - 0 + 1}`; + cardBodyAtTarget.children[0].children[0].children[0].textContent = `Asset ${index - 0 + 1}:`; + cardBodyAtTarget.children[0].children[0].children[0].ariaLabel = cardBodyAtTarget.children[0].children[0].children[0].ariaLabel.replace(/\s\d+\:/, ` ${newIndex + 1}:`); cardAtIndex.insertBefore(cardBodyAtTarget, null); cardAtTarget.insertBefore(cardBodyAtIndex, null); diff --git a/src/Views/Shared/_BatchButton.cshtml b/src/Views/Shared/_BatchButton.cshtml index 5fe2fdc..91504c4 100644 --- a/src/Views/Shared/_BatchButton.cshtml +++ b/src/Views/Shared/_BatchButton.cshtml @@ -1,8 +1,11 @@ +@using Microsoft.AspNetCore.Mvc.Localization +@inject IViewLocalizer T + \ No newline at end of file diff --git a/src/wwwroot/js/site.js b/src/wwwroot/js/site.js index a30dea4..0fd7bda 100644 --- a/src/wwwroot/js/site.js +++ b/src/wwwroot/js/site.js @@ -2,6 +2,16 @@ const container = document.createElement('div'); container.id = 'toastContainer'; container.className = 'toast-container position-fixed bottom-0 end-0 p-3'; + container.setAttribute("aria-live", "polite"); + container.setAttribute("aria-atomic", "true"); + + const liveRegion = document.createElement('div'); + liveRegion.id = 'toastLiveRegion'; + liveRegion.className = 'visually-hidden'; + liveRegion.setAttribute('aria-live', 'assertive'); + liveRegion.setAttribute('aria-atomic', 'true'); + container.appendChild(liveRegion); + document.body.appendChild(container); return container; } @@ -16,7 +26,7 @@ function showToast(message, type) { toast.innerHTML = `
${message}
- +
`; if (useDarkElements) { @@ -24,7 +34,14 @@ function showToast(message, type) { toast.classList.add("text-dark"); } toastContainer.appendChild(toast); - const bsToast = new bootstrap.Toast(toast, { delay: 5000 }); + + const liveRegion = document.getElementById('toastLiveRegion'); + if (liveRegion) { + liveRegion.textContent = ''; + setTimeout(() => liveRegion.textContent = message, 500); + } + + const bsToast = new bootstrap.Toast(toast, { delay: 10000 }); bsToast.show(); toast.addEventListener('hidden.bs.toast', () => toast.remove()); }