From 06755d7f8084157f0d82c121afdc2ff249e8c042 Mon Sep 17 00:00:00 2001 From: Anton Tranelis Date: Fri, 3 May 2024 12:49:19 +0200 Subject: [PATCH] basic public item support --- src/Components/Map/Layer.tsx | 5 +++-- src/Components/Map/Subcomponents/AddButton.tsx | 4 ++-- .../Map/Subcomponents/ItemFormPopup.tsx | 2 +- .../ItemPopupComponents/PopupCheckboxInput.tsx | 15 +++++++++++++++ src/Components/Map/hooks/usePermissions.tsx | 18 ++++++++++++++---- src/Components/Map/index.tsx | 1 + src/index.tsx | 2 +- src/types.ts | 6 +++++- 8 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 src/Components/Map/Subcomponents/ItemPopupComponents/PopupCheckboxInput.tsx diff --git a/src/Components/Map/Layer.tsx b/src/Components/Map/Layer.tsx index 458e1cf4..2d3114d9 100644 --- a/src/Components/Map/Layer.tsx +++ b/src/Components/Map/Layer.tsx @@ -43,6 +43,7 @@ export const Layer = ({ onlyOnePerOwner = false, customEditLink, customEditParameter, + public_edit_items, setItemFormPopup, itemFormPopup, clusterRef @@ -78,8 +79,8 @@ export const Layer = ({ useEffect(() => { - data && setItemsData({ data, children, name, menuIcon, menuText, menuColor, markerIcon, markerShape, markerDefaultColor, api, itemType, itemNameField, itemSubnameField, itemTextField, itemAvatarField, itemColorField, itemOwnerField, itemTagsField, itemOffersField, itemNeedsField, onlyOnePerOwner, customEditLink, customEditParameter, setItemFormPopup, itemFormPopup, clusterRef }); - api && setItemsApi({ data, children, name, menuIcon, menuText, menuColor, markerIcon, markerShape, markerDefaultColor, api, itemType, itemNameField, itemSubnameField, itemTextField, itemAvatarField, itemColorField, itemOwnerField, itemTagsField, itemOffersField, itemNeedsField, onlyOnePerOwner, customEditLink, customEditParameter, setItemFormPopup, itemFormPopup, clusterRef }); + data && setItemsData({ data, children, name, menuIcon, menuText, menuColor, markerIcon, markerShape, markerDefaultColor, api, itemType, itemNameField, itemSubnameField, itemTextField, itemAvatarField, itemColorField, itemOwnerField, itemTagsField, itemOffersField, itemNeedsField, onlyOnePerOwner, customEditLink, customEditParameter, public_edit_items, setItemFormPopup, itemFormPopup, clusterRef }); + api && setItemsApi({ data, children, name, menuIcon, menuText, menuColor, markerIcon, markerShape, markerDefaultColor, api, itemType, itemNameField, itemSubnameField, itemTextField, itemAvatarField, itemColorField, itemOwnerField, itemTagsField, itemOffersField, itemNeedsField, onlyOnePerOwner, customEditLink, customEditParameter, public_edit_items, setItemFormPopup, itemFormPopup, clusterRef }); }, [data, api]) useMapEvents({ diff --git a/src/Components/Map/Subcomponents/AddButton.tsx b/src/Components/Map/Subcomponents/AddButton.tsx index 0c871f9a..d5f4b794 100644 --- a/src/Components/Map/Subcomponents/AddButton.tsx +++ b/src/Components/Map/Subcomponents/AddButton.tsx @@ -11,7 +11,7 @@ export default function AddButton({ triggerAction }: { triggerAction: React.Disp const canAddItems = () => { let canAdd = false; layers.map(layer => { - if (layer.api?.createItem && hasUserPermission(layer.api.collectionName!, "create")) canAdd = true; + if (layer.api?.createItem && hasUserPermission(layer.api.collectionName!, "create", undefined, layer)) canAdd = true; }) return canAdd; } @@ -28,7 +28,7 @@ export default function AddButton({ triggerAction }: { triggerAction: React.Disp