feat(URL): add param for initial series and sop uids to display (#3265)

* feat: Allow navigating to a specified series and sop instance

This was a feature in OHIF v2, so adding it to v3, albeit with new
parameters.

feat: Allow comma separated as well as repeated args params

* docs

* Test fixes

* feat: Navigate to SOP selected - PR fixes

* Updated docs

* PR fixes
This commit is contained in:
Bill Wallace authored and GitHub committed 2023-04-05 12:59:56 -04:00
1 parent 226244a26c
commit 50ed96ff73
16 files changed
+284 -47

No files matched your search

+5
View File
@@ -33,6 +33,7 @@ import {
seriesSortCriteria,
} from './sortStudy';
import { subscribeToNextViewportGridChange } from './subscribeToNextViewportGridChange';
import { splitComma, getSplitParam } from './splitComma';
// Commented out unused functionality.
// Need to implement new mechanism for derived displaySets using the displaySetManager.
@@ -71,6 +72,8 @@ const utils = {
roundNumber,
downloadCSVReport,
subscribeToNextViewportGridChange,
splitComma,
getSplitParam,
};
export {
@@ -100,6 +103,8 @@ export {
debounce,
roundNumber,
downloadCSVReport,
splitComma,
getSplitParam,
};
export default utils;
+2
View File
@@ -13,6 +13,8 @@ describe('Top level exports', () => {
'sortStudyInstances',
'sortStudySeries',
'sortingCriteria',
'splitComma',
'getSplitParam',
'isLowPriorityModality',
'writeScript',
'debounce',
+31
View File
@@ -0,0 +1,31 @@
/** Splits a list of stirngs by commas within the strings */
const splitComma = (strings: string[]): string[] => {
if (!strings) return null;
for (let i = 0; i < strings.length; i++) {
const comma = strings[i].indexOf(',');
if (comma !== -1) {
const splits = strings[i].split(/,/);
strings.splice(i, 1, ...splits);
}
}
return strings;
};
/**
* Returns an array of the comma split parameters from the given URL search params
* @param lowerCaseKey - lower case search parameter value
* @param params - URLSearchParams
* @returns Array of comma split items matching, or null
*/
const getSplitParam = (
lowerCaseKey: string,
params = new URLSearchParams(window.location.search)
): string[] => {
return splitComma(
[...params]
.find(([key, value]) => key.toLowerCase() === lowerCaseKey && value)
?.slice?.(1)
);
};
export { splitComma, getSplitParam };