forked from ddrilling/asb_cloud_front
* Добавленна ссылка на месторождение в подсказке значка на карте
* Исправлено выделение месторождения в селекторе
This commit is contained in:
parent
4dd57aff98
commit
17d7b7c41d
@ -67,7 +67,15 @@ const Map = memo(() => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Overlay width={32} anchor={anchor} key={anchor.join(' ')}>
|
<Overlay width={32} anchor={anchor} key={anchor.join(' ')}>
|
||||||
<Popover content={links} trigger={['click']} title={deposit.caption}>
|
<Popover
|
||||||
|
content={links}
|
||||||
|
trigger={['click']}
|
||||||
|
title={(
|
||||||
|
<Link to={{ pathname: `/deposit/${deposit.id}` }}>
|
||||||
|
{deposit.caption}
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
|
>
|
||||||
<div className={'pointer'}>
|
<div className={'pointer'}>
|
||||||
<Badge count={deposit.clusters.length}>
|
<Badge count={deposit.clusters.length}>
|
||||||
<PointerIcon state={'active'} width={48} height={59} />
|
<PointerIcon state={'active'} width={48} height={59} />
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Navigate, Route, Routes, useLocation, useParams } from 'react-router-dom'
|
import { Navigate, Route, Routes, useParams } from 'react-router-dom'
|
||||||
import { lazy, memo, useEffect, useMemo } from 'react'
|
import { lazy, memo, useEffect, useMemo } from 'react'
|
||||||
|
|
||||||
import { DepositContext, RootPathContext, useDepositList, useLayoutProps, useRootPath } from '@asb/context'
|
import { DepositContext, RootPathContext, useDepositList, useLayoutProps, useRootPath } from '@asb/context'
|
||||||
@ -10,11 +10,13 @@ const DepositNavigationMenu = lazy(() => import('./DepositNavigationMenu'))
|
|||||||
|
|
||||||
const Deposit = memo(() => {
|
const Deposit = memo(() => {
|
||||||
const { '*': param } = useParams()
|
const { '*': param } = useParams()
|
||||||
const location = useLocation()
|
|
||||||
|
|
||||||
const setLayoutProps = useLayoutProps()
|
const setLayoutProps = useLayoutProps()
|
||||||
const deposits = useDepositList()
|
const deposits = useDepositList()
|
||||||
|
|
||||||
|
const root = useRootPath()
|
||||||
|
const rootPath = useMemo(() => `${root}/deposit`, [root])
|
||||||
|
|
||||||
const idDeposit = useMemo(() => {
|
const idDeposit = useMemo(() => {
|
||||||
const result = /^([^\/#?]+)/.exec(param)
|
const result = /^([^\/#?]+)/.exec(param)
|
||||||
return result && result[1] !== 'null' ? Number(result[1]) : null
|
return result && result[1] !== 'null' ? Number(result[1]) : null
|
||||||
@ -22,15 +24,12 @@ const Deposit = memo(() => {
|
|||||||
|
|
||||||
const deposit = useMemo(() => deposits.find((deposit) => deposit.id === idDeposit) || null, [deposits, idDeposit])
|
const deposit = useMemo(() => deposits.find((deposit) => deposit.id === idDeposit) || null, [deposits, idDeposit])
|
||||||
|
|
||||||
const root = useRootPath()
|
|
||||||
const rootPath = useMemo(() => `${root}/deposit`, [root])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const hasId = location.pathname.length > '/deposit/'.length
|
const key = idDeposit ? `/deposit/${idDeposit}` : null
|
||||||
|
|
||||||
const selectorProps = {
|
const selectorProps = {
|
||||||
expand: hasId ? [location.pathname] : true,
|
expand: key ? [key] : true,
|
||||||
current: hasId ? location.pathname : undefined,
|
current: key || undefined,
|
||||||
}
|
}
|
||||||
|
|
||||||
setLayoutProps({
|
setLayoutProps({
|
||||||
@ -40,7 +39,7 @@ const Deposit = memo(() => {
|
|||||||
selectorProps,
|
selectorProps,
|
||||||
title: 'Месторождение',
|
title: 'Месторождение',
|
||||||
})
|
})
|
||||||
}, [setLayoutProps, location.pathname, deposit])
|
}, [setLayoutProps, idDeposit])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RootPathContext.Provider value={rootPath}>
|
<RootPathContext.Provider value={rootPath}>
|
||||||
|
Loading…
Reference in New Issue
Block a user