mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-27 03:54:57 +02:00
Handler RefTo to display presenter (#547)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
@@ -15,13 +15,13 @@
|
||||
-->
|
||||
|
||||
<script lang="ts">
|
||||
import type { AttachedDoc, AttachedDoc, Doc } from '@anticrm/core'
|
||||
import type { AttachedDoc, Class, Doc, Ref } from '@anticrm/core'
|
||||
import core from '@anticrm/core'
|
||||
import { getResource } from '@anticrm/platform'
|
||||
import type { AnySvelteComponent } from '@anticrm/ui'
|
||||
import { CircleButton, Label } from '@anticrm/ui'
|
||||
import view from '@anticrm/view'
|
||||
import { getClient } from '../utils'
|
||||
import { getAttributePresenterClass, getClient } from '../utils'
|
||||
|
||||
// export let _class: Ref<Class<Doc>>
|
||||
export let key: string
|
||||
@@ -34,13 +34,13 @@
|
||||
const _class = object._class
|
||||
const client = getClient()
|
||||
const hierarchy = client.getHierarchy()
|
||||
const attribute = hierarchy.getAttribute(_class, key)
|
||||
|
||||
const typeClassId = attribute?.type._class
|
||||
$: attribute = hierarchy.getAttribute(_class, key)
|
||||
$: typeClassId = (attribute !== undefined) ? getAttributePresenterClass(attribute) : undefined
|
||||
|
||||
let editor: Promise<AnySvelteComponent> | undefined
|
||||
|
||||
if (typeClassId !== undefined) {
|
||||
$: if (typeClassId !== undefined) {
|
||||
const typeClass = hierarchy.getClass(typeClassId)
|
||||
const editorMixin = hierarchy.as(typeClass, view.mixin.AttributeEditor)
|
||||
editor = getResource(editorMixin.editor)
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
-->
|
||||
|
||||
<script lang="ts">
|
||||
import type { Ref, Class, Doc } from '@anticrm/core'
|
||||
import type { Class, Doc, Ref } from '@anticrm/core'
|
||||
import { getResource } from '@anticrm/platform'
|
||||
import type { AnySvelteComponent } from '@anticrm/ui'
|
||||
import { getClient } from '../utils'
|
||||
import view from '@anticrm/view'
|
||||
import { getAttributePresenterClass, getClient } from '../utils'
|
||||
|
||||
export let _class: Ref<Class<Doc>>
|
||||
export let key: string
|
||||
@@ -29,19 +29,19 @@
|
||||
|
||||
const client = getClient()
|
||||
const hierarchy = client.getHierarchy()
|
||||
const attribute = hierarchy.getAttribute(_class, key)
|
||||
|
||||
const typeClassId = attribute?.type._class
|
||||
$: attribute = hierarchy.getAttribute(_class, key)
|
||||
$: typeClassId = (attribute !== undefined) ? getAttributePresenterClass(attribute) : undefined
|
||||
|
||||
let editor: Promise<AnySvelteComponent> | undefined
|
||||
|
||||
if (typeClassId !== undefined) {
|
||||
$: if (typeClassId !== undefined) {
|
||||
const typeClass = hierarchy.getClass(typeClassId)
|
||||
const editorMixin = hierarchy.as(typeClass, view.mixin.AttributeEditor)
|
||||
editor = getResource(editorMixin.editor)
|
||||
}
|
||||
|
||||
function onChange(value: any) {
|
||||
function onChange (value: any) {
|
||||
const doc = object as Doc
|
||||
client.updateDoc(_class, doc.space, doc._id, { [key]: value })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user