diff --git a/client/src/components/windows/manage_tags/ManageTagMenu.tsx b/client/src/components/windows/manage_tags/ManageTagMenu.tsx index f1dde4c..3ed9a8f 100644 --- a/client/src/components/windows/manage_tags/ManageTagMenu.tsx +++ b/client/src/components/windows/manage_tags/ManageTagMenu.tsx @@ -34,7 +34,7 @@ export default function ManageTagMenu(props: { onRename: (s: string) => void, onDelete: () => void, onMove: (to: string | null) => void, - onCreateChild: (name: string) => void, + onMergeInto: (to: string) => void, tag: any, changedTags: any[], // Tags organized hierarchically with "children" fields }) { @@ -76,5 +76,15 @@ export default function ManageTagMenu(props: { props.onMove(v); }} /> + + { + if(v === null) { return; } + props.onClose(); + props.onMergeInto(v); + }} /> + } \ 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 b828ef8..4fd9cbc 100644 --- a/client/src/components/windows/manage_tags/ManageTagsWindow.tsx +++ b/client/src/components/windows/manage_tags/ManageTagsWindow.tsx @@ -201,8 +201,18 @@ export function SingleTag(props: { ] }) }} - onCreateChild={(name: string) => { - + onMergeInto={(into: string) => { + props.dispatch({ + type: ManageTagsWindowActions.SetPendingChanges, + value: [ + ...props.state.pendingChanges, + { + type: TagChangeType.MergeTo, + id: tag.tagId, + into: into, + } + ] + }) }} tag={tag} changedTags={props.changedTags} @@ -230,6 +240,9 @@ function annotateTagsWithChanges(tags: Record, changes: TagChange[] case TagChangeType.MoveTo: retval[change.id].proposedParent = change.parent; break; + case TagChangeType.MergeTo: + retval[change.id].proposedMergeInto = change.into; + break; case TagChangeType.Create: retval[change.id] = { isNewTag: true, @@ -270,6 +283,9 @@ function applyTagsChanges(tags: Record, changes: TagChange[]) { retval[change.id].parentId = change.parent; if (change.parent === null) { delete retval[change.id].parentId; } break; + case TagChangeType.MergeTo: + applyDelete(change.id); + break; case TagChangeType.Create: retval[change.id] = { name: change.name, diff --git a/client/src/components/windows/manage_tags/TagChange.tsx b/client/src/components/windows/manage_tags/TagChange.tsx index b15b160..b573ecd 100644 --- a/client/src/components/windows/manage_tags/TagChange.tsx +++ b/client/src/components/windows/manage_tags/TagChange.tsx @@ -20,6 +20,7 @@ export interface TagChange { parent?: string | null, // Stringified integer == MuDBase ID. Other string == not yet committed to DB. // null refers to the tags root. name?: string, + into?: string, // Used for storing the tag ID to merge into, if applicable. As in the other ID fields. } export async function submitTagChanges(changes: TagChange[]) { @@ -103,6 +104,10 @@ export function TagChangeDisplay(props: { : ; return Move {MainTag} from {OldParent} to {NewParent} + case TagChangeType.MergeTo: + const intoTag = props.getTagDetails(props.change.into || "unknown"); + const IntoTag = + return Merge {MainTag} into {IntoTag} case TagChangeType.Create: return props.change.parent ? Create {MainTag} under :