Fix remove tag (#2939)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-04-11 16:15:26 +06:00 committed by GitHub
parent 50b0f3b7c6
commit fdae734430
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View File

@ -59,7 +59,7 @@
{value.title}
</span>
{#if isEditable}
<button class="btn-close" on:click|stopPropagation={() => dispatch('remove', value.tag)}>
<button class="btn-close" on:click|stopPropagation={() => dispatch('remove', value)}>
<Icon icon={IconClose} size={'x-small'} />
</button>
{/if}

View File

@ -1,10 +1,10 @@
<script lang="ts">
import { AnyAttribute, Doc } from '@hcengineering/core'
import { IntlString } from '@hcengineering/platform'
import { AnyAttribute, Doc, Ref } from '@hcengineering/core'
import { createQuery, getClient } from '@hcengineering/presentation'
import type { TagReference, TagElement } from '@hcengineering/tags'
import type { TagReference } from '@hcengineering/tags'
import tags from '@hcengineering/tags'
import { getEventPopupPositionElement, Icon, IconAdd, Label, showPopup } from '@hcengineering/ui'
import { Icon, IconAdd, Label, getEventPopupPositionElement, showPopup } from '@hcengineering/ui'
import TagReferencePresenter from './TagReferencePresenter.svelte'
import TagsEditorPopup from './TagsEditorPopup.svelte'
@ -24,9 +24,8 @@
if (readonly) return
showPopup(TagsEditorPopup, { object }, getEventPopupPositionElement(evt))
}
async function removeTag (tag: Ref<TagElement>): Promise<void> {
const tagRef = await client.findOne(tags.class.TagReference, { tag })
if (tagRef) await client.remove(tagRef)
async function removeTag (tag: TagReference): Promise<void> {
if (tag !== undefined) await client.remove(tag)
}
</script>