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:
Gerard Lamusse
2022-08-03 21:20:13 +02:00
committed by GitHub
parent 2459d7d8ff
commit 9508ed4f7a
5 changed files with 13 additions and 1 deletions

View File

@@ -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);

View File

@@ -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']);

View File

@@ -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']);

View File

@@ -44,6 +44,7 @@ export default defineComponent({
interface: 'system-filter',
options: {
collectionName: collection.value,
includeRelations: false,
},
},
},

View File

@@ -46,6 +46,7 @@ export default defineComponent({
options: {
collectionName: permissionSync.value.collection,
includeValidation: true,
includeRelations: false,
},
},
},