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

Unify props for ResultTableCell

parent 794c606a
No related branches found
No related tags found
No related merge requests found
...@@ -17,7 +17,6 @@ import ResultTableHead from './ResultTableHead' ...@@ -17,7 +17,6 @@ import ResultTableHead from './ResultTableHead'
import TablePagination from '@material-ui/core/TablePagination' import TablePagination from '@material-ui/core/TablePagination'
import ResultTablePaginationActions from './ResultTablePaginationActions' import ResultTablePaginationActions from './ResultTablePaginationActions'
import history from '../../History' import history from '../../History'
import has from 'lodash'
const styles = theme => ({ const styles = theme => ({
tableContainer: { tableContainer: {
...@@ -177,10 +176,18 @@ class ResultTable extends React.Component { ...@@ -177,10 +176,18 @@ class ResultTable extends React.Component {
} }
rowRenderer = row => { rowRenderer = row => {
const { classes } = this.props const { classes, screenSize } = this.props
const expanded = this.state.expandedRows.has(row.id) const expanded = this.state.expandedRows.has(row.id)
let hasExpandableContent = false let hasExpandableContent = false
const dataCells = this.props.data.properties.map(column => { const dataCells = this.props.data.properties.map(column => {
const {
id, valueType, makeLink, externalLink, sortValues, sortBy, numberedList, minWidth,
linkAsButton, collapsedMaxWords, sourceExternalLink, renderAsHTML, HTMLParserTask
} = column
let { previewImageHeight } = column
if (screenSize === 'xs' || screenSize === 'sm') {
previewImageHeight = 50
}
if (column.onlyOnInstancePage) { return null } if (column.onlyOnInstancePage) { return null }
const columnData = row[column.id] == null ? '-' : row[column.id] const columnData = row[column.id] == null ? '-' : row[column.id]
const isArray = Array.isArray(columnData) const isArray = Array.isArray(columnData)
...@@ -202,28 +209,26 @@ class ResultTable extends React.Component { ...@@ -202,28 +209,26 @@ class ResultTable extends React.Component {
} }
return ( return (
<ResultTableCell <ResultTableCell
key={column.id} key={id}
columnId={column.id} columnId={id}
data={columnData} data={columnData}
valueType={column.valueType} valueType={valueType}
makeLink={column.makeLink} makeLink={makeLink}
externalLink={column.externalLink} externalLink={externalLink}
sortValues={column.sortValues} sortValues={sortValues}
sortBy={column.sortBy} sortBy={sortBy}
numberedList={column.numberedList} numberedList={numberedList}
minWidth={column.minWidth} minWidth={minWidth}
previewImageHeight={column.previewImageHeight} previewImageHeight={previewImageHeight}
container='cell' container='cell'
expanded={expanded} expanded={expanded}
linkAsButton={has(column, 'linkAsButton') linkAsButton={linkAsButton}
? column.linkAsButton collapsedMaxWords={collapsedMaxWords}
: null} showSource={false}
collapsedMaxWords={has(column, 'collapsedMaxWords') sourceExternalLink={sourceExternalLink}
? column.collapsedMaxWords renderAsHTML={renderAsHTML}
: null} HTMLParserTask={HTMLParserTask}
renderAsHTML={has(column, 'renderAsHTML') referencedTerm={columnData.referencedTerm}
? column.renderAsHTML
: null}
/> />
) )
}) })
......
...@@ -13,7 +13,9 @@ const ResultTableCell = props => { ...@@ -13,7 +13,9 @@ const ResultTableCell = props => {
sourceExternalLink, renderAsHTML, HTMLParserTask, referencedTerm, previewImageHeight sourceExternalLink, renderAsHTML, HTMLParserTask, referencedTerm, previewImageHeight
} = props } = props
let cellContent = null let cellContent = null
const cellStyle = { minWidth } const cellStyle = {
...(minWidth && { minWidth })
}
switch (valueType) { switch (valueType) {
case 'object': case 'object':
cellContent = cellContent =
......
...@@ -15,7 +15,7 @@ import InfoIcon from '@material-ui/icons/InfoOutlined' ...@@ -15,7 +15,7 @@ import InfoIcon from '@material-ui/icons/InfoOutlined'
const styles = theme => ({ const styles = theme => ({
instanceTable: { instanceTable: {
maxWidth: 800, maxWidth: 1200,
width: '100%', width: '100%',
[theme.breakpoints.down('md')]: { [theme.breakpoints.down('md')]: {
tableLayout: 'fixed', tableLayout: 'fixed',
...@@ -37,9 +37,11 @@ const styles = theme => ({ ...@@ -37,9 +37,11 @@ const styles = theme => ({
alignItems: 'center', alignItems: 'center',
justifyContent: 'center' justifyContent: 'center'
}, },
// labelCell: { labelCell: {
// maxWidth: 250 [theme.breakpoints.down('md')]: {
// }, paddingRight: 0
}
},
tooltip: { tooltip: {
marginTop: -3 marginTop: -3
}, },
...@@ -47,7 +49,10 @@ const styles = theme => ({ ...@@ -47,7 +49,10 @@ const styles = theme => ({
paddingRight: 0, paddingRight: 0,
paddingTop: 0, paddingTop: 0,
paddingBottom: 0, paddingBottom: 0,
width: 32 width: 32,
[theme.breakpoints.down('md')]: {
paddingLeft: 0
}
}, },
expand: { expand: {
transform: 'rotate(0deg)', transform: 'rotate(0deg)',
...@@ -121,7 +126,7 @@ class InstanceHomePageTable extends React.Component { ...@@ -121,7 +126,7 @@ class InstanceHomePageTable extends React.Component {
const label = intl.get(`perspectives.${resultClass}.properties.${row.id}.label`) const label = intl.get(`perspectives.${resultClass}.properties.${row.id}.label`)
const description = intl.get(`perspectives.${resultClass}.properties.${row.id}.description`) const description = intl.get(`perspectives.${resultClass}.properties.${row.id}.description`)
const { const {
id, valueType, makeLink, externalLink, sortValues, sortBy, numberedList, id, valueType, makeLink, externalLink, sortValues, sortBy, numberedList, minWidth,
linkAsButton, collapsedMaxWords, showSource, sourceExternalLink, renderAsHTML, HTMLParserTask linkAsButton, collapsedMaxWords, showSource, sourceExternalLink, renderAsHTML, HTMLParserTask
} = row } = row
let { previewImageHeight } = row let { previewImageHeight } = row
...@@ -157,6 +162,7 @@ class InstanceHomePageTable extends React.Component { ...@@ -157,6 +162,7 @@ class InstanceHomePageTable extends React.Component {
</IconButton>} </IconButton>}
</TableCell> </TableCell>
<ResultTableCell <ResultTableCell
key={id}
columnId={id} columnId={id}
data={data[id]} data={data[id]}
valueType={valueType} valueType={valueType}
...@@ -165,9 +171,10 @@ class InstanceHomePageTable extends React.Component { ...@@ -165,9 +171,10 @@ class InstanceHomePageTable extends React.Component {
sortValues={sortValues} sortValues={sortValues}
sortBy={sortBy} sortBy={sortBy}
numberedList={numberedList} numberedList={numberedList}
minWidth={minWidth}
previewImageHeight={previewImageHeight}
container='cell' container='cell'
expanded={expanded} expanded={expanded}
previewImageHeight={previewImageHeight}
linkAsButton={linkAsButton} linkAsButton={linkAsButton}
collapsedMaxWords={collapsedMaxWords} collapsedMaxWords={collapsedMaxWords}
showSource={showSource} showSource={showSource}
......
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