Fix Files interface with custom junction field (#22241)

This commit is contained in:
Hannes Küttner
2024-04-19 14:35:44 +02:00
committed by GitHub
parent c5fe153c62
commit f8a57a09ee
2 changed files with 16 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
---
'@directus/app': patch
---
Fixed Files interface when used with custom junction field

View File

@@ -219,8 +219,9 @@ const downloadName = computed(() => {
const junctionField = relationInfo.value.junctionField.field;
const relationPkField = relationInfo.value.relatedPrimaryKeyField.field;
return displayItems.value.find((item) => get(item, [junctionField, relationPkField]))?.directus_files_id
?.filename_download;
return displayItems.value.find((item) => get(item, [junctionField, relationPkField]) === relatedPrimaryKey.value)?.[
junctionField
]?.filename_download;
});
const downloadUrl = computed(() => {
@@ -238,6 +239,13 @@ function getFilename(junctionRow: Record<string, any>) {
return key;
}
function getDownloadName(junctionRow: Record<string, any>) {
const junctionField = relationInfo.value?.junctionField.field;
if (!junctionField) return;
return junctionRow[junctionField]?.filename_download;
}
const customFilter = computed(() => {
if (!relationInfo.value) return;
@@ -335,7 +343,7 @@ const allowDrag = computed(
</v-list-item>
<v-list-item
clickable
:download="element.directus_files_id.filename_download"
:download="getDownloadName(element)"
:href="getAssetUrl(getFilename(element), true)"
>
<v-list-item-icon><v-icon name="download" /></v-list-item-icon>