diff --git a/src/client/components/facet_bar/DateSliderFacet.js b/src/client/components/facet_bar/DateSliderFacet.js index 7f62d11ae85cdd3de88c7c591fb445ecc97ef2d5..fcec52bf5282a1da23ade1dd123f7daeeae4ab40 100644 --- a/src/client/components/facet_bar/DateSliderFacet.js +++ b/src/client/components/facet_bar/DateSliderFacet.js @@ -38,7 +38,8 @@ class DateSliderFacet extends Component { } handleSliderOnChange = values => { - // console.log(this.YearToISOString(values[0])) + values[0] = this.YearToISOString({ year: values[0], start: true }); + values[1] = this.YearToISOString({ year: values[1], start: false }); this.props.updateFacetOption({ facetClass: this.props.facetClass, facetID: this.props.facetID, @@ -57,10 +58,27 @@ class DateSliderFacet extends Component { return year; } - // YearToISOString = year => { - // let str = null; - // console.log(year) - // } + YearToISOString = ({ year, start }) => { + const abs = Math.abs(year); + let s = year.toString(); + let negative = false; + if (s.charAt(0) == '-') { + s = s.substring(1); + negative = true; + } + if (abs < 10) { + s = '000' + s; + } + if (abs >= 10 && abs < 100) { + s = '00' + s; + } + if (abs >= 100 && abs < 1000) { + s = '0' + s; + s = negative ? s = '-' + s : s; + } + s = start ? s + '-01-01' : s + '-12-31'; + return s; + } render() { const { classes, someFacetIsFetching } = this.props; diff --git a/src/client/components/facet_results/ResultTableCell.js b/src/client/components/facet_results/ResultTableCell.js index d0023ababebbcc767035f1100b32685341242ba1..86b6126bbc2c4dd8d90fb3b88f98574a75a55bc3 100644 --- a/src/client/components/facet_results/ResultTableCell.js +++ b/src/client/components/facet_results/ResultTableCell.js @@ -88,10 +88,10 @@ const ResultTableCell = props => { target='_blank' rel='noopener noreferrer' href={item.dataProviderUrl} > - {item.prefLabel} + {Array.isArray(item.prefLabel) ? item.prefLabel[0] : item.prefLabel} </a> } - {!makeLink && item.prefLabel} + {!makeLink && Array.isArray(item.prefLabel) ? item.prefLabel[0] : item.prefLabel} </li> ); if (numberedList) { @@ -104,13 +104,13 @@ const ResultTableCell = props => { return ( <React.Fragment> {!props.expanded && !makeLink && - <span>{firstValue.prefLabel} ...</span>} + <span>{Array.isArray(firstValue.prefLabel) ? firstValue.prefLabel[0] : firstValue.prefLabel} ...</span>} {!props.expanded && makeLink && <a target='_blank' rel='noopener noreferrer' href={firstValue.dataProviderUrl} > - {firstValue.prefLabel} ... + {Array.isArray(firstValue.prefLabel) ? firstValue.prefLabel[0] : firstValue.prefLabel} ... </a> } <Collapse in={props.expanded} timeout="auto" unmountOnExit> @@ -132,7 +132,7 @@ const ResultTableCell = props => { ); } else { return ( - <span>{cell.prefLabel}</span> + <span>{Array.isArray(cell.prefLabel) ? cell.prefLabel[0] : cell.prefLabel}</span> ); } }; diff --git a/src/client/reducers/manuscriptsFacets.js b/src/client/reducers/manuscriptsFacets.js index 51d0aefcd6dd8c73d74ce82474489c6c3936d7be..9fd7d2d69622f5b0ca5f760b86b26be73f4d5822 100644 --- a/src/client/reducers/manuscriptsFacets.js +++ b/src/client/reducers/manuscriptsFacets.js @@ -52,26 +52,26 @@ export const INITIAL_STATE = { spatialFilter: null, type: 'hierarchical', }, - // productionTimespan: { - // id: 'productionTimespan', - // label: 'Production date', - // //predicate: defined in backend - // distinctValueCount: 0, - // values: [], - // flatValues: [], - // sortBy: null, - // sortDirection: null, - // sortButton: false, - // spatialFilterButton: false, - // isFetching: false, - // searchField: false, - // containerClass: 'three', - // filterType: 'timespanFilter', - // min: null, - // max: null, - // timespanFilter: null, - // type: 'timespan' - // }, + productionTimespan: { + id: 'productionTimespan', + label: 'Production date', + //predicate: defined in backend + distinctValueCount: 0, + values: [], + flatValues: [], + sortBy: null, + sortDirection: null, + sortButton: false, + spatialFilterButton: false, + isFetching: false, + searchField: false, + containerClass: 'three', + filterType: 'timespanFilter', + min: null, + max: null, + timespanFilter: null, + type: 'timespan' + }, author: { id: 'author', label: 'Author',