From 94ab9ff791bb7d2ad2745df8ff2c994317788751 Mon Sep 17 00:00:00 2001 From: maltempi Date: Fri, 15 Feb 2019 23:36:33 -0200 Subject: [PATCH] Formating studyDate field --- Packages-react/ohif-viewer/src/sha.js | 2 +- .../src/studylist/StudyListWithData.js | 44 +++++++++++-------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/Packages-react/ohif-viewer/src/sha.js b/Packages-react/ohif-viewer/src/sha.js index bf332a624..0e6f6a765 100644 --- a/Packages-react/ohif-viewer/src/sha.js +++ b/Packages-react/ohif-viewer/src/sha.js @@ -1 +1 @@ -export default '993b50e3bce2cc6f007212aea6d0ace66543226b'; +export default '04dc3724ff959226b3178438e9bf6096fc923ef3'; diff --git a/Packages-react/ohif-viewer/src/studylist/StudyListWithData.js b/Packages-react/ohif-viewer/src/studylist/StudyListWithData.js index 79e5ba546..acf583da5 100644 --- a/Packages-react/ohif-viewer/src/studylist/StudyListWithData.js +++ b/Packages-react/ohif-viewer/src/studylist/StudyListWithData.js @@ -4,6 +4,7 @@ import OHIF from 'ohif-core'; import { withRouter } from 'react-router-dom'; import { StudyList } from 'react-viewerbase'; import ConnectedHeader from '../connectedComponents/ConnectedHeader.js'; +import moment from 'moment'; const subtractDaysFromDate = (date, days) => { date.setDate(date.getDate() - days); @@ -75,25 +76,32 @@ class StudyListWithData extends Component { } const { field, order } = searchData.sortData; - const sortedStudies = studies.sort(function(a, b) { - if (order === 'desc') { - if (a[field] < b[field]) { - return -1; + const sortedStudies = studies + .sort(function(a, b) { + if (order === 'desc') { + if (a[field] < b[field]) { + return -1; + } + if (a[field] > b[field]) { + return 1; + } + return 0; + } else { + if (a[field] > b[field]) { + return -1; + } + if (a[field] < b[field]) { + return 1; + } + return 0; } - if (a[field] > b[field]) { - return 1; - } - return 0; - } else { - if (a[field] > b[field]) { - return -1; - } - if (a[field] < b[field]) { - return 1; - } - return 0; - } - }); + }) + .map(study => { + study.studyDate = moment(study.studyDate, 'YYYYMMDD').format( + 'MMM DD, YYYY' + ); + return study; + }); this.setState({ studies: sortedStudies,