From e50576ddb317d4c93b0b14baccfa86f7e8a3d733 Mon Sep 17 00:00:00 2001 From: Felix Schlegel Date: Mon, 20 Jan 2025 00:48:17 +0100 Subject: [PATCH] feat: bind filter values for papers filtering Now all filters are available in the +page.ts file and can be used to make filtered requests --- .../navigation-bar/SimpleNavigationBar.svelte | 2 +- .../paper-view/cards/PaperDetailsCard.svelte | 2 +- .../composites/select/Select.svelte | 4 +- .../project/[projectId]/papers/+page.svelte | 116 +++++++++++++----- .../[projectId]/papers/CriteriaSelect.svelte | 5 +- .../[projectId]/papers/DecisionsSelect.svelte | 8 +- .../papers/PublishersSelect.svelte | 5 +- .../[projectId]/papers/ReviewersSelect.svelte | 5 +- .../[projectId]/papers/StagesSelect.svelte | 5 +- .../[projectId]/papers/YearsSelect.svelte | 5 +- 10 files changed, 113 insertions(+), 44 deletions(-) diff --git a/src/lib/components/composites/navigation-bar/SimpleNavigationBar.svelte b/src/lib/components/composites/navigation-bar/SimpleNavigationBar.svelte index dbd09027..19b4b858 100644 --- a/src/lib/components/composites/navigation-bar/SimpleNavigationBar.svelte +++ b/src/lib/components/composites/navigation-bar/SimpleNavigationBar.svelte @@ -27,6 +27,6 @@ {:then title}

{title}

{:catch} -

Error

+

Loading failed

{/await} diff --git a/src/lib/components/composites/paper-components/paper-view/cards/PaperDetailsCard.svelte b/src/lib/components/composites/paper-components/paper-view/cards/PaperDetailsCard.svelte index 9ef040dd..d1ab7f4d 100644 --- a/src/lib/components/composites/paper-components/paper-view/cards/PaperDetailsCard.svelte +++ b/src/lib/components/composites/paper-components/paper-view/cards/PaperDetailsCard.svelte @@ -68,7 +68,7 @@ loadingPaper .then((paper) => { additionalInfos = { - "Publication Type": paper.type ?? "N/A", + "Publication Type": paper.publicationType ?? "N/A", "Publication Name": "N/A", DOI: paper.doi ?? "N/A", }; diff --git a/src/lib/components/composites/select/Select.svelte b/src/lib/components/composites/select/Select.svelte index 9833fdba..7b0cf8d3 100644 --- a/src/lib/components/composites/select/Select.svelte +++ b/src/lib/components/composites/select/Select.svelte @@ -5,10 +5,10 @@ interface Props { options: SelectOption[]; categoryLabel?: string; + selectedValues?: string[]; } - const { options, categoryLabel = "category" }: Props = $props(); - let selectedValues = $state(undefined); + let { options, categoryLabel = "category", selectedValues = $bindable([]) }: Props = $props(); let label = $derived(getSelectLabel(selectedValues)); function getSelectLabel(selectedValues: string[] | undefined): string { diff --git a/src/routes/project/[projectId]/papers/+page.svelte b/src/routes/project/[projectId]/papers/+page.svelte index 566efdc9..aefdd1e3 100644 --- a/src/routes/project/[projectId]/papers/+page.svelte +++ b/src/routes/project/[projectId]/papers/+page.svelte @@ -14,6 +14,7 @@ import DecisionsSelect from "./DecisionsSelect.svelte"; import CriteriaSelect from "./CriteriaSelect.svelte"; import type { PapersByStage } from "./types"; + import type { Paper } from "$lib/model/backend"; let { data } = $props(); const { @@ -29,6 +30,7 @@ } = data; let papersByStage = $state([]); + let selectedPaper = $state(undefined); loadingPapersByStage .then((loadedPapersByStage) => { @@ -39,15 +41,38 @@ }); let showFilters = $state(true); + + interface PapersFilters { + stages: string[]; + reviewers: string[]; + publishers: string[]; + years: string[]; + decisions: string[]; + criteria: string[]; + } + + let papersFilters = $state({ + stages: [], + reviewers: [], + publishers: [], + years: [], + decisions: [], + criteria: [], + }); + + $effect(() => { + const filters = Object.assign({}, $state.snapshot(papersFilters)); + console.log(filters); + }); {#await loadingProject} - Loading Project... + Loading project... {:then project} Papers | {project.name} {:catch} - Papers + Failed loading project {/await} @@ -63,29 +88,58 @@ {/if} - {}} /> + { + console.log($state.snapshot(papersFilters)); + }} + /> {#if showFilters}
- - - - - - + + + + + +
{/if}
+ + {papersByStage.length} + {papersByStage.length === 1 ? "Stage" : "Stages"} + {#each papersByStage as stage, index} - Stage {stage.stageIndex} + + + Stage {stage.stageIndex} ({stage.papers.length}) +
{#each stage.papers as { paper }} - + { + selectedPaper = paper; + }} + /> {/each} +
@@ -93,23 +147,27 @@
-