Skip to content

Commit

Permalink
fix(style): resolve small issues for bulk removal
Browse files Browse the repository at this point in the history
Thank you, @a0eoc, for reporting issues and giving suggestions.
  • Loading branch information
vednoc committed Oct 17, 2023
1 parent 5c75f4e commit 33af62c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 25 deletions.
2 changes: 1 addition & 1 deletion handlers/style/ban.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func BanStyle(db *gorm.DB, style *models.Style, u *models.APIUser, user *storage
UserID: u.ID,
Username: u.Username,
Kind: models.LogRemoveStyle,
TargetUserName: style.User.Username,
TargetUserName: user.Username,
TargetData: style.Name,
Reason: strings.TrimSpace(c.FormValue("reason")),
Message: strings.TrimSpace(c.FormValue("message")),
Expand Down
7 changes: 6 additions & 1 deletion handlers/style/bulkban.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ func sendBulkRemovalEmail(user *storage.User, styles []*models.Style, event *mod
"Link": config.BaseURL + "/modlog#id-" + strconv.Itoa(int(event.ID)),
}

title := strconv.Itoa(len(styles)) + " of your style have been removed"
var title string
if len(styles) == 1 {
title = strconv.Itoa(len(styles)) + " of your styles has been removed"
} else {
title = strconv.Itoa(len(styles)) + " of your styles have been removed"
}
if err := email.Send("style/bulkban", user.Email, title, args); err != nil {
log.Warn.Printf("Failed to email %d: %s\n", user.ID, err)
}
Expand Down
36 changes: 13 additions & 23 deletions web/views/style/bulkban.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,24 @@
</section>

<style>
select[multiple] {
width: 100% !important;
border-radius: var(--br-3);
background-color: var(--bg-3);
}
select[multiple] option {
padding: 0.5rem;
font-feature-settings: 'tnum' 1;
}
select[multiple] option:checked {
color: var(--inverse);
background-color: var(--ac-3);
}
.tnum { font-feature-settings: 'tnum' 1 }
</style>

<section class="limit">
<form class="form-wrapper" method="post" action="/styles/bulk-ban/{{ .UserID }}">
<label for="ids">Select which styles to remove</label>
<i class="fg:3">Hold <kbd>CTRL</kbd> to select multiple styles.</i>
<select id="" name="ids" multiple>
{{ range .Styles }}
<option value="{{ .ID }}">
<label for="ids" class="mb:s">Select which styles to remove</label>
{{ range .Styles }}
<div class="checkbox iflex tnum">
<input type="checkbox" name="ids" id="id-{{ .ID }}" value="{{ .ID }}">
{{ template "partials/checkboxes" }}
<label for="id-{{ .ID }}">
{{ .ID }} - {{ .GetSourceCodeCRC32 }} - {{ .Name }}
</option>
{{ end }}
</label>
</div>
{{ end }}
</select>

<label for="reason">Reason for ban</label>
<label for="reason" class="mt:m">Reason for ban</label>
<i class="fg:3">Be aware that this reason will be made public alongside this action.</i>
<input
required
Expand All @@ -45,9 +35,9 @@
placeholder="Your message to the author of this style"></textarea>

<div class="checkbox flex">
<input type="checkbox" name="censor">
<input type="checkbox" name="censor" id="censor">
{{ template "partials/checkboxes" }}
<label class="ml:s" for="censor">Censor style's information</label>
<label for="censor">Censor style's information</label>
</div>
<i class="fg:3">This will censor the information about the styles with a spoiler, use this if the style has an innapropiate name.</i>

Expand Down

0 comments on commit 33af62c

Please sign in to comment.