mirror of
https://github.com/directus/directus.git
synced 2026-01-30 08:47:57 -05:00
Fix m2o interface display issues (#11567)
* Fix display of newly created entry in nested m2o interface * Fix display of updated existing m2o entry
This commit is contained in:
@@ -211,7 +211,7 @@ export default defineComponent({
|
||||
|
||||
watch(
|
||||
() => props.value,
|
||||
(newValue) => {
|
||||
async (newValue) => {
|
||||
// When the newly configured value is a primitive, assume it's the primary key
|
||||
// of the item and fetch it from the API to render the preview
|
||||
if (
|
||||
@@ -230,12 +230,17 @@ export default defineComponent({
|
||||
|
||||
// If value is already fullfilled, let's fetch all necessary
|
||||
// fields for display template
|
||||
else if (
|
||||
!currentItem.value &&
|
||||
typeof newValue === 'object' &&
|
||||
newValue[relatedPrimaryKeyField.value!.field]
|
||||
) {
|
||||
fetchCurrent(newValue[relatedPrimaryKeyField.value!.field]);
|
||||
else if (!currentItem.value && typeof newValue === 'object') {
|
||||
if (newValue[relatedPrimaryKeyField.value!.field]) {
|
||||
await fetchCurrent(newValue[relatedPrimaryKeyField.value!.field]);
|
||||
if (currentItem.value) {
|
||||
// Override with locally updated values
|
||||
Object.assign(currentItem.value, newValue);
|
||||
}
|
||||
} else {
|
||||
// Display newly created entry in nested m2o
|
||||
currentItem.value = newValue;
|
||||
}
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
|
||||
Reference in New Issue
Block a user