diff --git a/internal/views/account.templ b/internal/views/account.templ index 00d4a99..5b51190 100644 --- a/internal/views/account.templ +++ b/internal/views/account.templ @@ -89,222 +89,8 @@ templ (v Account) Profile() { } } -templ (v Account) Settings(section string, settings any) { - @Page(v.Nav()) { -
- @Image(ImageAttrs{ - URL: GravatarURL(ctx, v.Account, 48), - Width: 48, - Height: 48, - Extra: templ.Attributes{ - "class": "avatar", - }, - }) -

{ v.Account.Name }

-

Settings for your personal profile

-
-
- -
- - switch section { - case "profile": - @v.EditForm() - case "privacy": - @v.PrivacyForm(settings.(models.PrivacySettings)) - case "avatar": - @v.AvatarForm() - case "appearance": - @v.AppearanceForm(settings.(models.AppearanceSettings)) - case "clubs": - @v.MembershipOverview(models.AccountKindClub) - case "organizations": - @v.MembershipOverview(models.AccountKindOrganization) - } -
-
- - switch section { - case "profile": - - View Public Profile - - case "privacy": - @v.PrivacyContext() - case "organizations": - @v.MembershipContext(models.AccountKindOrganization) - case "clubs": - @v.MembershipContext(models.AccountKindClub) - } -
-
- } -} - -templ (v Account) PrivacyForm(val models.PrivacySettings) { - @Form("privacy", FormAttrs{ - Action: named.URLFor("settings-save", "privacy"), - - }) { - @InputRadioGroup("location", InputAttrs{ - Label: "Show location on profile?", - Values: []InputValue{ - {Value: "public", Label: "Yes", HelpText: "Anyone can see your location"}, - {Value: "protected", Label: "Users Only", HelpText: "Only users with an account will see your location"}, - {Value: "private", Label: "No", HelpText: "Your location won't be directly visible on your profile"}, - }, - Value: val.Location, - HelpText: "Control how your location is shared.", - }) - @InputRadioGroup("visibility", InputAttrs{ - Label: "Profile visiblity", - Values: []InputValue{ - {Value: "public", Label: "Yes", HelpText: "Anyone can see your profile"}, - {Value: "protected", Label: "Users Only", HelpText: "Only users with an account can see your profile"}, - {Value: "private", Label: "Private", HelpText: "Don't show up in any search results"}, - }, - Value: val.Visiblility, - HelpText: "Manage overall profile visiblity.", - }) - @InputSubmit(InputAttrs{ - Value: "Save", - }) - } -} - -templ (v Account) AppearanceForm(val models.AppearanceSettings) { - @Form("appearance", FormAttrs{ - Action: named.URLFor("settings-save", "appearance"), - }) { - @InputRadioGroup("activity-graphs", InputAttrs{ - Label: "Activity Graph", - Values: []InputValue{ - {Value: "on", Label: "Enable activity graphs", HelpText: "Show the activity graph on your profile?"}, - {Value: "off", Label: "Disable Activity Graph", HelpText: "Show the activity graph on your profile?"}, - }, - Value: val.ActivityGraphs, - }) - @InputSubmit(InputAttrs{ - Value: "Save", - }) - } -} - -templ (v Account) PrivacyContext() { -
- A note about privacy -

- It's important to remember that, while we will do our best to enforce - these privacy settings, your callsign is an identifier with the FCC or - other government agency. -

-

- Government records are generally publicly available and - much of the information will be accessible according to the laws in your country. -

-
-} - -templ (v Account) AvatarForm() { -

- Your avatar is managed with gravatar, a service that links your - email address with an image of your choosing. -

-} - -templ (v Account) MembershipOverview(kind models.AccountKind) { - if len(v.Memberships) == 0 { - Looks like you don't have any memberships yet. - Wanna join a club? - - Create a club - - } else { -

{ kind.String() } Memberships

-
- for _, m := range v.Memberships { -
-
- - { m.Target.Name } - - { m.Role.Name } -
-
- Settings - Leave -
-
- } -
- } -} - templ (v Account) MembershipContext(kind models.AccountKind) { Create a { kind.String() } } - -type AccountEditFormInput struct { - Name string - About string -} - -type AccountEditFormErrors struct { - Name string - About string -} - -templ (v Account) EditForm() { - @v.EditFormWithErrors( - AccountEditFormInput{ - Name: v.Account.Name, - About: v.Account.About, - - }, - AccountEditFormErrors{}, - ) -} - -templ (v Account) EditFormWithErrors(input AccountEditFormInput, inputErrs AccountEditFormErrors) { - @Form("edit-account", FormAttrs{ - Action: named.URLFor("account-edit-save", v.Account.Callsign().Call), - }) { - @InputText("name", InputAttrs{ - Label: "Name", - Value: input.Name, - Error: inputErrs.Name, - HelpText: "Your name as you'd like to be called on the air", - }) - @InputTextArea("about", InputAttrs{ - Label: "About you", - Placeholder: "Tell us about yourself", - Value: input.About, - Error: inputErrs.About, - Height: "30rem", - }) - @InputSubmit(InputAttrs{ - Value: "Save", - }) - } -} diff --git a/internal/views/settings.templ b/internal/views/settings.templ index f32559d..98c0d17 100644 --- a/internal/views/settings.templ +++ b/internal/views/settings.templ @@ -166,7 +166,9 @@ templ (v Settings) ProfileForm(val models.ProfileSettings, errs map[string]strin } templ (v Settings) ProfileContext() { - something context + + View Public Profile + } templ (v Settings) PrivacyForm(val models.PrivacySettings, errs map[string]string) {