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

search link is working properly

parent c1189325
No related branches found
No related tags found
2 merge requests!329Merge 18.0.5,!315Resolve "problem with overview image links cause map no to load"
Pipeline #98268 passed
minerva-front (18.0.3) stable; urgency=medium minerva-front (18.0.4) stable; urgency=medium
* Bug fix: mwhen compartment is missing "default" is added (#314) * Bug fix: link to search result from overview image caused map not to
load (#318)
* Bug fix: when compartment is missing "default" is added (#314)
-- Piotr Gawron <piotr.gawron@uni.lu> Thu, 11 Nov 2024 15:00:00 +0200 -- Piotr Gawron <piotr.gawron@uni.lu> Mon, 11 Nov 2024 15:00:00 +0200
minerva-front (18.0.3) stable; urgency=medium minerva-front (18.0.3) stable; urgency=medium
* Bug fix: Molart froze after clicking (#313) * Bug fix: Molart froze after clicking (#313)
......
import { OverviewImageLinkImage, OverviewImageLinkModel } from '@/types/models'; import {
OverviewImageLinkImage,
OverviewImageLinkModel,
OverviewImageLinkSearch,
} from '@/types/models';
export interface OverviewImageSize { export interface OverviewImageSize {
width: number; width: number;
...@@ -26,3 +30,5 @@ export interface OverviewImageLinkConfig { ...@@ -26,3 +30,5 @@ export interface OverviewImageLinkConfig {
export type OverviewImageLinkImageHandler = (link: OverviewImageLinkImage) => void; export type OverviewImageLinkImageHandler = (link: OverviewImageLinkImage) => void;
export type OverviewImageLinkModelHandler = (link: OverviewImageLinkModel) => void; export type OverviewImageLinkModelHandler = (link: OverviewImageLinkModel) => void;
export type OverviewImageLinkSearchHandler = (link: OverviewImageLinkSearch) => void;
import { NOOP } from '@/constants/common'; import { NOOP, ZERO } from '@/constants/common';
import { useAppDispatch } from '@/redux/hooks/useAppDispatch'; import { useAppDispatch } from '@/redux/hooks/useAppDispatch';
import { useAppSelector } from '@/redux/hooks/useAppSelector'; import { useAppSelector } from '@/redux/hooks/useAppSelector';
import { mapOpenedMapsSelector } from '@/redux/map/map.selectors'; import { mapOpenedMapsSelector } from '@/redux/map/map.selectors';
...@@ -8,9 +8,12 @@ import { currentModelIdSelector, modelsDataSelector } from '@/redux/models/model ...@@ -8,9 +8,12 @@ import { currentModelIdSelector, modelsDataSelector } from '@/redux/models/model
import { projectOverviewImagesSelector } from '@/redux/project/project.selectors'; import { projectOverviewImagesSelector } from '@/redux/project/project.selectors';
import { PluginsEventBus } from '@/services/pluginsManager/pluginsEventBus'; import { PluginsEventBus } from '@/services/pluginsManager/pluginsEventBus';
import { MapModel, OverviewImageLink, OverviewImageLinkModel } from '@/types/models'; import { MapModel, OverviewImageLink, OverviewImageLinkModel } from '@/types/models';
import { getSearchData } from '@/redux/search/search.thunks';
import { openSearchDrawerWithSelectedTab } from '@/redux/drawer/drawer.slice';
import { import {
OverviewImageLinkImageHandler, OverviewImageLinkImageHandler,
OverviewImageLinkModelHandler, OverviewImageLinkModelHandler,
OverviewImageLinkSearchHandler,
} from '../OverviewImageModal.types'; } from '../OverviewImageModal.types';
interface UseOverviewImageLinkActionsResult { interface UseOverviewImageLinkActionsResult {
...@@ -75,6 +78,16 @@ export const useOverviewImageLinkActions = (): UseOverviewImageLinkActionsResult ...@@ -75,6 +78,16 @@ export const useOverviewImageLinkActions = (): UseOverviewImageLinkActionsResult
dispatch(closeModal()); dispatch(closeModal());
}; };
const onSearchClick: OverviewImageLinkSearchHandler = link => {
const { query } = link;
const searchValues = query.split(',');
dispatch(getSearchData({ searchQueries: searchValues, isPerfectMatch: false }));
dispatch(openSearchDrawerWithSelectedTab(searchValues[ZERO]));
dispatch(closeModal());
};
const onImageClick: OverviewImageLinkImageHandler = link => { const onImageClick: OverviewImageLinkImageHandler = link => {
const isImageAvailable = checkIfImageIsAvailable(link.imageLinkId); const isImageAvailable = checkIfImageIsAvailable(link.imageLinkId);
if (!isImageAvailable) { if (!isImageAvailable) {
...@@ -87,6 +100,7 @@ export const useOverviewImageLinkActions = (): UseOverviewImageLinkActionsResult ...@@ -87,6 +100,7 @@ export const useOverviewImageLinkActions = (): UseOverviewImageLinkActionsResult
const handleLinkClick: UseOverviewImageLinkActionsResult['handleLinkClick'] = link => { const handleLinkClick: UseOverviewImageLinkActionsResult['handleLinkClick'] = link => {
const isImageLink = 'imageLinkId' in link; const isImageLink = 'imageLinkId' in link;
const isModelLink = 'modelLinkId' in link; const isModelLink = 'modelLinkId' in link;
const isSearchLink = 'query' in link;
if (isImageLink) { if (isImageLink) {
return onImageClick(link); return onImageClick(link);
...@@ -96,6 +110,10 @@ export const useOverviewImageLinkActions = (): UseOverviewImageLinkActionsResult ...@@ -96,6 +110,10 @@ export const useOverviewImageLinkActions = (): UseOverviewImageLinkActionsResult
return onSubmapClick(link); return onSubmapClick(link);
} }
if (isSearchLink) {
return onSearchClick(link);
}
return NOOP(); return NOOP();
}; };
......
...@@ -17,4 +17,15 @@ export const overviewImageLinkModel = z.object({ ...@@ -17,4 +17,15 @@ export const overviewImageLinkModel = z.object({
type: z.string(), type: z.string(),
}); });
export const overviewImageLink = z.union([overviewImageLinkImage, overviewImageLinkModel]); export const overviewImageLinkSearch = z.object({
idObject: z.number(),
polygon: z.array(positionSchema),
query: z.string(),
type: z.string(),
});
export const overviewImageLink = z.union([
overviewImageLinkImage,
overviewImageLinkModel,
overviewImageLinkSearch,
]);
...@@ -44,6 +44,7 @@ import { ...@@ -44,6 +44,7 @@ import {
overviewImageLink, overviewImageLink,
overviewImageLinkImage, overviewImageLinkImage,
overviewImageLinkModel, overviewImageLinkModel,
overviewImageLinkSearch,
} from '@/models/overviewImageLink'; } from '@/models/overviewImageLink';
import { overviewImageView } from '@/models/overviewImageView'; import { overviewImageView } from '@/models/overviewImageView';
import { pluginSchema } from '@/models/pluginSchema'; import { pluginSchema } from '@/models/pluginSchema';
...@@ -72,6 +73,7 @@ export type OverviewImageView = z.infer<typeof overviewImageView>; ...@@ -72,6 +73,7 @@ export type OverviewImageView = z.infer<typeof overviewImageView>;
export type OverviewImageLink = z.infer<typeof overviewImageLink>; export type OverviewImageLink = z.infer<typeof overviewImageLink>;
export type OverviewImageLinkImage = z.infer<typeof overviewImageLinkImage>; export type OverviewImageLinkImage = z.infer<typeof overviewImageLinkImage>;
export type OverviewImageLinkModel = z.infer<typeof overviewImageLinkModel>; export type OverviewImageLinkModel = z.infer<typeof overviewImageLinkModel>;
export type OverviewImageLinkSearch = z.infer<typeof overviewImageLinkSearch>;
export type MapModel = z.infer<typeof mapModelSchema>; export type MapModel = z.infer<typeof mapModelSchema>;
export type MapOverlay = z.infer<typeof mapOverlay>; export type MapOverlay = z.infer<typeof mapOverlay>;
export type MapBackground = z.infer<typeof mapBackground>; export type MapBackground = z.infer<typeof mapBackground>;
......
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