ui: tap any row to replay trip on mobile
- data-trip-id on the <tr> itself - click handler checks row if no button found - cursor: pointer on rows for discoverability Co-authored-by: Copilot <[email protected]>
This commit is contained in:
@@ -148,6 +148,8 @@
|
||||
row.dataset.distance = trip.distance_km;
|
||||
row.dataset.duration = trip.duration_seconds;
|
||||
row.dataset.maxSpeed = trip.max_speed_kmh;
|
||||
row.dataset.tripId = trip.id;
|
||||
row.style.cursor = "pointer";
|
||||
row.innerHTML = `
|
||||
<td>${formatDate(trip.start_datetime)}</td>
|
||||
<td>${formatDistance(trip.distance_km)}</td>
|
||||
@@ -164,11 +166,14 @@
|
||||
}
|
||||
|
||||
body.addEventListener("click", function (event) {
|
||||
// Button click (desktop) or row click (mobile)
|
||||
const button = event.target.closest("[data-trip-id]");
|
||||
if (!button) {
|
||||
const row = event.target.closest("tr[data-trip-id]");
|
||||
const tripId = button ? button.dataset.tripId : (row ? row.dataset.tripId : null);
|
||||
if (!tripId) {
|
||||
return;
|
||||
}
|
||||
replayTrip(button.dataset.tripId).catch(function (replayError) {
|
||||
replayTrip(tripId).catch(function (replayError) {
|
||||
if (replayError.name !== "AbortError") {
|
||||
showError(replayError.message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user