This commit is contained in:
rijkvanzanten
2020-07-23 17:23:57 -04:00
parent 1b6a18e30a
commit f004f72244
2 changed files with 25 additions and 1 deletions

View File

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

View File

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