Skip to content

Commit

Permalink
retain context when switching between views
Browse files Browse the repository at this point in the history
  • Loading branch information
franskloet committed Jan 12, 2023
1 parent 865810e commit ba05e54
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 6 additions & 2 deletions projects/mercury/src/metadata/views/MetadataView.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import MetadataViewContext from "./MetadataViewContext";
import BreadcrumbsContext from "../../common/contexts/BreadcrumbsContext";
import {getLocationContextFromString, getMetadataViewNameFromString} from "../../search/searchUtils";
import type {MetadataViewEntity} from "./metadataViewUtils";
import {getMetadataViewsPath, ofBooleanValueType, ofRangeValueType, RESOURCES_VIEW} from "./metadataViewUtils";
import {getMetadataViewsPath, getMetadataViewsPathContext, ofBooleanValueType, ofRangeValueType, RESOURCES_VIEW} from "./metadataViewUtils";
import MetadataViewActiveFacetFilters from "./MetadataViewActiveFacetFilters";
import MetadataViewInformationDrawer from "./MetadataViewInformationDrawer";
import {useSingleSelection} from "../../file/UseSelection";
Expand Down Expand Up @@ -356,7 +356,11 @@ export const ContextualMetadataView = (props: ContextualMetadataViewProperties)

const handleViewChangeRedirect = (viewName) => {
if (viewName) {
history.push(getMetadataViewsPath(viewName));
if (locationContext) {
history.push(getMetadataViewsPathContext(viewName, locationContext));
} else {
history.push(getMetadataViewsPath(viewName));
}
}
};

Expand Down
8 changes: 8 additions & 0 deletions projects/mercury/src/metadata/views/metadataViewUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,13 @@ export const getMetadataViewsPath = (viewName: string) => {
return path;
};

export const getMetadataViewsPathContext = (viewName: string, conText: string) => {
let path = '/metadata-views';
if (viewName) {
path += `?context=${encodeURIComponent(conText)}&view=${viewName}`;
}
return path;
};

export const ofRangeValueType: boolean = (type: ValueType) => type === 'Number' || type === 'Date';
export const ofBooleanValueType: boolean = (type: ValueType) => type === 'Boolean';

0 comments on commit ba05e54

Please sign in to comment.