Adjust label editors (#1961)

Signed-off-by: Dvinyanin Alexandr <dvinyanin.alexandr@gmail.com>
This commit is contained in:
Alex 2022-06-01 10:21:34 +07:00 committed by GitHub
parent 47f3880392
commit a4353b0fc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 35 additions and 7 deletions

View File

@ -8,6 +8,7 @@ Platform:
- Adjust label editors design
- Allow to define table columns order
- Fix skills/labels selection and show real usage counter
- Fix skills/labels activity
## 0.6.22

View File

@ -337,7 +337,7 @@ class ActivityImpl implements Activity {
// we have same keys,
// Remember previous transactions
if (result.txDocIds === undefined) {
result.txDocIds = new Set()
result.txDocIds = new Set(prevTx.txDocIds)
}
if (prevTx.doc?._id !== undefined) {
result.txDocIds?.add(prevTx.doc._id)

View File

@ -21,6 +21,7 @@
import { Component, Grid, IconActivity, Label, Scroller } from '@anticrm/ui'
import { ActivityKey, activityKey, DisplayTx, newActivity } from '../activity'
import TxView from './TxView.svelte'
import { filterCollectionTxes } from './utils'
export let object: Doc
export let integrate: boolean = false
@ -48,7 +49,7 @@
$: activityQuery.update(
object,
(result) => {
txes = result
txes = filterCollectionTxes(result)
},
SortingOrder.Descending,
new Map(

View File

@ -249,7 +249,7 @@
{/await}
{/each}
{:else if viewlet && viewlet.display === 'inline' && viewlet.component}
{#if tx.collectionAttribute !== undefined && (tx.txDocIds?.size ?? 0) > 1}
{#if tx.collectionAttribute !== undefined}
<ShowMore ignore={edit}>
<div class="flex-row-center flex-grow flex-wrap clear-mins">
<TxViewTx {tx} {onCancelEdit} {edit} {viewlet} />
@ -270,7 +270,7 @@
{#if viewlet && viewlet.component && viewlet.display !== 'inline'}
<div class={viewlet.display}>
<ShowMore ignore={edit}>
{#if tx.collectionAttribute !== undefined && (tx.txDocIds?.size ?? 0) > 1}
{#if tx.collectionAttribute !== undefined}
<div class="flex-row-center flex-grow flex-wrap clear-mins">
<TxViewTx {tx} {onCancelEdit} {edit} {viewlet} />
</div>

View File

@ -22,7 +22,7 @@
</script>
<div class="flex-row-center flex-grow flex-wrap content">
{#each filterTx([tx, ...tx.txes], core.class.TxCreateDoc) as ctx, i}
{#each filterTx([...tx.txes, tx], core.class.TxCreateDoc) as ctx, i}
{#if i === 0}
<div class="mr-2"><IconAdd size={'small'} /></div>
{/if}
@ -34,7 +34,7 @@
{/if}
</div>
{/each}
{#each filterTx([tx, ...tx.txes], core.class.TxRemoveDoc) as ctx, i}
{#each filterTx([...tx.txes, tx], core.class.TxRemoveDoc) as ctx, i}
{#if i === 0}
<div class="mr-2"><IconDelete size={'small'} /></div>
{/if}

View File

@ -125,7 +125,7 @@ async function checkInlineViewlets (
client: TxOperations,
model: AttributeModel[]
): Promise<{ viewlet: TxDisplayViewlet, model: AttributeModel[] }> {
if (dtx.collectionAttribute !== undefined && (dtx.txDocIds?.size ?? 0) > 1) {
if (dtx.collectionAttribute !== undefined) {
// Check if we have a class presenter we could have a pseudo viewlet based on class presenter.
viewlet = await createPseudoViewlet(client, dtx, activity.string.CollectionUpdated, 'content')
} else if (dtx.tx._class === core.class.TxCreateDoc) {
@ -252,3 +252,29 @@ export async function getValue (client: TxOperations, m: AttributeModel, tx: Dis
}
return value
}
export function filterCollectionTxes (txes: DisplayTx[]): DisplayTx[] {
return txes.map(filterCollectionTx).filter(Boolean) as DisplayTx[]
}
function filterCollectionTx (tx: DisplayTx): DisplayTx | undefined {
if (tx.collectionAttribute === undefined) return tx
const txes = tx.txes.reduceRight(
(txes, ctx) => {
const filtredTxes = txes.filter(
({ tx: { _class }, doc }) => doc?._id !== ctx.doc?._id || _class === core.class.TxUpdateDoc
)
return ctx.tx._class === core.class.TxUpdateDoc || filtredTxes.length === txes.length
? [ctx, ...txes]
: filtredTxes
},
[tx]
)
const txDocIds = txes.map(({ doc }) => doc?._id).filter(Boolean) as Array<Ref<Doc>>
const ctx = txes.pop()
if (ctx !== undefined) {
ctx.txes = txes
ctx.txDocIds = new Set(txDocIds)
}
return ctx
}