From a0622073418502c77b341f05a9aeeb4a018e4fe3 Mon Sep 17 00:00:00 2001 From: Allan Lasser Date: Thu, 5 Dec 2024 17:34:50 -0500 Subject: [PATCH] Adds menu with customization options --- src/langs/json/en.json | 3 +- .../components/documents/ResultsList.svelte | 22 +++++- .../components/layouts/DocumentBrowser.svelte | 28 +------ .../layouts/DocumentListToolbar.svelte | 77 +++++++++++++++++++ .../stories/DocumentBrowser.stories.svelte | 2 +- 5 files changed, 104 insertions(+), 28 deletions(-) create mode 100644 src/lib/components/layouts/DocumentListToolbar.svelte diff --git a/src/langs/json/en.json b/src/langs/json/en.json index 0157af71c..94b046bcf 100644 --- a/src/langs/json/en.json +++ b/src/langs/json/en.json @@ -8,7 +8,8 @@ "edit": "Edit", "search": "Search", "feedback": "Feedback", - "title": "Title" + "title": "Title", + "customize": "Customize" }, "search": { "loading": "Searching…", diff --git a/src/lib/components/documents/ResultsList.svelte b/src/lib/components/documents/ResultsList.svelte index 6ea8779a1..c27f47669 100644 --- a/src/lib/components/documents/ResultsList.svelte +++ b/src/lib/components/documents/ResultsList.svelte @@ -18,6 +18,17 @@ ); export let total: Writable = writable(0); + + // Allow users to customize the visible fields in document list items + const storage = new StorageManager("document-browser"); + const userDefaultVisible = storage.get( + "visibleFields", + defaultVisibleFields, + ); + export const visibleFields: Writable = writable( + Object.assign({}, defaultVisibleFields, userDefaultVisible), + ); + visibleFields.subscribe((val) => storage.set("visibleFields", val)); + + + + + + + {$_("common.customize")} + + + +
+ {#each Object.entries($visibleFields) as [key, value], index} + + {/each} +
+
+
+
+ +
+ +

+ {@html $_("search.help")} + + {$_("search.more")} + +

+
+
+
+ + diff --git a/src/lib/components/layouts/stories/DocumentBrowser.stories.svelte b/src/lib/components/layouts/stories/DocumentBrowser.stories.svelte index e8cb99807..f9c01fc7a 100644 --- a/src/lib/components/layouts/stories/DocumentBrowser.stories.svelte +++ b/src/lib/components/layouts/stories/DocumentBrowser.stories.svelte @@ -15,7 +15,7 @@ }; const args = { - documents: Promise.resolve(documentsList), + documents: Promise.resolve({ data: documentsList }), };