mirror of
https://github.com/directus/directus.git
synced 2026-01-27 02:48:02 -05:00
Also return the junction collection in getRelatedCollection (#9890)
This commit is contained in:
@@ -18,7 +18,11 @@
|
||||
<v-list class="links">
|
||||
<v-list-item v-for="item in value" :key="item[primaryKeyFieldPath]">
|
||||
<v-list-item-content>
|
||||
<render-template :template="internalTemplate" :item="item" :collection="relatedCollection" />
|
||||
<render-template
|
||||
:template="internalTemplate"
|
||||
:item="item"
|
||||
:collection="junctionCollection ?? relatedCollection"
|
||||
/>
|
||||
</v-list-item-content>
|
||||
<v-list-item-icon>
|
||||
<router-link :to="getLinkForItem(item)"><v-icon name="launch" small /></router-link>
|
||||
@@ -69,6 +73,10 @@ export default defineComponent({
|
||||
return relatedCollectionData.value.relatedCollection;
|
||||
});
|
||||
|
||||
const junctionCollection = computed(() => {
|
||||
return relatedCollectionData.value.junctionCollection;
|
||||
});
|
||||
|
||||
const localType = computed(() => {
|
||||
return getLocalTypeForField(props.collection, props.field);
|
||||
});
|
||||
@@ -105,7 +113,15 @@ export default defineComponent({
|
||||
return null;
|
||||
});
|
||||
|
||||
return { relatedCollection, primaryKeyFieldPath, getLinkForItem, internalTemplate, unit, localType };
|
||||
return {
|
||||
relatedCollection,
|
||||
junctionCollection,
|
||||
primaryKeyFieldPath,
|
||||
getLinkForItem,
|
||||
internalTemplate,
|
||||
unit,
|
||||
localType,
|
||||
};
|
||||
|
||||
function getLinkForItem(item: any) {
|
||||
if (!relatedCollectionData.value || !primaryKeyFieldPath.value) return null;
|
||||
|
||||
@@ -4,6 +4,7 @@ import { getLocalTypeForField } from '../../modules/settings/routes/data-model/g
|
||||
|
||||
export interface RelatedCollectionData {
|
||||
relatedCollection: string;
|
||||
junctionCollection?: string;
|
||||
path?: string[];
|
||||
}
|
||||
|
||||
@@ -18,6 +19,7 @@ export default function getRelatedCollection(collection: string, field: string):
|
||||
if (localType == 'm2m' && relations.length > 1) {
|
||||
return {
|
||||
relatedCollection: relations[1].related_collection!,
|
||||
junctionCollection: relations[0].collection,
|
||||
path: [relations[1].field],
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user