Bug 38201: Remove additional fields from resourceAttrs

Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Matt Blenkinsop 2025-05-22 12:00:16 +01:00 committed by Lucas Gass
parent 6b12997218
commit 35bc45139a
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
8 changed files with 17 additions and 35 deletions

View File

@ -106,7 +106,7 @@ export default {
this.extendedAttributesResourceType || null,
addFiltersToList: this.addFiltersToList || null,
formGroupsDisplayMode: this.formGroupsDisplayMode || null,
appendToShow: this.appendToShow || null,
appendToShow: this.appendToShow || (() => []),
nameAttr: this.nameAttr || null,
idAttr: this.idAttr || null,
};
@ -454,6 +454,14 @@ export default {
},
[]
);
if (this.extendedAttributesResourceType) {
attributesToConsider.push({
name: "additional_fields",
type: "additional_fields",
extended_attributes_resource_type:
this.extendedAttributesResourceType,
});
}
const groupings = attributesToConsider.reduce((acc, attr) => {
if (
attr.hasOwnProperty("group") &&
@ -556,15 +564,8 @@ export default {
acc[attr.name] = false;
return acc;
}
if (
attr.name === "additional_fields" ||
attr.type === "relationshipWidget"
) {
acc[
attr.name === "additional_fields"
? "extended_attributes"
: attr.name
] = [];
if (attr.type === "relationshipWidget") {
acc[attr.name] = [];
return acc;
}
acc[attr.name] = null;
@ -572,6 +573,9 @@ export default {
},
{}
);
if (this.extendedAttributesResourceType) {
this.resourceToBeGenerated.extended_attributes = [];
}
this.resourceToBeGenerated[this.idAttr] = null;
return this.resourceToBeGenerated;
},
@ -581,9 +585,7 @@ export default {
* @return {Boolean} true if the resource has additional fields, false otherwise.
*/
hasAdditionalFields() {
return this.resourceAttrs.some(
attr => attr.name === "additional_fields"
);
return !!this.extendedAttributesResourceType;
},
/**
* Returns the plural form of the resource name.

View File

@ -139,12 +139,6 @@ export default {
label: this.$__("License info"),
hideIn: ["List"],
},
{
name: "additional_fields",
extended_attributes_resource_type:
this.extendedAttributesResourceType,
hideIn: ["List"],
},
{
name: "periods",
type: "relationshipWidget",

View File

@ -120,12 +120,6 @@ export default {
type: "text",
label: this.$__("Notes"),
},
{
name: "additional_fields",
extended_attributes_resource_type:
this.extendedAttributesResourceType,
hideIn: ["List"],
},
{
name: "package_agreements",
type: "relationshipWidget",

View File

@ -127,12 +127,6 @@ export default {
format: this.format_date,
},
},
{
name: "additional_fields",
extended_attributes_resource_type:
this.extendedAttributesResourceType,
hideIn: ["List"],
},
{
name: "user_roles",
type: "relationshipWidget",

View File

@ -162,7 +162,7 @@
:resource="resource"
></FormRelationshipSelect>
</template>
<template v-else-if="attr.name == 'additional_fields'">
<template v-else-if="attr.type == 'additional_fields'">
<AdditionalFieldsEntry
:resource="resource"
:additional_field_values="resource.extended_attributes"

View File

@ -154,7 +154,6 @@ export default {
idAttr: String,
apiClient: Object,
i18n: Object,
resourceAttrs: Array,
listComponent: String,
newResource: Object,
onSubmit: Function,

View File

@ -60,7 +60,6 @@ export default {
idAttr: String,
apiClient: Object,
i18n: Object,
resourceAttrs: Array,
listComponent: String,
resourceNamePlural: String,
getFieldGroupings: Function,

View File

@ -123,7 +123,7 @@
</template>
<template
v-else-if="
attr.name == 'additional_fields' &&
attr.type == 'additional_fields' &&
resource._strings?.additional_field_values.length > 0
"
>