From e719dc14ed4a81a1ffd85c9ab3babda2cafa97a7 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Thu, 4 May 2023 16:14:55 +0600 Subject: [PATCH] TSK-1443 fix tags presenter (#3136) Signed-off-by: Denis Bykhov --- models/tracker/src/index.ts | 4 +-- .../src/components/LabelsPresenter.svelte | 26 +++++++++++-------- .../components/TagReferencePresenter.svelte | 2 -- .../src/components/issues/KanbanView.svelte | 2 +- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/models/tracker/src/index.ts b/models/tracker/src/index.ts index 935338604e..97e178f099 100644 --- a/models/tracker/src/index.ts +++ b/models/tracker/src/index.ts @@ -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: '', diff --git a/plugins/tags-resources/src/components/LabelsPresenter.svelte b/plugins/tags-resources/src/components/LabelsPresenter.svelte index 2950c90f30..b8ed083da5 100644 --- a/plugins/tags-resources/src/components/LabelsPresenter.svelte +++ b/plugins/tags-resources/src/components/LabelsPresenter.svelte @@ -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 export let full: boolean export let ckeckFilled: boolean = false @@ -16,21 +17,24 @@ export let action: (evt: MouseEvent) => Promise | 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, 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 { showPopup(TagsEditorPopup, { object }, getEventPopupPositionElement(evt)) } diff --git a/plugins/tags-resources/src/components/TagReferencePresenter.svelte b/plugins/tags-resources/src/components/TagReferencePresenter.svelte index 2976e1a04e..821187e72d 100644 --- a/plugins/tags-resources/src/components/TagReferencePresenter.svelte +++ b/plugins/tags-resources/src/components/TagReferencePresenter.svelte @@ -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] {#if value} diff --git a/plugins/tracker-resources/src/components/issues/KanbanView.svelte b/plugins/tracker-resources/src/components/issues/KanbanView.svelte index 825f06cc57..98a9ffbb2a 100644 --- a/plugins/tracker-resources/src/components/issues/KanbanView.svelte +++ b/plugins/tracker-resources/src/components/issues/KanbanView.svelte @@ -408,7 +408,7 @@ > { if (res.detail.full) fullFilled[issueId] = true }}