fix(URL): allow multi filter query (#3314)

This commit is contained in:
Bill Wallace 2023-04-05 16:37:37 -04:00 committed by GitHub
parent 25b4f8ed97
commit 45a34ae0fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -21,11 +21,11 @@ const getSplitParam = (
lowerCaseKey: string, lowerCaseKey: string,
params = new URLSearchParams(window.location.search) params = new URLSearchParams(window.location.search)
): string[] => { ): string[] => {
return splitComma( const sourceKey = [...params.keys()].find(
[...params] it => it.toLowerCase() === lowerCaseKey
.find(([key, value]) => key.toLowerCase() === lowerCaseKey && value)
?.slice?.(1)
); );
if (!sourceKey) return;
return splitComma(params.getAll(sourceKey));
}; };
export { splitComma, getSplitParam }; export { splitComma, getSplitParam };

View File

@ -1,15 +1,16 @@
import React, { useEffect, useState, useRef } from 'react'; import React, { useEffect, useState, useRef } from 'react';
import { useParams, useLocation } from 'react-router'; import { useParams, useLocation } from 'react-router';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
// TODO: DicomMetadataStore should be injected? // TODO: DicomMetadataStore should be injected?
import { DicomMetadataStore, ServicesManager } from '@ohif/core'; import { DicomMetadataStore, ServicesManager, utils } from '@ohif/core';
import { DragAndDropProvider, ImageViewerProvider } from '@ohif/ui'; import { DragAndDropProvider, ImageViewerProvider } from '@ohif/ui';
import { useQuery, useSearchParams } from '@hooks'; import { useQuery, useSearchParams } from '@hooks';
import ViewportGrid from '@components/ViewportGrid'; import ViewportGrid from '@components/ViewportGrid';
import Compose from './Compose'; import Compose from './Compose';
import getStudies from './studiesList'; import getStudies from './studiesList';
const { getSplitParam } = utils;
/** /**
* Initialize the route. * Initialize the route.
* *
@ -283,13 +284,14 @@ export default function ModeRoute({
if (lowerVal !== 'studyinstanceuids') { if (lowerVal !== 'studyinstanceuids') {
// Not sure why the case matters here - it doesn't in the URL // Not sure why the case matters here - it doesn't in the URL
if (lowerVal === 'seriesinstanceuid') { if (lowerVal === 'seriesinstanceuid') {
const seriesUIDs = getSplitParam(lowerVal, query);
return { return {
...acc, ...acc,
seriesInstanceUID: query.get(val), seriesInstanceUID: seriesUIDs,
}; };
} }
return { ...acc, [val]: query.get(val) }; return { ...acc, [val]: getSplitParam(lowerVal, query) };
} }
}, },
{} {}