Переработан вид страницы "Карта"

This commit is contained in:
goodmice 2022-12-26 17:58:46 +05:00
parent dde32f737a
commit 7a242ab59c
No known key found for this signature in database
GPG Key ID: EA4AA16454AC96C8
2 changed files with 79 additions and 20 deletions

View File

@ -1,13 +1,16 @@
import { memo, useMemo, useCallback } from 'react' import { memo, useMemo, useCallback } from 'react'
import { Link, useLocation } from 'react-router-dom' import { Link, useLocation } from 'react-router-dom'
import { Map as PigeonMap, Overlay } from 'pigeon-maps' import { Map as PigeonMap, Overlay } from 'pigeon-maps'
import { Popover, Badge } from 'antd' import { Popover, Button } from 'antd'
import { useDepositList } from '@asb/context' import { useDepositList, useLayoutProps } from '@asb/context'
import { PointerIcon } from '@components/icons'
import { limitValue, withPermissions } from '@utils' import { limitValue, withPermissions } from '@utils'
import '@styles/index.css' import { ClusterMapIcon } from '@images/pages/deposit/ClusterMapIcon'
import { ReactComponent as MapPointer } from '@images/pages/deposit/MapPointer.svg'
import { ReactComponent as WellMapIcon } from '@images/pages/deposit/WellMapIcon.svg'
import '@styles/pages/deposit_map.less'
const zoomLimit = limitValue(5, 15) const zoomLimit = limitValue(5, 15)
@ -39,18 +42,19 @@ const calcViewParams = (clusters) => {
const Map = memo(() => { const Map = memo(() => {
const deposits = useDepositList() const deposits = useDepositList()
const location = useLocation() const location = useLocation()
const { openWellTreeSelector } = useLayoutProps()
const makeDepositLinks = useCallback((clusters) => ( const makeClusterLinks = useCallback((wells) => (
<div> <div>
{clusters.map(cluster => ( {wells.map(well => (
<Link <Link
key={cluster.id} key={well.id}
to={{ to={{
pathname: `/cluster/${cluster.id}`, pathname: `/well/${well.id}`,
state: { from: location.pathname } state: { from: location.pathname }
}} }}
> >
<div>{cluster.caption}</div> <div>{well.caption}</div>
</Link> </Link>
))} ))}
</div> </div>
@ -61,31 +65,39 @@ const Map = memo(() => {
return ( return (
<div className={'deposit-page'}> <div className={'deposit-page'}>
<PigeonMap {...viewParams}> <PigeonMap {...viewParams}>
{deposits.map(deposit => { {deposits.map(deposit => deposit.clusters.map(cluster => {
const anchor = [deposit.latitude, deposit.longitude] const anchor = [cluster.latitude, cluster.longitude]
const links = makeDepositLinks(deposit.clusters) const count = cluster.wells.length
const title = `${deposit.caption} / ${cluster.caption}`
const links = makeClusterLinks(cluster.wells)
return ( return (
<Overlay width={32} anchor={anchor} key={anchor.join(' ')}> <Overlay width={65} anchor={anchor} key={anchor.join(' ')}>
<Popover <Popover
content={links} content={links}
trigger={['click']} trigger={['click']}
title={( title={(
<Link to={{ pathname: `/deposit/${deposit.id}` }}> <Link to={{ pathname: `/cluster/${cluster.id}` }}>
{deposit.caption} {title}
</Link> </Link>
)} )}
> >
<div className={'pointer'}> <div className={'pointer'} title={title}>
<Badge count={deposit.clusters.length}> {count <= 1 ? (
<PointerIcon state={'active'} width={48} height={59} /> <WellMapIcon />
</Badge> ) : (
<ClusterMapIcon count={count} />
)}
</div> </div>
</Popover> </Popover>
</Overlay> </Overlay>
) )
})} }))}
</PigeonMap> </PigeonMap>
<button className={'dd-deposit-open-selector-btn'} onClick={openWellTreeSelector}>
<MapPointer />
<span>Выберите месторождение</span>
</button>
</div> </div>
) )
}) })

View File

@ -0,0 +1,47 @@
.deposit-page {
@bg-color: #232323;
height: 100vh;
overflow: hidden;
& .pigeon-tiles-box > .pigeon-tiles > * {
filter: brightness(0.6) invert(1) contrast(3) hue-rotate(200deg) saturate(0.3) brightness(0.7);
background: @bg-color !important;
}
& .pigeon-attribution {
background: fade(@bg-color, 70%) !important;
color: white !important;
}
& .dd-deposit-open-selector-btn {
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
padding: 10px 25px;
color: white;
font-weight: 700;
font-size: 16px;
font-style: normal;
position: absolute;
gap: 10px;
top: 35px;
right: 60px;
border: 1px solid #4A4A4A;
background: @bg-color;
border-radius: 6px;
box-sizing: border-box;
transition: all .1s ease-in-out;
&:hover {
color: @bg-color;
background: white;
}
&:active {
background: rgba(255,255,255,.6);
color: @bg-color;
}
}
}