Skip to content

add coma for contribution list #520

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

Open
wants to merge 1 commit into
base: entitycore-migration
Choose a base branch
from
Open
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
9 changes: 6 additions & 3 deletions src/api/entitycore/transformers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ export function transformFiltersToQuery(
}

export function transformAgentToNames(
agentsWithRoles: Array<IContributor> | undefined | null
): string {
agentsWithRoles: Array<IContributor> | undefined | null,
asArray: boolean = false
): string | Array<string> {
if (!agentsWithRoles) {
return '';
}
Expand All @@ -142,7 +143,9 @@ export function transformAgentToNames(
type: agent.type === 'organization' ? 0 : 1, // 0 for Org, 1 for Person
}));

return map(sortBy(processedAgents, ['type', 'name']), 'name').join('\n');
return asArray
? map(sortBy(processedAgents, ['type', 'name']), 'name')
: map(sortBy(processedAgents, ['type', 'name']), 'name').join(',\n');
}

function resolveAgentName(agent: Agent) {
Expand Down
10 changes: 4 additions & 6 deletions src/entity-configuration/definitions/fields-defs/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,9 @@ export const FieldsDefinition: Partial<FieldsDefinitionRegistry<EntityCoreObject
title: 'Contributors',
filter: CoreFieldFilterTypeEnum.CheckList,
render: (r) =>
renderEmptyOrValue(
transformAgentToNames(
(r as EntityCoreObjectTypes & { contributions?: Array<IContributor> | null })
.contributions
)
transformAgentToNames(
(r as EntityCoreObjectTypes & { contributions?: Array<IContributor> | null }).contributions,
false
),
vocabulary: {
plural: 'Contributors',
Expand All @@ -150,7 +148,7 @@ export const FieldsDefinition: Partial<FieldsDefinitionRegistry<EntityCoreObject
[EntityCoreFields.BrainRegion]: {
title: 'Brain Region',
filter: null,
render: (r) => renderEmptyOrValue(r.brain_region.name),
render: (r) => ('brain_region' in r ? renderEmptyOrValue(r.brain_region.name) : EmptyValue),
vocabulary: {
plural: 'Brain Regions',
singular: 'Brain Region',
Expand Down
6 changes: 5 additions & 1 deletion src/entity-configuration/definitions/renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ export const renderAsString = (value: any) => {
};

export const renderArray = (array: string[]) => {
return array.map((item) => <div key={item}>{item}</div>);
return array.map((item) => (
<div key={item} className="line-clamp-1 text-ellipsis" title={item}>
{item}
</div>
));
};

export const renderDate = (isoDateString: string) => {
Expand Down