diff --git a/api/src/controllers/fields.ts b/api/src/controllers/fields.ts
index 4d36982244..6530f8c0ad 100644
--- a/api/src/controllers/fields.ts
+++ b/api/src/controllers/fields.ts
@@ -55,7 +55,7 @@ router.get(
const newFieldSchema = Joi.object({
collection: Joi.string().optional(),
field: Joi.string().required(),
- type: Joi.string().valid(...types),
+ type: Joi.string().valid(...types, null),
schema: Joi.object({
comment: Joi.string().allow(null),
default_value: Joi.any(),
diff --git a/app/src/modules/settings/routes/data-model/field-detail/components/relationship-m2m.vue b/app/src/modules/settings/routes/data-model/field-detail/components/relationship-m2m.vue
index 15ff8a34f9..2f1b87c607 100644
--- a/app/src/modules/settings/routes/data-model/field-detail/components/relationship-m2m.vue
+++ b/app/src/modules/settings/routes/data-model/field-detail/components/relationship-m2m.vue
@@ -8,11 +8,22 @@
{{ $t('junction_collection') }}
-
+
-
+
@@ -34,11 +45,23 @@
{{ $t('related_collection') }}
-
+
-
+
@@ -59,11 +82,22 @@
-
+
-
+
@@ -84,11 +118,22 @@
-
+
-
+
@@ -107,9 +152,14 @@
-
+
-
+
@@ -123,7 +173,12 @@
{{ $t('field_name') }}
-
+
@@ -164,13 +219,13 @@ export default defineComponent({
},
set(newAuto: boolean) {
state.autoFillJunctionRelation = newAuto;
- }
- })
+ },
+ });
const availableCollections = computed(() => {
return orderBy(
collectionsStore.state.collections.filter((collection) => {
- return (collection.collection.startsWith('directus_') === false);
+ return collection.collection.startsWith('directus_') === false;
}),
['collection'],
['asc']
@@ -217,7 +272,19 @@ export default defineComponent({
const { hasCorresponding, correspondingField, correspondingLabel } = useCorresponding();
- return { relations: state.relations, autoFill, collectionItems, junctionCollection, junctionFields, junctionCollectionExists, relatedCollectionExists, junctionFieldExists, hasCorresponding, correspondingField, correspondingLabel };
+ return {
+ relations: state.relations,
+ autoFill,
+ collectionItems,
+ junctionCollection,
+ junctionFields,
+ junctionCollectionExists,
+ relatedCollectionExists,
+ junctionFieldExists,
+ hasCorresponding,
+ correspondingField,
+ correspondingLabel,
+ };
function junctionFieldExists(fieldKey: string) {
if (!junctionCollection.value) return false;
@@ -230,8 +297,12 @@ export default defineComponent({
return !!state.newFields.find((field: any) => field.$type === 'corresponding');
},
set(enabled: boolean) {
- if (enabled === true) {
+ if (
+ enabled === true &&
+ !!state.newFields.find((field: any) => field.$type === 'corresponding') === false
+ ) {
state.newFields = [
+ ...state.newFields,
{
$type: 'corresponding',
field: state.relations[0].one_collection,
@@ -260,12 +331,12 @@ export default defineComponent({
if (newField.$type === 'corresponding') {
return {
...newField,
- field: field
- }
+ field: field,
+ };
}
return newField;
- })
+ });
state.relations[1].one_field = field;
},
@@ -309,12 +380,12 @@ export default defineComponent({
&:first-of-type {
bottom: 141px;
- left: 32.5%;
+ left: 32.5%;
}
&:last-of-type {
bottom: 76px;
- left: 67.4%;
+ left: 67.4%;
}
}
}
diff --git a/app/src/modules/settings/routes/data-model/field-detail/store.ts b/app/src/modules/settings/routes/data-model/field-detail/store.ts
index 862bf975ad..7122950771 100644
--- a/app/src/modules/settings/routes/data-model/field-detail/store.ts
+++ b/app/src/modules/settings/routes/data-model/field-detail/store.ts
@@ -81,8 +81,6 @@ function initLocalStore(
matchesRelation = inter.relationship === type;
}
- console.log(inter.id, matchesType, matchesRelation);
-
return matchesType && matchesRelation;
})
.sort((a, b) => (a.name > b.name ? 1 : -1));
@@ -225,7 +223,7 @@ function initLocalStore(
}
if (type === 'o2m') {
- state.fieldData.schema = null;
+ delete state.fieldData.schema;
state.fieldData.type = null;
const syncNewCollectionsO2M = throttle(() => {
@@ -321,7 +319,7 @@ function initLocalStore(
}
if (type === 'm2m' || type === 'files' || type === 'translations') {
- state.fieldData.schema = null;
+ delete state.fieldData.schema;
state.fieldData.type = null;
const syncNewCollectionsM2M = throttle(([junctionCollection, manyCurrent, manyRelated, relatedCollection]) => {
@@ -558,7 +556,7 @@ function initLocalStore(
}
if (type === 'presentation') {
- state.fieldData.schema = null;
+ delete state.fieldData.schema;
state.fieldData.type = null;
state.fieldData.meta.special = ['alias'];