Skip to content

Commit 0e24f51

Browse files
Nitwelpaescujrijkvanzanten
authored andcommitted
Use technical collection/field names in settings (directus#19444)
* temp commit * change to non translated names * Add changeset * Fix linter warning * Update related collection selection as well Unfortunately, modifiying the font via css var doesn't work so we need to pass it down via prop. See vuejs/core#7312 --------- Co-authored-by: Pascal Jufer <[email protected]> Co-authored-by: Rijk van Zanten <[email protected]>
1 parent c06b4d3 commit 0e24f51

File tree

18 files changed

+114
-62
lines changed

18 files changed

+114
-62
lines changed

.changeset/tame-dolphins-begin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@directus/app": patch
3+
---
4+
5+
Switched to technical collection/field names in settings for clarity

app/src/components/v-field-list/v-field-list-item.vue

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
v-if="field.children || supportedFunctions.length > 0"
44
:clickable="!field.disabled && (relationalFieldSelectable || !field.relatedCollection)"
55
:value="field.path"
6+
:class="{ 'raw-field-names': rawFieldNames }"
67
@click="$emit('add', [field.key])"
78
>
89
<template #activator>
910
<v-list-item-content>
10-
<v-text-overflow :text="field.name || formatTitle(field.field)" :highlight="search" />
11+
<v-text-overflow
12+
:text="rawFieldNames ? field.field : field.name || formatTitle(field.field)"
13+
:highlight="search"
14+
/>
1115
</v-list-item-content>
1216
</template>
1317

@@ -24,7 +28,7 @@
2428
</v-list-item-icon>
2529
<v-list-item-content>
2630
<v-text-overflow
27-
:text="`${t(`functions.${fn}`)} (${field.name || formatTitle(field.field)})`"
31+
:text="`${t(`functions.${fn}`)} (${rawFieldNames ? field.field : field.name || formatTitle(field.field)})`"
2832
:highlight="search"
2933
/>
3034
</v-list-item-content>
@@ -50,13 +54,23 @@
5054
:relational-field-selectable="relationalFieldSelectable"
5155
:parent="field.field"
5256
:allow-select-all="allowSelectAll"
57+
:raw-field-names="rawFieldNames"
5358
@add="$emit('add', $event)"
5459
/>
5560
</v-list-group>
5661

57-
<v-list-item v-else :disabled="field.disabled" clickable @click="$emit('add', [field.key])">
62+
<v-list-item
63+
v-else
64+
:disabled="field.disabled"
65+
:class="{ 'raw-field-names': rawFieldNames }"
66+
clickable
67+
@click="$emit('add', [field.key])"
68+
>
5869
<v-list-item-content>
59-
<v-text-overflow :text="field.name || formatTitle(field.field)" :highlight="search" />
70+
<v-text-overflow
71+
:text="rawFieldNames ? field.field : field.name || formatTitle(field.field)"
72+
:highlight="search"
73+
/>
6074
</v-list-item-content>
6175
</v-list-item>
6276
</template>
@@ -86,6 +100,7 @@ interface Props {
86100
relationalFieldSelectable?: boolean;
87101
allowSelectAll?: boolean;
88102
parent?: string | null;
103+
rawFieldNames?: boolean;
89104
}
90105
91106
const props = withDefaults(defineProps<Props>(), {
@@ -94,6 +109,7 @@ const props = withDefaults(defineProps<Props>(), {
94109
relationalFieldSelectable: true,
95110
allowSelectAll: false,
96111
parent: null,
112+
rawFieldNames: false,
97113
});
98114
99115
const emit = defineEmits(['add']);
@@ -129,4 +145,8 @@ const addAll = () => {
129145
--v-icon-color: var(--primary);
130146
--v-list-item-color: var(--primary);
131147
}
148+
149+
.raw-field-names {
150+
--v-list-item-content-font-family: var(--family-monospace);
151+
}
132152
</style>

app/src/components/v-field-list/v-field-list.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
:include-functions="includeFunctions"
2828
:relational-field-selectable="relationalFieldSelectable"
2929
:allow-select-all="allowSelectAll"
30+
:raw-field-names="rawFieldNames"
3031
@add="$emit('add', $event)"
3132
/>
3233
</v-list>
@@ -49,6 +50,7 @@ interface Props {
4950
includeRelations?: boolean;
5051
relationalFieldSelectable?: boolean;
5152
allowSelectAll?: boolean;
53+
rawFieldNames?: boolean;
5254
}
5355
5456
const props = withDefaults(defineProps<Props>(), {
@@ -58,6 +60,7 @@ const props = withDefaults(defineProps<Props>(), {
5860
includeRelations: true,
5961
relationalFieldSelectable: true,
6062
allowSelectAll: false,
63+
rawFieldNames: false,
6164
});
6265
6366
const emit = defineEmits(['add']);

app/src/components/v-select/select-list-item-group.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<select-list-item-group
2828
v-if="childItem.children"
2929
:item="childItem"
30+
:item-label-font-family="itemLabelFontFamily"
3031
:model-value="modelValue"
3132
:multiple="multiple"
3233
:allow-other="allowOther"
@@ -37,6 +38,7 @@
3738
v-else
3839
:model-value="modelValue"
3940
:item="childItem"
41+
:item-label-font-family="itemLabelFontFamily"
4042
:multiple="multiple"
4143
:allow-other="allowOther"
4244
@update:model-value="$emit('update:modelValue', $event)"
@@ -52,6 +54,7 @@ import SelectListItem from './select-list-item.vue';
5254
5355
interface Props {
5456
item: Option;
57+
itemLabelFontFamily?: string;
5558
modelValue?: string | number | (string | number)[] | null;
5659
multiple?: boolean;
5760
allowOther?: boolean;

app/src/components/v-select/select-list-item.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<span v-if="multiple === false || item.selectable === false" class="item-text">{{ item.text }}</span>
1818
<v-checkbox
1919
v-else
20+
class="checkbox"
2021
:model-value="modelValue || []"
2122
:label="item.text"
2223
:value="item.value"
@@ -33,12 +34,14 @@ import { Option } from './types';
3334
3435
interface Props {
3536
item: Option;
37+
itemLabelFontFamily: string;
3638
modelValue?: string | number | (string | number)[] | null;
3739
multiple?: boolean;
3840
allowOther?: boolean;
3941
}
4042
4143
const props = withDefaults(defineProps<Props>(), {
44+
itemLabelFontFamily: 'var(--v-select-font-family)',
4245
modelValue: null,
4346
multiple: true,
4447
allowOther: false,
@@ -58,3 +61,9 @@ const isActive = computed(() => {
5861
}
5962
});
6063
</script>
64+
65+
<style scoped>
66+
.checkbox :deep(.type-text) {
67+
font-family: v-bind('$props.itemLabelFontFamily');
68+
}
69+
</style>

app/src/components/v-select/v-select.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<select-list-item-group
6969
v-if="item.children"
7070
:item="item"
71+
:item-label-font-family="itemLabelFontFamily"
7172
:model-value="modelValue"
7273
:multiple="multiple"
7374
:allow-other="allowOther"
@@ -78,6 +79,7 @@
7879
v-else
7980
:model-value="modelValue"
8081
:item="item"
82+
:item-label-font-family="itemLabelFontFamily"
8183
:multiple="multiple"
8284
:allow-other="allowOther"
8385
@update:model-value="$emit('update:modelValue', $event)"
@@ -155,6 +157,8 @@ interface Props {
155157
itemValue?: string;
156158
/** Which key in items is used to show an icon */
157159
itemIcon?: string | null;
160+
/** Which font family to use for checkbox item label */
161+
itemLabelFontFamily?: string;
158162
/** Which key in items is used to model the disabled state */
159163
itemDisabled?: string;
160164
/** Which key in items is used to model the selectable state */
@@ -368,10 +372,6 @@ function useDisplayValue() {
368372
--v-list-min-width: 0;
369373
}
370374
371-
.item-text {
372-
font-family: var(--v-select-font-family);
373-
}
374-
375375
.v-input {
376376
--v-input-font-family: var(--v-select-font-family);
377377

app/src/interfaces/_system/system-filter/nodes.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
<template #item="{ element, index }">
1515
<li class="row">
1616
<div v-if="filterInfo[index].isField" block class="node field">
17-
<div class="header" :class="{ inline }">
17+
<div class="header" :class="{ inline, 'raw-field-names': rawFieldNames }">
1818
<v-icon name="drag_indicator" class="drag-handle" small></v-icon>
19-
<span v-if="field || !isExistingField(element)" class="plain-name">{{ getFieldPreview(element) }}</span>
19+
<span v-if="field || !isExistingField(element)" class="plain-name">
20+
{{ getFieldPreview(element) }}
21+
</span>
2022
<v-menu v-else placement="bottom-start" show-arrow>
2123
<template #activator="{ toggle }">
2224
<button class="name" @click="toggle">
@@ -31,6 +33,7 @@
3133
:include-relations="includeRelations"
3234
:relational-field-selectable="relationalFieldSelectable"
3335
:allow-select-all="false"
36+
:raw-field-names="rawFieldNames"
3437
@add="updateField(index, $event[0])"
3538
/>
3639
</v-menu>
@@ -89,6 +92,7 @@
8992
:collection="collection"
9093
:depth="depth + 1"
9194
:inline="inline"
95+
:raw-field-names="rawFieldNames"
9296
@change="$emit('change')"
9397
@remove-node="$emit('remove-node', [`${index}.${filterInfo[index].name}`, ...$event])"
9498
@update:filter="replaceNode(index, { [filterInfo[index].name]: $event })"
@@ -146,6 +150,7 @@ interface Props {
146150
includeValidation?: boolean;
147151
includeRelations?: boolean;
148152
relationalFieldSelectable?: boolean;
153+
rawFieldNames?: boolean;
149154
}
150155
151156
const props = withDefaults(defineProps<Props>(), {
@@ -155,6 +160,7 @@ const props = withDefaults(defineProps<Props>(), {
155160
includeValidation: false,
156161
includeRelations: true,
157162
relationalFieldSelectable: true,
163+
rawFieldNames: false,
158164
});
159165
160166
const emit = defineEmits(['remove-node', 'update:filter', 'change']);
@@ -211,7 +217,7 @@ function getFieldPreview(node: Record<string, any>) {
211217
const pathPrefix = fieldParts.slice(0, index);
212218
const field = fieldsStore.getField(props.collection, [...pathPrefix, key].join('.'));
213219
214-
const name = field?.name ?? key;
220+
const name = (props.rawFieldNames ? field?.field : field?.name) ?? key;
215221
216222
if (hasFunction) {
217223
return t(`functions.${functionName}`) + ` (${name})`;
@@ -428,6 +434,13 @@ function isExistingField(node: Record<string, any>): boolean {
428434
white-space: nowrap;
429435
}
430436
437+
&.raw-field-names {
438+
.plain-name,
439+
.name {
440+
font-family: var(--family-monospace);
441+
}
442+
}
443+
431444
.name,
432445
.comparator {
433446
position: relative;

app/src/interfaces/_system/system-filter/system-filter.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
:include-validation="includeValidation"
2222
:include-relations="includeRelations"
2323
:relational-field-selectable="relationalFieldSelectable"
24+
:raw-field-names="rawFieldNames"
2425
@remove-node="removeNode($event)"
2526
@change="emitValue"
2627
/>
@@ -47,6 +48,7 @@
4748
:include-relations="includeRelations"
4849
:relational-field-selectable="relationalFieldSelectable"
4950
:allow-select-all="false"
51+
:raw-field-names="rawFieldNames"
5052
@add="addNode($event[0])"
5153
>
5254
<template #prepend>
@@ -114,6 +116,7 @@ interface Props {
114116
includeValidation?: boolean;
115117
includeRelations?: boolean;
116118
relationalFieldSelectable?: boolean;
119+
rawFieldNames?: boolean;
117120
}
118121
119122
const props = withDefaults(defineProps<Props>(), {
@@ -127,6 +130,7 @@ const props = withDefaults(defineProps<Props>(), {
127130
includeValidation: false,
128131
includeRelations: true,
129132
relationalFieldSelectable: true,
133+
rawFieldNames: false,
130134
});
131135
132136
const emit = defineEmits(['input']);

app/src/modules/settings/routes/data-model/field-detail/field-detail-advanced/field-detail-advanced-relationship-m2a.vue

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
:placeholder="t('collection') + '...'"
2222
:items="availableCollections"
2323
item-value="collection"
24-
item-text="name"
24+
item-text="collection"
25+
item-label-font-family="var(--family-monospace)"
2526
item-disabled="meta.singleton"
2627
multiple
2728
:is-menu-same-width="false"
@@ -188,21 +189,17 @@ const isExisting = computed(() => editing.value !== '+');
188189
const currentPrimaryKey = computed(() => fieldsStore.getPrimaryKeyFieldForCollection(collection.value!)?.field);
189190
190191
const availableCollections = computed(() => {
191-
return orderBy(
192-
[
193-
...collectionsStore.databaseCollections,
194-
{
195-
divider: true,
196-
},
197-
{
198-
name: t('system'),
199-
selectable: false,
200-
children: collectionsStore.crudSafeSystemCollections,
201-
},
202-
],
203-
['collection'],
204-
['asc']
205-
);
192+
return [
193+
...orderBy(collectionsStore.databaseCollections, ['collection'], ['asc']),
194+
{
195+
divider: true,
196+
},
197+
{
198+
collection: t('system'),
199+
selectable: false,
200+
children: orderBy(collectionsStore.crudSafeSystemCollections, ['collection'], ['asc']),
201+
},
202+
];
206203
});
207204
208205
const unsortableJunctionFields = computed(() => {

app/src/modules/settings/routes/data-model/field-detail/field-detail-simple/relationship-configuration.vue

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858
:placeholder="t('collection') + '...'"
5959
:items="availableCollections"
6060
item-value="collection"
61-
item-text="name"
61+
item-text="collection"
62+
item-label-font-family="var(--family-monospace)"
6263
item-disabled="meta.singleton"
6364
multiple
6465
:multiple-preview-threshold="0"
@@ -90,21 +91,17 @@ const o2mField = syncFieldDetailStoreProperty('relations.o2m.field');
9091
const oneAllowedCollections = syncFieldDetailStoreProperty('relations.m2o.meta.one_allowed_collections', []);
9192
9293
const availableCollections = computed(() => {
93-
return orderBy(
94-
[
95-
...collectionsStore.databaseCollections,
96-
{
97-
divider: true,
98-
},
99-
{
100-
name: t('system'),
101-
selectable: false,
102-
children: collectionsStore.crudSafeSystemCollections,
103-
},
104-
],
105-
['collection'],
106-
['asc']
107-
);
94+
return [
95+
...orderBy(collectionsStore.databaseCollections, ['collection'], ['asc']),
96+
{
97+
divider: true,
98+
},
99+
{
100+
collection: t('system'),
101+
selectable: false,
102+
children: orderBy(collectionsStore.crudSafeSystemCollections, ['collection'], ['asc']),
103+
},
104+
];
108105
});
109106
</script>
110107

0 commit comments

Comments
 (0)