diff --git a/client/src/components/windows/manage_tags/ManageTagMenu.tsx b/client/src/components/windows/manage_tags/ManageTagMenu.tsx
index 08bd55b..758b689 100644
--- a/client/src/components/windows/manage_tags/ManageTagMenu.tsx
+++ b/client/src/components/windows/manage_tags/ManageTagMenu.tsx
@@ -26,27 +26,34 @@ export function MenuEditText(props: {
}
export interface IProps {
- anchorEl: null | HTMLElement,
+ position: null | number[],
+ open: boolean,
onClose: () => void,
onRename: (s: string) => void,
+ onDelete: () => void,
tag: any,
}
export default function ManageTagMenu(props: IProps) {
- const anchorEl = props.anchorEl;
-
- const onRename = (name: string) => {
-
- }
+ const pos = props.open && props.position ?
+ { left: props.position[0], top: props.position[1] }
+ : { left: 0, top: 0 }
return
}
\ No newline at end of file
diff --git a/client/src/components/windows/manage_tags/ManageTagsWindow.tsx b/client/src/components/windows/manage_tags/ManageTagsWindow.tsx
index 8fc2514..816bf1f 100644
--- a/client/src/components/windows/manage_tags/ManageTagsWindow.tsx
+++ b/client/src/components/windows/manage_tags/ManageTagsWindow.tsx
@@ -106,31 +106,35 @@ export function SingleTag(props: {
const tag = props.tag;
const hasChildren = 'children' in tag && tag.children.length > 0;
- const [menuAnchorEl, setMenuAnchorEl] = React.useState(null);
+ const [menuPos, setMenuPos] = React.useState(null);
const [expanded, setExpanded] = useState(false);
const theme = useTheme();
- const onOpenMenu = (event: any) => {
- setMenuAnchorEl(event.currentTarget);
+ const onOpenMenu = (e: any) => {
+ setMenuPos([e.clientX, e.clientY])
};
const onCloseMenu = () => {
- setMenuAnchorEl(null);
+ setMenuPos(null);
};
- const tagLabel = ("proposedName" in tag) ?
- <>{tag.name}→{tag.proposedName}> :
- tag.name;
+ var tagLabel: any = tag.name;
+ if ("proposedName" in tag) {
+ tagLabel = <>{tag.name}→{tag.proposedName}>;
+ } else if ("proposeDelete" in tag && tag.proposeDelete) {
+ tagLabel = <>{tag.name}>;
+ }
const expandArrow = expanded ?
setExpanded(false)}> :
setExpanded(true)}>;
- const GreyedTag = (props: any) =>
;
@@ -140,22 +144,19 @@ export function SingleTag(props: {
{expandArrow}
{props.prependElems}
-
+
{hasChildren && expanded && tag.children.map((child: any) => ,
+ ,
/]}
dispatch={props.dispatch}
state={props.state}
/>)}
{
props.dispatch({
@@ -170,6 +171,18 @@ export function SingleTag(props: {
]
})
}}
+ onDelete={() => {
+ props.dispatch({
+ type: ManageTagsWindowActions.SetPendingChanges,
+ value: [
+ ...props.state.pendingChanges,
+ {
+ type: TagChangeType.Delete,
+ id: tag.tagId,
+ }
+ ]
+ })
+ }}
tag={tag}
/>
>
@@ -177,11 +190,21 @@ export function SingleTag(props: {
function addTagChanges(tags: Record, changes: TagChange[]) {
var retval = tags;
+
+ const applyDelete = (id: number) => {
+ retval[id].proposeDelete = true;
+ Object.values(tags).filter((t: any) => t.parentId === id)
+ .forEach((child: any) => applyDelete(child.tagId));
+ }
+
changes.forEach((change: TagChange) => {
switch (change.type) {
case TagChangeType.Rename:
retval[change.id].proposedName = change.name;
break;
+ case TagChangeType.Delete:
+ applyDelete(change.id);
+ break;
default:
throw new Error("Unimplemented tag change")
}