mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
ensure update of one_field in m2o (#9708)
This commit is contained in:
@@ -18,6 +18,10 @@ export function applyChanges(updates: StateUpdates, state: State, helperFn: Help
|
||||
preventCircularConstraint(updates, state);
|
||||
setTypeToRelatedPrimaryKey(updates, state);
|
||||
}
|
||||
|
||||
if (hasChanged('fields.corresponding')) {
|
||||
setRelatedOneFieldForCorrespondingField(updates);
|
||||
}
|
||||
}
|
||||
|
||||
export function prepareRelation(updates: StateUpdates, state: State) {
|
||||
@@ -99,3 +103,13 @@ export function setTypeToRelatedPrimaryKey(updates: StateUpdates, state: State)
|
||||
set(updates, 'field.type', state.collections.related.fields[0].type);
|
||||
}
|
||||
}
|
||||
|
||||
export function setRelatedOneFieldForCorrespondingField(updates: StateUpdates) {
|
||||
if (updates?.fields?.corresponding?.field) {
|
||||
set(updates, 'relations.m2o.meta.one_field', updates.fields.corresponding.field);
|
||||
}
|
||||
|
||||
if (!updates.fields?.corresponding) {
|
||||
set(updates, 'relations.m2o.meta.one_field', null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user