diff --git a/frontend/src/lib/components/project/Column.svelte b/frontend/src/lib/components/project/Column.svelte index db53358..75f01bd 100644 --- a/frontend/src/lib/components/project/Column.svelte +++ b/frontend/src/lib/components/project/Column.svelte @@ -3,9 +3,10 @@ import CardComponent from '../card/Card.svelte'; import AddIcon from '../icons/AddIcon.svelte'; import type TagOption from '$lib/types/TagOption'; - import type ProjectTag from '$lib/types/ProjectTag'; + import ProjectTag, { projectTags } from '$lib/types/ProjectTag'; import type Project from '$lib/types/Project'; import currentDraggedCard from '$lib/stores/currentDraggedCard'; + import currentView from '$lib/stores/currentView'; export let project: Project; export let option: TagOption | null = null; @@ -43,10 +44,22 @@ const card = await Card.create(project); if (!card) return; - if (!primaryTag) return; - if (!option) return; - await card.addTag(primaryTag, option, null); + if ($currentView?.filters && $currentView.filters.length > 0) { + for (const projectTag of $projectTags) { + for (const filter of $currentView.filters) { + if (projectTag !== filter.projectTag) continue; + if (!filter.tagOption) continue; + if (filter.filterType !== 0) continue; + + if (await card.addTag(projectTag, filter.tagOption, null)) break; + } + } + } + + if (primaryTag && option) { + await card.addTag(primaryTag, option, null); + } cards.reload(); } diff --git a/frontend/src/lib/components/project/Header.svelte b/frontend/src/lib/components/project/Header.svelte index cf1eab9..2314f26 100644 --- a/frontend/src/lib/components/project/Header.svelte +++ b/frontend/src/lib/components/project/Header.svelte @@ -2,7 +2,7 @@ import GroupMenu from '$lib/components/menu/GroupMenu.svelte'; import SortMenu from '$lib/components/menu/SortMenu.svelte'; import currentView from '$lib/stores/currentView'; - import Card from '$lib/types/Card'; + import Card, { cards } from '$lib/types/Card'; import type Project from '$lib/types/Project'; import type ProjectTag from '$lib/types/ProjectTag'; import { projectTags } from '$lib/types/ProjectTag'; @@ -35,6 +35,26 @@ return res; } + + async function addCard() { + const card = await Card.create(project); + + if (!card) return; + + if ($currentView?.filters && $currentView.filters.length > 0) { + for (const projectTag of $projectTags) { + for (const filter of $currentView.filters) { + if (projectTag !== filter.projectTag) continue; + if (!filter.tagOption) continue; + if (filter.filterType !== 0) continue; + + if (await card.addTag(projectTag, filter.tagOption, null)) break; + } + } + } + + cards.reload(); + }
@@ -80,7 +100,7 @@ currentDirection={$currentView?.sortDirection || null} /> - +