New card respect filters
Backend docker image / release-image (push) Successful in 10m4s Details
Frontend and backend docker image / release-image (push) Successful in 14m44s Details
Frontend docker image / release-image (push) Successful in 3m48s Details

This commit is contained in:
Brieuc Dubois 2024-01-10 19:11:03 +01:00
parent 2092125fc5
commit 9bb9041580
2 changed files with 39 additions and 6 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();
}

View File

@ -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();
}
</script>
<header>
@ -80,7 +100,7 @@
currentDirection={$currentView?.sortDirection || null}
/>
</div>
<button id="newButton" on:click={async () => Card.create(project)}>New</button>
<button id="newButton" on:click={addCard}>New</button>
</nav>
</header>