From 563e8b49e86785112ec440f2e82a3ed387089433 Mon Sep 17 00:00:00 2001 From: hazycora Date: Tue, 26 Sep 2023 01:21:52 -0500 Subject: [PATCH] Add "Unspecified" option to pronouns dropdown --- options/locale/locale_en-US.ini | 1 + routers/web/user/setting/profile.go | 4 ++-- templates/user/settings/profile.tmpl | 5 ++++- web_src/js/features/user-settings.js | 10 ++++++++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index b7237711de..6fa4e6d78f 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -703,6 +703,7 @@ website = Website location = Location pronouns = Pronouns pronouns_custom = Custom +pronouns_unspecified = Unspecified update_theme = Change theme update_profile = Update profile update_language = Change language diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go index 6843340fec..1b1cdb54d4 100644 --- a/routers/web/user/setting/profile.go +++ b/routers/web/user/setting/profile.go @@ -46,7 +46,7 @@ func Profile(ctx *context.Context) { ctx.Data["PageIsSettingsProfile"] = true ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice() ctx.Data["DisableGravatar"] = setting.Config().Picture.DisableGravatar.Value(ctx) - ctx.Data["PronounsAreCustom"] = ctx.Doer.Pronouns != "he/him" && ctx.Doer.Pronouns != "she/her" && ctx.Doer.Pronouns != "they/them" && ctx.Doer.Pronouns != "it/its" + ctx.Data["PronounsAreCustom"] = ctx.Doer.Pronouns != "" && ctx.Doer.Pronouns != "he/him" && ctx.Doer.Pronouns != "she/her" && ctx.Doer.Pronouns != "they/them" && ctx.Doer.Pronouns != "it/its" ctx.HTML(http.StatusOK, tplSettingsProfile) } @@ -57,7 +57,7 @@ func ProfilePost(ctx *context.Context) { ctx.Data["PageIsSettingsProfile"] = true ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice() ctx.Data["DisableGravatar"] = setting.Config().Picture.DisableGravatar.Value(ctx) - ctx.Data["PronounsAreCustom"] = ctx.Doer.Pronouns != "he/him" && ctx.Doer.Pronouns != "she/her" && ctx.Doer.Pronouns != "they/them" && ctx.Doer.Pronouns != "it/its" + ctx.Data["PronounsAreCustom"] = ctx.Doer.Pronouns != "" && ctx.Doer.Pronouns != "he/him" && ctx.Doer.Pronouns != "she/her" && ctx.Doer.Pronouns != "they/them" && ctx.Doer.Pronouns != "it/its" if ctx.HasError() { ctx.HTML(http.StatusOK, tplSettingsProfile) diff --git a/templates/user/settings/profile.tmpl b/templates/user/settings/profile.tmpl index 822651a9db..9d279f23a2 100644 --- a/templates/user/settings/profile.tmpl +++ b/templates/user/settings/profile.tmpl @@ -44,12 +44,15 @@
{{if .PronounsAreCustom}} {{.locale.Tr "settings.pronouns_custom"}} + {{else if eq "" .SignedUser.Pronouns}} + {{.locale.Tr "settings.pronouns_unspecified"}} {{else}} {{.SignedUser.Pronouns}} {{end}}
{{svg "octicon-triangle-down" 14 "dropdown icon"}} diff --git a/web_src/js/features/user-settings.js b/web_src/js/features/user-settings.js index d2617dda6a..ec99f168fe 100644 --- a/web_src/js/features/user-settings.js +++ b/web_src/js/features/user-settings.js @@ -2,15 +2,21 @@ import {hideElem, showElem} from '../utils/dom.js'; function onPronounsDropdownUpdate() { const pronounsCustom = document.getElementById('pronouns-custom'); - const pronounsInput = document.querySelector('#pronouns-dropdown input'); + const pronounsDropdown = document.getElementById('pronouns-dropdown'); + const pronounsInput = pronounsDropdown.querySelector('input'); const isCustom = !( + pronounsInput.value === '' || pronounsInput.value === 'he/him' || pronounsInput.value === 'she/her' || pronounsInput.value === 'they/them' || pronounsInput.value === 'it/its' ); if (isCustom) { - pronounsCustom.value = pronounsInput.value; + if (pronounsInput.value === '!') { + pronounsCustom.value = ''; + } else { + pronounsCustom.value = pronounsInput.value; + } pronounsCustom.style.display = ''; } else { pronounsCustom.style.display = 'none';