fix: 🐛 Load default display set when no time metadata (#1684)

* fix: 🐛 Load default display set when no time metadata

Load default displayset (first item in the array) when no series date or
series time availalbe

 Closes: #1683

* Add batch update

* Fix tests.

Co-authored-by: James Petts <jamesapetts@gmail.com>
This commit is contained in:
Igor Octaviano 2020-05-14 08:51:57 -03:00 committed by GitHub
parent 79fe442293
commit f7b8b6a41c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 8 deletions

View File

@ -190,7 +190,7 @@ const RTPanel = ({ studies, viewports, activeIndex, isOpen, onContourItemClick }
/>
</div>
{!state.referencedDisplaysets.length && <LoadingIndicator expand height="70px" width="70px" />}
{state.referencedDisplaysets.map(displaySet => {
{state.sets && state.referencedDisplaysets.map(displaySet => {
const { SeriesInstanceUID, metadata, isLoaded } = displaySet;
const module = cornerstoneTools.getModule('rtstruct');
@ -205,9 +205,14 @@ const RTPanel = ({ studies, viewports, activeIndex, isOpen, onContourItemClick }
visible={isLoaded && loadedSet.visible}
hideVisibleButton={!isLoaded}
expanded={isLoaded && loadedSet.SeriesInstanceUID === state.selectedSet.SeriesInstanceUID}
onVisibilityChange={() => {
onVisibilityChange={newVisibility => {
const module = cornerstoneTools.getModule('rtstruct');
module.setters.toggleStructureSet(SeriesInstanceUID);
loadedSet.ROIContours.forEach(({ ROINumber }) => {
module.setters.toggleROIContour(loadedSet.SeriesInstanceUID, ROINumber);
});
const sets = module.getters.structuresSetsWhichReferenceSeriesInstanceUid(viewports[activeIndex].SeriesInstanceUID);
setState(state => ({ ...state, sets }));
refreshViewport();
}}
onExpandChange={async () => {
if (!isLoaded) {

View File

@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import { TableListItem, Icon } from '@ohif/ui';
@ -28,6 +28,11 @@ const StructureSetItem = ({
selected = false,
}) => {
const [isVisible, setIsVisible] = useState(visible);
useEffect(() => {
setIsVisible(visible);
}, [visible])
return (
<div className={`dcmrt-structure-set-item ${selected && 'selected'}`}>
<TableListItem

View File

@ -90,7 +90,7 @@ const loadAndCacheDerivedDisplaySets = (referencedDisplaySet, studies) => {
// find most recent and load it.
let recentDateTime = 0;
let recentDisplaySet;
let recentDisplaySet = displaySets[0];
displaySets.forEach(displaySet => {
const dateTime = Number(

View File

@ -22,7 +22,7 @@ describe('OHIF Study List', function() {
//Wait result list to be displayed
cy.waitStudyList();
cy.get('@searchResult').should($list => {
expect($list.length).to.be.eq(2);
expect($list.length).to.be.eq(3);
expect($list).to.contain('Juno');
});
});
@ -127,7 +127,7 @@ describe('OHIF Study List', function() {
//Wait result list to be displayed
cy.waitStudyList();
cy.get('@searchResult').should($list => {
expect($list.length).to.be.eq(2);
expect($list.length).to.be.eq(3);
expect($list).to.contain('Juno');
});
});
@ -137,7 +137,7 @@ describe('OHIF Study List', function() {
//Wait result list to be displayed
cy.waitStudyList();
cy.get('@searchResult').should($list => {
expect($list.length).to.be.eq(2);
expect($list.length).to.be.eq(6);
expect($list).to.contain('ProstateX-0000');
});
});