Filter out any non existent fields (#19352)

* filter out any non existent fields

* hide upsi

* fix layout throwing error

* Format file

* Add changeset

---------

Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>
This commit is contained in:
Nitwel
2023-08-10 14:42:56 +02:00
committed by GitHub
parent 7f2e58ee44
commit cd78801f9a
2 changed files with 18 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
'@directus/app': patch
---
Fixed issue preventing tabular layout from loading when fields are referenced that no longer exist

View File

@@ -11,7 +11,7 @@ import { useCollection, useItems, useSync } from '@directus/composables';
import { Field } from '@directus/types';
import { defineLayout } from '@directus/utils';
import { debounce } from 'lodash';
import { computed, ref, toRefs, watch } from 'vue';
import { computed, ref, toRefs, unref, watch } from 'vue';
import { useRouter } from 'vue-router';
import TabularActions from './actions.vue';
import TabularOptions from './options.vue';
@@ -166,7 +166,18 @@ export default defineLayout<LayoutOptions, LayoutQuery>({
.sort();
});
const fields = syncRefProperty(layoutQuery, 'fields', fieldsDefaultValue);
const fields = computed({
get() {
if (layoutQuery.value?.fields) {
return layoutQuery.value.fields.filter((field) => fieldsStore.getField(collection.value!, field));
} else {
return unref(fieldsDefaultValue);
}
},
set(value) {
layoutQuery.value.fields = value;
},
});
const fieldsWithRelational = computed(() => {
if (!props.collection) return [];