mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
fix(lib): adjust index page for external profiles (#361)
* don't open internal profile, if item has external profile url * refactor(backend): simplified icon config (#359) * simplified icon config * fixed linting * fixed linting * fix linting and searchControl * adjust useSelectPosition * adjust useSelectPosition * fixed presets * removed menuIcon artefacts * fix example * adjust icon size in addButton * item index page is now not opening internal profile if external profile exist * fix imports * reset layer * fix behaviour * set map position to popup form
This commit is contained in:
parent
a9004a47ea
commit
659efc0d5e
@ -267,14 +267,14 @@ function App() {
|
|||||||
path='attestation-form'
|
path='attestation-form'
|
||||||
element={<AttestationForm api={attestationApi} />}
|
element={<AttestationForm api={attestationApi} />}
|
||||||
/>
|
/>
|
||||||
{layers.map((l: any) => (
|
{layers.map((l: LayerProps) => (
|
||||||
<Route
|
<Route
|
||||||
key={l.id}
|
key={l.id}
|
||||||
path={l.name}
|
path={l.name}
|
||||||
element={
|
element={
|
||||||
<OverlayItemsIndexPage
|
<OverlayItemsIndexPage
|
||||||
layerName={l.name}
|
layerName={l.name}
|
||||||
url={'/item/'}
|
url={l.itemType.custom_profile_url ? '/' : '/item/'}
|
||||||
parameterField={'id'}
|
parameterField={'id'}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
|
import { LatLng } from 'leaflet'
|
||||||
import { useMap } from 'react-leaflet'
|
import { useMap } from 'react-leaflet'
|
||||||
import { useNavigate } from 'react-router-dom'
|
import { useNavigate } from 'react-router-dom'
|
||||||
|
|
||||||
|
import { usePopupForm } from '#components/Map/hooks/usePopupForm'
|
||||||
import { useSetSelectPosition } from '#components/Map/hooks/useSelectPosition'
|
import { useSetSelectPosition } from '#components/Map/hooks/useSelectPosition'
|
||||||
import useWindowDimensions from '#components/Map/hooks/useWindowDimension'
|
import useWindowDimensions from '#components/Map/hooks/useWindowDimension'
|
||||||
import { StartEndView, TextView } from '#components/Map/Subcomponents/ItemPopupComponents'
|
import { StartEndView, TextView } from '#components/Map/Subcomponents/ItemPopupComponents'
|
||||||
@ -25,6 +27,31 @@ export const ItemCard = ({
|
|||||||
const windowDimensions = useWindowDimensions()
|
const windowDimensions = useWindowDimensions()
|
||||||
const map = useMap()
|
const map = useMap()
|
||||||
const setSelectPosition = useSetSelectPosition()
|
const setSelectPosition = useSetSelectPosition()
|
||||||
|
const { setPopupForm } = usePopupForm()
|
||||||
|
|
||||||
|
const handleEdit = () => {
|
||||||
|
if (!i.layer) {
|
||||||
|
throw new Error('Layer is not defined')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i.layer.itemType.small_form_edit && i.position) {
|
||||||
|
navigate('/')
|
||||||
|
// Wait for navigation to complete before setting popup
|
||||||
|
setTimeout(() => {
|
||||||
|
if (i.position && i.layer) {
|
||||||
|
const position = new LatLng(i.position.coordinates[1], i.position.coordinates[0])
|
||||||
|
setPopupForm({
|
||||||
|
position,
|
||||||
|
layer: i.layer,
|
||||||
|
item: i,
|
||||||
|
})
|
||||||
|
map.setView(position, map.getZoom(), { duration: 1 })
|
||||||
|
}
|
||||||
|
}, 100)
|
||||||
|
} else {
|
||||||
|
navigate('/edit-item/' + i.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@ -41,7 +68,7 @@ export const ItemCard = ({
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
item={i}
|
item={i}
|
||||||
api={i.layer?.api}
|
api={i.layer?.api}
|
||||||
editCallback={() => navigate('/edit-item/' + i.id)}
|
editCallback={() => handleEdit()}
|
||||||
setPositionCallback={() => {
|
setPositionCallback={() => {
|
||||||
map.closePopup()
|
map.closePopup()
|
||||||
setSelectPosition(i)
|
setSelectPosition(i)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user