Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Affiliations dropdown fixes #265

Merged
merged 4 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(", ") || ""
slint marked this conversation as resolved.
Show resolved Hide resolved
);
}
};
Expand All @@ -84,9 +90,9 @@ export const AffiliationsSuggestions = (creatibutors, isOrganization) => {

return {
text: creatibutor.name,
value: creatibutor.name,
value: creatibutor.id || creatibutor.name,
slint marked this conversation as resolved.
Show resolved Hide resolved
name: creatibutor.id || creatibutor.name,
extra: creatibutor,
name: creatibutor.name,
key: creatibutor.id,
id: creatibutor.id,
content: (
Expand Down
12 changes: 10 additions & 2 deletions src/lib/forms/RemoteSelectField.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Loading