Skip to content
Snippets Groups Projects
Commit ca6b414e authored by esikkala's avatar esikkala
Browse files

Result table: fix shorten label prop

parent 0353f50d
No related branches found
No related tags found
No related merge requests found
...@@ -73,6 +73,7 @@ const ObjectListCollapsible = props => { ...@@ -73,6 +73,7 @@ const ObjectListCollapsible = props => {
<> <>
<ObjectListItem <ObjectListItem
data={itemData} data={itemData}
shortenLabel={shortenLabel}
makeLink={makeLink} makeLink={makeLink}
externalLink={externalLink} externalLink={externalLink}
linkAsButton={linkAsButton} linkAsButton={linkAsButton}
...@@ -84,6 +85,7 @@ const ObjectListCollapsible = props => { ...@@ -84,6 +85,7 @@ const ObjectListCollapsible = props => {
{showSource && itemData.source && {showSource && itemData.source &&
<ObjectListItemSources <ObjectListItemSources
data={itemData.source} data={itemData.source}
shortenLabel={shortenLabel}
externalLink={sourceExternalLink} externalLink={sourceExternalLink}
/>} />}
</> </>
......
...@@ -3,9 +3,9 @@ import PropTypes from 'prop-types' ...@@ -3,9 +3,9 @@ import PropTypes from 'prop-types'
import ObjectListItemLink from './ObjectListItemLink' import ObjectListItemLink from './ObjectListItemLink'
const ObjectListItem = props => { const ObjectListItem = props => {
const { data, makeLink, externalLink, linkAsButton, isFirstValue, collapsedMaxWords } = props const { data, makeLink, externalLink, linkAsButton, isFirstValue, collapsedMaxWords, shortenLabel } = props
let label = Array.isArray(data.prefLabel) ? data.prefLabel[0] : data.prefLabel let label = Array.isArray(data.prefLabel) ? data.prefLabel[0] : data.prefLabel
if ((isFirstValue || data.shortenLabel) && collapsedMaxWords) { if ((isFirstValue || shortenLabel) && collapsedMaxWords) {
const wordCount = label.split(' ').length const wordCount = label.split(' ').length
if (wordCount > collapsedMaxWords) { if (wordCount > collapsedMaxWords) {
label = label.trim().split(' ').splice(0, props.collapsedMaxWords).join(' ') label = label.trim().split(' ').splice(0, props.collapsedMaxWords).join(' ')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment