Fix trip delete button: layout and click handler

- text-nowrap on action cell so Replay+trash stay on same line
- Delete button inline with Replay (no whitespace between)
- Explicit deletable guard in click handler

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
Mathieu Moran
2026-08-10 04:45:05 -04:00
co-authored by Copilot
parent 7aa9ffda16
commit 72e4c1b1d7
+8 -6
View File
@@ -203,24 +203,25 @@
<td>${formatDuration(trip.duration_seconds)}</td>
<td>${formatSpeed(trip.max_speed_kmh)}</td>
<td class="text-muted small">${trip.odo_start_km != null ? trip.odo_start_km.toFixed(0) + ' → ' + trip.odo_end_km.toFixed(0) + ' km' : '—'}</td>
<td class="text-end d-none d-sm-table-cell">
<td class="text-end text-nowrap d-none d-sm-table-cell">
<button class="btn btn-sm btn-primary" type="button" data-trip-id="${trip.id}">
Replay
</button>
${deleteBtn}
</button>${deleteBtn}
</td>`;
body.appendChild(row);
});
}
body.addEventListener("click", function (event) {
// Delete button
// Delete button — must check before replay to prevent row click triggering replay
if (deletable) {
const deleteBtn = event.target.closest("[data-delete-trip-id]");
if (deleteBtn) {
event.stopPropagation();
event.preventDefault();
const tripId = deleteBtn.dataset.deleteTripId;
const date = deleteBtn.closest("tr").querySelector("td").textContent;
window.confirmDelete(`Delete trip from ${date}? The raw GPS data is kept — only the computed trip record is removed.`)
const date = deleteBtn.closest("tr").querySelector("td").textContent.trim();
window.confirmDelete(`Delete trip from ${date}?\n\nThe raw GPS data is kept — only this computed trip record is removed.`)
.then(function(confirmed) {
if (!confirmed) return;
return fetch(`/api/v1/portal/trip/${tripId}`, { method: "DELETE" })
@@ -232,6 +233,7 @@
});
return;
}
}
// Replay button click (desktop) or row click (mobile)
const button = event.target.closest("[data-trip-id]");