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

View File

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

View File

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

View File

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

View File

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

View File

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