diff --git a/frontend/src/lib/components/IconButton.svelte b/frontend/src/lib/components/IconButton.svelte index 580e63d..16473c5 100644 --- a/frontend/src/lib/components/IconButton.svelte +++ b/frontend/src/lib/components/IconButton.svelte @@ -6,6 +6,7 @@ export let tooltip: string; export let active: boolean = false; export let disabled: boolean = false; + export let type: string | undefined = undefined; export let click: ((e: MouseEvent) => void) | undefined = undefined; export let href: string | undefined = undefined; @@ -14,6 +15,6 @@ {tooltip} - + diff --git a/frontend/src/routes/edit/EditableField.svelte b/frontend/src/routes/edit/EditableField.svelte index afa5fcc..446fe71 100644 --- a/frontend/src/routes/edit/EditableField.svelte +++ b/frontend/src/routes/edit/EditableField.svelte @@ -10,7 +10,9 @@ let newEntry: string = ""; - const addEntry = () => { + const addEntry = (event: Event) => { + event.preventDefault(); + field.entries = [...field.entries, { value: newEntry, status: WordStatus.Okay }]; newEntry = ""; }; @@ -61,8 +63,8 @@ /> {/each} - + - addEntry()} /> - + + diff --git a/frontend/src/routes/edit/member/[id]/+page.svelte b/frontend/src/routes/edit/member/[id]/+page.svelte index c8e701f..8b8c029 100644 --- a/frontend/src/routes/edit/member/[id]/+page.svelte +++ b/frontend/src/routes/edit/member/[id]/+page.svelte @@ -20,6 +20,7 @@ Modal, ModalBody, ModalFooter, + Popover, } from "sveltestrap"; import { encode } from "base64-arraybuffer"; import { apiFetchClient, fastFetchClient } from "$lib/api/fetch"; @@ -59,7 +60,6 @@ let newName = ""; let newPronouns = ""; - let newPronounsDisplay = ""; let newLink = ""; let modified = false; @@ -169,21 +169,38 @@ fields[newIndex] = temp; }; - const addName = () => { + const addName = (event: Event) => { + event.preventDefault(); + names = [...names, { value: newName, status: WordStatus.Okay }]; newName = ""; }; - const addPronouns = () => { - pronouns = [ - ...pronouns, - { pronouns: newPronouns, display_text: newPronounsDisplay || null, status: WordStatus.Okay }, - ]; + const addPronouns = (event: Event) => { + event.preventDefault(); + + if (newPronouns in data.pronouns) { + const fullSet = data.pronouns[newPronouns]; + pronouns = [ + ...pronouns, + { + pronouns: fullSet.pronouns.join("/"), + display_text: fullSet.display || null, + status: WordStatus.Okay, + }, + ]; + } else { + pronouns = [ + ...pronouns, + { pronouns: newPronouns, display_text: null, status: WordStatus.Okay }, + ]; + } newPronouns = ""; - newPronounsDisplay = ""; }; - const addLink = () => { + const addLink = (event: Event) => { + event.preventDefault(); + links = [...links, newLink]; newLink = ""; }; @@ -375,9 +392,10 @@ - - - + + Bio ({bio.length}/{MAX_DESCRIPTION_LENGTH}) + + Your bio supports limited removeName(index)} /> {/each} - + - addName()} /> - + + Links @@ -420,10 +438,10 @@ /> {/each} - + - addLink()} /> - + + @@ -437,27 +455,43 @@ remove={() => removePronoun(index)} /> {/each} - + - addPronouns()} + disabled={newPronouns === ""} /> - + + + + + + For common pronouns, the short form (e.g. "she/her" or "he/him") is enough; for less + common pronouns, you will have to use all five forms (e.g. "ce/cir/cir/cirs/cirself"). + + + diff --git a/frontend/src/routes/edit/member/[id]/+page.ts b/frontend/src/routes/edit/member/[id]/+page.ts index e69d1fc..b695c60 100644 --- a/frontend/src/routes/edit/member/[id]/+page.ts +++ b/frontend/src/routes/edit/member/[id]/+page.ts @@ -1,7 +1,10 @@ -import type { MeUser, APIError, Member } from "$lib/api/entities"; +import type { MeUser, APIError, Member, PronounsJson } from "$lib/api/entities"; import { apiFetchClient } from "$lib/api/fetch"; import { error } from "@sveltejs/kit"; +import pronounsRaw from "$lib/pronouns.json"; +const pronouns = pronounsRaw as PronounsJson; + export const ssr = false; export const load = async ({ params }) => { @@ -12,6 +15,7 @@ export const load = async ({ params }) => { return { user, member, + pronouns: pronouns.autocomplete, }; } catch (e) { throw error((e as APIError).code, (e as APIError).message); diff --git a/frontend/src/routes/edit/profile/+page.svelte b/frontend/src/routes/edit/profile/+page.svelte index 3e32438..6663a09 100644 --- a/frontend/src/routes/edit/profile/+page.svelte +++ b/frontend/src/routes/edit/profile/+page.svelte @@ -148,12 +148,16 @@ fields[newIndex] = temp; }; - const addName = () => { + const addName = (event: Event) => { + event.preventDefault(); + names = [...names, { value: newName, status: WordStatus.Okay }]; newName = ""; }; - const addPronouns = () => { + const addPronouns = (event: Event) => { + event.preventDefault(); + if (newPronouns in data.pronouns) { const fullSet = data.pronouns[newPronouns]; pronouns = [ @@ -173,7 +177,9 @@ newPronouns = ""; }; - const addLink = () => { + const addLink = (event: Event) => { + event.preventDefault(); + links = [...links, newLink]; newLink = ""; }; @@ -297,9 +303,10 @@ - - - + + Bio ({bio.length}/{MAX_DESCRIPTION_LENGTH}) + + Your bio supports limited removeName(index)} /> {/each} - + - addName()} /> - + + Links @@ -342,10 +349,10 @@ /> {/each} - + - addLink()} /> - + + @@ -359,7 +366,7 @@ remove={() => removePronoun(index)} /> {/each} - + addPronouns()} /> For common pronouns, the short form (e.g. "she/her" or "he/him") is enough; for less common pronouns, you will have to use all five forms (e.g. "ce/cir/cir/cirs/cirself"). - +
Your bio supports limited removeName(index)} /> {/each} - + - addName()} /> - + +