sorts summit log entries by date

This commit is contained in:
Christian Beutel
2024-11-02 01:43:59 +01:00
parent 63da3d4144
commit ebfd6f0e72
3 changed files with 10 additions and 7 deletions

View File

@@ -36,7 +36,7 @@
if (!log.expand.gpx_data) {
return;
}
layerGroup.clearLayers();
const geoJson = gpx(
new DOMParser().parseFromString(log.expand.gpx_data, "text/xml"),
@@ -78,7 +78,7 @@
});
layerGroup.addLayer(startMarker);
layerGroup.addLayer(endMarker)
layerGroup.addLayer(endMarker);
}
},
filter: (feature: any, layer: any) => {

View File

@@ -73,17 +73,17 @@
}
</script>
<tr class="h-24 text-center">
<tr class="text-center">
<td>
<button
type="button"
on:click={openMap}
class="h-24 aspect-square shrink-0 rounded-xl !bg-background"
class="h-20 aspect-square shrink-0 rounded-xl !bg-background"
class:hidden={!log.expand.gpx_data}
id="mini-map-{index}"
></button>
</td>
<td
<td class:py-4={!log.text && !log.expand.gpx_data}
>{new Date(log.date).toLocaleDateString(undefined, {
month: "2-digit",
day: "2-digit",
@@ -111,8 +111,11 @@
</tr>
{#if showText}
<tr
><td class="text-left text-sm whitespace-pre-wrap" colspan="6"
><td class="text-left text-sm whitespace-pre-wrap pb-4" colspan="6"
>{log.text}</td
></tr
>
{/if}
<tr>
<td colspan="6"> <hr /> </td>
</tr>

View File

@@ -165,7 +165,7 @@ export async function trails_show(id: string, loadGPX?: boolean, f: (url: Reques
}
response.expand.waypoints = response.expand.waypoints || [];
response.expand.summit_logs = response.expand.summit_logs || [];
response.expand.summit_logs = response.expand.summit_logs.sort((a: SummitLog, b: SummitLog) => Date.parse(a.date) - Date.parse(b.date)) || [];
trail.set(response);