Working on merge into. Cannot be applied yet.

pull/24/head
Sander Vocke 5 years ago
parent ff800978d1
commit 045cdc51e2
  1. 12
      client/src/components/windows/manage_tags/ManageTagMenu.tsx
  2. 20
      client/src/components/windows/manage_tags/ManageTagsWindow.tsx
  3. 5
      client/src/components/windows/manage_tags/TagChange.tsx

@ -34,7 +34,7 @@ export default function ManageTagMenu(props: {
onRename: (s: string) => void, onRename: (s: string) => void,
onDelete: () => void, onDelete: () => void,
onMove: (to: string | null) => void, onMove: (to: string | null) => void,
onCreateChild: (name: string) => void, onMergeInto: (to: string) => void,
tag: any, tag: any,
changedTags: any[], // Tags organized hierarchically with "children" fields changedTags: any[], // Tags organized hierarchically with "children" fields
}) { }) {
@ -76,5 +76,15 @@ export default function ManageTagMenu(props: {
props.onMove(v); props.onMove(v);
}} /> }} />
</NestedMenuItem> </NestedMenuItem>
<NestedMenuItem
parentMenuOpen={props.open}
label="Merge into"
>
<PickTag tags={props.changedTags} open={props.open} root={false} onPick={(v: string | null) => {
if(v === null) { return; }
props.onClose();
props.onMergeInto(v);
}} />
</NestedMenuItem>
</Menu> </Menu>
} }

@ -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} tag={tag}
changedTags={props.changedTags} changedTags={props.changedTags}
@ -230,6 +240,9 @@ function annotateTagsWithChanges(tags: Record<string, any>, changes: TagChange[]
case TagChangeType.MoveTo: case TagChangeType.MoveTo:
retval[change.id].proposedParent = change.parent; retval[change.id].proposedParent = change.parent;
break; break;
case TagChangeType.MergeTo:
retval[change.id].proposedMergeInto = change.into;
break;
case TagChangeType.Create: case TagChangeType.Create:
retval[change.id] = { retval[change.id] = {
isNewTag: true, isNewTag: true,
@ -270,6 +283,9 @@ function applyTagsChanges(tags: Record<string, any>, changes: TagChange[]) {
retval[change.id].parentId = change.parent; retval[change.id].parentId = change.parent;
if (change.parent === null) { delete retval[change.id].parentId; } if (change.parent === null) { delete retval[change.id].parentId; }
break; break;
case TagChangeType.MergeTo:
applyDelete(change.id);
break;
case TagChangeType.Create: case TagChangeType.Create:
retval[change.id] = { retval[change.id] = {
name: change.name, name: change.name,

@ -20,6 +20,7 @@ export interface TagChange {
parent?: string | null, // Stringified integer == MuDBase ID. Other string == not yet committed to DB. parent?: string | null, // Stringified integer == MuDBase ID. Other string == not yet committed to DB.
// null refers to the tags root. // null refers to the tags root.
name?: string, 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[]) { export async function submitTagChanges(changes: TagChange[]) {
@ -103,6 +104,10 @@ export function TagChangeDisplay(props: {
<MakeTag name={newParent ? newParent.name : "/"} /> : <MakeTag name={newParent ? newParent.name : "/"} /> :
<CircularProgress />; <CircularProgress />;
return <Typography>Move {MainTag} from {OldParent} to {NewParent}</Typography> return <Typography>Move {MainTag} from {OldParent} to {NewParent}</Typography>
case TagChangeType.MergeTo:
const intoTag = props.getTagDetails(props.change.into || "unknown");
const IntoTag = <MakeTag name={intoTag.name} />
return <Typography>Merge {MainTag} into {IntoTag}</Typography>
case TagChangeType.Create: case TagChangeType.Create:
return props.change.parent ? return props.change.parent ?
<Typography>Create {MainTag} under <MakeTag name={newParent.name} /></Typography> : <Typography>Create {MainTag} under <MakeTag name={newParent.name} /></Typography> :

Loading…
Cancel
Save