mirror of
https://github.com/directus/directus.git
synced 2026-01-29 19:58:08 -05:00
use right collection on O2M
This commit is contained in:
@@ -8,7 +8,14 @@
|
||||
>
|
||||
{{ field.name }}
|
||||
</v-chip>
|
||||
<v-menu showArrow v-model="menuActive" v-show="selectableFields.length > 0" slot="footer" class="add">
|
||||
<v-menu
|
||||
showArrow
|
||||
v-model="menuActive"
|
||||
v-show="selectableFields.length > 0"
|
||||
slot="footer"
|
||||
class="add"
|
||||
placement="bottom-end"
|
||||
>
|
||||
<template #activator="{ toggle }">
|
||||
<v-chip class="field" @click="toggle">
|
||||
<v-icon name="add" />
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
<template>
|
||||
<v-notice type="warning" v-if="fieldData.meta.collection == null">
|
||||
<v-notice type="warning" v-if="collection == null">
|
||||
{{ $t('interfaces.one-to-many.no_collection') }}
|
||||
</v-notice>
|
||||
<div v-else>
|
||||
<p class="type-label">{{ $t('select_fields') }}</p>
|
||||
<v-field-select :collection="fieldData.meta.collection" v-model="fields"></v-field-select>
|
||||
<v-field-select :collection="collection" v-model="fields"></v-field-select>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Field } from '@/types';
|
||||
import { defineComponent, PropType, computed } from '@vue/composition-api';
|
||||
import { useRelationsStore } from '@/stores/';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
@@ -24,6 +25,8 @@ export default defineComponent({
|
||||
},
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
const relationsStore = useRelationsStore();
|
||||
|
||||
const fields = computed({
|
||||
get() {
|
||||
return props.value?.fields;
|
||||
@@ -35,7 +38,17 @@ export default defineComponent({
|
||||
});
|
||||
},
|
||||
});
|
||||
return { fields };
|
||||
|
||||
const collection = computed(() => {
|
||||
if (props.fieldData.field == null || props.fieldData.meta?.collection == null) return null;
|
||||
const relationData = relationsStore.getRelationsForField(
|
||||
props.fieldData.meta.collection,
|
||||
props.fieldData.field
|
||||
)?.[0];
|
||||
return relationData.many_collection;
|
||||
});
|
||||
|
||||
return { fields, collection };
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user