App: fix relationships raw value (#10161)

* fix raw value for relationships

* add 'files' and 'translations'
This commit is contained in:
José Varela
2021-12-01 18:57:46 +00:00
committed by GitHub
parent 0425809db1
commit 81f81c82b1
2 changed files with 13 additions and 8 deletions

View File

@@ -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({

View File

@@ -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';
}