From 81f81c82b142f7efec7ae5aedb7c814a9df6fef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Varela?= Date: Wed, 1 Dec 2021 18:57:46 +0000 Subject: [PATCH] App: fix relationships raw value (#10161) * fix raw value for relationships * add 'files' and 'translations' --- app/src/components/v-form/form-field.vue | 2 +- app/src/utils/get-js-type.ts | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/src/components/v-form/form-field.vue b/app/src/components/v-form/form-field.vue index f49f59fb39..16632aff4d 100644 --- a/app/src/components/v-form/form-field.vue +++ b/app/src/components/v-form/form-field.vue @@ -176,7 +176,7 @@ export default defineComponent({ const showRaw = ref(false); const type = computed(() => { - return getJSType(props.field.type); + return getJSType(props.field); }); const rawValue = computed({ diff --git a/app/src/utils/get-js-type.ts b/app/src/utils/get-js-type.ts index 66e1b050a7..d84d1d3eac 100644 --- a/app/src/utils/get-js-type.ts +++ b/app/src/utils/get-js-type.ts @@ -1,10 +1,15 @@ -import { Type } from '@directus/shared/types'; +import { Field } from '@directus/shared/types'; -export function getJSType(type: Type): string { - if (['bigInteger', 'integer', 'float', 'decimal'].includes(type)) return 'number'; - if (['string', 'text', 'uuid', 'hash'].includes(type)) return 'string'; - if (['boolean'].includes(type)) return 'boolean'; - if (['time', 'timestamp', 'date', 'dateTime'].includes(type)) return 'string'; - if (['json', 'csv'].includes(type)) return 'object'; +export function getJSType(field: Field): string { + if (['bigInteger', 'integer', 'float', 'decimal'].includes(field.type)) return 'number'; + if (['string', 'text', 'uuid', 'hash'].includes(field.type)) return 'string'; + if (['boolean'].includes(field.type)) return 'boolean'; + if (['time', 'timestamp', 'date', 'dateTime'].includes(field.type)) return 'string'; + if (['json', 'csv'].includes(field.type)) return 'object'; + if ( + Array.isArray(field.meta?.special) && + field.meta!.special.some((special) => ['o2m', 'm2m', 'm2a', 'files', 'translations'].includes(special)) + ) + return 'object'; return 'undefined'; }