fix sortField selection (#16379)

This commit is contained in:
Nitwel
2022-11-09 16:29:00 +01:00
committed by GitHub
parent 20a06a6c0e
commit 4e70be6da7
4 changed files with 10 additions and 2 deletions

View File

@@ -64,6 +64,7 @@
<v-divider large :inline-title="false">{{ t('sort_field') }}</v-divider>
<related-field-select
v-model="sortField"
:type-allow-list="['integer', 'bigInteger', 'float', 'decimal']"
:disabled-fields="unsortableJunctionFields"
:collection="junctionCollection"
:placeholder="t('add_sort_field')"

View File

@@ -71,6 +71,7 @@
<related-field-select
v-model="sortField"
:collection="junctionCollection"
:type-allow-list="['integer', 'bigInteger', 'float', 'decimal']"
:disabled-fields="unsortableJunctionFields"
:placeholder="t('add_sort_field') + '...'"
:nullable="true"

View File

@@ -24,6 +24,7 @@
<related-field-select
v-model="sortField"
:collection="relatedCollection"
:type-allow-list="['integer', 'bigInteger', 'float', 'decimal']"
:disabled-fields="unsortableJunctionFields"
:placeholder="t('add_sort_field') + '...'"
:nullable="true"
@@ -142,7 +143,7 @@ export default defineComponent({
const currentPrimaryKey = computed(() => fieldsStore.getPrimaryKeyFieldForCollection(collection.value!)?.field);
const unsortableJunctionFields = computed(() => {
let fields = ['item', 'collection'];
let fields = [];
if (relatedCollection.value) {
const relations = relationsStore.getRelationsForCollection(relatedCollection.value);
fields.push(...relations.map((field) => field.field));

View File

@@ -65,6 +65,10 @@ export default defineComponent({
type: Array as PropType<string[]>,
default: () => [],
},
typeAllowList: {
type: Array as PropType<string[]>,
default: () => [],
},
placeholder: {
type: String,
default: () => i18n.global.t('foreign_key') + '...',
@@ -89,7 +93,8 @@ export default defineComponent({
!field.schema ||
!!field.schema?.is_primary_key ||
props.disabledFields.includes(field.field) ||
props.typeDenyList.includes(field.type),
props.typeDenyList.includes(field.type) ||
!props.typeAllowList.includes(field.type),
}));
});