Added note edit flags
This commit is contained in:
parent
8873e59205
commit
6fedcc171d
@ -40,6 +40,7 @@ function Map({
|
|||||||
allowMapDrawing,
|
allowMapDrawing,
|
||||||
allowFogDrawing,
|
allowFogDrawing,
|
||||||
allowMapChange,
|
allowMapChange,
|
||||||
|
allowNoteEditing,
|
||||||
disabledTokens,
|
disabledTokens,
|
||||||
session,
|
session,
|
||||||
}) {
|
}) {
|
||||||
@ -138,7 +139,6 @@ function Map({
|
|||||||
disabledControls.push("pan");
|
disabledControls.push("pan");
|
||||||
disabledControls.push("measure");
|
disabledControls.push("measure");
|
||||||
disabledControls.push("pointer");
|
disabledControls.push("pointer");
|
||||||
disabledControls.push("note");
|
|
||||||
}
|
}
|
||||||
if (!allowFogDrawing) {
|
if (!allowFogDrawing) {
|
||||||
disabledControls.push("fog");
|
disabledControls.push("fog");
|
||||||
@ -146,6 +146,9 @@ function Map({
|
|||||||
if (!allowMapChange) {
|
if (!allowMapChange) {
|
||||||
disabledControls.push("map");
|
disabledControls.push("map");
|
||||||
}
|
}
|
||||||
|
if (!allowNoteEditing) {
|
||||||
|
disabledControls.push("note");
|
||||||
|
}
|
||||||
|
|
||||||
const disabledSettings = { fog: [], drawing: [] };
|
const disabledSettings = { fog: [], drawing: [] };
|
||||||
if (mapShapes.length === 0) {
|
if (mapShapes.length === 0) {
|
||||||
@ -399,7 +402,10 @@ function Map({
|
|||||||
: []
|
: []
|
||||||
}
|
}
|
||||||
onNoteMenuOpen={handleNoteMenuOpen}
|
onNoteMenuOpen={handleNoteMenuOpen}
|
||||||
draggable={selectedToolId === "note" || selectedToolId === "pan"}
|
draggable={
|
||||||
|
allowNoteEditing &&
|
||||||
|
(selectedToolId === "note" || selectedToolId === "pan")
|
||||||
|
}
|
||||||
onNoteDragStart={(e, noteId) =>
|
onNoteDragStart={(e, noteId) =>
|
||||||
setNoteDraggingOptions({ dragging: true, noteId, noteGroup: e.target })
|
setNoteDraggingOptions({ dragging: true, noteId, noteGroup: e.target })
|
||||||
}
|
}
|
||||||
|
@ -233,6 +233,16 @@ function MapSettings({
|
|||||||
/>
|
/>
|
||||||
Tokens
|
Tokens
|
||||||
</Label>
|
</Label>
|
||||||
|
<Label>
|
||||||
|
<Checkbox
|
||||||
|
checked={
|
||||||
|
!mapStateEmpty && mapState.editFlags.includes("notes")
|
||||||
|
}
|
||||||
|
disabled={mapStateEmpty}
|
||||||
|
onChange={(e) => handleFlagChange(e, "notes")}
|
||||||
|
/>
|
||||||
|
Notes
|
||||||
|
</Label>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Box>
|
</Box>
|
||||||
</>
|
</>
|
||||||
|
@ -19,7 +19,7 @@ const defaultMapState = {
|
|||||||
fogDrawActionIndex: -1,
|
fogDrawActionIndex: -1,
|
||||||
fogDrawActions: [],
|
fogDrawActions: [],
|
||||||
// Flags to determine what other people can edit
|
// Flags to determine what other people can edit
|
||||||
editFlags: ["drawing", "tokens"],
|
editFlags: ["drawing", "tokens", "notes"],
|
||||||
notes: {},
|
notes: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -277,6 +277,7 @@ function loadVersions(db) {
|
|||||||
.toCollection()
|
.toCollection()
|
||||||
.modify((state) => {
|
.modify((state) => {
|
||||||
state.notes = {};
|
state.notes = {};
|
||||||
|
state.editFlags = [...state.editFlags, "notes"];
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -463,6 +463,12 @@ function NetworkedMapAndTokens({ session }) {
|
|||||||
currentMapState !== null &&
|
currentMapState !== null &&
|
||||||
(currentMapState.editFlags.includes("fog") || currentMap.owner === userId);
|
(currentMapState.editFlags.includes("fog") || currentMap.owner === userId);
|
||||||
|
|
||||||
|
const canEditNotes =
|
||||||
|
currentMap !== null &&
|
||||||
|
currentMapState !== null &&
|
||||||
|
(currentMapState.editFlags.includes("notes") ||
|
||||||
|
currentMap.owner === userId);
|
||||||
|
|
||||||
const disabledMapTokens = {};
|
const disabledMapTokens = {};
|
||||||
// If we have a map and state and have the token permission disabled
|
// If we have a map and state and have the token permission disabled
|
||||||
// and are not the map owner
|
// and are not the map owner
|
||||||
@ -499,6 +505,7 @@ function NetworkedMapAndTokens({ session }) {
|
|||||||
allowMapDrawing={canEditMapDrawing}
|
allowMapDrawing={canEditMapDrawing}
|
||||||
allowFogDrawing={canEditFogDrawing}
|
allowFogDrawing={canEditFogDrawing}
|
||||||
allowMapChange={canChangeMap}
|
allowMapChange={canChangeMap}
|
||||||
|
allowNoteEditing={canEditNotes}
|
||||||
disabledTokens={disabledMapTokens}
|
disabledTokens={disabledMapTokens}
|
||||||
session={session}
|
session={session}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user