From d2ba0a316ee75a7e1d28f14dab876b44cc72fcf7 Mon Sep 17 00:00:00 2001 From: esikkala <esko.ikkala@aalto.fi> Date: Tue, 11 Jun 2019 10:00:38 +0300 Subject: [PATCH] Manuscripts table: handle open-ended timespans --- src/client/components/facet_results/ResultTableCell.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/client/components/facet_results/ResultTableCell.js b/src/client/components/facet_results/ResultTableCell.js index 61271471..011383a2 100644 --- a/src/client/components/facet_results/ResultTableCell.js +++ b/src/client/components/facet_results/ResultTableCell.js @@ -1,6 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { sortBy, orderBy, has } from 'lodash'; +import { orderBy, has } from 'lodash'; import TableCell from '@material-ui/core/TableCell'; import { withStyles } from '@material-ui/core/styles'; import Collapse from '@material-ui/core/Collapse'; @@ -34,9 +34,6 @@ const ResultTableCell = props => { month = parseInt(str.substring(6,7)); day = parseInt(str.substring(9,10)); } - // console.log(year) - // console.log(month) - // console.log(day) return new Date(year, month, day); }; @@ -64,8 +61,8 @@ const ResultTableCell = props => { if (props.columnId == 'productionTimespan') { cell = sortValues ? cell.sort((a,b) => { - a = ISOStringToDate(a.start); - b = ISOStringToDate(b.start); + a = has(a, 'start') ? ISOStringToDate(a.start) : ISOStringToDate(a.end); + b = has(b, 'start') ? ISOStringToDate(b.start) : ISOStringToDate(b.end); // arrange from the most recent to the oldest return a > b ? 1 : a < b ? -1 : 0; }) -- GitLab