fix 5323 unexpected series list filter change from all to recent (#5337)

* fix to unexpected change from All to recent browser study lists because of the search order for the presence of the study in the tab groups and subsequent reset of the active tab state.
Minor comment in the study browser header.

Signed-off-by: Luis M. Santos <luis.santos2@nih.gov>

* chore Added type annotations and cleaned up stylistically.

Signed-off-by: Luis M. Santos <luis.santos2@nih.gov>

* Tighten up a bit of the code to make it easier to follow

* Fix warnings

---------

Signed-off-by: Luis M. Santos <luis.santos2@nih.gov>
Co-authored-by: Bill Wallace <wayfarer3130@gmail.com>

Confirm that Alireza's requested change was included.
This commit is contained in:
Luis Miguel Santos 2025-10-16 21:55:31 -04:00 committed by GitHub
parent be6f3db1ce
commit 42aa2df626
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 38 additions and 22 deletions

View File

@ -7,6 +7,7 @@ import { PanelStudyBrowserHeader } from './PanelStudyBrowserHeader';
import { defaultActionIcons } from './constants'; import { defaultActionIcons } from './constants';
import MoreDropdownMenu from '../../Components/MoreDropdownMenu'; import MoreDropdownMenu from '../../Components/MoreDropdownMenu';
import { CallbackCustomization } from 'platform/core/src/types'; import { CallbackCustomization } from 'platform/core/src/types';
import { type TabsProps } from '@ohif/core/src/utils/createStudyBrowserTabs';
const { sortStudyInstances, formatDate, createStudyBrowserTabs } = utils; const { sortStudyInstances, formatDate, createStudyBrowserTabs } = utils;
@ -27,7 +28,7 @@ function PanelStudyBrowser({
const { servicesManager, commandsManager, extensionManager } = useSystem(); const { servicesManager, commandsManager, extensionManager } = useSystem();
const { displaySetService, customizationService } = servicesManager.services; const { displaySetService, customizationService } = servicesManager.services;
const navigate = useNavigate(); const navigate = useNavigate();
const studyMode = customizationService.getCustomization('studyBrowser.studyMode') || 'all'; const studyMode = (customizationService.getCustomization('studyBrowser.studyMode') as string) || 'all';
const internalImageViewer = useImageViewer(); const internalImageViewer = useImageViewer();
const StudyInstanceUIDs = internalImageViewer.StudyInstanceUIDs; const StudyInstanceUIDs = internalImageViewer.StudyInstanceUIDs;
@ -382,8 +383,8 @@ function PanelStudyBrowser({
} }
const displaySetInstanceUID = jumpToDisplaySet; const displaySetInstanceUID = jumpToDisplaySet;
// Set the activeTabName and expand the study // It is possible to navigate to a study not currently in view
const thumbnailLocation = _findTabAndStudyOfDisplaySet(displaySetInstanceUID, tabs); const thumbnailLocation = _findTabAndStudyOfDisplaySet(displaySetInstanceUID, tabs, activeTabName);
if (!thumbnailLocation) { if (!thumbnailLocation) {
return; return;
} }
@ -532,23 +533,21 @@ function getImageIdForThumbnail(displaySet, imageIds) {
return imageId; return imageId;
} }
function _findTabAndStudyOfDisplaySet(displaySetInstanceUID, tabs) { function _findTabAndStudyOfDisplaySet(
for (let t = 0; t < tabs.length; t++) { displaySetInstanceUID: string,
const { studies } = tabs[t]; tabs: TabsProps,
currentTabName: string
) {
const current = tabs.find(tab => tab.name===currentTabName) || tabs[0];
const biasedTabs = [current, ...tabs];
for (let s = 0; s < studies.length; s++) { for (let t = 0; t < biasedTabs.length; t++) {
const { displaySets } = studies[s]; const study = biasedTabs[t].studies.find(study => study.displaySets.find(ds => ds.displaySetInstanceUID ===displaySetInstanceUID));
if (study) {
for (let d = 0; d < displaySets.length; d++) {
const displaySet = displaySets[d];
if (displaySet.displaySetInstanceUID === displaySetInstanceUID) {
return { return {
tabName: tabs[t].name, tabName: biasedTabs[t].name,
StudyInstanceUID: studies[s].studyInstanceUid, StudyInstanceUID: study.studyInstanceUid,
}; };
} }
} }
}
}
} }

View File

@ -14,6 +14,7 @@ function PanelStudyBrowserHeader({
actionIcons: actionIcon[]; actionIcons: actionIcon[];
updateActionIconValue: (actionIcon: actionIcon) => void; updateActionIconValue: (actionIcon: actionIcon) => void;
}) { }) {
// Button order: Settings button then List view mode (thumbnails vs. list)
return ( return (
<> <>
<div className="bg-muted flex h-[40px] select-none rounded-t p-2"> <div className="bg-muted flex h-[40px] select-none rounded-t p-2">

View File

@ -45,7 +45,8 @@ export type Customization =
| CommandCustomization | CommandCustomization
| CodeCustomization | CodeCustomization
| ComponentCustomization | ComponentCustomization
| CallbackCustomization; | CallbackCustomization
| string | number | boolean;
export default Customization; export default Customization;

View File

@ -1,5 +1,20 @@
import { useSystem } from '../contextProviders/SystemProvider'; import { useSystem } from '../contextProviders/SystemProvider';
/**
* Tab properties that drive which tab group is used for thumbnail display.
*/
export type TabProp = {
name: string,
label: string,
studies: any[],
}
/**
* Collection of tab properties with studies presorted depending on tab mod.
* This is used in deciding what thumbnails to show.
*/
export type TabsProps = TabProp[];
/** /**
* *
* @param {string[]} primaryStudyInstanceUIDs * @param {string[]} primaryStudyInstanceUIDs
@ -11,7 +26,7 @@ import { useSystem } from '../contextProviders/SystemProvider';
* @param {number} studyDisplayList.numInstances * @param {number} studyDisplayList.numInstances
* @param {object[]} displaySets * @param {object[]} displaySets
* @param {number} recentTimeframe - The number of milliseconds to consider a study recent * @param {number} recentTimeframe - The number of milliseconds to consider a study recent
* @returns tabs - The prop object expected by the StudyBrowser component * @returns {TabsProps} tabs - The prop object expected by the StudyBrowser component
*/ */
export function createStudyBrowserTabs( export function createStudyBrowserTabs(
@ -19,7 +34,7 @@ export function createStudyBrowserTabs(
studyDisplayList, studyDisplayList,
displaySets, displaySets,
recentTimeframeMS = 31536000000 recentTimeframeMS = 31536000000
) { ): TabsProps {
const { servicesManager } = useSystem(); const { servicesManager } = useSystem();
const { displaySetService } = servicesManager.services; const { displaySetService } = servicesManager.services;