From 2092125fc5980ed2081457dddc42af2aa7f108ea Mon Sep 17 00:00:00 2001 From: Bhasher Date: Wed, 10 Jan 2024 19:01:53 +0100 Subject: [PATCH] Filter cards --- .../src/lib/components/menu/FilterMenu.svelte | 16 +-- .../lib/components/menu/FilterMenuItem.svelte | 41 ++++++- .../src/lib/components/project/Header.svelte | 9 +- .../src/lib/components/project/Project.svelte | 102 +++++++++++++----- 4 files changed, 128 insertions(+), 40 deletions(-) diff --git a/frontend/src/lib/components/menu/FilterMenu.svelte b/frontend/src/lib/components/menu/FilterMenu.svelte index 423d56c..c33c841 100644 --- a/frontend/src/lib/components/menu/FilterMenu.svelte +++ b/frontend/src/lib/components/menu/FilterMenu.svelte @@ -1,18 +1,20 @@ - - {#each filters as filter} - - {/each} - - +{#if $currentView} + + {#each $currentView.filters as filter} + + {/each} + + +{/if} diff --git a/frontend/src/lib/components/menu/FilterMenuItem.svelte b/frontend/src/lib/components/menu/FilterMenuItem.svelte index a171c75..951e0e3 100644 --- a/frontend/src/lib/components/menu/FilterMenuItem.svelte +++ b/frontend/src/lib/components/menu/FilterMenuItem.svelte @@ -3,6 +3,7 @@ import Filter from '$lib/types/Filter'; import ProjectTag, { projectTags } from '$lib/types/ProjectTag'; import type TagOption from '$lib/types/TagOption'; + import TrashIcon from '../icons/TrashIcon.svelte'; import Menu from './Menu.svelte'; export let filter: Filter | null = null; @@ -14,7 +15,8 @@ async function selectProjectTag(projectTag: ProjectTag) { if (!$currentView) return; if (!filter) { - filter = await $currentView?.addFilter(projectTag, 0, null); + await $currentView?.addFilter(projectTag, 0, null); + currentView.reload(); return; } @@ -47,6 +49,14 @@ } isOptionOpen = false; } + + async function deleteFilter() { + if (!filter) return; + + const res = await $currentView?.removeFilter(filter); + if (!res) return; + currentView.reload(); + }
@@ -83,7 +93,11 @@ role="button" > {#if filter} - {filter.filterType} + {#if filter.filterType === 0} + is + {:else if filter.filterType === 1} + is not + {/if} {/if}
{#if filter} @@ -124,6 +138,19 @@ {/if} + {#if filter} +
deleteFilter()} + on:keydown={(e) => { + if (e.key === 'Enter') deleteFilter(); + }} + > + +
+ {/if}