fix popup button (#339)

This commit is contained in:
Anton Tranelis 2025-08-27 13:17:20 +02:00 committed by GitHub
parent 1b0b51e91a
commit 94ec2e5576
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View File

@ -117,8 +117,11 @@ function MapContainer({ layers, map }: { layers: LayerProps[]; map: any }) {
{layer.itemType.show_profile_button && (
<PopupButton
url={layer.itemType.custom_profile_url ?? '/item'}
parameterField={'extended.external_profile_id'}
parameterField={
layer.itemType.custom_profile_url ? 'extended.external_profile_id' : 'id'
}
text={layer.itemType.botton_label ?? 'Profile'}
target={layer.itemType.custom_profile_url ? '_parent' : '_self'}
/>
)}
{layer.itemType.show_text && <TextView truncate></TextView>}

View File

@ -15,18 +15,20 @@ export const PopupButton = ({
parameterField,
text,
item,
target,
}: {
url: string
parameterField?: string
text: string
item?: Item
target?: string
}) => {
const params = new URLSearchParams(window.location.search)
const getItemTags = useGetItemTags()
const parameter = get(item, parameterField ?? 'id')
return (
<Link to={`${url}/${parameter || item?.id}?${params}`} target='_parent'>
<Link to={`${url}/${parameter || item?.id}?${params}`} target={target ?? '_self'}>
<button
style={{
backgroundColor: `${item?.color ?? (item && (getItemTags(item) && getItemTags(item)[0] && getItemTags(item)[0].color ? getItemTags(item)[0].color : (item?.layer?.markerDefaultColor ?? '#000')))}`,