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:
Anton Tranelis 2025-09-07 13:42:29 +02:00 committed by GitHub
parent a9004a47ea
commit 659efc0d5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 3 deletions

View File

@ -267,14 +267,14 @@ function App() {
path='attestation-form'
element={<AttestationForm api={attestationApi} />}
/>
{layers.map((l: any) => (
{layers.map((l: LayerProps) => (
<Route
key={l.id}
path={l.name}
element={
<OverlayItemsIndexPage
layerName={l.name}
url={'/item/'}
url={l.itemType.custom_profile_url ? '/' : '/item/'}
parameterField={'id'}
/>
}

View File

@ -1,6 +1,8 @@
import { LatLng } from 'leaflet'
import { useMap } from 'react-leaflet'
import { useNavigate } from 'react-router-dom'
import { usePopupForm } from '#components/Map/hooks/usePopupForm'
import { useSetSelectPosition } from '#components/Map/hooks/useSelectPosition'
import useWindowDimensions from '#components/Map/hooks/useWindowDimension'
import { StartEndView, TextView } from '#components/Map/Subcomponents/ItemPopupComponents'
@ -25,6 +27,31 @@ export const ItemCard = ({
const windowDimensions = useWindowDimensions()
const map = useMap()
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 (
<div
@ -41,7 +68,7 @@ export const ItemCard = ({
loading={loading}
item={i}
api={i.layer?.api}
editCallback={() => navigate('/edit-item/' + i.id)}
editCallback={() => handleEdit()}
setPositionCallback={() => {
map.closePopup()
setSelectPosition(i)