feat: improve job details interaction and accessibility

- Enhanced job details toggle functionality by adding event listeners to job detail elements.
- Updated job detail rows to use data attributes for better accessibility and maintainability.
- Improved the rendering of file information with unique keys for each file entry.
This commit is contained in:
xeisenberg
2025-05-27 16:10:35 +05:30
committed by Emrik Östling
parent 50725edd02
commit 29ba229bc2

View File

@@ -1169,7 +1169,9 @@ const app = new Elysia({
px-2 py-2 px-2 py-2
sm:px-4 sm:px-4
`} `}
/> >
<span class="sr-only">Expand details</span>
</th>
<th <th
class={` class={`
px-2 py-2 px-2 py-2
@@ -1216,10 +1218,10 @@ const app = new Elysia({
<tbody> <tbody>
{userJobs.map((job) => ( {userJobs.map((job) => (
<> <>
<tr id={`job-row-${job.id}`}> <tr key={`job-${job.id}` as any} id={`job-row-${job.id}`}>
<td <td
class="cursor-pointer" class="job-details-toggle cursor-pointer"
onclick={`toggleJobDetails(${job.id})`} data-job-id={job.id}
> >
<svg <svg
id={`arrow-${job.id}`} id={`arrow-${job.id}`}
@@ -1261,8 +1263,12 @@ const app = new Elysia({
<div class="mb-1 font-semibold"> <div class="mb-1 font-semibold">
Detailed File Information: Detailed File Information:
</div> </div>
{job.files_detailed.map((file: Filename) => ( {job.files_detailed.map(
<div class="flex items-center"> (file: Filename, index: number) => (
<div
key={String(file.id) as any}
class="flex items-center"
>
<span <span
class="w-5/12 truncate" class="w-5/12 truncate"
title={file.file_name} title={file.file_name}
@@ -1290,7 +1296,8 @@ const app = new Elysia({
{file.output_file_name} {file.output_file_name}
</span> </span>
</div> </div>
))} ),
)}
</div> </div>
</td> </td>
</tr> </tr>
@@ -1302,18 +1309,28 @@ const app = new Elysia({
</main> </main>
<script> <script>
{` {`
function toggleJobDetails(jobId) { document.addEventListener('DOMContentLoaded', () => {
const toggles = document.querySelectorAll('.job-details-toggle');
toggles.forEach(toggle => {
toggle.addEventListener('click', function() {
const jobId = this.dataset.jobId;
const detailsRow = document.getElementById(\`details-\${jobId}\`); const detailsRow = document.getElementById(\`details-\${jobId}\`);
// The arrow SVG itself has the ID arrow-\${jobId}
const arrow = document.getElementById(\`arrow-\${jobId}\`); const arrow = document.getElementById(\`arrow-\${jobId}\`);
if (detailsRow && arrow) { if (detailsRow && arrow) {
detailsRow.classList.toggle("hidden"); detailsRow.classList.toggle("hidden");
if (detailsRow.classList.contains("hidden")) { if (detailsRow.classList.contains("hidden")) {
// Right-facing arrow (collapsed)
arrow.innerHTML = '<path stroke-linecap="round" stroke-linejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" />'; arrow.innerHTML = '<path stroke-linecap="round" stroke-linejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" />';
} else { } else {
// Down-facing arrow (expanded)
arrow.innerHTML = '<path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" />'; arrow.innerHTML = '<path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" />';
} }
} }
} });
});
});
`} `}
</script> </script>
</> </>