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

Merge branch '318-problem-with-overview-image-links-cause-map-no-to-load' into 'main'

Resolve "problem with overview image links cause map no to load"

See merge request !315
parents c1189325 574d0349
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 #98275 passed
minerva-front (18.0.3) stable; urgency=medium
* Bug fix: mwhen compartment is missing "default" is added (#314)
minerva-front (18.0.4) stable; urgency=medium
* 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
* Bug fix: Molart froze after clicking (#313)
......
import { OverviewImageLinkImage, OverviewImageLinkModel } from '@/types/models';
import {
OverviewImageLinkImage,
OverviewImageLinkModel,
OverviewImageLinkSearch,
} from '@/types/models';
export interface OverviewImageSize {
width: number;
......@@ -26,3 +30,5 @@ export interface OverviewImageLinkConfig {
export type OverviewImageLinkImageHandler = (link: OverviewImageLinkImage) => 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 { useAppSelector } from '@/redux/hooks/useAppSelector';
import { mapOpenedMapsSelector } from '@/redux/map/map.selectors';
......@@ -8,9 +8,12 @@ import { currentModelIdSelector, modelsDataSelector } from '@/redux/models/model
import { projectOverviewImagesSelector } from '@/redux/project/project.selectors';
import { PluginsEventBus } from '@/services/pluginsManager/pluginsEventBus';
import { MapModel, OverviewImageLink, OverviewImageLinkModel } from '@/types/models';
import { getSearchData } from '@/redux/search/search.thunks';
import { openSearchDrawerWithSelectedTab } from '@/redux/drawer/drawer.slice';
import {
OverviewImageLinkImageHandler,
OverviewImageLinkModelHandler,
OverviewImageLinkSearchHandler,
} from '../OverviewImageModal.types';
interface UseOverviewImageLinkActionsResult {
......@@ -75,6 +78,16 @@ export const useOverviewImageLinkActions = (): UseOverviewImageLinkActionsResult
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 isImageAvailable = checkIfImageIsAvailable(link.imageLinkId);
if (!isImageAvailable) {
......@@ -87,6 +100,7 @@ export const useOverviewImageLinkActions = (): UseOverviewImageLinkActionsResult
const handleLinkClick: UseOverviewImageLinkActionsResult['handleLinkClick'] = link => {
const isImageLink = 'imageLinkId' in link;
const isModelLink = 'modelLinkId' in link;
const isSearchLink = 'query' in link;
if (isImageLink) {
return onImageClick(link);
......@@ -96,6 +110,10 @@ export const useOverviewImageLinkActions = (): UseOverviewImageLinkActionsResult
return onSubmapClick(link);
}
if (isSearchLink) {
return onSearchClick(link);
}
return NOOP();
};
......
......@@ -17,4 +17,15 @@ export const overviewImageLinkModel = z.object({
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 {
overviewImageLink,
overviewImageLinkImage,
overviewImageLinkModel,
overviewImageLinkSearch,
} from '@/models/overviewImageLink';
import { overviewImageView } from '@/models/overviewImageView';
import { pluginSchema } from '@/models/pluginSchema';
......@@ -72,6 +73,7 @@ export type OverviewImageView = z.infer<typeof overviewImageView>;
export type OverviewImageLink = z.infer<typeof overviewImageLink>;
export type OverviewImageLinkImage = z.infer<typeof overviewImageLinkImage>;
export type OverviewImageLinkModel = z.infer<typeof overviewImageLinkModel>;
export type OverviewImageLinkSearch = z.infer<typeof overviewImageLinkSearch>;
export type MapModel = z.infer<typeof mapModelSchema>;
export type MapOverlay = z.infer<typeof mapOverlay>;
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