forked from OHIF/Viewers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sort): custom series sort in study panel (OHIF#4214)
- Loading branch information
1 parent
6f93449
commit a433d40
Showing
17 changed files
with
211 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
platform/ui/src/components/StudyBrowserSort/StudyBrowserSort.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import Icon from '../Icon'; | ||
|
||
export default function StudyBrowserSort({ servicesManager }: withAppTypes) { | ||
const { customizationService, displaySetService } = servicesManager.services; | ||
const { values: sortFunctions } = customizationService.get('studyBrowser.sortFunctions'); | ||
|
||
const [selectedSort, setSelectedSort] = useState(sortFunctions[0]); | ||
const [sortDirection, setSortDirection] = useState('ascending'); | ||
|
||
const handleSortChange = event => { | ||
const selectedSortFunction = sortFunctions.find(sort => sort.label === event.target.value); | ||
setSelectedSort(selectedSortFunction); | ||
}; | ||
|
||
const toggleSortDirection = e => { | ||
e.stopPropagation(); | ||
setSortDirection(prevDirection => (prevDirection === 'ascending' ? 'descending' : 'ascending')); | ||
}; | ||
|
||
useEffect(() => { | ||
displaySetService.sortDisplaySets(selectedSort.sortFunction, sortDirection); | ||
}, [displaySetService, selectedSort, sortDirection]); | ||
|
||
useEffect(() => { | ||
const SubscriptionDisplaySetsChanged = displaySetService.subscribe( | ||
displaySetService.EVENTS.DISPLAY_SETS_CHANGED, | ||
() => { | ||
displaySetService.sortDisplaySets(selectedSort.sortFunction, sortDirection, true); | ||
} | ||
); | ||
const SubscriptionDisplaySetMetaDataInvalidated = displaySetService.subscribe( | ||
displaySetService.EVENTS.DISPLAY_SET_SERIES_METADATA_INVALIDATED, | ||
() => { | ||
displaySetService.sortDisplaySets(selectedSort.sortFunction, sortDirection, true); | ||
} | ||
); | ||
|
||
return () => { | ||
SubscriptionDisplaySetsChanged.unsubscribe(); | ||
SubscriptionDisplaySetMetaDataInvalidated.unsubscribe(); | ||
}; | ||
}, [displaySetService, selectedSort, sortDirection]); | ||
|
||
return ( | ||
<div className="flex gap-2"> | ||
<select | ||
onChange={handleSortChange} | ||
value={selectedSort.label} | ||
onClick={e => e.stopPropagation()} | ||
className="border-inputfield-main focus:border-inputfield-main w-full appearance-none rounded border bg-black py-2 px-3 text-sm leading-tight text-white shadow transition duration-300 focus:outline-none" | ||
> | ||
{sortFunctions.map(sort => ( | ||
<option | ||
value={sort.label} | ||
key={sort.label} | ||
> | ||
{sort.label} | ||
</option> | ||
))} | ||
</select> | ||
<button | ||
onClick={toggleSortDirection} | ||
className="border-inputfield-main flex items-center justify-center rounded border bg-black" | ||
> | ||
<Icon | ||
name={sortDirection === 'ascending' ? 'sorting-active-up' : 'sorting-active-down'} | ||
className="text-primary-main mx-2 w-2" | ||
/> | ||
</button> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import StudyBrowserSort from './StudyBrowserSort'; | ||
|
||
export default StudyBrowserSort; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters