New card respect filters
This commit is contained in:
parent
2092125fc5
commit
9bb9041580
|
@ -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;
|
||||
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
Loading…
Reference in New Issue