From 87eb879c7ff3400db2824f7d3ed46d5ff235fe7c Mon Sep 17 00:00:00 2001 From: Christian Beutel <> Date: Tue, 5 Nov 2024 00:47:47 +0100 Subject: [PATCH] finishes profile page --- web/src/lib/components/base/calendar.svelte | 34 +- .../lib/components/base/multi_select.svelte | 83 +++++ .../summit_log/summit_log_table.svelte | 55 ++- .../summit_log/summit_log_table_row.svelte | 42 ++- .../trail/trail_filter_panel.svelte | 4 +- web/src/lib/i18n/locales/de.json | 39 ++- web/src/lib/i18n/locales/en.json | 5 + web/src/lib/i18n/locales/fr.json | 5 + web/src/lib/i18n/locales/hu.json | 5 + web/src/lib/i18n/locales/it.json | 5 + web/src/lib/i18n/locales/nl.json | 5 + web/src/lib/i18n/locales/pl.json | 5 + web/src/lib/i18n/locales/pt.json | 5 + web/src/lib/i18n/locales/zh.json | 5 + web/src/lib/models/summit_log.ts | 7 +- web/src/lib/stores/summit_log_store.ts | 42 ++- web/src/lib/util/format_util.ts | 18 +- web/src/routes/api/v1/summit-log/+server.ts | 5 +- web/src/routes/profile/+page.svelte | 331 ++++++++++++------ web/src/routes/profile/+page.ts | 28 +- 20 files changed, 541 insertions(+), 187 deletions(-) create mode 100644 web/src/lib/components/base/multi_select.svelte diff --git a/web/src/lib/components/base/calendar.svelte b/web/src/lib/components/base/calendar.svelte index 6647dcc2..6de3ecd2 100644 --- a/web/src/lib/components/base/calendar.svelte +++ b/web/src/lib/components/base/calendar.svelte @@ -2,7 +2,7 @@ import type { SummitLog } from "$lib/models/summit_log"; import { createEventDispatcher } from "svelte"; import { isSameDay, isToday } from "../../util/date_util"; - + import { _ } from "svelte-i18n"; export let logs: SummitLog[] = []; export let colorMap: Record = {}; @@ -15,6 +15,7 @@ start: Date; end: Date; }; + click: Date; }>(); const weekdays = ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"]; @@ -74,9 +75,11 @@ i + 1 - firstDay, ); const today = isToday(date); + const logAtDate = logs.find((l) => isSameDay(date, new Date(l.date)), ); + a.push({ date: date, today: today, log: logAtDate }); } } @@ -108,6 +111,21 @@ end: new Date(currentYear, currentMonth + 1, 0), }); } + + function colorKey(i: number) { + return $_( + currentMonthArray[i]?.log?.expand.trails_via_summit_logs?.at(0) + ?.expand?.category?.name ?? "", + ); + } + + function handleDateClick(date?: Date) { + if (!date) { + return; + } + + dispatch("click", date); + }
@@ -134,18 +152,14 @@
{#each { length: 42 } as _, i} -
handleDateClick(currentMonthArray[i]?.date)} class:today={currentMonthArray[i]?.today} - style="background-color: {colorMap[ - currentMonthArray[ - i - ]?.log?.expand.trails_via_summit_logs?.at(0)?.expand - ?.category?.name ?? '' - ] ?? ''}" + style="background-color: {colorMap[colorKey(i)] ?? ''}" > {currentMonthArray[i]?.date?.getDate() ?? ""} -
+ {/each}
diff --git a/web/src/lib/components/base/multi_select.svelte b/web/src/lib/components/base/multi_select.svelte new file mode 100644 index 00000000..a7ea3720 --- /dev/null +++ b/web/src/lib/components/base/multi_select.svelte @@ -0,0 +1,83 @@ + + + +
+ {#if label.length} + + {/if} + +
+ {/each} + + + + {#if showDropdown} +
+ {#each items as item} + + {/each} +
+ {/if} + diff --git a/web/src/lib/components/summit_log/summit_log_table.svelte b/web/src/lib/components/summit_log/summit_log_table.svelte index ad1b7cac..0fb1a737 100644 --- a/web/src/lib/components/summit_log/summit_log_table.svelte +++ b/web/src/lib/components/summit_log/summit_log_table.svelte @@ -5,24 +5,28 @@ import Modal from "../base/modal.svelte"; import SummitLogTableRow from "./summit_log_table_row.svelte"; - import type { Map } from "leaflet"; - import { gpx } from "$lib/vendor/toGeoJSON/toGeoJSON"; - import { endIcon, startIcon } from "$lib/util/leaflet_util"; - import { _ } from "svelte-i18n"; - import MapWithElevation from "../trail/map_with_elevation.svelte"; import type { Trail } from "$lib/models/trail"; import { gpx2trail } from "$lib/util/gpx_util"; + import type { Map } from "leaflet"; + import { _ } from "svelte-i18n"; + import MapWithElevation from "../trail/map_with_elevation.svelte"; export let summitLogs: SummitLog[]; export let showCategory: boolean = false; + export let showTrail: boolean = false; - let openModal: () => void; - let closeModal: () => void; + let openMapModal: () => void; + let closeMapModal: () => void; + + let openTextModal: () => void; + let closeTextModal: () => void; let map: Map; let trail: Trail | null = null; + let currentText: string = ""; + onMount(async () => { // L = (await import("leaflet")).default; // map = L.map("summit-log-table-map"); @@ -42,12 +46,17 @@ trail = (await gpx2trail(log.expand.gpx_data)).trail; trail.expand.gpx_data = log.expand.gpx_data; - openModal(); + openMapModal(); await tick(); map.invalidateSize(); return; } + + async function openText(log: SummitLog) { + currentText = log.text ?? ""; + openTextModal(); + } @@ -64,7 +73,12 @@ {$_("category")} {/if} - + {#if showTrail} + + {/if} + @@ -72,24 +86,37 @@ openMap(log)} + on:open={(e) => openMap(e.detail)} + on:text={(e) => openText(e.detail)} {showCategory} + {showTrail} > {/each}
+ {$_("trail", { values: { n: 1 } })} + {$_("description")}
- +{#if !summitLogs.length} +

{$_("no-data")}

+{/if}
+ +

{currentText}

+