mirror of
https://github.com/directus/directus.git
synced 2026-02-18 18:14:29 -05:00
Exclude relationship fields on field validation (#14818)
* Exclude relationship fields on field validation * Refactor to includeRelations. Also add to conditions
This commit is contained in:
@@ -36,11 +36,13 @@ interface Props {
|
||||
field?: string;
|
||||
disabledFields?: string[];
|
||||
includeFunctions?: boolean;
|
||||
includeRelations?: boolean;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
disabledFields: () => [],
|
||||
includeFunctions: false,
|
||||
includeRelations: true,
|
||||
field: undefined,
|
||||
});
|
||||
|
||||
@@ -48,7 +50,7 @@ defineEmits(['select-field']);
|
||||
|
||||
const fieldsStore = useFieldsStore();
|
||||
|
||||
const { collection } = toRefs(props);
|
||||
const { collection, includeRelations } = toRefs(props);
|
||||
|
||||
const fieldsCount = computed(() => fieldsStore.getFieldsForCollection(collection.value)?.length ?? 0);
|
||||
|
||||
@@ -85,6 +87,7 @@ const treeList = computed(() => {
|
||||
});
|
||||
|
||||
function filter(field: Field): boolean {
|
||||
if (!includeRelations.value && (field.collection !== collection.value || field.type === 'alias')) return false;
|
||||
if (!search.value) return true;
|
||||
const children = fieldsStore.getFieldGroupChildren(collection.value, field.field);
|
||||
return children?.some((field) => matchesSearch(field)) || matchesSearch(field);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
:collection="collection"
|
||||
:field="field"
|
||||
include-functions
|
||||
:include-relations="includeRelations"
|
||||
@select-field="updateField(index, $event)"
|
||||
/>
|
||||
</v-menu>
|
||||
@@ -139,6 +140,7 @@ interface Props {
|
||||
depth?: number;
|
||||
inline?: boolean;
|
||||
includeValidation?: boolean;
|
||||
includeRelations?: boolean;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
@@ -146,6 +148,7 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
depth: 1,
|
||||
inline: false,
|
||||
includeValidation: false,
|
||||
includeRelations: true,
|
||||
});
|
||||
|
||||
const emit = defineEmits(['remove-node', 'update:filter', 'change']);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
:field="fieldName"
|
||||
:depth="1"
|
||||
:include-validation="includeValidation"
|
||||
:include-relations="includeRelations"
|
||||
@remove-node="removeNode($event)"
|
||||
@change="emitValue"
|
||||
/>
|
||||
@@ -42,6 +43,7 @@
|
||||
v-if="collectionRequired"
|
||||
:collection="collection"
|
||||
include-functions
|
||||
:include-relations="includeRelations"
|
||||
@select-field="addNode($event)"
|
||||
>
|
||||
<template #prepend>
|
||||
@@ -96,6 +98,7 @@ interface Props {
|
||||
fieldName?: string;
|
||||
inline?: boolean;
|
||||
includeValidation?: boolean;
|
||||
includeRelations?: boolean;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
@@ -107,6 +110,7 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
fieldName: undefined,
|
||||
inline: false,
|
||||
includeValidation: false,
|
||||
includeRelations: true,
|
||||
});
|
||||
|
||||
const emit = defineEmits(['input']);
|
||||
|
||||
@@ -44,6 +44,7 @@ export default defineComponent({
|
||||
interface: 'system-filter',
|
||||
options: {
|
||||
collectionName: collection.value,
|
||||
includeRelations: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -46,6 +46,7 @@ export default defineComponent({
|
||||
options: {
|
||||
collectionName: permissionSync.value.collection,
|
||||
includeValidation: true,
|
||||
includeRelations: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user