Skip to content
Snippets Groups Projects
Commit cd49594f authored by Piotr Gawron's avatar Piotr Gawron
Browse files

action for clicking on comment pin

parent 3d09c245
No related branches found
No related tags found
2 merge requests!223reset the pin numbers before search results are fetch (so the results will be...,!201Resolve "[MIN-114] Browse comments on the map"
...@@ -26,11 +26,12 @@ export const getCommentFeature = ( ...@@ -26,11 +26,12 @@ export const getCommentFeature = (
{ {
x: comment.coord.x, x: comment.coord.x,
height: 0, height: 0,
id: `comment_${comment.id}`, id: comment.id,
width: 0, width: 0,
y: comment.coord.y, y: comment.coord.y,
}, },
pointToProjection, pointToProjection,
type,
); );
const style = getPinStyle({ const style = getPinStyle({
color, color,
......
...@@ -31,7 +31,7 @@ export const getBioEntitySingleFeature = ( ...@@ -31,7 +31,7 @@ export const getBioEntitySingleFeature = (
? TEXT_COLOR ? TEXT_COLOR
: addAlphaToHexString(TEXT_COLOR, INACTIVE_ELEMENT_OPACITY); : addAlphaToHexString(TEXT_COLOR, INACTIVE_ELEMENT_OPACITY);
const feature = getPinFeature(bioEntity, pointToProjection); const feature = getPinFeature(bioEntity, pointToProjection, type);
const style = getPinStyle({ const style = getPinStyle({
color, color,
value, value,
......
...@@ -13,7 +13,7 @@ export const getMarkerSingleFeature = ( ...@@ -13,7 +13,7 @@ export const getMarkerSingleFeature = (
pointToProjection: UsePointToProjectionResult; pointToProjection: UsePointToProjectionResult;
}, },
): Feature => { ): Feature => {
const feature = getPinFeature(marker, pointToProjection); const feature = getPinFeature(marker, pointToProjection, 'bioEntity');
const style = getPinStyle({ const style = getPinStyle({
color: addAlphaToHexString(marker.color, marker.opacity), color: addAlphaToHexString(marker.color, marker.opacity),
value: marker.number, value: marker.number,
......
...@@ -22,7 +22,7 @@ export const getMultipinSingleFeature = ( ...@@ -22,7 +22,7 @@ export const getMultipinSingleFeature = (
const [mainElement, ...sortedElements] = multipin.sort( const [mainElement, ...sortedElements] = multipin.sort(
(a, b) => (activeIds.includes(b.id) ? ONE : ZERO) - (activeIds.includes(a.id) ? ONE : ZERO), (a, b) => (activeIds.includes(b.id) ? ONE : ZERO) - (activeIds.includes(a.id) ? ONE : ZERO),
); );
const feature = getPinFeature(mainElement, pointToProjection); const feature = getPinFeature(mainElement, pointToProjection, mainElement.type);
const canvasPinsArgMainElement = getMultipinCanvasArgs(mainElement, { const canvasPinsArgMainElement = getMultipinCanvasArgs(mainElement, {
activeIds, activeIds,
......
...@@ -17,7 +17,7 @@ describe('getPinFeature - subUtil', () => { ...@@ -17,7 +17,7 @@ describe('getPinFeature - subUtil', () => {
wrapper: Wrapper, wrapper: Wrapper,
}); });
const pointToProjection = usePointToProjectionHook.current; const pointToProjection = usePointToProjectionHook.current;
const result = getPinFeature(bioEntity, pointToProjection); const result = getPinFeature(bioEntity, pointToProjection, 'bioEntity');
it('should return instance of Feature', () => { it('should return instance of Feature', () => {
expect(result).toBeInstanceOf(Feature); expect(result).toBeInstanceOf(Feature);
...@@ -38,7 +38,7 @@ describe('getPinFeature - subUtil', () => { ...@@ -38,7 +38,7 @@ describe('getPinFeature - subUtil', () => {
}); });
describe('when is Marker Pin', () => { describe('when is Marker Pin', () => {
const pinMarkerResult = getPinFeature(PIN_MARKER, pointToProjection); const pinMarkerResult = getPinFeature(PIN_MARKER, pointToProjection, 'bioEntity');
it('should return point parsed with point to projection', () => { it('should return point parsed with point to projection', () => {
const [x, y] = pinMarkerResult.getGeometry()?.getExtent() || []; const [x, y] = pinMarkerResult.getGeometry()?.getExtent() || [];
......
...@@ -6,6 +6,7 @@ import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; ...@@ -6,6 +6,7 @@ import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection';
import isUUID from 'is-uuid'; import isUUID from 'is-uuid';
import { Feature } from 'ol'; import { Feature } from 'ol';
import { Point } from 'ol/geom'; import { Point } from 'ol/geom';
import { PinType } from '@/types/pin';
export const getPinFeature = ( export const getPinFeature = (
{ {
...@@ -16,6 +17,7 @@ export const getPinFeature = ( ...@@ -16,6 +17,7 @@ export const getPinFeature = (
id, id,
}: Pick<BioEntity, 'id' | 'width' | 'height' | 'x' | 'y'> | MarkerWithPosition, }: Pick<BioEntity, 'id' | 'width' | 'height' | 'x' | 'y'> | MarkerWithPosition,
pointToProjection: UsePointToProjectionResult, pointToProjection: UsePointToProjectionResult,
pinType: PinType,
): Feature => { ): Feature => {
const isMarker = isUUID.anyNonNil(`${id}`); const isMarker = isUUID.anyNonNil(`${id}`);
...@@ -24,10 +26,18 @@ export const getPinFeature = ( ...@@ -24,10 +26,18 @@ export const getPinFeature = (
y: y + (height || ZERO) / HALF, y: y + (height || ZERO) / HALF,
}; };
let type = null;
if (pinType === 'comment') {
type = FEATURE_TYPE.PIN_ICON_COMMENT;
} else {
type = isMarker ? FEATURE_TYPE.PIN_ICON_MARKER : FEATURE_TYPE.PIN_ICON_BIOENTITY;
}
const feature = new Feature({ const feature = new Feature({
geometry: new Point(pointToProjection(point)), geometry: new Point(pointToProjection(point)),
id, id,
type: isMarker ? FEATURE_TYPE.PIN_ICON_MARKER : FEATURE_TYPE.PIN_ICON_BIOENTITY, type,
}); });
return feature; return feature;
......
...@@ -23,6 +23,8 @@ export const handleFeaturesClick = ( ...@@ -23,6 +23,8 @@ export const handleFeaturesClick = (
if (pin.get('type') === FEATURE_TYPE.PIN_ICON_BIOENTITY) { if (pin.get('type') === FEATURE_TYPE.PIN_ICON_BIOENTITY) {
dispatch(openBioEntityDrawerById(pinId)); dispatch(openBioEntityDrawerById(pinId));
} else if (pin.get('type') === FEATURE_TYPE.PIN_ICON_COMMENT) {
alert(`Show comment: ${pinId}`);
} }
}); });
......
...@@ -3,7 +3,12 @@ export const FEATURE_TYPE = { ...@@ -3,7 +3,12 @@ export const FEATURE_TYPE = {
PIN_ICON_MARKER: 'PIN_ICON_MARKER', PIN_ICON_MARKER: 'PIN_ICON_MARKER',
SURFACE_OVERLAY: 'SURFACE_OVERLAY', SURFACE_OVERLAY: 'SURFACE_OVERLAY',
SURFACE_MARKER: 'SURFACE_MARKER', SURFACE_MARKER: 'SURFACE_MARKER',
PIN_ICON_COMMENT: 'PIN_ICON_COMMENT',
} as const; } as const;
export const PIN_ICON_ANY = [FEATURE_TYPE.PIN_ICON_BIOENTITY, FEATURE_TYPE.PIN_ICON_MARKER]; export const PIN_ICON_ANY = [
FEATURE_TYPE.PIN_ICON_BIOENTITY,
FEATURE_TYPE.PIN_ICON_MARKER,
FEATURE_TYPE.PIN_ICON_COMMENT,
];
export const SURFACE_ANY = [FEATURE_TYPE.SURFACE_OVERLAY, FEATURE_TYPE.SURFACE_MARKER]; export const SURFACE_ANY = [FEATURE_TYPE.SURFACE_OVERLAY, FEATURE_TYPE.SURFACE_MARKER];
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