Skip to content

Commit 6933c99

Browse files
authored
Fixes display of custom attributes in ListView (#9639)
1 parent d4216a6 commit 6933c99

File tree

7 files changed

+49
-13
lines changed

7 files changed

+49
-13
lines changed

models/card/src/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export class TFavoriteCard extends TPreference implements FavoriteCard {
170170
export * from './migration'
171171

172172
const listConfig: (BuildModelKey | string)[] = [
173-
{ key: '', props: { showParent: true } },
173+
{ key: '' },
174174
{ key: '_class' },
175175
{ key: '', displayProps: { grow: true } },
176176
{
@@ -180,14 +180,13 @@ const listConfig: (BuildModelKey | string)[] = [
180180
props: {
181181
showType: false
182182
},
183-
displayProps: { key: 'tags', fixed: 'right' }
183+
displayProps: { optional: true }
184184
},
185185
{
186186
key: '',
187187
presenter: card.component.LabelsPresenter,
188188
label: card.string.Labels,
189-
props: { fullSize: true },
190-
displayProps: { fixed: 'right', key: 'labels' }
189+
props: { fullSize: true }
191190
},
192191
{
193192
key: 'modifiedOn',

models/card/src/migration.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//
1515

1616
import { type Card, cardId, DOMAIN_CARD } from '@hcengineering/card'
17-
import core, { type Ref, TxOperations, type Client, type Data, type Doc } from '@hcengineering/core'
17+
import core, { DOMAIN_MODEL, type Ref, TxOperations, type Client, type Data, type Doc } from '@hcengineering/core'
1818
import {
1919
tryMigrate,
2020
tryUpgrade,
@@ -23,7 +23,7 @@ import {
2323
type MigrationUpgradeClient,
2424
createOrUpdate
2525
} from '@hcengineering/model'
26-
import view from '@hcengineering/view'
26+
import view, { type Viewlet } from '@hcengineering/view'
2727
import card from '.'
2828
import tags from '@hcengineering/tags'
2929

@@ -44,13 +44,18 @@ export const cardOperation: MigrateOperation = {
4444
state: 'migrate-childs-spaces',
4545
mode: 'upgrade',
4646
func: migrateChildsSpaces
47+
},
48+
{
49+
state: 'update-custom-fields-displayprops',
50+
mode: 'upgrade',
51+
func: updateCustomFieldsDisplayProps
4752
}
4853
])
4954
},
5055
async upgrade (state: Map<string, Set<string>>, client: () => Promise<MigrationUpgradeClient>, mode): Promise<void> {
5156
await tryUpgrade(mode, state, client, cardId, [
5257
{
53-
state: 'migrateViewlets-v4',
58+
state: 'migrateViewlets-v5',
5459
func: migrateViewlets
5560
},
5661
{
@@ -302,3 +307,24 @@ async function defaultLabels (client: Client): Promise<void> {
302307
card.label.NewMessages
303308
)
304309
}
310+
311+
async function updateCustomFieldsDisplayProps (client: MigrationClient): Promise<void> {
312+
const viewlets = await client.find<Viewlet>(DOMAIN_MODEL, { _class: view.class.Viewlet })
313+
314+
for (const viewlet of viewlets) {
315+
if (viewlet.config !== undefined && Array.isArray(viewlet.config)) {
316+
let hasChanges = false
317+
const newConfig = viewlet.config.map((item: any) => {
318+
if (typeof item === 'string' && item.startsWith('custom')) {
319+
hasChanges = true
320+
return { key: item, displayProps: { optional: true } }
321+
}
322+
return item
323+
})
324+
325+
if (hasChanges) {
326+
await client.update(DOMAIN_MODEL, { _id: viewlet._id }, { config: newConfig })
327+
}
328+
}
329+
}
330+
}

packages/theme/styles/components.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2504,6 +2504,8 @@
25042504
}
25052505
.panel-trigger > * { pointer-events: none; }
25062506
}
2507+
// Custom on the ListView
2508+
.list-container .listGrid .yesno-container { flex-shrink: 0; }
25072509
// Labels on the ListView
25082510
.list-container .listitems-container,
25092511
.list-container .listitems-container:hover,

plugins/contact-resources/src/components/AssigneeBox.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132

133133
<!-- svelte-ignore a11y-click-events-have-key-events -->
134134
<!-- svelte-ignore a11y-no-static-element-interactions -->
135-
<div {id} bind:this={container} class="min-w-0 h-full" class:w-full={width === '100%'} style:flex-shrink={shrink}>
135+
<div {id} bind:this={container} class="min-w-0" class:w-full={width === '100%'} style:flex-shrink={shrink}>
136136
{#if $$slots.content}
137137
<div
138138
class="w-full h-full flex-streatch"

plugins/view-resources/src/components/EnumEditor.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
3434
const query = createQuery()
3535
36-
query.query(
36+
$: query.query(
3737
core.class.Enum,
3838
{
3939
_id: type.of

plugins/view-resources/src/components/ViewletSetting.svelte

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@
111111
if (param.length === 0) {
112112
result.push(getObjectConfig(viewlet.attachTo, param))
113113
} else {
114+
const paramValue = param.startsWith('custom') ? { key: param, displayProps: { optional: true } } : param
114115
const attrCfg: AttributeConfig = {
115116
type: 'attribute',
116-
value: param,
117+
value: paramValue,
117118
enabled: true,
118119
label: getKeyLabel(client, viewlet.attachTo, param, lookup),
119120
_class: viewlet.attachTo,
@@ -201,9 +202,12 @@
201202
result.push(newValue)
202203
}
203204
} else {
205+
const isCustomAttribute = attribute.name.startsWith('custom')
206+
const attributeValue = isCustomAttribute ? { key: value, displayProps: { optional: true } } : value
207+
204208
const newValue: AttributeConfig = {
205209
type: 'attribute',
206-
value: extraProps ? { ...extraProps, key: value } : value,
210+
value: extraProps != null ? { ...extraProps, key: value } : attributeValue,
207211
label: attribute.label,
208212
enabled: false,
209213
_class: attribute.attributeOf,
@@ -272,7 +276,13 @@
272276
((p.type === 'divider' && typeof p.value === 'object' && p.value.displayProps?.grow) ||
273277
(p.type === 'attribute' && (p as AttributeConfig).enabled))
274278
)
275-
const config = configValues.map((p) => p.value as string | BuildModelKey)
279+
const config = configValues.map((p) => {
280+
const value = p.value as string | BuildModelKey
281+
if (typeof value === 'string' && value.startsWith('custom')) {
282+
return { key: value, displayProps: { optional: true } }
283+
}
284+
return value
285+
})
276286
const preference = preferences.find((p) => p.attachedTo === viewletId)
277287
if (preference !== undefined) {
278288
await client.update(preference, {

plugins/view-resources/src/components/list/ListItem.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import view from '../../plugin'
2323
import GrowPresenter from './GrowPresenter.svelte'
2424
import ListPresenter from './ListPresenter.svelte'
25-
import { restrictionStore } from '../../utils'
2625
2726
export let docObject: Doc
2827
export let model: AttributeModel[]

0 commit comments

Comments
 (0)