Bug 37893: VueJS Framework: Consider rendering of relationshipSelect attribute on list

The display of a relationshipSelect on the ResourceList defaults to
whats in the showElement part of the attribute definition.
This also means we can now get rid of the 'vendor' attribute type and
have that be a 'relationshipSelect' instead.

Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Pedro Amorim 2025-10-09 12:27:34 +00:00 committed by Lucas Gass
parent d6ba3806fa
commit cd25cca2b5
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 41 additions and 0 deletions

View File

@ -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 (
'<a href="' +
href +
'">' +
relationshipDisplayAttr +
"</a>"
);
}
return accessNestedProperty(
attr.relationshipDisplayAttr,
row
);
},
});
return acc;
}
if (attr.type === "select" && attr.avCat) {
acc.push({
title: attr.label,