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

+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 };