mirror of
https://github.com/directus/directus.git
synced 2026-01-29 16:28:02 -05:00
Add m2o
This commit is contained in:
@@ -82,6 +82,11 @@ export default defineComponent({
|
||||
const typesWithLabels = computed(() =>
|
||||
types
|
||||
.filter((type) => {
|
||||
// Only allow primary key types in m2o fields
|
||||
if (props.type === 'm2o') {
|
||||
return ['integer', 'string', 'uuid'].includes(type);
|
||||
}
|
||||
|
||||
// Remove alias and unknown, as those aren't real column types you can use
|
||||
return ['alias', 'unknown'].includes(type) === false;
|
||||
})
|
||||
@@ -94,7 +99,7 @@ export default defineComponent({
|
||||
);
|
||||
|
||||
const typeDisabled = computed(() => {
|
||||
return props.type !== 'standard';
|
||||
return ['file', 'files', 'o2m', 'm2m'].includes(props.type);
|
||||
});
|
||||
|
||||
return { _field, typesWithLabels, setType, typeDisabled };
|
||||
|
||||
@@ -198,6 +198,25 @@ export default defineComponent({
|
||||
);
|
||||
}
|
||||
|
||||
if (props.type === 'm2o') {
|
||||
relations.value = [
|
||||
{
|
||||
collection_many: props.collection,
|
||||
field_many: '',
|
||||
primary_many: fieldsStore.getPrimaryKeyFieldForCollection(props.collection)?.field,
|
||||
collection_one: '',
|
||||
primary_one: fieldsStore.getPrimaryKeyFieldForCollection('directus_files')?.field,
|
||||
},
|
||||
];
|
||||
|
||||
watch(
|
||||
() => fieldData.field,
|
||||
() => {
|
||||
relations.value[0].field_many = fieldData.field;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return { fieldData, relations };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user