diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ResourceList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ResourceList.vue index 705c26dfd1..636857763d 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ResourceList.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ResourceList.vue @@ -26,6 +26,7 @@ import { ref, inject, onBeforeMount, computed } from "vue"; import { APIClient } from "../fetch/api-client.js"; import KohaTable from "./KohaTable.vue"; import { $__ } from "@koha-vue/i18n"; +import { useBaseElement } from "../composables/base-element.js"; export default { inheritAttrs: false, @@ -42,6 +43,8 @@ export default { select: props.instancedResource.doResourceSelect, }); + const { accessNestedProperty } = useBaseElement(); + const getResourceCount = async () => { await props.instancedResource.apiClient.count().then( count => { @@ -174,6 +177,44 @@ export default { }); return acc; } + if (attr.type === "relationshipSelect") { + acc.push({ + title: attr.label, + data: attr.name, + searchable: true, + orderable: true, + render: function (data, type, row, meta) { + if (attr.showElement) { + const relationshipDisplayAttr = + accessNestedProperty( + attr.showElement.value, + row + ); + let href = "#"; + if ( + attr.showElement.link?.href && + attr.showElement.link.slug + ) { + href = + attr.showElement.link.href + + `/${row[attr.showElement.link.slug]}`; + } + return ( + '' + + relationshipDisplayAttr + + "" + ); + } + return accessNestedProperty( + attr.relationshipDisplayAttr, + row + ); + }, + }); + return acc; + } if (attr.type === "select" && attr.avCat) { acc.push({ title: attr.label,