Adding study list sorting
This commit is contained in:
parent
9e7d14d4c8
commit
04dc3724ff
@ -47,7 +47,8 @@ class StudyListWithData extends Component {
|
|||||||
currentPage: 0,
|
currentPage: 0,
|
||||||
rowsPerPage: StudyListWithData.rowsPerPage,
|
rowsPerPage: StudyListWithData.rowsPerPage,
|
||||||
studyDateFrom: StudyListWithData.defaultStudyDateFrom,
|
studyDateFrom: StudyListWithData.defaultStudyDateFrom,
|
||||||
studyDateTo: StudyListWithData.defaultStudyDateTo
|
studyDateTo: StudyListWithData.defaultStudyDateTo,
|
||||||
|
sortData: StudyListWithData.defaultSort
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
const { server } = this.props;
|
const { server } = this.props;
|
||||||
@ -56,7 +57,7 @@ class StudyListWithData extends Component {
|
|||||||
patientName: searchData.patientName,
|
patientName: searchData.patientName,
|
||||||
accessionNumber: searchData.accessionNumber,
|
accessionNumber: searchData.accessionNumber,
|
||||||
studyDescription: searchData.studyDescription,
|
studyDescription: searchData.studyDescription,
|
||||||
modalitiesInStudy: searchData.modalitiesInStudy,
|
modalitiesInStudy: searchData.modalities,
|
||||||
studyDateFrom: searchData.studyDateFrom,
|
studyDateFrom: searchData.studyDateFrom,
|
||||||
studyDateTo: searchData.studyDateTo,
|
studyDateTo: searchData.studyDateTo,
|
||||||
limit: searchData.rowsPerPage,
|
limit: searchData.rowsPerPage,
|
||||||
@ -73,17 +74,30 @@ class StudyListWithData extends Component {
|
|||||||
studies = [];
|
studies = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Fix casing of this property!
|
const { field, order } = searchData.sortData;
|
||||||
const fixedStudies = studies.map(study => {
|
const sortedStudies = studies.sort(function(a, b) {
|
||||||
const fixedStudy = study;
|
if (order === 'desc') {
|
||||||
fixedStudy.studyInstanceUID = study.studyInstanceUid;
|
if (a[field] < b[field]) {
|
||||||
|
return -1;
|
||||||
return fixedStudy;
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
studies: fixedStudies,
|
studies: sortedStudies,
|
||||||
studyCount: fixedStudies.length
|
studyCount: studies.length
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user