From 1c00e6abf113f9b0061d7ca7e1b9211c8d7f7279 Mon Sep 17 00:00:00 2001 From: Anton Tranelis Date: Sat, 4 May 2024 09:20:44 +0200 Subject: [PATCH] improved permission detection in items index --- src/Components/Profile/PlusButton.tsx | 5 +++-- src/Components/Templates/OverlayItemsIndexPage.tsx | 12 +++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Components/Profile/PlusButton.tsx b/src/Components/Profile/PlusButton.tsx index db616578..5a6f0e37 100644 --- a/src/Components/Profile/PlusButton.tsx +++ b/src/Components/Profile/PlusButton.tsx @@ -1,9 +1,10 @@ +import { LayerProps } from "../../types"; import { useHasUserPermission } from "../Map/hooks/usePermissions"; -export function PlusButton({ triggerAction, color, collection="items" }: { triggerAction: any, color: string, collection?:string }) { +export function PlusButton({ layer, triggerAction, color, collection="items" }: { layer?: LayerProps ,triggerAction: any, color: string, collection?:string }) { const hasUserPermission = useHasUserPermission(); return ( - <>{hasUserPermission(collection, "create") && + <>{hasUserPermission(collection, "create", undefined, layer) &&
@@ -160,6 +159,9 @@ export const OverlayItemsIndexPage = ({ url, layerName, parameterField, breadcru }}>

+ {layer?.itemType.show_start_end_input && + + }
@@ -175,7 +177,7 @@ export const OverlayItemsIndexPage = ({ url, layerName, parameterField, breadcru - {plusButton && { setAddItemPopupType("place"); scroll(); }} color={'#777'} collection='items' />} + {plusButton && { setAddItemPopupType("place"); scroll(); }} color={'#777'} collection='items' />}