From 9e6bdb5fd4416f2af0cdecf6adb7dfcee6319386 Mon Sep 17 00:00:00 2001 From: Gisle Aune Date: Tue, 9 May 2023 20:36:01 +0200 Subject: [PATCH] allow non-optional tags for multi-tag scopes with ! prefix to restore old behavior. --- .../lib/components/controls/TagInput.svelte | 11 ++++++- .../lib/modals/SprintCreateUpdateModal.svelte | 2 +- ports/mysql/items.go | 33 +++++++++++++++---- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/frontend/src/lib/components/controls/TagInput.svelte b/frontend/src/lib/components/controls/TagInput.svelte index 8870e9c..19581c6 100644 --- a/frontend/src/lib/components/controls/TagInput.svelte +++ b/frontend/src/lib/components/controls/TagInput.svelte @@ -1,7 +1,8 @@
diff --git a/frontend/src/lib/modals/SprintCreateUpdateModal.svelte b/frontend/src/lib/modals/SprintCreateUpdateModal.svelte index 07c8590..05f588f 100644 --- a/frontend/src/lib/modals/SprintCreateUpdateModal.svelte +++ b/frontend/src/lib/modals/SprintCreateUpdateModal.svelte @@ -158,7 +158,7 @@ - + {#if sprint.kind != SprintKind.Items} diff --git a/ports/mysql/items.go b/ports/mysql/items.go index eb809db..953e622 100644 --- a/ports/mysql/items.go +++ b/ports/mysql/items.go @@ -215,17 +215,36 @@ func (r *itemRepository) Fetch(ctx context.Context, filter models.ItemFilter) ([ } res = genutils.RetainInPlace(res, func(item entities.Item) bool { + good := false + for _, tag := range filter.Tags { - if item.HasTag(tag) { - return true - } else if item.RequirementID != nil && - (genutils.Contains(requirementTagMap[*item.RequirementID], tag) || - genutils.Contains(projectTagMap[*item.ProjectID], tag)) { - return true + if strings.HasPrefix(tag, "!") { + tag = tag[1:] + + if !item.HasTag(tag) { + if item.RequirementID != nil { + if !genutils.Contains(requirementTagMap[*item.RequirementID], tag) && + !genutils.Contains(projectTagMap[*item.ProjectID], tag) { + return false + } + } else { + return false + } + } + + good = true + } else { + if item.HasTag(tag) { + good = true + } else if item.RequirementID != nil && + (genutils.Contains(requirementTagMap[*item.RequirementID], tag) || + genutils.Contains(projectTagMap[*item.ProjectID], tag)) { + good = true + } } } - return false + return good }) }