diff --git a/frontend/src/routes/edit/EditableField.svelte b/frontend/src/routes/edit/EditableField.svelte index 68b81f1..72b1ad0 100644 --- a/frontend/src/routes/edit/EditableField.svelte +++ b/frontend/src/routes/edit/EditableField.svelte @@ -6,6 +6,7 @@ export let field: Field; export let deleteField: () => void; + export let moveField: (up: boolean) => void; let newEntry: string = ""; @@ -31,12 +32,26 @@ }; -
+
+
{field.name}
- Name + moveField(true)} + /> + moveField(false)} + /> + +
{#each field.entries as _, index} { + if (up && index == 0) return; + if (!up && index == fields.length - 1) return; + + const newIndex = up ? index - 1 : index + 1; + + const temp = fields[index]; + fields[index] = fields[newIndex]; + fields[newIndex] = temp; + }; + const addName = () => { names = [...names, { value: newName, status: WordStatus.Okay }]; newName = ""; @@ -425,7 +436,11 @@
{#each fields as _, index} - removeField(index)} /> + removeField(index)} + moveField={(up) => moveField(index, up)} + /> {/each}
diff --git a/frontend/src/routes/edit/profile/+page.svelte b/frontend/src/routes/edit/profile/+page.svelte index faec515..eae1a32 100644 --- a/frontend/src/routes/edit/profile/+page.svelte +++ b/frontend/src/routes/edit/profile/+page.svelte @@ -150,6 +150,17 @@ pronouns[newIndex] = temp; }; + const moveField = (index: number, up: boolean) => { + if (up && index == 0) return; + if (!up && index == fields.length - 1) return; + + const newIndex = up ? index - 1 : index + 1; + + const temp = fields[index]; + fields[index] = fields[newIndex]; + fields[newIndex] = temp; + }; + const addName = () => { names = [...names, { value: newName, status: WordStatus.Okay }]; newName = ""; @@ -367,7 +378,11 @@
{#each fields as _, index} - removeField(index)} /> + removeField(index)} + moveField={(up) => moveField(index, up)} + /> {/each}