Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • minerva/frontend
1 result
Show changes
Commits on Source (10)
Showing
with 130 additions and 15 deletions
...@@ -10,6 +10,7 @@ import { ...@@ -10,6 +10,7 @@ import {
} from '@/utils/testing/getReduxWrapperWithStore'; } from '@/utils/testing/getReduxWrapperWithStore';
import { act, render, screen, within } from '@testing-library/react'; import { act, render, screen, within } from '@testing-library/react';
import { HISTAMINE_MAP_ID, MAIN_MAP_ID } from '@/constants/mocks'; import { HISTAMINE_MAP_ID, MAIN_MAP_ID } from '@/constants/mocks';
import MapBackgroundsEnum from '@/redux/map/map.enums';
import { MapNavigation } from './MapNavigation.component'; import { MapNavigation } from './MapNavigation.component';
const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => { const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => {
...@@ -35,6 +36,7 @@ describe('MapNavigation - component', () => { ...@@ -35,6 +36,7 @@ describe('MapNavigation - component', () => {
loading: 'succeeded', loading: 'succeeded',
error: { message: '', name: '' }, error: { message: '', name: '' },
openedMaps: openedMapsThreeSubmapsFixture, openedMaps: openedMapsThreeSubmapsFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
}); });
...@@ -55,6 +57,7 @@ describe('MapNavigation - component', () => { ...@@ -55,6 +57,7 @@ describe('MapNavigation - component', () => {
loading: 'succeeded', loading: 'succeeded',
error: { message: '', name: '' }, error: { message: '', name: '' },
openedMaps: openedMapsThreeSubmapsFixture, openedMaps: openedMapsThreeSubmapsFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
}); });
...@@ -81,6 +84,7 @@ describe('MapNavigation - component', () => { ...@@ -81,6 +84,7 @@ describe('MapNavigation - component', () => {
loading: 'succeeded', loading: 'succeeded',
error: { message: '', name: '' }, error: { message: '', name: '' },
openedMaps: openedMapsThreeSubmapsFixture, openedMaps: openedMapsThreeSubmapsFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
}); });
...@@ -111,6 +115,7 @@ describe('MapNavigation - component', () => { ...@@ -111,6 +115,7 @@ describe('MapNavigation - component', () => {
modelId: HISTAMINE_MAP_ID, modelId: HISTAMINE_MAP_ID,
}, },
openedMaps: openedMapsThreeSubmapsFixture, openedMaps: openedMapsThreeSubmapsFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
loading: 'succeeded', loading: 'succeeded',
error: { message: '', name: '' }, error: { message: '', name: '' },
}, },
...@@ -157,6 +162,7 @@ describe('MapNavigation - component', () => { ...@@ -157,6 +162,7 @@ describe('MapNavigation - component', () => {
modelId: HISTAMINE_MAP_ID, modelId: HISTAMINE_MAP_ID,
}, },
openedMaps: openedMapsThreeSubmapsFixture, openedMaps: openedMapsThreeSubmapsFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
loading: 'succeeded', loading: 'succeeded',
error: { message: '', name: '' }, error: { message: '', name: '' },
}, },
...@@ -183,6 +189,7 @@ describe('MapNavigation - component', () => { ...@@ -183,6 +189,7 @@ describe('MapNavigation - component', () => {
modelId: HISTAMINE_MAP_ID, modelId: HISTAMINE_MAP_ID,
}, },
openedMaps: openedMapsThreeSubmapsFixture, openedMaps: openedMapsThreeSubmapsFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
loading: 'succeeded', loading: 'succeeded',
error: { message: '', name: '' }, error: { message: '', name: '' },
}, },
...@@ -207,6 +214,7 @@ describe('MapNavigation - component', () => { ...@@ -207,6 +214,7 @@ describe('MapNavigation - component', () => {
modelId: HISTAMINE_MAP_ID, modelId: HISTAMINE_MAP_ID,
}, },
openedMaps: openedMapsThreeSubmapsFixture, openedMaps: openedMapsThreeSubmapsFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
loading: 'succeeded', loading: 'succeeded',
error: { message: '', name: '' }, error: { message: '', name: '' },
}, },
......
...@@ -17,6 +17,7 @@ import { OverviewImageLink } from '@/types/models'; ...@@ -17,6 +17,7 @@ import { OverviewImageLink } from '@/types/models';
import { getReduxStoreWithActionsListener } from '@/utils/testing/getReduxStoreActionsListener'; import { getReduxStoreWithActionsListener } from '@/utils/testing/getReduxStoreActionsListener';
import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore';
import { renderHook } from '@testing-library/react'; import { renderHook } from '@testing-library/react';
import MapBackgroundsEnum from '@/redux/map/map.enums';
import { import {
FIRST_ARRAY_ELEMENT, FIRST_ARRAY_ELEMENT,
NOOP, NOOP,
...@@ -59,6 +60,7 @@ describe('useOverviewImageLinkActions - hook', () => { ...@@ -59,6 +60,7 @@ describe('useOverviewImageLinkActions - hook', () => {
loading: 'succeeded', loading: 'succeeded',
error: { name: '', message: '' }, error: { name: '', message: '' },
openedMaps: openedMapsThreeSubmapsFixture, openedMaps: openedMapsThreeSubmapsFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
}); });
...@@ -109,6 +111,7 @@ describe('useOverviewImageLinkActions - hook', () => { ...@@ -109,6 +111,7 @@ describe('useOverviewImageLinkActions - hook', () => {
loading: 'succeeded', loading: 'succeeded',
error: { name: '', message: '' }, error: { name: '', message: '' },
openedMaps: openedMapsThreeSubmapsFixture, openedMaps: openedMapsThreeSubmapsFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
}); });
...@@ -166,6 +169,7 @@ describe('useOverviewImageLinkActions - hook', () => { ...@@ -166,6 +169,7 @@ describe('useOverviewImageLinkActions - hook', () => {
loading: 'succeeded', loading: 'succeeded',
error: { name: '', message: '' }, error: { name: '', message: '' },
openedMaps: openedMapsThreeSubmapsFixture, openedMaps: openedMapsThreeSubmapsFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
models: { models: {
data: MODELS_MOCK_SHORT, data: MODELS_MOCK_SHORT,
...@@ -244,6 +248,7 @@ describe('useOverviewImageLinkActions - hook', () => { ...@@ -244,6 +248,7 @@ describe('useOverviewImageLinkActions - hook', () => {
loading: 'succeeded', loading: 'succeeded',
error: { name: '', message: '' }, error: { name: '', message: '' },
openedMaps: openedMapsInitialValueFixture, openedMaps: openedMapsInitialValueFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
models: { models: {
data: MODELS_MOCK_SHORT, data: MODELS_MOCK_SHORT,
...@@ -348,6 +353,7 @@ describe('useOverviewImageLinkActions - hook', () => { ...@@ -348,6 +353,7 @@ describe('useOverviewImageLinkActions - hook', () => {
loading: 'succeeded', loading: 'succeeded',
error: { name: '', message: '' }, error: { name: '', message: '' },
openedMaps: openedMapsInitialValueFixture, openedMaps: openedMapsInitialValueFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
models: { models: {
data: MODELS_MOCK_SHORT, data: MODELS_MOCK_SHORT,
...@@ -405,6 +411,7 @@ describe('useOverviewImageLinkActions - hook', () => { ...@@ -405,6 +411,7 @@ describe('useOverviewImageLinkActions - hook', () => {
loading: 'succeeded', loading: 'succeeded',
error: { name: '', message: '' }, error: { name: '', message: '' },
openedMaps: openedMapsInitialValueFixture, openedMaps: openedMapsInitialValueFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
models: { models: {
data: MODELS_MOCK_SHORT, data: MODELS_MOCK_SHORT,
...@@ -466,6 +473,7 @@ describe('useOverviewImageLinkActions - hook', () => { ...@@ -466,6 +473,7 @@ describe('useOverviewImageLinkActions - hook', () => {
loading: 'succeeded', loading: 'succeeded',
error: { name: '', message: '' }, error: { name: '', message: '' },
openedMaps: openedMapsInitialValueFixture, openedMaps: openedMapsInitialValueFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
models: { models: {
data: MODELS_MOCK_SHORT, data: MODELS_MOCK_SHORT,
...@@ -529,6 +537,7 @@ describe('useOverviewImageLinkActions - hook', () => { ...@@ -529,6 +537,7 @@ describe('useOverviewImageLinkActions - hook', () => {
loading: 'succeeded', loading: 'succeeded',
error: { name: '', message: '' }, error: { name: '', message: '' },
openedMaps: openedMapsInitialValueFixture, openedMaps: openedMapsInitialValueFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
models: { models: {
data: MODELS_MOCK_SHORT, data: MODELS_MOCK_SHORT,
......
...@@ -14,6 +14,7 @@ import { ...@@ -14,6 +14,7 @@ import {
import { render, screen, waitFor } from '@testing-library/react'; import { render, screen, waitFor } from '@testing-library/react';
import { HttpStatusCode } from 'axios'; import { HttpStatusCode } from 'axios';
import { MockStoreEnhanced } from 'redux-mock-store'; import { MockStoreEnhanced } from 'redux-mock-store';
import MapBackgroundsEnum from '@/redux/map/map.enums';
import { ElementLink } from './ElementLink.component'; import { ElementLink } from './ElementLink.component';
const mockedAxiosNewClient = mockNetworkNewAPIResponse(); const mockedAxiosNewClient = mockNetworkNewAPIResponse();
...@@ -208,6 +209,7 @@ describe('ElementLink - component', () => { ...@@ -208,6 +209,7 @@ describe('ElementLink - component', () => {
lastPosition: DEFAULT_POSITION, lastPosition: DEFAULT_POSITION,
}, },
], ],
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
}, },
); );
......
...@@ -18,6 +18,7 @@ import { ...@@ -18,6 +18,7 @@ import {
getReduxWrapperWithStore, getReduxWrapperWithStore,
} from '@/utils/testing/getReduxWrapperWithStore'; } from '@/utils/testing/getReduxWrapperWithStore';
import { act, render, screen } from '@testing-library/react'; import { act, render, screen } from '@testing-library/react';
import MapBackgroundsEnum from '@/redux/map/map.enums';
import { AssociatedSubmap } from './AssociatedSubmap.component'; import { AssociatedSubmap } from './AssociatedSubmap.component';
const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => { const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => {
...@@ -91,6 +92,7 @@ describe('AssociatedSubmap - component', () => { ...@@ -91,6 +92,7 @@ describe('AssociatedSubmap - component', () => {
loading: 'succeeded', loading: 'succeeded',
error: { name: '', message: '' }, error: { name: '', message: '' },
openedMaps: openedMapsInitialValueFixture, openedMaps: openedMapsInitialValueFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
bioEntity: { bioEntity: {
...BIOENTITY_INITIAL_STATE_MOCK, ...BIOENTITY_INITIAL_STATE_MOCK,
...@@ -150,6 +152,7 @@ describe('AssociatedSubmap - component', () => { ...@@ -150,6 +152,7 @@ describe('AssociatedSubmap - component', () => {
loading: 'succeeded', loading: 'succeeded',
error: { name: '', message: '' }, error: { name: '', message: '' },
openedMaps: openedMapsThreeSubmapsFixture, openedMaps: openedMapsThreeSubmapsFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
bioEntity: { bioEntity: {
...BIOENTITY_INITIAL_STATE_MOCK, ...BIOENTITY_INITIAL_STATE_MOCK,
......
...@@ -13,6 +13,7 @@ import { ...@@ -13,6 +13,7 @@ import {
openedMapsInitialValueFixture, openedMapsInitialValueFixture,
openedMapsThreeSubmapsFixture, openedMapsThreeSubmapsFixture,
} from '@/redux/map/map.fixtures'; } from '@/redux/map/map.fixtures';
import MapBackgroundsEnum from '@/redux/map/map.enums';
import { BioEntitiesSubmapItem } from './BioEntitiesSubmapItem.component'; import { BioEntitiesSubmapItem } from './BioEntitiesSubmapItem.component';
const CORE_MAP_ID = 5053; const CORE_MAP_ID = 5053;
...@@ -100,6 +101,7 @@ describe('BioEntitiesSubmapItem - component', () => { ...@@ -100,6 +101,7 @@ describe('BioEntitiesSubmapItem - component', () => {
loading: 'succeeded', loading: 'succeeded',
error: { name: '', message: '' }, error: { name: '', message: '' },
openedMaps: openedMapsInitialValueFixture, openedMaps: openedMapsInitialValueFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
}); });
...@@ -157,6 +159,7 @@ describe('BioEntitiesSubmapItem - component', () => { ...@@ -157,6 +159,7 @@ describe('BioEntitiesSubmapItem - component', () => {
loading: 'succeeded', loading: 'succeeded',
error: { name: '', message: '' }, error: { name: '', message: '' },
openedMaps: openedMapsThreeSubmapsFixture, openedMaps: openedMapsThreeSubmapsFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
}); });
......
...@@ -11,6 +11,7 @@ import { initialMapDataFixture, openedMapsThreeSubmapsFixture } from '@/redux/ma ...@@ -11,6 +11,7 @@ import { initialMapDataFixture, openedMapsThreeSubmapsFixture } from '@/redux/ma
import { MODELS_DATA_MOCK_WITH_MAIN_MAP } from '@/redux/models/models.mock'; import { MODELS_DATA_MOCK_WITH_MAIN_MAP } from '@/redux/models/models.mock';
import { getReduxStoreWithActionsListener } from '@/utils/testing/getReduxStoreActionsListener'; import { getReduxStoreWithActionsListener } from '@/utils/testing/getReduxStoreActionsListener';
import { MockStoreEnhanced } from 'redux-mock-store'; import { MockStoreEnhanced } from 'redux-mock-store';
import MapBackgroundsEnum from '@/redux/map/map.enums';
import { PinTypeWithNone } from '../PinsList.types'; import { PinTypeWithNone } from '../PinsList.types';
import { PinsListItem } from './PinsListItem.component'; import { PinsListItem } from './PinsListItem.component';
...@@ -37,6 +38,7 @@ const INITIAL_STORE_STATE: InitialStoreState = { ...@@ -37,6 +38,7 @@ const INITIAL_STORE_STATE: InitialStoreState = {
loading: 'succeeded', loading: 'succeeded',
error: { message: '', name: '' }, error: { message: '', name: '' },
openedMaps: openedMapsThreeSubmapsFixture, openedMaps: openedMapsThreeSubmapsFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
}; };
...@@ -169,6 +171,7 @@ describe('PinsListItem - component ', () => { ...@@ -169,6 +171,7 @@ describe('PinsListItem - component ', () => {
loading: 'succeeded', loading: 'succeeded',
error: { message: '', name: '' }, error: { message: '', name: '' },
openedMaps: openedMapsThreeSubmapsFixture, openedMaps: openedMapsThreeSubmapsFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
}, },
); );
...@@ -202,6 +205,7 @@ describe('PinsListItem - component ', () => { ...@@ -202,6 +205,7 @@ describe('PinsListItem - component ', () => {
loading: 'succeeded', loading: 'succeeded',
error: { message: '', name: '' }, error: { message: '', name: '' },
openedMaps: openedMapsThreeSubmapsFixture, openedMaps: openedMapsThreeSubmapsFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
}, },
); );
......
...@@ -11,6 +11,7 @@ import { ...@@ -11,6 +11,7 @@ import {
openedMapsInitialValueFixture, openedMapsInitialValueFixture,
openedMapsThreeSubmapsFixture, openedMapsThreeSubmapsFixture,
} from '@/redux/map/map.fixtures'; } from '@/redux/map/map.fixtures';
import MapBackgroundsEnum from '@/redux/map/map.enums';
import { SubmapsDrawer } from './SubmapsDrawer'; import { SubmapsDrawer } from './SubmapsDrawer';
const MAIN_MAP_ID = 5053; const MAIN_MAP_ID = 5053;
...@@ -64,6 +65,7 @@ describe('SubmapsDrawer - component', () => { ...@@ -64,6 +65,7 @@ describe('SubmapsDrawer - component', () => {
loading: 'succeeded', loading: 'succeeded',
error: { name: '', message: '' }, error: { name: '', message: '' },
openedMaps: openedMapsInitialValueFixture, openedMaps: openedMapsInitialValueFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
}); });
...@@ -109,6 +111,7 @@ describe('SubmapsDrawer - component', () => { ...@@ -109,6 +111,7 @@ describe('SubmapsDrawer - component', () => {
openedMaps: openedMapsThreeSubmapsFixture, openedMaps: openedMapsThreeSubmapsFixture,
loading: 'succeeded', loading: 'succeeded',
error: { name: '', message: '' }, error: { name: '', message: '' },
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
}); });
......
...@@ -3,18 +3,23 @@ import { Drawer } from '@/components/Map/Drawer'; ...@@ -3,18 +3,23 @@ import { Drawer } from '@/components/Map/Drawer';
import { Legend } from '@/components/Map/Legend'; import { Legend } from '@/components/Map/Legend';
import { MapViewer } from '@/components/Map/MapViewer'; import { MapViewer } from '@/components/Map/MapViewer';
import { MapLoader } from '@/components/Map/MapLoader/MapLoader.component'; import { MapLoader } from '@/components/Map/MapLoader/MapLoader.component';
import { MapVectorBackgroundSelector } from '@/components/Map/MapVectorBackgroundSelector/MapVectorBackgroundSelector.component';
import { useAppSelector } from '@/redux/hooks/useAppSelector';
import { vectorRenderingSelector } from '@/redux/models/models.selectors';
import { MapAdditionalActions } from './MapAdditionalActions'; import { MapAdditionalActions } from './MapAdditionalActions';
import { MapAdditionalOptions } from './MapAdditionalOptions'; import { MapAdditionalOptions } from './MapAdditionalOptions';
import { PluginsDrawer } from './PluginsDrawer'; import { PluginsDrawer } from './PluginsDrawer';
export const Map = (): JSX.Element => { export const Map = (): JSX.Element => {
const vectorRendering = useAppSelector(vectorRenderingSelector);
return ( return (
<div <div
className="relative z-0 h-screen w-full overflow-hidden bg-black" className="relative z-0 h-screen w-full overflow-hidden bg-black"
data-testid="map-container" data-testid="map-container"
> >
<MapViewer /> <MapViewer />
<MapAdditionalOptions /> {!vectorRendering && <MapAdditionalOptions />}
{vectorRendering && <MapVectorBackgroundSelector />}
<Drawer /> <Drawer />
<PluginsDrawer /> <PluginsDrawer />
<Legend /> <Legend />
......
...@@ -11,6 +11,7 @@ import { ...@@ -11,6 +11,7 @@ import {
import { act, render, screen } from '@testing-library/react'; import { act, render, screen } from '@testing-library/react';
import Map from 'ol/Map'; import Map from 'ol/Map';
import { MockStoreEnhanced } from 'redux-mock-store'; import { MockStoreEnhanced } from 'redux-mock-store';
import MapBackgroundsEnum from '@/redux/map/map.enums';
import { MapAdditionalActions } from './MapAdditionalActions.component'; import { MapAdditionalActions } from './MapAdditionalActions.component';
import { useVisibleBioEntitiesPolygonCoordinates } from './utils/useVisibleBioEntitiesPolygonCoordinates'; import { useVisibleBioEntitiesPolygonCoordinates } from './utils/useVisibleBioEntitiesPolygonCoordinates';
...@@ -145,6 +146,7 @@ describe('MapAdditionalActions - component', () => { ...@@ -145,6 +146,7 @@ describe('MapAdditionalActions - component', () => {
message: '', message: '',
}, },
openedMaps: [], openedMaps: [],
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
}); });
......
...@@ -8,6 +8,7 @@ import { getReduxStoreWithActionsListener } from '@/utils/testing/getReduxStoreA ...@@ -8,6 +8,7 @@ import { getReduxStoreWithActionsListener } from '@/utils/testing/getReduxStoreA
import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore';
import { renderHook } from '@testing-library/react'; import { renderHook } from '@testing-library/react';
import Map from 'ol/Map'; import Map from 'ol/Map';
import MapBackgroundsEnum from '@/redux/map/map.enums';
import { useAddtionalActions } from './useAdditionalActions'; import { useAddtionalActions } from './useAdditionalActions';
import { useVisibleBioEntitiesPolygonCoordinates } from './useVisibleBioEntitiesPolygonCoordinates'; import { useVisibleBioEntitiesPolygonCoordinates } from './useVisibleBioEntitiesPolygonCoordinates';
...@@ -94,6 +95,7 @@ describe('useAddtionalActions - hook', () => { ...@@ -94,6 +95,7 @@ describe('useAddtionalActions - hook', () => {
message: '', message: '',
}, },
openedMaps: [], openedMaps: [],
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
}, },
{ {
......
import { useAppSelector } from '@/redux/hooks/useAppSelector';
import { mapBackgroundTypeSelector } from '@/redux/map/map.selectors';
import { twMerge } from 'tailwind-merge';
import { MAP_BACKGROUND_TYPES } from '@/redux/map/map.constants';
import { setMapBackgroundType } from '@/redux/map/map.slice';
import { useAppDispatch } from '@/redux/hooks/useAppDispatch';
import { Select } from '@/shared/Select';
export const MapVectorBackgroundSelector = (): JSX.Element => {
const dispatch = useAppDispatch();
const backgroundType = useAppSelector(mapBackgroundTypeSelector);
const handleChange = (selectedBackgroundType: number): void => {
dispatch(setMapBackgroundType(selectedBackgroundType));
};
return (
<div className={twMerge('absolute right-6 top-[calc(64px+40px+24px)] z-10 flex')}>
<Select
options={MAP_BACKGROUND_TYPES}
selectedId={backgroundType}
onChange={handleChange}
width={100}
/>
</div>
);
};
...@@ -10,6 +10,8 @@ export type MapConfig = { ...@@ -10,6 +10,8 @@ export type MapConfig = {
export type VerticalAlign = 'TOP' | 'MIDDLE' | 'BOTTOM'; export type VerticalAlign = 'TOP' | 'MIDDLE' | 'BOTTOM';
export type HorizontalAlign = 'LEFT' | 'RIGHT' | 'CENTER' | 'END' | 'START'; export type HorizontalAlign = 'LEFT' | 'RIGHT' | 'CENTER' | 'END' | 'START';
export type ScaleFunction = (resolution: number) => number;
export type OverlayBioEntityGroupedElementsType = { export type OverlayBioEntityGroupedElementsType = {
[id: string]: Array<OverlayBioEntityRender & { amount: number }>; [id: string]: Array<OverlayBioEntityRender & { amount: number }>;
}; };
...@@ -51,7 +51,11 @@ describe('onMapLeftClick', () => { ...@@ -51,7 +51,11 @@ describe('onMapLeftClick', () => {
it('dispatches updateLastClick and resets data if no feature at pixel', async () => { it('dispatches updateLastClick and resets data if no feature at pixel', async () => {
const dispatch = jest.fn(); const dispatch = jest.fn();
jest.spyOn(mapInstance, 'forEachFeatureAtPixel').mockImplementation((_, callback) => { jest.spyOn(mapInstance, 'forEachFeatureAtPixel').mockImplementation((_, callback) => {
callback(new Feature({}), null as unknown as Layer, null as unknown as SimpleGeometry); callback(
new Feature({ zIndex: 1 }),
null as unknown as Layer,
null as unknown as SimpleGeometry,
);
}); });
await onMapLeftClick( await onMapLeftClick(
mapSize, mapSize,
...@@ -74,7 +78,7 @@ describe('onMapLeftClick', () => { ...@@ -74,7 +78,7 @@ describe('onMapLeftClick', () => {
const dispatch = jest.fn(() => ({ const dispatch = jest.fn(() => ({
unwrap: jest.fn().mockResolvedValue(mockBioEntities), unwrap: jest.fn().mockResolvedValue(mockBioEntities),
})); }));
const feature = new Feature({ id: 1, type: FEATURE_TYPE.ALIAS }); const feature = new Feature({ id: 1, type: FEATURE_TYPE.ALIAS, zIndex: 1 });
jest.spyOn(mapInstance, 'forEachFeatureAtPixel').mockImplementation((_, callback) => { jest.spyOn(mapInstance, 'forEachFeatureAtPixel').mockImplementation((_, callback) => {
callback(feature, null as unknown as Layer, null as unknown as SimpleGeometry); callback(feature, null as unknown as Layer, null as unknown as SimpleGeometry);
}); });
...@@ -98,7 +102,7 @@ describe('onMapLeftClick', () => { ...@@ -98,7 +102,7 @@ describe('onMapLeftClick', () => {
const dispatch = jest.fn(() => ({ const dispatch = jest.fn(() => ({
unwrap: jest.fn().mockResolvedValue(mockBioEntities), unwrap: jest.fn().mockResolvedValue(mockBioEntities),
})); }));
const feature = new Feature({ id: 1, type: FEATURE_TYPE.REACTION }); const feature = new Feature({ id: 1, type: FEATURE_TYPE.REACTION, zIndex: 1 });
jest.spyOn(mapInstance, 'forEachFeatureAtPixel').mockImplementation((_, callback) => { jest.spyOn(mapInstance, 'forEachFeatureAtPixel').mockImplementation((_, callback) => {
callback(feature, null as unknown as Layer, null as unknown as SimpleGeometry); callback(feature, null as unknown as Layer, null as unknown as SimpleGeometry);
}); });
......
/* eslint-disable no-magic-numbers */
import { MapSize } from '@/redux/map/map.types'; import { MapSize } from '@/redux/map/map.types';
import { AppDispatch } from '@/redux/store'; import { AppDispatch } from '@/redux/store';
import { Map, MapBrowserEvent } from 'ol'; import { Map, MapBrowserEvent } from 'ol';
...@@ -26,13 +27,12 @@ export const onMapLeftClick = ...@@ -26,13 +27,12 @@ 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'))) { if(feature.get('id') && [...Object.values(FEATURE_TYPE)].includes(feature.get('type')) && feature.get('zIndex') >= 0) {
featureAtPixel = feature; featureAtPixel = feature;
return true; return true;
} }
return false; return false;
}, {hitTolerance: 10}); }, {hitTolerance: 10});
if(!featureAtPixel) { if(!featureAtPixel) {
if (isResultDrawerOpen) { if (isResultDrawerOpen) {
dispatch(closeDrawer()); dispatch(closeDrawer());
...@@ -53,7 +53,7 @@ export const onMapLeftClick = ...@@ -53,7 +53,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(type === FEATURE_TYPE.ALIAS) { if([FEATURE_TYPE.ALIAS, FEATURE_TYPE.GLYPH].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);
......
/* eslint-disable no-magic-numbers */
import { MapSize } from '@/redux/map/map.types'; import { MapSize } from '@/redux/map/map.types';
import { AppDispatch } from '@/redux/store'; import { AppDispatch } from '@/redux/store';
import { Feature, Map, MapBrowserEvent } from 'ol'; import { Feature, Map, MapBrowserEvent } from 'ol';
...@@ -30,7 +31,11 @@ export const onMapRightClick = ...@@ -30,7 +31,11 @@ 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 [FEATURE_TYPE.ALIAS, FEATURE_TYPE.REACTION].includes(feature.get('type')); return [
FEATURE_TYPE.ALIAS,
FEATURE_TYPE.REACTION,
FEATURE_TYPE.GLYPH
].includes(feature.get('type')) && feature.get('zIndex') >= 0;
}); });
} }
} }
...@@ -44,7 +49,7 @@ export const onMapRightClick = ...@@ -44,7 +49,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(type === FEATURE_TYPE.ALIAS) { if([FEATURE_TYPE.ALIAS, FEATURE_TYPE.GLYPH].includes(type)) {
const modelElement = modelElements.find(element => element.id === id); const modelElement = modelElements.find(element => element.id === id);
if(!modelElement) { if(!modelElement) {
return; return;
......
...@@ -5,6 +5,7 @@ import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithSto ...@@ -5,6 +5,7 @@ import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithSto
import { initialMapDataFixture, openedMapsThreeSubmapsFixture } from '@/redux/map/map.fixtures'; import { initialMapDataFixture, openedMapsThreeSubmapsFixture } from '@/redux/map/map.fixtures';
import { useOlMapVectorListeners } from '@/components/Map/MapViewer/MapViewerVector/listeners/useOlMapVectorListeners'; import { useOlMapVectorListeners } from '@/components/Map/MapViewer/MapViewerVector/listeners/useOlMapVectorListeners';
import { onMapLeftClick } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/onMapLeftClick'; import { onMapLeftClick } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/onMapLeftClick';
import MapBackgroundsEnum from '@/redux/map/map.enums';
jest.mock('./mouseClick/mouseLeftClick/onMapLeftClick', () => ({ jest.mock('./mouseClick/mouseLeftClick/onMapLeftClick', () => ({
__esModule: true, __esModule: true,
...@@ -25,6 +26,7 @@ describe('useOlMapVectorListeners - util', () => { ...@@ -25,6 +26,7 @@ describe('useOlMapVectorListeners - util', () => {
loading: 'succeeded', loading: 'succeeded',
error: { message: '', name: '' }, error: { message: '', name: '' },
openedMaps: openedMapsThreeSubmapsFixture, openedMaps: openedMapsThreeSubmapsFixture,
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
}); });
......
...@@ -14,6 +14,8 @@ import { BioShapesDict, LineTypeDict } from '@/redux/shapes/shapes.types'; ...@@ -14,6 +14,8 @@ import { BioShapesDict, LineTypeDict } from '@/redux/shapes/shapes.types';
import { OverlayOrder } from '@/redux/overlayBioEntity/overlayBioEntity.utils'; import { OverlayOrder } from '@/redux/overlayBioEntity/overlayBioEntity.utils';
import { OverlayBioEntityRender } from '@/types/OLrendering'; import { OverlayBioEntityRender } from '@/types/OLrendering';
import { GetOverlayBioEntityColorByAvailableProperties } from '@/components/Map/MapViewer/utils/config/overlaysLayer/useGetOverlayColor'; import { GetOverlayBioEntityColorByAvailableProperties } from '@/components/Map/MapViewer/utils/config/overlaysLayer/useGetOverlayColor';
import VectorSource from 'ol/source/Vector';
import { MapSize } from '@/redux/map/map.types';
export default function processModelElements( export default function processModelElements(
modelElements: ModelElements, modelElements: ModelElements,
...@@ -22,8 +24,11 @@ export default function processModelElements( ...@@ -22,8 +24,11 @@ export default function processModelElements(
groupedElementsOverlays: Record<string, Array<OverlayBioEntityRender>>, groupedElementsOverlays: Record<string, Array<OverlayBioEntityRender>>,
overlaysOrder: Array<OverlayOrder>, overlaysOrder: Array<OverlayOrder>,
getOverlayColor: GetOverlayBioEntityColorByAvailableProperties, getOverlayColor: GetOverlayBioEntityColorByAvailableProperties,
vectorSource: VectorSource,
mapInstance: MapInstance, mapInstance: MapInstance,
pointToProjection: UsePointToProjectionResult, pointToProjection: UsePointToProjectionResult,
mapBackgroundType: number,
mapSize: MapSize,
): Array<MapElement | CompartmentCircle | CompartmentSquare | CompartmentPathway | Glyph> { ): Array<MapElement | CompartmentCircle | CompartmentSquare | CompartmentPathway | Glyph> {
const validElements: Array< const validElements: Array<
MapElement | CompartmentCircle | CompartmentSquare | CompartmentPathway | Glyph MapElement | CompartmentCircle | CompartmentSquare | CompartmentPathway | Glyph
...@@ -31,7 +36,8 @@ export default function processModelElements( ...@@ -31,7 +36,8 @@ export default function processModelElements(
modelElements.content.forEach((element: ModelElement) => { modelElements.content.forEach((element: ModelElement) => {
if (element.glyph) { if (element.glyph) {
const glyph = new Glyph({ const glyph = new Glyph({
id: element.glyph.id, elementId: element.id,
glyphId: element.glyph.id,
x: element.x, x: element.x,
y: element.y, y: element.y,
width: element.width, width: element.width,
...@@ -47,6 +53,8 @@ export default function processModelElements( ...@@ -47,6 +53,8 @@ export default function processModelElements(
if (element.sboTerm === 'SBO:0000290') { if (element.sboTerm === 'SBO:0000290') {
const compartmentProps = { const compartmentProps = {
id: element.id, id: element.id,
complexId: element.complex,
compartmentId: element.compartment,
x: element.x, x: element.x,
y: element.y, y: element.y,
nameX: element.nameX, nameX: element.nameX,
...@@ -66,8 +74,12 @@ export default function processModelElements( ...@@ -66,8 +74,12 @@ export default function processModelElements(
nameHorizontalAlign: element.nameHorizontalAlign as HorizontalAlign, nameHorizontalAlign: element.nameHorizontalAlign as HorizontalAlign,
text: element.name, text: element.name,
fontSize: element.fontSize, fontSize: element.fontSize,
overlaysVisible: Boolean(overlaysOrder.length),
pointToProjection, pointToProjection,
mapInstance, mapInstance,
vectorSource,
mapBackgroundType,
mapSize,
}; };
if (element.shape === 'OVAL_COMPARTMENT') { if (element.shape === 'OVAL_COMPARTMENT') {
validElements.push(new CompartmentCircle(compartmentProps)); validElements.push(new CompartmentCircle(compartmentProps));
...@@ -83,6 +95,8 @@ export default function processModelElements( ...@@ -83,6 +95,8 @@ export default function processModelElements(
validElements.push( validElements.push(
new MapElement({ new MapElement({
id: element.id, id: element.id,
complexId: element.complex,
compartmentId: element.compartment,
sboTerm: element.sboTerm, sboTerm: element.sboTerm,
shapes: elementShapes, shapes: elementShapes,
x: element.x, x: element.x,
...@@ -107,12 +121,15 @@ export default function processModelElements( ...@@ -107,12 +121,15 @@ export default function processModelElements(
fontSize: element.fontSize, fontSize: element.fontSize,
pointToProjection, pointToProjection,
mapInstance, mapInstance,
vectorSource,
modifications: element.modificationResidues, modifications: element.modificationResidues,
lineTypes, lineTypes,
bioShapes: shapes, bioShapes: shapes,
overlays: groupedElementsOverlays[element.id], overlays: groupedElementsOverlays[element.id],
overlaysOrder, overlaysOrder,
getOverlayColor, getOverlayColor,
mapBackgroundType,
mapSize,
}), }),
); );
} }
......
...@@ -38,6 +38,7 @@ import { parseSurfaceMarkersToBioEntityRender } from '@/components/Map/MapViewer ...@@ -38,6 +38,7 @@ import { parseSurfaceMarkersToBioEntityRender } from '@/components/Map/MapViewer
import MarkerOverlay from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/MarkerOverlay'; import MarkerOverlay from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/MarkerOverlay';
import processModelElements from '@/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/processModelElements'; import processModelElements from '@/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/processModelElements';
import useDebouncedValue from '@/utils/useDebouncedValue'; import useDebouncedValue from '@/utils/useDebouncedValue';
import { mapBackgroundTypeSelector, mapDataSizeSelector } from '@/redux/map/map.selectors';
export const useOlMapReactionsLayer = ({ export const useOlMapReactionsLayer = ({
mapInstance, mapInstance,
...@@ -50,17 +51,22 @@ export const useOlMapReactionsLayer = ({ ...@@ -50,17 +51,22 @@ export const useOlMapReactionsLayer = ({
const modelElements = useSelector(modelElementsSelector); const modelElements = useSelector(modelElementsSelector);
const modelReactions = useSelector(newReactionsDataSelector); const modelReactions = useSelector(newReactionsDataSelector);
const shapes = useSelector(bioShapesSelector); const shapes = useSelector(bioShapesSelector);
const mapSize = useSelector(mapDataSizeSelector);
const lineTypes = useSelector(lineTypesSelector); const lineTypes = useSelector(lineTypesSelector);
const arrowTypes = useSelector(arrowTypesSelector); const arrowTypes = useSelector(arrowTypesSelector);
const overlaysOrder = useSelector(getOverlayOrderSelector); const overlaysOrder = useSelector(getOverlayOrderSelector);
const mapBackgroundType = useSelector(mapBackgroundTypeSelector);
const currentMarkers = useAppSelector(markersSufraceOfCurrentMapDataSelector); const currentMarkers = useAppSelector(markersSufraceOfCurrentMapDataSelector);
const markersRender = parseSurfaceMarkersToBioEntityRender(currentMarkers); const markersRender = parseSurfaceMarkersToBioEntityRender(currentMarkers);
const bioEntities = useAppSelector(overlayBioEntitiesForCurrentModelSelector); const bioEntities = useAppSelector(overlayBioEntitiesForCurrentModelSelector);
const debouncedBioEntities = useDebouncedValue(bioEntities, 2000); const debouncedBioEntities = useDebouncedValue(bioEntities, 2000);
const { getOverlayBioEntityColorByAvailableProperties } = useGetOverlayColor(); const { getOverlayBioEntityColorByAvailableProperties } = useGetOverlayColor();
const pointToProjection = usePointToProjection(); const pointToProjection = usePointToProjection();
const vectorSource = useMemo(() => new VectorSource(), []);
useEffect(() => { useEffect(() => {
if (currentModelId) { if (currentModelId) {
dispatch(getModelElements(currentModelId)); dispatch(getModelElements(currentModelId));
...@@ -130,11 +136,12 @@ export const useOlMapReactionsLayer = ({ ...@@ -130,11 +136,12 @@ export const useOlMapReactionsLayer = ({
arrowTypes, arrowTypes,
shapes: reactionShapes, shapes: reactionShapes,
pointToProjection, pointToProjection,
vectorSource,
mapInstance, mapInstance,
}); });
return reactionObject.features; return reactionObject.features;
}); });
}, [arrowTypes, lineTypes, mapInstance, modelReactions, pointToProjection, shapes]); }, [arrowTypes, lineTypes, mapInstance, modelReactions, pointToProjection, shapes, vectorSource]);
const elements: Array< const elements: Array<
MapElement | CompartmentCircle | CompartmentSquare | CompartmentPathway | Glyph MapElement | CompartmentCircle | CompartmentSquare | CompartmentPathway | Glyph
...@@ -149,18 +156,24 @@ export const useOlMapReactionsLayer = ({ ...@@ -149,18 +156,24 @@ export const useOlMapReactionsLayer = ({
groupedElementsOverlays, groupedElementsOverlays,
overlaysOrder, overlaysOrder,
getOverlayBioEntityColorByAvailableProperties, getOverlayBioEntityColorByAvailableProperties,
vectorSource,
mapInstance, mapInstance,
pointToProjection, pointToProjection,
mapBackgroundType,
mapSize,
); );
}, [ }, [
modelElements, modelElements,
shapes, shapes,
pointToProjection,
mapInstance,
lineTypes, lineTypes,
groupedElementsOverlays, groupedElementsOverlays,
overlaysOrder, overlaysOrder,
getOverlayBioEntityColorByAvailableProperties, getOverlayBioEntityColorByAvailableProperties,
vectorSource,
mapInstance,
pointToProjection,
mapBackgroundType,
mapSize,
]); ]);
const features = useMemo(() => { const features = useMemo(() => {
...@@ -174,8 +187,6 @@ export const useOlMapReactionsLayer = ({ ...@@ -174,8 +187,6 @@ export const useOlMapReactionsLayer = ({
]; ];
}, [elements, linesOverlaysFeatures, markerOverlaysFeatures, reactions]); }, [elements, linesOverlaysFeatures, markerOverlaysFeatures, reactions]);
const vectorSource = useMemo(() => new VectorSource(), []);
useEffect(() => { useEffect(() => {
vectorSource.clear(); vectorSource.clear();
vectorSource.addFeatures(features); vectorSource.addFeatures(features);
...@@ -184,6 +195,8 @@ export const useOlMapReactionsLayer = ({ ...@@ -184,6 +195,8 @@ export const useOlMapReactionsLayer = ({
return useMemo(() => { return useMemo(() => {
const vectorLayer = new VectorLayer({ const vectorLayer = new VectorLayer({
source: vectorSource, source: vectorSource,
updateWhileAnimating: true,
updateWhileInteracting: true,
}); });
vectorLayer.set('type', VECTOR_MAP_LAYER_TYPE); vectorLayer.set('type', VECTOR_MAP_LAYER_TYPE);
return vectorLayer; return vectorLayer;
......
...@@ -7,6 +7,7 @@ import VectorLayer from 'ol/layer/Vector'; ...@@ -7,6 +7,7 @@ import VectorLayer from 'ol/layer/Vector';
import React from 'react'; import React from 'react';
import { useOlMap } from '@/components/Map/MapViewer/utils/useOlMap'; import { useOlMap } from '@/components/Map/MapViewer/utils/useOlMap';
import { useOlMapVectorLayers } from '@/components/Map/MapViewer/MapViewerVector/utils/config/useOlMapVectorLayers'; import { useOlMapVectorLayers } from '@/components/Map/MapViewer/MapViewerVector/utils/config/useOlMapVectorLayers';
import MapBackgroundsEnum from '@/redux/map/map.enums';
const useRefValue = { const useRefValue = {
current: null, current: null,
...@@ -59,6 +60,7 @@ describe('useOlMapLayers - util', () => { ...@@ -59,6 +60,7 @@ describe('useOlMapLayers - util', () => {
message: '', message: '',
}, },
openedMaps: OPENED_MAPS_INITIAL_STATE, openedMaps: OPENED_MAPS_INITIAL_STATE,
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
}); });
const dummyElement = document.createElement('div'); const dummyElement = document.createElement('div');
......
...@@ -5,6 +5,7 @@ import { renderHook } from '@testing-library/react'; ...@@ -5,6 +5,7 @@ import { renderHook } from '@testing-library/react';
import BaseLayer from 'ol/layer/Base'; import BaseLayer from 'ol/layer/Base';
import VectorLayer from 'ol/layer/Vector'; import VectorLayer from 'ol/layer/Vector';
import React from 'react'; import React from 'react';
import MapBackgroundsEnum from '@/redux/map/map.enums';
import { useOlMapWhiteCardLayer } from './useOlMapWhiteCardLayer'; import { useOlMapWhiteCardLayer } from './useOlMapWhiteCardLayer';
const useRefValue = { const useRefValue = {
...@@ -58,6 +59,7 @@ describe('useOlMapWhiteCardLayer - util', () => { ...@@ -58,6 +59,7 @@ describe('useOlMapWhiteCardLayer - util', () => {
message: '', message: '',
}, },
openedMaps: OPENED_MAPS_INITIAL_STATE, openedMaps: OPENED_MAPS_INITIAL_STATE,
backgroundType: MapBackgroundsEnum.SEMANTIC,
}, },
}); });
......