Skip to content
Snippets Groups Projects
Commit bf3b7217 authored by Miłosz Grocholewski's avatar Miłosz Grocholewski
Browse files

Merge branch 'feat/MIN-74-implementic-semantic-view-mouse-click' into 'development'

feat(vector-map): add support for compartment mouse click

Closes MIN-74

See merge request !326
parents a2d6a2fe ce3297cf
No related branches found
No related tags found
1 merge request!326feat(vector-map): add support for compartment mouse click
Pipeline #98662 passed
...@@ -48,7 +48,7 @@ export const BioEntityDrawer = (): React.ReactNode => { ...@@ -48,7 +48,7 @@ export const BioEntityDrawer = (): React.ReactNode => {
).filter(modificationResidue => modificationResidue.state && modificationResidue.state !== ''); ).filter(modificationResidue => modificationResidue.state && modificationResidue.state !== '');
const isModificationAvailable = modificationResidues.length > ZERO; const isModificationAvailable = modificationResidues.length > ZERO;
const type = getTypeBySBOTerm(bioEntityData.sboTerm); const type = getTypeBySBOTerm(bioEntityData.sboTerm, bioEntityData.shape);
return ( return (
<div className="h-calc-drawer" data-testid="bioentity-drawer"> <div className="h-calc-drawer" data-testid="bioentity-drawer">
......
...@@ -27,7 +27,15 @@ export const onMapLeftClick = ...@@ -27,7 +27,15 @@ export const onMapLeftClick =
let featureAtPixel: FeatureLike | undefined; let featureAtPixel: FeatureLike | undefined;
mapInstance.forEachFeatureAtPixel(pixel, (feature, ) => { mapInstance.forEachFeatureAtPixel(pixel, (feature, ) => {
if(feature.get('id') && [...Object.values(FEATURE_TYPE)].includes(feature.get('type')) && feature.get('zIndex') >= 0) { if(
feature.get('id') &&
(
feature.get('type') === FEATURE_TYPE.COMPARTMENT && feature.get('filled') ||
[...Object.values(FEATURE_TYPE)].includes(feature.get('type')) && feature.get('type') !== FEATURE_TYPE.COMPARTMENT
)
&& feature.get('zIndex') >= 0
&& !feature.get('hidden')
) {
featureAtPixel = feature; featureAtPixel = feature;
return true; return true;
} }
...@@ -53,7 +61,7 @@ export const onMapLeftClick = ...@@ -53,7 +61,7 @@ export const onMapLeftClick =
const type = featureAtPixel.get('type'); const type = featureAtPixel.get('type');
const id = featureAtPixel.get('id'); const id = featureAtPixel.get('id');
if([FEATURE_TYPE.ALIAS, FEATURE_TYPE.GLYPH].includes(type)) { if([FEATURE_TYPE.ALIAS, FEATURE_TYPE.GLYPH, FEATURE_TYPE.COMPARTMENT].includes(type)) {
await leftClickHandleAlias(dispatch)(featureAtPixel, modelId); await leftClickHandleAlias(dispatch)(featureAtPixel, modelId);
} else if (type === FEATURE_TYPE.REACTION) { } else if (type === FEATURE_TYPE.REACTION) {
clickHandleReaction(dispatch)(modelElements, reactions, id, modelId); clickHandleReaction(dispatch)(modelElements, reactions, id, modelId);
......
...@@ -31,11 +31,14 @@ export const onMapRightClick = ...@@ -31,11 +31,14 @@ export const onMapRightClick =
const source = layer.getSource(); const source = layer.getSource();
if (source instanceof VectorSource) { if (source instanceof VectorSource) {
foundFeature = source.getClosestFeatureToCoordinate(coordinate, (feature) => { foundFeature = source.getClosestFeatureToCoordinate(coordinate, (feature) => {
return [ return (
FEATURE_TYPE.ALIAS, feature.get('type') === FEATURE_TYPE.COMPARTMENT && feature.get('filled') ||
FEATURE_TYPE.REACTION, [
FEATURE_TYPE.GLYPH FEATURE_TYPE.ALIAS,
].includes(feature.get('type')) && feature.get('zIndex') >= 0; FEATURE_TYPE.REACTION,
FEATURE_TYPE.GLYPH
].includes(feature.get('type'))
) && feature.get('zIndex') >= 0 && !feature.get('hidden');
}); });
} }
} }
...@@ -49,7 +52,7 @@ export const onMapRightClick = ...@@ -49,7 +52,7 @@ export const onMapRightClick =
const type = foundFeature.get('type'); const type = foundFeature.get('type');
const id = foundFeature.get('id'); const id = foundFeature.get('id');
if([FEATURE_TYPE.ALIAS, FEATURE_TYPE.GLYPH].includes(type)) { if([FEATURE_TYPE.ALIAS, FEATURE_TYPE.GLYPH, FEATURE_TYPE.COMPARTMENT].includes(type)) {
const modelElement = modelElements.find(element => element.id === id); const modelElement = modelElements.find(element => element.id === id);
if(!modelElement) { if(!modelElement) {
return; return;
......
...@@ -340,9 +340,14 @@ export default class Reaction { ...@@ -340,9 +340,14 @@ export default class Reaction {
} }
protected getStyle(feature: FeatureLike, resolution: number): Style | Array<Style> | void { protected getStyle(feature: FeatureLike, resolution: number): Style | Array<Style> | void {
if (!(feature instanceof Feature)) {
return undefined;
}
if (this.isAnyOfElementsHidden()) { if (this.isAnyOfElementsHidden()) {
feature.set('hidden', true);
return undefined; return undefined;
} }
feature.set('hidden', false);
const styles: Array<Style> = []; const styles: Array<Style> = [];
const maxZoom = this.mapInstance?.getView().get('originalMaxZoom'); const maxZoom = this.mapInstance?.getView().get('originalMaxZoom');
......
...@@ -190,7 +190,6 @@ describe('handleAliasResults - util', () => { ...@@ -190,7 +190,6 @@ describe('handleAliasResults - util', () => {
.reply(HttpStatusCode.Ok, bioEntityFixture); .reply(HttpStatusCode.Ok, bioEntityFixture);
const { store } = getReduxStoreWithActionsListener(); const { store } = getReduxStoreWithActionsListener();
const { dispatch } = store; const { dispatch } = store;
await handleAliasResults(dispatch, ELEMENT_SEARCH_RESULT_MOCK_ALIAS, { await handleAliasResults(dispatch, ELEMENT_SEARCH_RESULT_MOCK_ALIAS, {
...SEARCH_CONFIG_MOCK, ...SEARCH_CONFIG_MOCK,
isResultDrawerOpen: true, isResultDrawerOpen: true,
......
...@@ -7,6 +7,7 @@ export const FEATURE_TYPE = { ...@@ -7,6 +7,7 @@ export const FEATURE_TYPE = {
ALIAS: 'ALIAS', ALIAS: 'ALIAS',
REACTION: 'REACTION', REACTION: 'REACTION',
GLYPH: 'GLYPH', GLYPH: 'GLYPH',
COMPARTMENT: 'COMPARTMENT',
} as const; } as const;
export const PIN_ICON_ANY = [ export const PIN_ICON_ANY = [
......
...@@ -53,6 +53,7 @@ export const bioEntitySchema = z.object({ ...@@ -53,6 +53,7 @@ export const bioEntitySchema = z.object({
charge: z.number().nullable().optional(), charge: z.number().nullable().optional(),
substanceUnits: z.string().nullable().optional(), substanceUnits: z.string().nullable().optional(),
onlySubstanceUnits: z.boolean().optional().nullable(), onlySubstanceUnits: z.boolean().optional().nullable(),
shape: z.string().nullable().optional(),
modificationResidues: z.optional(z.array(modificationResiduesSchema)), modificationResidues: z.optional(z.array(modificationResiduesSchema)),
complex: z.number().nullable().optional(), complex: z.number().nullable().optional(),
compartment: z.number().nullable().optional(), compartment: z.number().nullable().optional(),
......
export const getTypeBySBOTerm = (sbo: string | undefined): string => { export const getTypeBySBOTerm = (sbo: string | undefined, shape?: string | null): string => {
switch (sbo) { switch (sbo) {
case 'SBO:0000334': case 'SBO:0000334':
return 'Antisense RNA'; return 'Antisense RNA';
...@@ -29,6 +29,16 @@ export const getTypeBySBOTerm = (sbo: string | undefined): string => { ...@@ -29,6 +29,16 @@ export const getTypeBySBOTerm = (sbo: string | undefined): string => {
return 'Simple molecule'; return 'Simple molecule';
case 'SBO:0000285': case 'SBO:0000285':
return 'Unknown'; return 'Unknown';
case 'SBO:0000290':
switch (shape) {
case 'PATHWAY':
return 'Pathway';
case 'SQUARE_COMPARTMENT':
case 'CIRCLE_COMPARTMENT':
return 'Compartment';
default:
return '---';
}
default: default:
return '---'; return '---';
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment