person presenter to open corresponding editor

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-09-08 18:42:40 +02:00
parent a29afa4d98
commit 9874c47cf2
No known key found for this signature in database
GPG Key ID: C8787EFEB4B64AF0
9 changed files with 520 additions and 441 deletions

File diff suppressed because it is too large Load Diff

View File

@ -142,6 +142,10 @@ export function createModel (builder: Builder): void {
builder.mixin(recruit.class.Applicant, core.class.Class, view.mixin.KanbanCard, {
card: recruit.component.KanbanCard
})
builder.mixin(recruit.class.Candidate, core.class.Class, view.mixin.ObjectEditor, {
editor: recruit.component.EditCandidate
})
}
export { default } from './plugin'

View File

@ -18,7 +18,7 @@ import type { Ref, Class, Space } from '@anticrm/core'
import { DOMAIN_MODEL } from '@anticrm/core'
import { Model, Mixin, Builder } from '@anticrm/model'
import type { AnyComponent } from '@anticrm/ui'
import type { ViewletDescriptor, Viewlet, AttributeEditor, AttributePresenter, KanbanCard } from '@anticrm/view'
import type { ViewletDescriptor, Viewlet, AttributeEditor, AttributePresenter, KanbanCard, ObjectEditor } from '@anticrm/view'
import core, { TDoc, TClass } from '@anticrm/model-core'
@ -39,6 +39,11 @@ export class TKanbanCard extends TClass implements KanbanCard {
card!: AnyComponent
}
@Mixin(view.mixin.ObjectEditor, core.class.Class)
export class TObjectEditor extends TClass implements ObjectEditor {
editor!: AnyComponent
}
@Model(view.class.ViewletDescriptor, core.class.Doc, DOMAIN_MODEL)
export class TViewletDescriptor extends TDoc implements ViewletDescriptor {
component!: AnyComponent
@ -53,7 +58,7 @@ export class TViewlet extends TDoc implements Viewlet {
}
export function createModel (builder: Builder): void {
builder.createModel(TAttributeEditor, TAttributePresenter, TKanbanCard, TViewletDescriptor, TViewlet)
builder.createModel(TAttributeEditor, TAttributePresenter, TKanbanCard, TObjectEditor, TViewletDescriptor, TViewlet)
builder.mixin(core.class.TypeString, core.class.Class, view.mixin.AttributeEditor, {
editor: view.component.StringEditor

View File

@ -23,7 +23,7 @@
export let size: 'x-small' | 'small' | 'medium' | 'large' | 'x-large'
</script>
<div class="flex-row-center">
<div class="flex-row-center" on:click>
<Avatar {size} />
<div class="flex-col user-info">
{#if subtitle}<div class="subtitle">{subtitle}</div>{/if}

View File

@ -24,6 +24,7 @@
"@anticrm/contact": "~0.6.0",
"@anticrm/ui": "~0.6.0",
"@anticrm/presentation": "~0.6.1",
"@anticrm/core": "~0.6.11"
"@anticrm/core": "~0.6.11",
"@anticrm/view": "~0.6.0"
}
}

View File

@ -15,14 +15,24 @@
-->
<script lang="ts">
import { getResource } from '@anticrm/platform'
import type { Person } from '@anticrm/contact'
import { UserInfo } from '@anticrm/presentation'
import { UserInfo, getClient } from '@anticrm/presentation'
import { showPopup } from '@anticrm/ui'
import view from '@anticrm/view'
export let value: Person
async function onClick() {
const client = getClient()
const hierarchy = client.getHierarchy()
const clazz = hierarchy.getClass(value._class)
const editorMixin = hierarchy.as(clazz, view.mixin.ObjectEditor)
const editor = await getResource(editorMixin.editor)
showPopup(editor, { object: value }, 'float')
}
</script>
<UserInfo size={'x-small'} {value}/>
<UserInfo size={'x-small'} {value} on:click={onClick}/>

View File

@ -20,13 +20,11 @@
import { buildModel } from '../utils'
import { getClient } from '@anticrm/presentation'
import { Label, showPopup, Loading, ScrollBox } from '@anticrm/ui'
import type { AnyComponent } from '@anticrm/ui'
import { createQuery } from '@anticrm/presentation'
export let _class: Ref<Class<Doc>>
export let space: Ref<Space>
export let open: AnyComponent
export let options: FindOptions<Doc> | undefined
export let config: string[]
@ -49,9 +47,6 @@
const client = getClient()
function onClick(object: Doc) {
showPopup(open, { object, space }, 'float')
}
</script>
{#await buildModel(client, _class, config, options)}
@ -70,7 +65,7 @@
{#if objects}
<tbody>
{#each objects as object (object._id)}
<tr class="tr-body" on:click={() => onClick(object)}>
<tr class="tr-body">
{#each model as attribute}
<td><svelte:component this={attribute.presenter} {object} value={getValue(object, attribute.key)}/></td>
{/each}

View File

@ -41,6 +41,13 @@ export interface KanbanCard extends Class<Doc> {
card: AnyComponent
}
/**
* @public
*/
export interface ObjectEditor extends Class<Doc> {
editor: AnyComponent
}
/**
* @public
*/
@ -68,7 +75,8 @@ export default plugin(viewId, {
mixin: {
AttributeEditor: '' as Ref<Mixin<AttributeEditor>>,
AttributePresenter: '' as Ref<Mixin<AttributePresenter>>,
KanbanCard: '' as Ref<Mixin<KanbanCard>>
KanbanCard: '' as Ref<Mixin<KanbanCard>>,
ObjectEditor: '' as Ref<Mixin<ObjectEditor>>
},
class: {
ViewletDescriptor: '' as Ref<Class<ViewletDescriptor>>,

File diff suppressed because it is too large Load Diff