From 089bde27fdb0011024555a5ad1484db9b19573b0 Mon Sep 17 00:00:00 2001 From: Brieuc Dubois Date: Wed, 17 Jan 2024 21:23:10 +0100 Subject: [PATCH] Update tag option list on new/delete --- frontend/src/lib/components/tags/SelectTags.svelte | 9 ++++++--- frontend/src/lib/types/ProjectTag.ts | 9 ++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/frontend/src/lib/components/tags/SelectTags.svelte b/frontend/src/lib/components/tags/SelectTags.svelte index 44da128..395dd24 100644 --- a/frontend/src/lib/components/tags/SelectTags.svelte +++ b/frontend/src/lib/components/tags/SelectTags.svelte @@ -4,6 +4,7 @@ import { cards } from '$lib/types/Card'; import CardTag from '$lib/types/CardTag'; import type ProjectTag from '$lib/types/ProjectTag'; + import { projectTags } from '$lib/types/ProjectTag'; import type TagOption from '$lib/types/TagOption'; import TrashIcon from '../icons/TrashIcon.svelte'; @@ -37,6 +38,7 @@ if (!newOption) return; if (!(await projectTag.addOption(newOption))) return; newOption = ''; + projectTags.reload(); } @@ -66,7 +68,7 @@ isOpen = false; }} > - {#each projectTag.options as option} + {#each projectTag.options as option (option.id)}
selectOption(option)} @@ -80,8 +82,9 @@ > {option.value}
diff --git a/frontend/src/lib/types/ProjectTag.ts b/frontend/src/lib/types/ProjectTag.ts index de5ac3f..bf39e1e 100644 --- a/frontend/src/lib/types/ProjectTag.ts +++ b/frontend/src/lib/types/ProjectTag.ts @@ -5,7 +5,14 @@ import TagOption from './TagOption'; import Project from './Project'; import projectTagsApi from '$lib/api/projectTagsApi'; -export const projectTags = writable([] as ProjectTag[]); +const { subscribe, update, set } = writable([] as ProjectTag[]); + +export const projectTags = { + subscribe, + update, + set, + reload: () => update((ps) => ps) +}; export const ProjectTagTypes = {};