From 12e38589e9bcb578d341798d0862aa8ce2596651 Mon Sep 17 00:00:00 2001 From: Brieuc Dubois Date: Wed, 24 Jan 2024 15:27:17 +0100 Subject: [PATCH] Hide filtered columns --- .../src/lib/components/project/Project.svelte | 58 +++++++++++++++---- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/frontend/src/lib/components/project/Project.svelte b/frontend/src/lib/components/project/Project.svelte index 026ac6a..0a8b568 100644 --- a/frontend/src/lib/components/project/Project.svelte +++ b/frontend/src/lib/components/project/Project.svelte @@ -52,6 +52,27 @@ return true; } + function columnPassFilters(tagOption: TagOption | null, filters: Filter[]): boolean { + let is: TagOption[] = []; + + for (const filter of filters) { + if ($currentView?.sortTag !== filter.projectTag) continue; + if (!filter.tagOption) continue; + + if (filter.filterType === 0) { + is.push(filter.tagOption); + } else if (filter.filterType === 1) { + if (tagOption === filter.tagOption) return false; + } + } + + if (is.length > 0) { + if (!is.some((o) => o === tagOption)) return false; + } + + return true; + } + function extractColumnCards(view: View | null, cards: Card[], tagOption: TagOption | null) { if (!view) return cards; @@ -77,6 +98,17 @@ return sortedCards; } + + function isFiltered(tagOption: TagOption) { + if (!$currentView) return false; + if (!$currentView.filters) return false; + + for (const filter of $currentView.filters) { + if (filter.tagOption === tagOption) return true; + } + + return false; + } {#if project} @@ -87,19 +119,23 @@
{#if $currentView.primaryTag} {#each $currentView.primaryTag.options as option (option.id)} - + {#if columnPassFilters(option, $currentView.filters)} + + {/if} {/each} {/if} - + {#if columnPassFilters(null, $currentView.filters)} + + {/if}
{/if} {/if}