From f361ae3531825b82dd4c99160a1f69f77799e370 Mon Sep 17 00:00:00 2001 From: jrcastro2 Date: Thu, 7 Nov 2024 16:08:32 +0100 Subject: [PATCH] records: allow to override affiliations display * closes https://github.com/CERNDocumentServer/cds-rdm/issues/193 --- package-lock.json | 20 ++++++++++++------- package.json | 1 + .../records/AffiliationsSuggestions.js | 20 ++++++++++++++----- src/lib/forms/RemoteSelectField.js | 2 +- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8b88075e..a2828195 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "react-invenio-forms", - "version": "4.2.1", + "version": "4.3.0", "license": "MIT", "devDependencies": { "@babel/cli": "^7.5.0", @@ -60,6 +60,7 @@ "query-string": "^7.0.0", "react": "^16.13.0", "react-dom": "^16.13.0", + "react-overridable": "^0.0.3", "semantic-ui-css": "^2.4.0", "semantic-ui-react": "^2.1.0", "tinymce": "^6.7.2", @@ -15565,7 +15566,6 @@ }, "node_modules/js-tokens": { "version": "4.0.0", - "dev": true, "license": "MIT" }, "node_modules/js-yaml": { @@ -16065,7 +16065,6 @@ }, "node_modules/loose-envify": { "version": "1.4.0", - "dev": true, "license": "MIT", "dependencies": { "js-tokens": "^3.0.0 || ^4.0.0" @@ -16521,7 +16520,6 @@ }, "node_modules/object-assign": { "version": "4.1.1", - "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -18576,7 +18574,6 @@ }, "node_modules/prop-types": { "version": "15.8.1", - "dev": true, "license": "MIT", "dependencies": { "loose-envify": "^1.4.0", @@ -18778,7 +18775,6 @@ }, "node_modules/react": { "version": "16.14.0", - "dev": true, "license": "MIT", "dependencies": { "loose-envify": "^1.1.0", @@ -18953,9 +18949,19 @@ }, "node_modules/react-is": { "version": "16.13.1", - "dev": true, "license": "MIT" }, + "node_modules/react-overridable": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/react-overridable/-/react-overridable-0.0.3.tgz", + "integrity": "sha512-BlDKflgyXDAbSO1xST2gXw5ZYAnVoazhaOodzgQAFbtS6r2+qJGMfz3WQblrLWR57Tu7KYT2mKZ6a1o/zdAzKw==", + "peer": true, + "peerDependencies": { + "@babel/runtime": "^7.9.0", + "prop-types": "^15.7.0", + "react": "^16.13.0" + } + }, "node_modules/react-popper": { "version": "2.3.0", "dev": true, diff --git a/package.json b/package.json index 5a706a7a..e79362d9 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "semantic-ui-css": "^2.4.0", "semantic-ui-react": "^2.1.0", "tinymce": "^6.7.2", + "react-overridable": "^0.0.3", "yup": "^0.32.11" }, "devDependencies": { diff --git a/src/lib/elements/contrib/invenioRDM/records/AffiliationsSuggestions.js b/src/lib/elements/contrib/invenioRDM/records/AffiliationsSuggestions.js index fd2bd484..32dd4afd 100644 --- a/src/lib/elements/contrib/invenioRDM/records/AffiliationsSuggestions.js +++ b/src/lib/elements/contrib/invenioRDM/records/AffiliationsSuggestions.js @@ -9,6 +9,7 @@ import React from "react"; import { Image } from "../../../Image"; import { Header } from "semantic-ui-react"; +import Overridable from "react-overridable"; const makeIdEntry = (identifier) => { let icon, link; @@ -85,14 +86,23 @@ export const AffiliationsSuggestions = (creatibutors, isOrganization) => { text: creatibutor.name, value: creatibutor.name, extra: creatibutor, - key: creatibutor.name, name: creatibutor.name, + key: creatibutor.id, id: creatibutor.id, content: ( -
- {name} {idString.length > 0 && <>({idString})} - {subheader.length > 0 && {subheader}} -
+ +
+ {name} {idString.length > 0 && <>({idString})} + {subheader.length > 0 && {subheader}} +
+
), }; }); diff --git a/src/lib/forms/RemoteSelectField.js b/src/lib/forms/RemoteSelectField.js index 3f9ff926..e8b7d703 100644 --- a/src/lib/forms/RemoteSelectField.js +++ b/src/lib/forms/RemoteSelectField.js @@ -102,7 +102,7 @@ export class RemoteSelectField extends Component { this.setState((prevState) => ({ suggestions: _uniqBy( [...prevState.selectedSuggestions, ...serializedSuggestions], - "value" + "key" ), isFetching: false, error: false,