Bug 43053: Simplify code, only 1 return statement

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2026-07-31 10:45:38 +02:00 committed by Lucas Gass
parent db56e2f581
commit 06eafc0d60
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 11 additions and 21 deletions

View File

@ -621,27 +621,17 @@ export function useBaseResource(resourceConfig) {
const newResource = computed(() => {
resourceConfig.resourceToBeGenerated =
resourceConfig.resourceAttrs.reduce((acc, attr) => {
if (attr.hasOwnProperty("defaultValue")) {
acc[attr.name] = attr.defaultValue;
return acc;
}
if (["text", "textarea", "select"].includes(attr.type)) {
if (attr.allowMultipleChoices) {
acc[attr.name] = [];
return acc;
}
acc[attr.name] = "";
return acc;
}
if (["boolean", "checkbox"].includes(attr.type)) {
acc[attr.name] = false;
return acc;
}
if (attr.type === "relationshipWidget") {
acc[attr.name] = [];
return acc;
}
acc[attr.name] = null;
acc[attr.name] = attr.hasOwnProperty("defaultValue")
? attr.defaultValue
: ["text", "textarea", "select"].includes(attr.type)
? attr.allowMultipleChoices
? []
: ""
: ["boolean", "checkbox"].includes(attr.type)
? false
: attr.type === "relationshipWidget"
? []
: null;
return acc;
}, {});
if (resourceConfig.extendedAttributesResourceType) {