Fix description diff and collections presenters (#4240)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina 2023-12-21 21:05:32 +04:00 committed by GitHub
parent ba49e4d66e
commit 396160a27c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 40 additions and 25 deletions

View File

@ -14,6 +14,7 @@
//
import {
type ActivityAttributeUpdatesPresenter,
type ActivityDoc,
type ActivityExtension,
type ActivityExtensionKind,
@ -55,9 +56,9 @@ import {
import { TAttachedDoc, TClass, TDoc } from '@hcengineering/model-core'
import type { Asset, IntlString, Resource } from '@hcengineering/platform'
import { type AnyComponent } from '@hcengineering/ui/src/types'
import view from '@hcengineering/model-view'
import activity from './plugin'
import view from '@hcengineering/model-view'
export { activityOperation } from './migration'
export { activityId } from '@hcengineering/activity'
@ -70,6 +71,11 @@ export class TActivityDoc extends TClass implements ActivityDoc {
ignoreCollections?: string[]
}
@Mixin(activity.mixin.ActivityAttributeUpdatesPresenter, core.class.Class)
export class TActivityAttributeUpdatesPresenter extends TClass implements ActivityAttributeUpdatesPresenter {
presenter!: AnyComponent
}
@Model(activity.class.TxViewlet, core.class.Doc, DOMAIN_MODEL)
export class TTxViewlet extends TDoc implements TxViewlet {
icon!: Asset
@ -177,7 +183,8 @@ export function createModel (builder: Builder): void {
TDocUpdateMessage,
TDocUpdateMessageViewlet,
TActivityExtension,
TReaction
TReaction,
TActivityAttributeUpdatesPresenter
)
builder.mixin(activity.class.DocUpdateMessage, core.class.Class, activity.mixin.ActivityDoc, {})

View File

@ -473,7 +473,7 @@ export function createModel (builder: Builder): void {
notification.ids.NotificationCollaboratorsChanged
)
builder.mixin(notification.mixin.Collaborators, core.class.Class, view.mixin.ActivityAttributePresenter, {
builder.mixin(notification.mixin.Collaborators, core.class.Class, activity.mixin.ActivityAttributeUpdatesPresenter, {
presenter: notification.component.NotificationCollaboratorsChanged
})

View File

@ -469,7 +469,8 @@ export function createModel (builder: Builder): void {
core.class.TypeMarkup,
view.component.MarkupPresenter,
view.component.MarkupEditor,
view.component.MarkupEditorPopup
view.component.MarkupEditorPopup,
view.component.MarkupDiffPresenter
)
builder.mixin(core.class.TypeMarkup, core.class.Class, view.mixin.InlineAttributEditor, {

View File

@ -14,10 +14,12 @@
-->
<script lang="ts">
import { Component } from '@hcengineering/ui'
import view, { AttributeModel } from '@hcengineering/view'
import { AttributeModel } from '@hcengineering/view'
import { getClient } from '@hcengineering/presentation'
import { DocAttributeUpdates, DocUpdateMessageViewlet } from '@hcengineering/activity'
import activity from '../../plugin'
import AddedAttributesPresenter from './attributes/AddedAttributesPresenter.svelte'
import RemovedAttributesPresenter from './attributes/RemovedAttributesPresenter.svelte'
import SetAttributesPresenter from './attributes/SetAttributesPresenter.svelte'
@ -31,7 +33,8 @@
$: presenter =
viewlet?.config?.[attributeModel.key]?.presenter ??
hierarchy.classHierarchyMixin(attributeUpdates.attrClass, view.mixin.ActivityAttributePresenter)?.presenter
hierarchy.classHierarchyMixin(attributeUpdates.attrClass, activity.mixin.ActivityAttributeUpdatesPresenter)
?.presenter
</script>
{#if presenter}

View File

@ -32,11 +32,7 @@
let object: Doc | undefined = undefined
async function getValue (object: Doc | undefined): Promise<string | undefined> {
if (object === undefined) {
return ''
}
async function getValue (object: Doc): Promise<string | undefined> {
if (viewlet?.valueAttr) {
return (object as any)[viewlet.valueAttr]
}
@ -60,15 +56,17 @@
</script>
{#if object}
{#await getValue(object) then value}
{#if withIcon && message.action === 'create'}
<Icon icon={IconAdd} size="x-small" />
{/if}
{#if withIcon && message.action === 'remove'}
<Icon icon={IconDelete} size="x-small" />
{/if}
{#if withIcon && message.action === 'create'}
<Icon icon={IconAdd} size="x-small" />
{/if}
{#if withIcon && message.action === 'remove'}
<Icon icon={IconDelete} size="x-small" />
{/if}
{#if value}
{#if objectPresenter && !viewlet?.valueAttr}
<Component is={objectPresenter.presenter} props={{ value: object, accent: true, shouldShowAvatar: false }} />
{:else}
{#await getValue(object) then value}
<span>
<DocNavLink
{object}
@ -82,10 +80,8 @@
<span class="separator">,</span>
{/if}
</span>
{:else if objectPresenter && object}
<Component is={objectPresenter.presenter} props={{ value: object, accent: true, shouldShowAvatar: false }} />
{/if}
{/await}
{/await}
{/if}
{/if}
<style lang="scss">

View File

@ -215,6 +215,13 @@ export interface ActivityDoc extends Class<Doc> {
ignoreCollections?: string[]
}
/**
* @public
*/
export interface ActivityAttributeUpdatesPresenter extends Class<Doc> {
presenter: AnyComponent
}
/**
* @public
*/
@ -238,7 +245,8 @@ export interface Reaction extends AttachedDoc {
export default plugin(activityId, {
mixin: {
ActivityDoc: '' as Ref<Mixin<ActivityDoc>>
ActivityDoc: '' as Ref<Mixin<ActivityDoc>>,
ActivityAttributeUpdatesPresenter: '' as Ref<Mixin<ActivityAttributeUpdatesPresenter>>
},
class: {
TxViewlet: '' as Ref<Class<TxViewlet>>,

View File

@ -51,7 +51,7 @@
{#if value}
<div class="flex-row-center">
{#if taskType !== undefined}
{#if shouldShowAvatar && taskType !== undefined}
<div class="text-sm mr-1">
<TaskTypeIcon value={taskType} />
</div>