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:
parent
db56e2f581
commit
06eafc0d60
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue