From 06eafc0d60616b0bfe5f5f49c41839f56eaefe26 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 31 Jul 2026 10:45:38 +0200 Subject: [PATCH] Bug 43053: Simplify code, only 1 return statement Signed-off-by: Jonathan Druart Signed-off-by: Lucas Gass --- .../prog/js/vue/composables/base-resource.js | 32 +++++++------------ 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/composables/base-resource.js b/koha-tmpl/intranet-tmpl/prog/js/vue/composables/base-resource.js index aba8e036a4..01acaad28a 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/composables/base-resource.js +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/composables/base-resource.js @@ -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) {