diff --git a/src/Components/Map/Subcomponents/ItemFormPopup.tsx b/src/Components/Map/Subcomponents/ItemFormPopup.tsx
index 8714772c..1f3237bc 100644
--- a/src/Components/Map/Subcomponents/ItemFormPopup.tsx
+++ b/src/Components/Map/Subcomponents/ItemFormPopup.tsx
@@ -96,7 +96,7 @@ export function ItemFormPopup(props: ItemFormPopupProps) {
}
if(success) {
props.layer.onlyOnePerOwner && item && updateItem({...item, ...formItem});
- (!props.layer.onlyOnePerOwner || !item) && addItem({...formItem, name: formItem.name ? formItem.name : user?.first_name , user_created: user, type: props.layer.itemType, id: uuid, layer: props.layer});
+ (!props.layer.onlyOnePerOwner || !item) && addItem({...formItem, name: formItem.name ? formItem.name : user?.first_name , user_created: user, type: props.layer.itemType, id: uuid, layer: props.layer, public_edit: !user ? true : false});
toast.success("New item created");
resetFilterTags();
}
diff --git a/src/Components/Map/Subcomponents/ItemPopupComponents/PopupCheckboxInput.tsx b/src/Components/Map/Subcomponents/ItemPopupComponents/PopupCheckboxInput.tsx
new file mode 100644
index 00000000..119dd804
--- /dev/null
+++ b/src/Components/Map/Subcomponents/ItemPopupComponents/PopupCheckboxInput.tsx
@@ -0,0 +1,15 @@
+import * as React from 'react'
+import { TextInput } from '../../../Input'
+import { Item } from '../../../../types'
+
+export const PopupCheckboxInput = ({ dataField, label, item }:
+ {
+ dataField: string,
+ label: string,
+ item?: Item
+ }) => {
+
+ return (
+
+ )
+}
diff --git a/src/Components/Map/hooks/usePermissions.tsx b/src/Components/Map/hooks/usePermissions.tsx
index a199c143..75accf79 100644
--- a/src/Components/Map/hooks/usePermissions.tsx
+++ b/src/Components/Map/hooks/usePermissions.tsx
@@ -1,6 +1,6 @@
import { useCallback, useReducer, createContext, useContext } from "react";
import * as React from "react";
-import { Item, ItemsApi, Permission, PermissionAction } from "../../../types";
+import { Item, ItemsApi, LayerProps, Permission, PermissionAction } from "../../../types";
import { useAuth } from "../../Auth";
type ActionType =
@@ -22,7 +22,7 @@ function usePermissionsManager(initialPermissions: Permission[]): {
setPermissionApi: (api: ItemsApi
) => void;
setPermissionData: (data: Permission[]) => void;
setAdminRole: (adminRole: string) => void;
- hasUserPermission: (collectionName: string, action: PermissionAction, item?: Item) => boolean;
+ hasUserPermission: (collectionName: string, action: PermissionAction, item?: Item, layer?: LayerProps) => boolean;
} {
const [permissions, dispatch] = useReducer((state: Permission[], action: ActionType) => {
switch (action.type) {
@@ -63,7 +63,7 @@ function usePermissionsManager(initialPermissions: Permission[]): {
}, []);
const hasUserPermission = useCallback(
- (collectionName: string, action: PermissionAction, item?: Item) => {
+ (collectionName: string, action: PermissionAction, item?: Item, layer?: LayerProps) => {
if (permissions.length === 0) return true;
else if (user && user.role === adminRole) return true;
else {
@@ -80,7 +80,17 @@ function usePermissionsManager(initialPermissions: Permission[]): {
item.user_created?.id === user?.id
)
)
- // || ( !user && p.role == null )
+ || ( !user && p.role == null ) &&
+ (layer?.public_edit_items || item?.layer?.public_edit_items) &&
+ (
+ // Wenn 'item' nicht gesetzt ist, ignorieren wir die Überprüfung von 'public_edit'
+ !item ||
+ p.permissions?._and?.some(condition =>
+ condition.public_edit &&
+ condition.public_edit._eq == true &&
+ item.public_edit == true
+ )
+ )
);
}
},
diff --git a/src/Components/Map/index.tsx b/src/Components/Map/index.tsx
index ff42e8cb..fcf5fb36 100644
--- a/src/Components/Map/index.tsx
+++ b/src/Components/Map/index.tsx
@@ -7,6 +7,7 @@ export {ItemView} from './ItemView';
export {PopupTextAreaInput} from './Subcomponents/ItemPopupComponents/PopupTextAreaInput';
export {PopupStartEndInput} from './Subcomponents/ItemPopupComponents/PopupStartEndInput';
export {PopupTextInput} from './Subcomponents/ItemPopupComponents/PopupTextInput';
+export {PopupCheckboxInput} from './Subcomponents/ItemPopupComponents/PopupCheckboxInput'
export {TextView} from './Subcomponents/ItemPopupComponents/TextView';
export {StartEndView} from './Subcomponents/ItemPopupComponents/StartEndView'
export {PopupButton} from './Subcomponents/ItemPopupComponents/PopupButton'
\ No newline at end of file
diff --git a/src/index.tsx b/src/index.tsx
index 0883b072..f474dc83 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -1,4 +1,4 @@
-export { UtopiaMap, Layer, Tags, Permissions, ItemForm, ItemView, PopupTextAreaInput, PopupStartEndInput, PopupTextInput, PopupButton, TextView, StartEndView } from './Components/Map';
+export { UtopiaMap, Layer, Tags, Permissions, ItemForm, ItemView, PopupTextAreaInput, PopupStartEndInput, PopupTextInput, PopupButton, TextView, StartEndView, PopupCheckboxInput } from './Components/Map';
export {AppShell, Content, SideBar} from "./Components/AppShell"
export {AuthProvider, useAuth, LoginPage, SignupPage, RequestPasswordPage, SetNewPasswordPage} from "./Components/Auth"
export {UserSettings, ProfileSettings, OverlayProfile, OverlayProfileSettings, OverlayUserSettings, OverlayItemProfile, OverlayItemProfileSettings} from './Components/Profile'
diff --git a/src/types.ts b/src/types.ts
index 1d94f338..c9990edf 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -37,6 +37,7 @@ export interface LayerProps {
onlyOnePerOwner?: boolean,
customEditLink?: string,
customEditParameter?: string,
+ public_edit_items?: boolean
setItemFormPopup?: React.Dispatch>,
itemFormPopup?: ItemFormPopupProps | null,
clusterRef?: any
@@ -63,6 +64,7 @@ export class Item {
relations?: Relation[];
parent?:string;
subname?: string;
+ public_edit?: boolean;
[key: string]: any;
constructor(id:string,name:string,text:string,position:Geometry, layer?: LayerProps, api?: ItemsApi){
this.id = id;
@@ -138,7 +140,9 @@ export type PermissionCondition = {
user_created?: {
_eq: string; // Erwartet den speziellen Wert "$CURRENT_USER" oder eine spezifische UUID
};
- // Hier können weitere Bedingungen nach Bedarf hinzugefügt werden
+ public_edit?: {
+ _eq: boolean; // Erwartet den speziellen Wert "$CURRENT_USER" oder eine spezifische UUID
+ };
};
export type Permission = {