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

Fix collapsedMaxWords

parent fef05846
No related branches found
No related tags found
No related merge requests found
......@@ -173,22 +173,24 @@ class ResultTable extends React.Component {
const expanded = this.state.expandedRows.has(row.id);
let hasExpandableContent = false;
const dataCells = this.props.data.tableColumns.map(column => {
const columnData = row[column.id];
const columnData = row[column.id] == null ? '-' : row[column.id];
const isArray = Array.isArray(columnData);
if (isArray) {
hasExpandableContent = true;
}
if (!isArray
&& columnData !== '-'
&& column.valueType === 'string'
&& column.collapsedMaxWords
&& columnData.split(' ').length > column.collapsedMaxWords) {
&& columnData.split(' ').length > column.collapsedMaxWords
) {
hasExpandableContent = true;
}
return (
<ResultTableCell
key={column.id}
columnId={column.id}
data={row[column.id] == null ? '-' : row[column.id]}
data={columnData}
valueType={column.valueType}
makeLink={column.makeLink}
externalLink={column.externalLink}
......
......@@ -31,9 +31,9 @@ const StringList = props => {
const createFirstValue = (data, isArray) => {
let firstValue = isArray ? data[0] : data;
if (props.collapsedMaxWords) {
const wordCount = data.split(' ').length;
const wordCount = firstValue.split(' ').length;
if (wordCount > props.collapsedMaxWords) {
firstValue = data.trim().split(' ').splice(0, props.collapsedMaxWords).join(' ');
firstValue = firstValue.trim().split(' ').splice(0, props.collapsedMaxWords).join(' ');
firstValue = `${firstValue}...`;
}
} else if (isArray) {
......
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