From c00cf85fedc79ee5b3a2a6c5620fe7455a41b9e2 Mon Sep 17 00:00:00 2001 From: Christian Beutel <> Date: Fri, 13 Dec 2024 18:05:57 +0100 Subject: [PATCH] adds lists search and filter --- .../lib/components/base/skeleton_card.svelte | 7 +- web/src/lib/components/confirm_modal.svelte | 2 +- web/src/lib/components/list/list_card.svelte | 24 +- web/src/lib/components/list/list_panel.svelte | 24 +- .../components/list/list_select_modal.svelte | 7 +- .../components/list/list_share_modal.svelte | 9 +- web/src/lib/components/share_info.svelte | 2 +- .../components/trail/trail_dropdown.svelte | 11 +- web/src/lib/models/list.ts | 9 +- web/src/lib/stores/list_store.ts | 55 +++- web/src/routes/api/v1/list/+server.ts | 31 ++- web/src/routes/lists/+page.svelte | 259 +++++++++++++++--- web/src/routes/lists/+page.ts | 35 ++- web/src/routes/lists/edit/[id]/+page.svelte | 3 +- web/src/routes/map/trail/[id]/+page.ts | 1 - web/src/routes/map/trail/[id]/print/+page.ts | 4 +- web/src/routes/trail/edit/[id]/+page.svelte | 19 +- web/src/routes/trail/edit/[id]/+page.ts | 7 +- web/src/routes/trail/view/[id]/+page.svelte | 4 +- web/src/routes/trail/view/[id]/+page.ts | 8 +- 20 files changed, 417 insertions(+), 104 deletions(-) diff --git a/web/src/lib/components/base/skeleton_card.svelte b/web/src/lib/components/base/skeleton_card.svelte index 81cae29c..aee56e80 100644 --- a/web/src/lib/components/base/skeleton_card.svelte +++ b/web/src/lib/components/base/skeleton_card.svelte @@ -1,5 +1,10 @@ + + + {/if} -
+
{list.name}
{#if list.public} - + {/if} @@ -70,6 +67,21 @@ {/if}
+ {#if list.expand?.author} +

+ {$_("by")} + avatar + {list.expand?.author.username} +

+ {/if}
diff --git a/web/src/lib/components/list/list_panel.svelte b/web/src/lib/components/list/list_panel.svelte index 4c0691b2..7f4bb60e 100644 --- a/web/src/lib/components/list/list_panel.svelte +++ b/web/src/lib/components/list/list_panel.svelte @@ -42,8 +42,12 @@ list.author == $currentUser?.id || list.expand?.list_share_via_list?.some((s) => s.permission == "edit"); + $: allowShare = + list.author == $currentUser?.id && + !list.expand?.trails?.some((t) => t.author !== $currentUser?.id); + $: dropdownItems = [ - ...(list.author == $currentUser?.id + ...(allowShare ? [{ text: $_("share"), value: "share", icon: "share" }] : []), ...(allowEdit @@ -122,7 +126,23 @@

{list.name}

- + {#if list.expand?.author} +

+ {$_("by")} + avatar + {list.expand.author.username} +

+ {/if}
void) | undefined = undefined; export let closeModal: (() => void) | undefined = undefined; @@ -34,7 +35,7 @@
    - {#each $lists as list} + {#each lists as list}
  • handleSelect(list)} diff --git a/web/src/lib/components/list/list_share_modal.svelte b/web/src/lib/components/list/list_share_modal.svelte index 69a41b98..33fe8fde 100644 --- a/web/src/lib/components/list/list_share_modal.svelte +++ b/web/src/lib/components/list/list_share_modal.svelte @@ -3,7 +3,6 @@ import type { List } from "$lib/models/list"; import { ListShare } from "$lib/models/list_share"; import { TrailShare } from "$lib/models/trail_share"; - import type { User } from "$lib/models/user"; import { list_share_create, list_share_delete, @@ -11,19 +10,15 @@ list_share_update, shares, } from "$lib/stores/list_share_store"; - import { lists } from "$lib/stores/list_store"; - import { show_toast } from "$lib/stores/toast_store"; import { trail_share_create, trail_share_delete, trail_share_index, } from "$lib/stores/trail_share_store"; - import { users_search } from "$lib/stores/user_store"; import { getFileURL } from "$lib/util/file_util"; import { createEventDispatcher } from "svelte"; import { _ } from "svelte-i18n"; import Button from "../base/button.svelte"; - import Search, { type SearchItem } from "../base/search.svelte"; import type { SelectItem } from "../base/select.svelte"; import Select from "../base/select.svelte"; import UserSearch from "../user_search.svelte"; @@ -116,8 +111,8 @@ trails: list.expand?.trails ?? [], list_share_via_list: fetchedShares, }; - lists.set($lists); - sharesLoading = false; + sharesLoading = false; + dispatch("update", list) } diff --git a/web/src/lib/components/share_info.svelte b/web/src/lib/components/share_info.svelte index e967e462..2f8893e4 100644 --- a/web/src/lib/components/share_info.svelte +++ b/web/src/lib/components/share_info.svelte @@ -52,7 +52,7 @@ > {#if showInfo}