Navigate from ID presenter (#10242)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2025-11-23 12:16:48 +07:00
committed by GitHub
parent 40dc9cb528
commit 90d2af45e9
3 changed files with 27 additions and 5 deletions
@@ -86,7 +86,7 @@
disabled: true
}
: {}
if (attribute.collectionAttr) {
if (attribute.collectionAttr || attribute.attribute?.type?._class === core.class.TypeIdentifier) {
return { object, ...attribute.props, ...readonlyParams }
}
if (attribute.attribute?.type._class === core.class.EnumOf) {
@@ -13,10 +13,15 @@
// limitations under the License.
-->
<script lang="ts">
import { AnyAttribute, Doc } from '@hcengineering/core'
import { getEmbeddedLabel } from '@hcengineering/platform'
import { createQuery } from '@hcengineering/presentation'
import { LabelAndProps, tooltip } from '@hcengineering/ui'
import DocNavLink from './DocNavLink.svelte'
export let value: string | undefined
export let attribute: AnyAttribute
export let object: Doc | undefined = undefined
$: tooltipParams = getTooltip(value)
@@ -26,8 +31,25 @@
label: getEmbeddedLabel(value)
}
}
const query = createQuery()
$: if (value !== undefined && object === undefined) {
query.query(attribute.attributeOf, { [attribute.name]: value }, (res) => {
object = res.length > 0 ? res[0] : undefined
})
} else {
query.unsubscribe()
}
</script>
<span class="overflow-label px-3" use:tooltip={tooltipParams}>
{value ?? ''}
</span>
{#if object !== undefined}
<DocNavLink {object} shrink={0}>
<span class="overflow-label cursor-pointer px-3">
{value ?? ''}
</span>
</DocNavLink>
{:else}
<span class="overflow-label px-3" use:tooltip={tooltipParams}>
{value ?? ''}
</span>
{/if}
@@ -269,7 +269,7 @@
readonly: !editable,
editable
}
if (attribute.collectionAttr) {
if (attribute.collectionAttr || attribute.attribute?.type?._class === core.class.TypeIdentifier) {
return { object, ...attribute.props, ...readonlyParams }
}
if (attribute.attribute?.type._class === core.class.EnumOf) {