mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-26 02:10:07 +00:00
Fix same tags adding uberf 4427 (#4235)
Signed-off-by: Sergey Voytsehovich <syargreg@gmail.com>
This commit is contained in:
parent
d80ca00f98
commit
93551a71b0
@ -28,16 +28,29 @@
|
|||||||
})
|
})
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
async function addRef ({ title, color, _id: tag }: TagElement): Promise<void> {
|
async function addRef ({ title, color, _id: tag }: TagElement): Promise<void> {
|
||||||
|
// check if tag already attached, could happen if 'add' clicked faster than ui updates
|
||||||
|
const containsTag = selected.some((refElement) => refElement === tag)
|
||||||
|
if (containsTag) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
selected.push(tag)
|
||||||
|
|
||||||
await client.addCollection(tags.class.TagReference, object.space, object._id, object._class, 'labels', {
|
await client.addCollection(tags.class.TagReference, object.space, object._id, object._class, 'labels', {
|
||||||
title,
|
title,
|
||||||
color,
|
color,
|
||||||
tag
|
tag
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function removeTag (tag: TagElement): Promise<void> {
|
async function removeTag (tag: TagElement): Promise<void> {
|
||||||
const tagRef = await client.findOne(tags.class.TagReference, { tag: tag._id, attachedTo: object._id })
|
const tagRef = await client.findOne(tags.class.TagReference, { tag: tag._id, attachedTo: object._id })
|
||||||
if (tagRef) await client.remove(tagRef)
|
if (tagRef) {
|
||||||
|
await client.remove(tagRef)
|
||||||
|
selected.splice(selected.indexOf(tag._id), 1)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function onUpdate (event: CustomEvent<{ action: string, tag: TagElement }>) {
|
async function onUpdate (event: CustomEvent<{ action: string, tag: TagElement }>) {
|
||||||
const result = event.detail
|
const result = event.detail
|
||||||
if (result === undefined) return
|
if (result === undefined) return
|
||||||
|
Loading…
Reference in New Issue
Block a user