- {$_("new-list")}
+
+
-
+ {#if filterExpanded}
+
+
+ setAuthorFilter(e.detail)}
+ on:clear={clearAuthorFilter}
+ bind:value={userQuery}
+ clearAfterSelect={false}
+ label={$_("author")}
+ >
+
+ {/if}
{$_("sort")}
+
+
+
+
+ {#if $currentUser}
+ +
+
+
+
+
+
+
+
+ {/if}
+ -
+
{#if !selectedList}
-
- {#each $lists as item, i}
-
- setCurrentList(item)}
- role="presentation"
- >
-
-
- {/each}
+
+ {#if loading}
+ {#each { length: 3 } as _, index}
+
+ {/each}
+ {:else}
+ {#each data.lists.items as item, i}
+
{:else if selectedList && !selectedTrail}
setCurrentList(item)}
+ role="presentation"
+ >
+
+
+ {/each}
+ {/if}
+
{#if selectedList}
- {
+ data.lists.items = data.lists.items;
+ selectedList = selectedList;
+ }}
>
{/if}
@@ -202,5 +385,9 @@
#trail-map {
height: calc(100vh - 124px);
}
+
+ #list-container {
+ height: calc(100vh - 204px);
+ }
}
diff --git a/web/src/routes/lists/+page.ts b/web/src/routes/lists/+page.ts
index 59ad4453..9a29f45b 100644
--- a/web/src/routes/lists/+page.ts
+++ b/web/src/routes/lists/+page.ts
@@ -1,6 +1,35 @@
-import { lists_index } from "$lib/stores/list_store";
-import type { Load } from "@sveltejs/kit";
+import type { List, ListFilter } from "$lib/models/list";
+import { lists_index, lists_show } from "$lib/stores/list_store";
+import { error, type Load } from "@sveltejs/kit";
+import { ClientResponseError, type ListResult } from "pocketbase";
export const load: Load = async ({ params, fetch, url }) => {
- await lists_index(undefined, fetch);
+ const filter: ListFilter = {
+ q: "",
+ author: "",
+ shared: true,
+ public: true,
+ sort: "created",
+ sortOrder: "+",
+ };
+
+ let lists: ListResult
- ;
+ if (url.searchParams.get("list")) {
+ try {
+ const list = await lists_show(url.searchParams.get("list") ?? "", fetch)
+
+ lists = { items: [list], page: 1, perPage: 1, totalItems: 1, totalPages: 1 }
+ } catch (e) {
+ if (e instanceof ClientResponseError && e.status == 404) {
+ error(404, {
+ message: 'Not found'
+ });
+ }
+ throw e
+ }
+ } else {
+ lists = await lists_index(filter, 1, undefined, fetch);
+ }
+
+ return { lists, filter }
};
\ No newline at end of file
diff --git a/web/src/routes/lists/edit/[id]/+page.svelte b/web/src/routes/lists/edit/[id]/+page.svelte
index 8447403a..926f71f9 100644
--- a/web/src/routes/lists/edit/[id]/+page.svelte
+++ b/web/src/routes/lists/edit/[id]/+page.svelte
@@ -82,7 +82,8 @@
if ($form.id) {
await lists_update($form, avatarFile);
} else {
- await lists_create($form, avatarFile);
+ const createdList = await lists_create($form, avatarFile);
+ $form.id = createdList.id;
}
show_toast({
type: "success",
diff --git a/web/src/routes/map/trail/[id]/+page.ts b/web/src/routes/map/trail/[id]/+page.ts
index 9afb63bc..8cab3d75 100644
--- a/web/src/routes/map/trail/[id]/+page.ts
+++ b/web/src/routes/map/trail/[id]/+page.ts
@@ -14,5 +14,4 @@ export const load: ServerLoad = async ({ params, locals, fetch }) => {
}
}
- await lists_index(undefined, fetch);
};
\ No newline at end of file
diff --git a/web/src/routes/map/trail/[id]/print/+page.ts b/web/src/routes/map/trail/[id]/print/+page.ts
index b7aa33b1..4379e1f7 100644
--- a/web/src/routes/map/trail/[id]/print/+page.ts
+++ b/web/src/routes/map/trail/[id]/print/+page.ts
@@ -1,4 +1,3 @@
-import { lists_index } from "$lib/stores/list_store";
import { trails_show } from "$lib/stores/trail_store";
import { error, type Load } from "@sveltejs/kit";
import { ClientResponseError } from "pocketbase";
@@ -13,7 +12,6 @@ export const load: Load = async ({ params, fetch }) => {
});
}
console.log(e);
-
+
}
- await lists_index(undefined, fetch);
};
\ No newline at end of file
diff --git a/web/src/routes/trail/edit/[id]/+page.svelte b/web/src/routes/trail/edit/[id]/+page.svelte
index 0416e802..64f16488 100644
--- a/web/src/routes/trail/edit/[id]/+page.svelte
+++ b/web/src/routes/trail/edit/[id]/+page.svelte
@@ -22,10 +22,9 @@
import { Waypoint } from "$lib/models/waypoint";
import { categories } from "$lib/stores/category_store";
import {
- lists,
lists_add_trail,
lists_index,
- lists_remove_trail,
+ lists_remove_trail
} from "$lib/stores/list_store";
import { summitLog } from "$lib/stores/summit_log_store";
import { show_toast } from "$lib/stores/toast_store";
@@ -34,6 +33,7 @@
trails_create,
trails_update,
} from "$lib/stores/trail_store";
+ import { currentUser } from "$lib/stores/user_store.js";
import {
anchors,
appendToRoute,
@@ -53,11 +53,7 @@
} from "$lib/util/format_util";
import {
fromFile,
- fromFIT,
- fromKML,
- fromTCX,
- gpx2trail,
- isFITFile,
+ gpx2trail
} from "$lib/util/gpx_util";
import {
@@ -73,7 +69,7 @@
import { scale } from "svelte/transition";
import { array, number, object, string } from "yup";
- export let data: { trail: Trail };
+ export let data;
let map: M.Map;
@@ -455,7 +451,7 @@
} else {
await lists_add_trail(list, $form);
}
- await lists_index();
+ await lists_index({ q: "", author: $currentUser?.id ?? "" }, 1, -1);
} catch (e) {
console.error(e);
show_toast({
@@ -844,13 +840,13 @@
on:click={beforeSummitLogModalOpen}
>{$_("add-entry")}
- {#if $lists.length}
+ {#if data.lists.items.length}
{$_("list", { values: { n: 2 } })}
- {#each $lists as list}
+ {#each data.lists.items as list}
{#if $form.id && list.trails?.includes($form.id)}
handleListSelection(e.detail)}
>
diff --git a/web/src/routes/trail/edit/[id]/+page.ts b/web/src/routes/trail/edit/[id]/+page.ts
index 458cf2c8..ab518b65 100644
--- a/web/src/routes/trail/edit/[id]/+page.ts
+++ b/web/src/routes/trail/edit/[id]/+page.ts
@@ -1,15 +1,16 @@
import { Trail } from "$lib/models/trail";
+import { pb } from "$lib/pocketbase";
import { categories_index } from "$lib/stores/category_store";
import { lists_index } from "$lib/stores/list_store";
import { trails_show } from "$lib/stores/trail_store";
import { error, type Load } from "@sveltejs/kit";
-export const load: Load = async ({ params, fetch, data }) => {
+export const load: Load = async ({ params, fetch }) => {
if (!params.id) {
return error(400, "Bad Request")
}
const categories = await categories_index(fetch)
- const lists = await lists_index(undefined, fetch)
+ const lists = await lists_index({ q: "", author: pb.authStore.model?.id ?? "" }, 1, -1, fetch)
let trail: Trail;
if (params.id === "new") {
@@ -18,5 +19,5 @@ export const load: Load = async ({ params, fetch, data }) => {
trail = await trails_show(params.id, true, fetch);
}
- return { trail: trail }
+ return { trail: trail, lists: lists }
};
\ No newline at end of file
diff --git a/web/src/routes/trail/view/[id]/+page.svelte b/web/src/routes/trail/view/[id]/+page.svelte
index b753e4e1..76468b2e 100644
--- a/web/src/routes/trail/view/[id]/+page.svelte
+++ b/web/src/routes/trail/view/[id]/+page.svelte
@@ -2,9 +2,11 @@
import TrailInfoPanel from "$lib/components/trail/trail_info_panel.svelte";
import { trail } from "$lib/stores/trail_store";
import { _ } from "svelte-i18n";
+
+ export let data;
-
+
{$trail.name} | {$_("trail", { values: { n: 1 } })} | wanderer {
try {
- await trails_show(params.id!, true, fetch)
+ const trail = await trails_show(params.id!, true, fetch)
+
+ return { trail }
} catch (e) {
if (e instanceof ClientResponseError && e.status == 404) {
error(404, {
@@ -13,7 +16,6 @@ export const load: Load = async ({ params, fetch }) => {
});
}
console.log(e);
-
}
- await lists_index(undefined, fetch);
+
};
\ No newline at end of file