mirror of
https://github.com/hcengineering/platform.git
synced 2025-01-30 07:17:35 +00:00
TSK-1443 fix tags presenter (#3136)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
4801b20d8b
commit
e719dc14ed
@ -546,9 +546,9 @@ export function createModel (builder: Builder): void {
|
||||
{ key: '', presenter: tracker.component.SubIssuesSelector, props: {} },
|
||||
{ key: '', presenter: view.component.GrowPresenter, props: { type: 'grow' } },
|
||||
{
|
||||
key: '$lookup.labels',
|
||||
key: 'labels',
|
||||
presenter: tags.component.LabelsPresenter,
|
||||
props: { kind: 'list', full: false, lookupField: 'labels', listProps: { optional: true, compression: true } }
|
||||
props: { kind: 'list', full: false, listProps: { optional: true, compression: true } }
|
||||
},
|
||||
{
|
||||
key: '',
|
||||
|
@ -3,11 +3,12 @@
|
||||
import { createQuery } from '@hcengineering/presentation'
|
||||
import type { TagReference } from '@hcengineering/tags'
|
||||
import tags from '@hcengineering/tags'
|
||||
import { getEventPopupPositionElement, showPopup, resizeObserver } from '@hcengineering/ui'
|
||||
import { getEventPopupPositionElement, resizeObserver, showPopup } from '@hcengineering/ui'
|
||||
import { afterUpdate, createEventDispatcher } from 'svelte'
|
||||
import TagReferencePresenter from './TagReferencePresenter.svelte'
|
||||
import TagsEditorPopup from './TagsEditorPopup.svelte'
|
||||
import { createEventDispatcher, afterUpdate } from 'svelte'
|
||||
|
||||
export let value: number
|
||||
export let object: WithLookup<Doc>
|
||||
export let full: boolean
|
||||
export let ckeckFilled: boolean = false
|
||||
@ -16,21 +17,24 @@
|
||||
export let action: (evt: MouseEvent) => Promise<void> | void = async () => {}
|
||||
export let compression: boolean = false
|
||||
|
||||
export let lookupField: string | undefined
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
let items: TagReference[] = []
|
||||
const query = createQuery()
|
||||
|
||||
$: if (lookupField === undefined) {
|
||||
query.query(tags.class.TagReference, { attachedTo: object._id }, (result) => {
|
||||
items = result
|
||||
})
|
||||
} else {
|
||||
query.unsubscribe()
|
||||
items = (object.$lookup as any)[lookupField]
|
||||
$: update(object, value)
|
||||
|
||||
function update (object: WithLookup<Doc>, value: number) {
|
||||
if (value > 0) {
|
||||
query.query(tags.class.TagReference, { attachedTo: object._id }, (result) => {
|
||||
items = result
|
||||
})
|
||||
} else {
|
||||
query.unsubscribe()
|
||||
items = []
|
||||
}
|
||||
}
|
||||
|
||||
async function tagsHandler (evt: MouseEvent): Promise<void> {
|
||||
showPopup(TagsEditorPopup, { object }, getEventPopupPositionElement(evt))
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
import type { TagReference } from '@hcengineering/tags'
|
||||
import { getPlatformColor, Icon, IconClose, resizeObserver } from '@hcengineering/ui'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { tagLevel } from '../utils'
|
||||
import TagItem from './TagItem.svelte'
|
||||
|
||||
export let value: TagReference
|
||||
@ -28,7 +27,6 @@
|
||||
export let inline: boolean = false
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
$: tagIcon = tagLevel[(((value?.weight ?? 0) % 3) + 1) as 1 | 2 | 3]
|
||||
</script>
|
||||
|
||||
{#if value}
|
||||
|
@ -408,7 +408,7 @@
|
||||
>
|
||||
<Component
|
||||
is={tags.component.LabelsPresenter}
|
||||
props={{ object: issue, ckeckFilled: fullFilled[issueId], lookupField: 'labels', kind: 'kanban' }}
|
||||
props={{ value: issue.labels, object: issue, ckeckFilled: fullFilled[issueId], kind: 'kanban' }}
|
||||
on:change={(res) => {
|
||||
if (res.detail.full) fullFilled[issueId] = true
|
||||
}}
|
||||
|
Loading…
Reference in New Issue
Block a user