From 6933c99f0170f769298443c3f22dce87f18a03bc Mon Sep 17 00:00:00 2001 From: Alexander Platov Date: Tue, 5 Aug 2025 09:19:04 +0700 Subject: [PATCH] Fixes display of custom attributes in ListView (#9639) --- models/card/src/index.ts | 7 ++-- models/card/src/migration.ts | 32 +++++++++++++++++-- packages/theme/styles/components.scss | 2 ++ .../src/components/AssigneeBox.svelte | 2 +- .../src/components/EnumEditor.svelte | 2 +- .../src/components/ViewletSetting.svelte | 16 ++++++++-- .../src/components/list/ListItem.svelte | 1 - 7 files changed, 49 insertions(+), 13 deletions(-) diff --git a/models/card/src/index.ts b/models/card/src/index.ts index 2a83d69b7e..7b0b2ffc8e 100644 --- a/models/card/src/index.ts +++ b/models/card/src/index.ts @@ -170,7 +170,7 @@ export class TFavoriteCard extends TPreference implements FavoriteCard { export * from './migration' const listConfig: (BuildModelKey | string)[] = [ - { key: '', props: { showParent: true } }, + { key: '' }, { key: '_class' }, { key: '', displayProps: { grow: true } }, { @@ -180,14 +180,13 @@ const listConfig: (BuildModelKey | string)[] = [ props: { showType: false }, - displayProps: { key: 'tags', fixed: 'right' } + displayProps: { optional: true } }, { key: '', presenter: card.component.LabelsPresenter, label: card.string.Labels, - props: { fullSize: true }, - displayProps: { fixed: 'right', key: 'labels' } + props: { fullSize: true } }, { key: 'modifiedOn', diff --git a/models/card/src/migration.ts b/models/card/src/migration.ts index 1e5dd963f2..de2be052f8 100644 --- a/models/card/src/migration.ts +++ b/models/card/src/migration.ts @@ -14,7 +14,7 @@ // import { type Card, cardId, DOMAIN_CARD } from '@hcengineering/card' -import core, { type Ref, TxOperations, type Client, type Data, type Doc } from '@hcengineering/core' +import core, { DOMAIN_MODEL, type Ref, TxOperations, type Client, type Data, type Doc } from '@hcengineering/core' import { tryMigrate, tryUpgrade, @@ -23,7 +23,7 @@ import { type MigrationUpgradeClient, createOrUpdate } from '@hcengineering/model' -import view from '@hcengineering/view' +import view, { type Viewlet } from '@hcengineering/view' import card from '.' import tags from '@hcengineering/tags' @@ -44,13 +44,18 @@ export const cardOperation: MigrateOperation = { state: 'migrate-childs-spaces', mode: 'upgrade', func: migrateChildsSpaces + }, + { + state: 'update-custom-fields-displayprops', + mode: 'upgrade', + func: updateCustomFieldsDisplayProps } ]) }, async upgrade (state: Map>, client: () => Promise, mode): Promise { await tryUpgrade(mode, state, client, cardId, [ { - state: 'migrateViewlets-v4', + state: 'migrateViewlets-v5', func: migrateViewlets }, { @@ -302,3 +307,24 @@ async function defaultLabels (client: Client): Promise { card.label.NewMessages ) } + +async function updateCustomFieldsDisplayProps (client: MigrationClient): Promise { + const viewlets = await client.find(DOMAIN_MODEL, { _class: view.class.Viewlet }) + + for (const viewlet of viewlets) { + if (viewlet.config !== undefined && Array.isArray(viewlet.config)) { + let hasChanges = false + const newConfig = viewlet.config.map((item: any) => { + if (typeof item === 'string' && item.startsWith('custom')) { + hasChanges = true + return { key: item, displayProps: { optional: true } } + } + return item + }) + + if (hasChanges) { + await client.update(DOMAIN_MODEL, { _id: viewlet._id }, { config: newConfig }) + } + } + } +} diff --git a/packages/theme/styles/components.scss b/packages/theme/styles/components.scss index 61b956822a..31f2e487b3 100644 --- a/packages/theme/styles/components.scss +++ b/packages/theme/styles/components.scss @@ -2504,6 +2504,8 @@ } .panel-trigger > * { pointer-events: none; } } +// Custom on the ListView +.list-container .listGrid .yesno-container { flex-shrink: 0; } // Labels on the ListView .list-container .listitems-container, .list-container .listitems-container:hover, diff --git a/plugins/contact-resources/src/components/AssigneeBox.svelte b/plugins/contact-resources/src/components/AssigneeBox.svelte index a337a7a180..84b843bdc5 100644 --- a/plugins/contact-resources/src/components/AssigneeBox.svelte +++ b/plugins/contact-resources/src/components/AssigneeBox.svelte @@ -132,7 +132,7 @@ -
+
{#if $$slots.content}
p.value as string | BuildModelKey) + const config = configValues.map((p) => { + const value = p.value as string | BuildModelKey + if (typeof value === 'string' && value.startsWith('custom')) { + return { key: value, displayProps: { optional: true } } + } + return value + }) const preference = preferences.find((p) => p.attachedTo === viewletId) if (preference !== undefined) { await client.update(preference, { diff --git a/plugins/view-resources/src/components/list/ListItem.svelte b/plugins/view-resources/src/components/list/ListItem.svelte index e5ad7eb9e0..a63ebad99a 100644 --- a/plugins/view-resources/src/components/list/ListItem.svelte +++ b/plugins/view-resources/src/components/list/ListItem.svelte @@ -22,7 +22,6 @@ import view from '../../plugin' import GrowPresenter from './GrowPresenter.svelte' import ListPresenter from './ListPresenter.svelte' - import { restrictionStore } from '../../utils' export let docObject: Doc export let model: AttributeModel[]