diff --git a/models/card/src/index.ts b/models/card/src/index.ts index 68a5365910..fb22a6d125 100644 --- a/models/card/src/index.ts +++ b/models/card/src/index.ts @@ -12,27 +12,19 @@ // limitations under the License. import activity from '@hcengineering/activity' -import { - CardEvents, - cardId, - DOMAIN_CARD, - type Card, - type MasterTag, - type ParentInfo, - type Tag -} from '@hcengineering/card' +import { cardId, DOMAIN_CARD, type Card, type MasterTag, type ParentInfo, type Tag } from '@hcengineering/card' import chunter from '@hcengineering/chunter' import core, { AccountRole, - type Blobs, + ClassifierKind, DOMAIN_MODEL, IndexKind, SortingOrder, + type Blobs, type CollectionSize, + type MarkupBlobRef, type Rank, - type Ref, - ClassifierKind, - type MarkupBlobRef + type Ref } from '@hcengineering/core' import { Collection, @@ -54,6 +46,7 @@ import workbench from '@hcengineering/model-workbench' import { getEmbeddedLabel, type IntlString } from '@hcengineering/platform' import time, { type ToDo } from '@hcengineering/time' import { type AnyComponent } from '@hcengineering/ui/src/types' +import { type BuildModelKey } from '@hcengineering/view' import card from './plugin' export { cardId } from '@hcengineering/card' @@ -142,6 +135,23 @@ export function createModel (builder: Builder): void { ] }) + const listConfig: (BuildModelKey | string)[] = [ + { key: '', props: { showParent: true }, displayProps: { fixed: 'left', key: 'card' } }, + { key: '_class', displayProps: { fixed: 'left', key: 'type' } }, + { key: '', displayProps: { grow: true } }, + { + key: '', + presenter: view.component.RolePresenter, + label: card.string.Tags, + props: { fullSize: true }, + displayProps: { key: 'tags', fixed: 'right' } + }, + { + key: 'modifiedOn', + displayProps: { fixed: 'right', dividerBefore: true } + } + ] + builder.createDoc(view.class.Viewlet, core.space.Model, { attachTo: card.types.File, descriptor: view.viewlet.List, @@ -156,22 +166,7 @@ export function createModel (builder: Builder): void { configOptions: { hiddenKeys: ['content', 'title'] }, - config: [ - { key: '', props: { showParent: true } }, - { key: '_class', displayProps: { fixed: 'left' } }, - { - key: '', - presenter: view.component.RolePresenter, - label: card.string.Tags, - props: { fullSize: true }, - displayProps: { fixed: 'left' } - }, - { key: '', displayProps: { grow: true } }, - { - key: 'modifiedOn', - displayProps: { fixed: 'right', dividerBefore: true } - } - ] + config: listConfig }) builder.createDoc( @@ -276,20 +271,35 @@ export function createModel (builder: Builder): void { configOptions: { hiddenKeys: ['content', 'title'] }, - config: [ - { key: '', props: { showParent: true } }, - '_class', - { key: '', presenter: view.component.RolePresenter, label: card.string.Tags, props: { fullSize: true } }, - { key: '', displayProps: { grow: true } }, - { - key: 'modifiedOn', - displayProps: { fixed: 'right', dividerBefore: true } - } - ] + config: listConfig }, card.viewlet.CardList ) + builder.createDoc( + view.class.Viewlet, + core.space.Model, + { + attachTo: card.class.Card, + descriptor: view.viewlet.List, + variant: 'child', + viewOptions: { + groupBy: ['_class', 'createdBy', 'modifiedBy'], + orderBy: [ + ['modifiedOn', SortingOrder.Descending], + ['rank', SortingOrder.Ascending] + ], + other: [] + }, + configOptions: { + strict: true, + hiddenKeys: ['content', 'title'] + }, + config: listConfig + }, + card.viewlet.CardChildList + ) + builder.mixin(card.class.Card, core.class.Class, view.mixin.ObjectPresenter, { presenter: card.component.CardPresenter }) @@ -389,8 +399,7 @@ export function createModel (builder: Builder): void { context: { mode: ['context', 'browser'], group: 'remove' - }, - analyticsEvent: CardEvents.MasterTagRemoved + } }, card.action.DeleteMasterTag ) @@ -405,8 +414,7 @@ export function createModel (builder: Builder): void { context: { mode: ['context', 'browser'], group: 'remove' - }, - analyticsEvent: CardEvents.MasterTagRemoved + } }) createAction(builder, { diff --git a/models/card/src/migration.ts b/models/card/src/migration.ts index 0cfe1319d9..82ed95c82c 100644 --- a/models/card/src/migration.ts +++ b/models/card/src/migration.ts @@ -15,7 +15,7 @@ import { DOMAIN_CARD } from '@hcengineering/card' import { chunterId } from '@hcengineering/chunter' -import core, { type Client, type Data, type Doc, TxOperations } from '@hcengineering/core' +import core, { TxOperations, type Client, type Data, type Doc } from '@hcengineering/core' import { tryMigrate, tryUpgrade, @@ -39,7 +39,7 @@ export const cardOperation: MigrateOperation = { async upgrade (state: Map>, client: () => Promise, mode): Promise { await tryUpgrade(mode, state, client, chunterId, [ { - state: 'migrateViewlets', + state: 'migrateViewlets-v2', func: migrateViewlets } ]) @@ -71,23 +71,39 @@ function extractObjectProps (doc: T): Data { async function migrateViewlets (client: Client): Promise { const txOp = new TxOperations(client, core.account.System) - const viewlets = await client.findAll(view.class.Viewlet, { attachTo: card.class.Card }) + const viewlets = await client.findAll(view.class.Viewlet, { attachTo: card.class.Card, variant: { $exists: false } }) const masterTags = await client.findAll(card.class.MasterTag, {}) const currentViewlets = await client.findAll(view.class.Viewlet, { attachTo: { $in: masterTags.map((p) => p._id) } }) for (const masterTag of masterTags) { for (const viewlet of viewlets) { const base = extractObjectProps(viewlet) + const resConfig = base.config + let index = -1 + if (viewlet.descriptor === view.viewlet.List) { + index = viewlet.config.findIndex((p) => typeof p !== 'string' && p.displayProps?.grow === true) + } + const attributes = client.getHierarchy().getOwnAttributes(masterTag._id) + for (const attr of attributes) { + // let push it after grow for the list + if (index !== -1) { + resConfig.splice(index + 1, 0, attr[1].name) + } else { + resConfig.push(attr[1].name) + } + } const current = currentViewlets.find( (p) => p.attachTo === masterTag._id && p.variant === viewlet.variant && p.descriptor === viewlet.descriptor ) if (current === undefined) { await txOp.createDoc(view.class.Viewlet, core.space.Model, { ...base, + config: resConfig, attachTo: masterTag._id }) } else { await txOp.diffUpdate(current, { ...base, + config: resConfig, attachTo: masterTag._id }) } diff --git a/plugins/card-resources/src/components/Childs.svelte b/plugins/card-resources/src/components/Childs.svelte index 1f96035311..4447b4637f 100644 --- a/plugins/card-resources/src/components/Childs.svelte +++ b/plugins/card-resources/src/components/Childs.svelte @@ -48,7 +48,7 @@ const query = createQuery() - const viewletId = card.viewlet.CardList + const viewletId = card.viewlet.CardChildList let list: List const listProvider = new ListSelectionProvider( diff --git a/plugins/card-resources/src/components/CreateTag.svelte b/plugins/card-resources/src/components/CreateTag.svelte index 0e0e99184b..720c6f306d 100644 --- a/plugins/card-resources/src/components/CreateTag.svelte +++ b/plugins/card-resources/src/components/CreateTag.svelte @@ -13,13 +13,14 @@ // limitations under the License. --> - + diff --git a/plugins/card-resources/src/components/settings/RelationsSection.svelte b/plugins/card-resources/src/components/settings/RelationsSection.svelte index e52172e9d1..a402ba6a01 100644 --- a/plugins/card-resources/src/components/settings/RelationsSection.svelte +++ b/plugins/card-resources/src/components/settings/RelationsSection.svelte @@ -13,7 +13,7 @@ // limitations under the License. -->