diff --git a/api/src/services/fields.ts b/api/src/services/fields.ts index 09b133e589..0342b0c31b 100644 --- a/api/src/services/fields.ts +++ b/api/src/services/fields.ts @@ -68,9 +68,8 @@ export class FieldsService { }); const aliasQuery = this.knex - .select('*') - .from('directus_fields') - .whereIn('special', ['alias', 'o2m', 'm2m']); + .select('*') + .from('directus_fields'); if (collection) { aliasQuery.andWhere('collection', collection); @@ -78,6 +77,18 @@ export class FieldsService { let aliasFields = await aliasQuery; + const aliasTypes = ['alias', 'o2m', 'm2m', 'files', 'files', 'translations']; + + aliasFields = aliasFields.filter((field) => { + const specials = (field.special || '').split(','); + + for (const type of aliasTypes) { + if (specials.includes(type)) return true; + } + + return false; + }); + aliasFields = (await this.payloadService.processValues('read', aliasFields)) as FieldMeta[]; const aliasFieldsAsField = aliasFields.map((field) => { diff --git a/app/src/components/v-list/v-list-item.vue b/app/src/components/v-list/v-list-item.vue index 4b8715bfd3..5d442c023d 100644 --- a/app/src/components/v-list/v-list-item.vue +++ b/app/src/components/v-list/v-list-item.vue @@ -164,7 +164,9 @@ body { } &.disabled { - --v-list-item-color: var(--foreground-subdued); + --v-list-item-color: var(--foreground-subdued) !important; + + cursor: not-allowed; } @at-root { diff --git a/app/src/interfaces/translations/translations.vue b/app/src/interfaces/translations/translations.vue index aafc414a2f..ae397188da 100644 --- a/app/src/interfaces/translations/translations.vue +++ b/app/src/interfaces/translations/translations.vue @@ -68,7 +68,13 @@ export default defineComponent({ const fieldsStore = useFieldsStore(); const relationsStore = useRelationsStore(); - const { relations, translationsCollection, languagesCollection, languageField, translationsPrimaryKeyField } = useRelation(); + const { + relations, + translationsCollection, + languagesCollection, + languageField, + translationsPrimaryKeyField, + } = useRelation(); const { languages, @@ -84,7 +90,7 @@ export default defineComponent({ const { info, primaryKeyField } = useCollection(languagesCollection); const defaultTemplate = info.value?.meta?.display_template; - return defaultTemplate || props.template || `{{ $${primaryKeyField.value.field} }}`; + return props.template || defaultTemplate || `{{ ${primaryKeyField.value.field} }}`; }); return { @@ -113,10 +119,12 @@ export default defineComponent({ const translationsRelation = computed(() => { if (!relations.value || relations.value.length === 0) return null; - return relations.value.find((relation: Relation) => { - return relation.one_collection === props.collection && relation.one_field === props.field; - }) || null; - }) + return ( + relations.value.find((relation: Relation) => { + return relation.one_collection === props.collection && relation.one_field === props.field; + }) || null + ); + }); const translationsCollection = computed(() => { if (!translationsRelation.value) return null; @@ -130,9 +138,11 @@ export default defineComponent({ const languagesRelation = computed(() => { if (!relations.value || relations.value.length === 0) return null; - return relations.value.find((relation: Relation) => { - return relation.one_collection !== props.collection && relation.one_field !== props.field; - }) || null; + return ( + relations.value.find((relation: Relation) => { + return relation.one_collection !== props.collection && relation.one_field !== props.field; + }) || null + ); }); const languagesCollection = computed(() => { @@ -143,9 +153,15 @@ export default defineComponent({ const languageField = computed(() => { if (!languagesRelation.value) return null; return languagesRelation.value.many_field; - }) + }); - return { relations, translationsCollection, languagesCollection, languageField, translationsPrimaryKeyField }; + return { + relations, + translationsCollection, + languagesCollection, + languageField, + translationsPrimaryKeyField, + }; } function useLanguages() { diff --git a/app/src/lang/en-US/index.json b/app/src/lang/en-US/index.json index 065da128ac..2beb9995f0 100644 --- a/app/src/lang/en-US/index.json +++ b/app/src/lang/en-US/index.json @@ -193,6 +193,15 @@ "not_available_for_type": "Not Available for this Type", + "create_translations": "Create Translations", + + "auto_generate": "Auto-Generate", + "this_will_auto_setup_fields_relations": "This will automatically setup all required fields and relations.", + "click_here": "Click here", + "to_manually_setup_translations": "to manually setup translations.", + + "click_to_manage_translated_fields": "There are no translated fields yet. Click here to create them. | There is one translated field. Click here to manage it. | There are {count} translated fields. Click here to manage them.", + "configure_m2o": "Configure your Many-to-One Relationship...", "configure_o2m": "Configure your One-to-Many Relationship...", "configure_m2m": "Configure your Many-to-Many Relationship...", diff --git a/app/src/modules/settings/routes/data-model/field-detail/components/translations.vue b/app/src/modules/settings/routes/data-model/field-detail/components/translations.vue index 9b42843aa8..44c03504a8 100644 --- a/app/src/modules/settings/routes/data-model/field-detail/components/translations.vue +++ b/app/src/modules/settings/routes/data-model/field-detail/components/translations.vue @@ -1,84 +1,206 @@