From 401713e7208392054bc339dfad4b4a8cb38093b7 Mon Sep 17 00:00:00 2001 From: Alex Ioannidis Date: Sat, 23 Nov 2024 18:21:38 +0100 Subject: [PATCH 1/4] RemoteSelectField: fix handling of multiple value selection --- src/lib/forms/RemoteSelectField.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/forms/RemoteSelectField.js b/src/lib/forms/RemoteSelectField.js index e8b7d703..c7d56c36 100644 --- a/src/lib/forms/RemoteSelectField.js +++ b/src/lib/forms/RemoteSelectField.js @@ -44,9 +44,17 @@ export class RemoteSelectField extends Component { this.cancellableAction && this.cancellableAction.cancel(); } - onSelectValue = (event, { options, value }, callbackFunc) => { + onSelectValue = (event, { options, value, ...otherData }, callbackFunc) => { const { multiple } = this.props; - const newSelectedSuggestions = options.filter((item) => value.includes(item.value)); + const newSelectedSuggestions = options.filter((item) => { + if (multiple) { + // "value" is an array so check if it includes the option's value + return value.includes(item.value); + } else { + // "value" is a string so we just compare directly + return item.value === value; + } + }); this.setState( { From 6f9f5fd6d58800b7db696e4e8225ff22030a2670 Mon Sep 17 00:00:00 2001 From: Alex Ioannidis Date: Sat, 23 Nov 2024 18:23:26 +0100 Subject: [PATCH 2/4] affiliations: fix serialization values * Fixes a bug where dropdown values with the same title/name but different unique identifiers would be mixed after selection and only the first one would be actually selected for its value. --- .../contrib/invenioRDM/records/AffiliationsSuggestions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/elements/contrib/invenioRDM/records/AffiliationsSuggestions.js b/src/lib/elements/contrib/invenioRDM/records/AffiliationsSuggestions.js index 81af02d2..41fb0c20 100644 --- a/src/lib/elements/contrib/invenioRDM/records/AffiliationsSuggestions.js +++ b/src/lib/elements/contrib/invenioRDM/records/AffiliationsSuggestions.js @@ -84,9 +84,9 @@ export const AffiliationsSuggestions = (creatibutors, isOrganization) => { return { text: creatibutor.name, - value: creatibutor.name, + value: creatibutor.id || creatibutor.name, + name: creatibutor.id || creatibutor.name, extra: creatibutor, - name: creatibutor.name, key: creatibutor.id, id: creatibutor.id, content: ( From 3263c37efc9e0ff0f3663ead4f96161942837e33 Mon Sep 17 00:00:00 2001 From: Alex Ioannidis Date: Wed, 27 Nov 2024 14:20:59 +0100 Subject: [PATCH 3/4] affiliations: render organization acronym in subheader --- .../invenioRDM/records/AffiliationsSuggestions.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/elements/contrib/invenioRDM/records/AffiliationsSuggestions.js b/src/lib/elements/contrib/invenioRDM/records/AffiliationsSuggestions.js index 41fb0c20..560252fa 100644 --- a/src/lib/elements/contrib/invenioRDM/records/AffiliationsSuggestions.js +++ b/src/lib/elements/contrib/invenioRDM/records/AffiliationsSuggestions.js @@ -60,8 +60,14 @@ export const makeSubheader = (creatibutor, isOrganization) => { }`.trim(); } else { return ( - creatibutor?.affiliations?.map((affiliation) => affiliation.name)?.join(", ") || - "" + creatibutor?.affiliations + ?.map((affiliation) => { + if (affiliation.acronym?.length > 0) { + return `${affiliation.name} (${affiliation.acronym})`; + } + return affiliation.name; + }) + ?.join(", ") || "" ); } }; From 8a2a925387527111ac30fac0a0d4893cd7e4b5f2 Mon Sep 17 00:00:00 2001 From: Alex Ioannidis Date: Wed, 27 Nov 2024 14:21:05 +0100 Subject: [PATCH 4/4] chore: remove unused import --- .../forms/widgets/custom_fields/AddDiscoverableFieldsModal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/forms/widgets/custom_fields/AddDiscoverableFieldsModal.js b/src/lib/forms/widgets/custom_fields/AddDiscoverableFieldsModal.js index ef7bb208..27030157 100644 --- a/src/lib/forms/widgets/custom_fields/AddDiscoverableFieldsModal.js +++ b/src/lib/forms/widgets/custom_fields/AddDiscoverableFieldsModal.js @@ -10,7 +10,7 @@ import { RemoveField } from "./RemoveField"; import { ListAndFilterCustomFields } from "./ListAndFilterCustomFields"; import { importWidget } from "../loader"; -import { Button, Icon, Modal, Divider } from "semantic-ui-react"; +import { Button, Icon, Modal } from "semantic-ui-react"; import PropTypes from "prop-types";