diff --git a/plugins/activity-resources/src/components/TxView.svelte b/plugins/activity-resources/src/components/TxView.svelte
index 9445e4b801..5eda03639a 100644
--- a/plugins/activity-resources/src/components/TxView.svelte
+++ b/plugins/activity-resources/src/components/TxView.svelte
@@ -32,7 +32,7 @@
TimeSince
} from '@hcengineering/ui'
import type { AttributeModel } from '@hcengineering/view'
- import { getActions } from '@hcengineering/view-resources'
+ import { getActions, ObjectPresenter } from '@hcengineering/view-resources'
import { ActivityKey, DisplayTx } from '../activity'
import activity from '../plugin'
import TxViewTx from './TxViewTx.svelte'
@@ -215,7 +215,11 @@
1}>
{#each value.added as cvalue}
-
+ {#if value.isObjectAdded}
+
+ {:else}
+
+ {/if}
{/each}
@@ -234,11 +238,15 @@
1}>
{#each value.removed as cvalue}
-
+ {#if value.isObjectRemoved}
+
+ {:else}
+
+ {/if}
{/each}
- {:else if value.set === null || value.set === undefined}
+ {:else if value.set === null || value.set === undefined || value.set === ''}
{:else}
@@ -251,11 +259,19 @@
{/if}
{#if isMessageType(m.attribute)}
-
+ {#if value.isObjectSet}
+
+ {:else}
+
+ {/if}
{:else}
-
+ {#if value.isObjectSet}
+
+ {:else}
+
+ {/if}
{/if}
{/if}
@@ -264,7 +280,7 @@
{:else if viewlet === undefined && model.length > 0 && tx.mixinTx}
{#each model as m}
{#await getValue(client, m, tx) then value}
- {#if value.set === null}
+ {#if value.set === null || value.set === ''}
@@ -276,11 +292,19 @@
{#if isMessageType(m.attribute)}
-
+ {#if value.isObjectSet}
+
+ {:else}
+
+ {/if}
{:else}
-
+ {#if value.isObjectSet}
+
+ {:else}
+
+ {/if}
{/if}
{/if}
diff --git a/plugins/activity-resources/src/utils.ts b/plugins/activity-resources/src/utils.ts
index 03ebebf847..ba25fa7e5b 100644
--- a/plugins/activity-resources/src/utils.ts
+++ b/plugins/activity-resources/src/utils.ts
@@ -224,10 +224,14 @@ async function buildRemovedDoc (
return doc
}
-async function getAllRealValues (client: TxOperations, values: any[], _class: Ref>): Promise {
- if (values.length === 0) return []
+async function getAllRealValues (
+ client: TxOperations,
+ values: any[],
+ _class: Ref>
+): Promise<[any[], boolean]> {
+ if (values.length === 0) return [[], false]
if (values.some((value) => typeof value !== 'string')) {
- return values
+ return [values, false]
}
if (
_class === core.class.TypeString ||
@@ -235,12 +239,12 @@ async function getAllRealValues (client: TxOperations, values: any[], _class: Re
_class === core.class.TypeNumber ||
_class === core.class.TypeDate
) {
- return values
+ return [values, false]
}
const realValues = await client.findAll(_class, { _id: { $in: values } })
const realValuesIds = realValues.map(({ _id }) => _id)
- return [
+ const res = [
...realValues,
...(await Promise.all(
values
@@ -248,6 +252,7 @@ async function getAllRealValues (client: TxOperations, values: any[], _class: Re
.map(async (value) => await buildRemovedDoc(client, value, _class))
))
].filter((v) => v != null)
+ return [res, true]
}
function combineAttributes (attributes: any[], key: string, operator: string, arrayKey: string): any[] {
@@ -260,15 +265,31 @@ function combineAttributes (attributes: any[], key: string, operator: string, ar
).filter((v) => v != null)
}
-export async function getValue (client: TxOperations, m: AttributeModel, tx: DisplayTx): Promise {
+interface TxAttributeValue {
+ set: any
+ isObjectSet: boolean
+ added: any[]
+ isObjectAdded: boolean
+ removed: any[]
+ isObjectRemoved: boolean
+}
+
+export async function getValue (client: TxOperations, m: AttributeModel, tx: DisplayTx): Promise {
const utxs = getModifiedAttributes(tx)
- const value = {
+ const added = await getAllRealValues(client, combineAttributes(utxs, m.key, '$push', '$each'), m._class)
+ const removed = await getAllRealValues(client, combineAttributes(utxs, m.key, '$pull', '$in'), m._class)
+ const value: TxAttributeValue = {
set: utxs[0][m.key],
- added: await getAllRealValues(client, combineAttributes(utxs, m.key, '$push', '$each'), m._class),
- removed: await getAllRealValues(client, combineAttributes(utxs, m.key, '$pull', '$in'), m._class)
+ isObjectSet: false,
+ added: added[0],
+ isObjectAdded: added[1],
+ removed: removed[0],
+ isObjectRemoved: removed[1]
}
if (value.set !== undefined) {
- ;[value.set] = await getAllRealValues(client, [value.set], m._class)
+ const res = await getAllRealValues(client, [value.set], m._class)
+ value.set = res[0][0]
+ value.isObjectSet = res[1]
}
return value
}