New card respect filters

This commit is contained in:
Brieuc Dubois 2024-01-10 19:11:03 +01:00
parent 2092125fc5
commit 1f5285c276
1 changed files with 17 additions and 4 deletions

View File

@ -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();
}