Skip to content

Commit

Permalink
remove unused template bits
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanfaerman committed Feb 11, 2024
1 parent 37722f9 commit 11e7e35
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 215 deletions.
214 changes: 0 additions & 214 deletions internal/views/account.templ
Original file line number Diff line number Diff line change
Expand Up @@ -89,222 +89,8 @@ templ (v Account) Profile() {
}
}

templ (v Account) Settings(section string, settings any) {
@Page(v.Nav()) {
<header class="grid-container profile-settings">
@Image(ImageAttrs{
URL: GravatarURL(ctx, v.Account, 48),
Width: 48,
Height: 48,
Extra: templ.Attributes{
"class": "avatar",
},
})
<h1 class="account-name">{ v.Account.Name }</h1>
<p class="context">Settings for your personal profile</p>
</header>
<div class="grid-container left-split with-context">
<div class="nav sidebar">
<!-- sidebar -->
@Nav("", Menu{
{Value: "Public Profile", URL: named.URLFor("settings", "profile"), Icon: IconAttrs{Name: "user", FixedWidth: true}},
{Value: "Privacy", URL: named.URLFor("settings","privacy"), Icon: IconAttrs{Name: "shield-halved", FixedWidth: true}},
{Value: "Avatar", URL: named.URLFor("settings","avatar"), Icon: IconAttrs{Name: "image", Kind: "regular", FixedWidth: true}},
{Value: "Appearance", URL: named.URLFor("settings","appearance"), Icon: IconAttrs{Name: "paintbrush", Kind: "solid", FixedWidth: true}},
})
@Nav("Access", Menu{
{Value: "Billing & Plans", URL: named.URLFor("settings","billing"), Icon: IconAttrs{Name: "credit-card", FixedWidth: true}},
{Value: "Emails", URL: named.URLFor("settings","emails"), Icon: IconAttrs{Name: "envelope", FixedWidth: true}},
{Value: "Sessions", URL: named.URLFor("settings","sessions"), Icon: IconAttrs{Name: "tower-broadcast", FixedWidth: true}},
{Value: "Organizations", URL: named.URLFor("settings", "organizations"), Icon: IconAttrs{Name: "landmark", FixedWidth: true}},
{Value: "Clubs", URL: named.URLFor("settings", "clubs"), Icon: IconAttrs{Name: "people-group", FixedWidth: true}},
})
@Nav("Archives", Menu{
{Value: "Checkins", URL: "#", Icon: IconAttrs{Name: "list-check", FixedWidth: true}},
{Value: "Security Logs", URL: "#", Icon: IconAttrs{Name: "scroll", FixedWidth: true}},
})
</div>
<div>
<!-- main content -->
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)
}
</div>
<div>
<!-- context content -->
switch section {
case "profile":
<a href={ templ.URL(named.URLFor("account-profile", v.Account.Callsign().Call)) } class="button">
View Public Profile
</a>
case "privacy":
@v.PrivacyContext()
case "organizations":
@v.MembershipContext(models.AccountKindOrganization)
case "clubs":
@v.MembershipContext(models.AccountKindClub)
}
</div>
</div>
}
}

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() {
<div class="callout notice">
<strong>A note about privacy</strong>
<p>
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.
</p>
<p>
Government records are generally publicly available and
much of the information will be accessible according to the laws in your country.
</p>
</div>
}

templ (v Account) AvatarForm() {
<p>
Your avatar is managed with gravatar, a service that links your
email address with an image of your choosing.
</p>
}

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?
<a href={ templ.URL(named.URLFor("group-new", kind.String())) } class="button">
Create a club
</a>
} else {
<h3>{ kind.String() } Memberships</h3>
<div class="membership-list">
for _, m := range v.Memberships {
<div class="membership">
<div class="group">
<a href="#">
{ m.Target.Name }
</a>
<span class="role badge">{ m.Role.Name }</span>
</div>
<div class="actions">
<a href="#" class="button">Settings</a>
<a href="#" class="button danger">Leave</a>
</div>
</div>
}
</div>
}
}

templ (v Account) MembershipContext(kind models.AccountKind) {
<a href={ templ.URL(named.URLFor("group-new", kind.String())) } class="button">
Create a { kind.String() }
</a>
}

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",
})
}
}
4 changes: 3 additions & 1 deletion internal/views/settings.templ
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ templ (v Settings) ProfileForm(val models.ProfileSettings, errs map[string]strin
}

templ (v Settings) ProfileContext() {
something context
<a href={ templ.URL(named.URLFor("account-profile", v.Account.Slug)) } class="button">
View Public Profile
</a>
}

templ (v Settings) PrivacyForm(val models.PrivacySettings, errs map[string]string) {
Expand Down

0 comments on commit 11e7e35

Please sign in to comment.