Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Fix search in modpanel (@SpamNeko broke it)

Cette révision appartient à :
sfan5 2017-05-14 13:01:59 +02:00
Parent afb2fc7e8c
révision c60a8635fc
3 fichiers modifiés avec 25 ajouts et 4 suppressions

Voir le fichier

@ -110,7 +110,9 @@ func IndexModPanel(w http.ResponseWriter, r *http.Request) {
torrentReports, _, _ := reportService.GetAllTorrentReports(offset, 0) torrentReports, _, _ := reportService.GetAllTorrentReports(offset, 0)
languages.SetTranslationFromRequest(panelIndex, r, "en-us") languages.SetTranslationFromRequest(panelIndex, r, "en-us")
htv := PanelIndexVbs{torrents, model.TorrentReportsToJSON(torrentReports), users, comments, NewSearchForm(), currentUser, r.URL} search := NewSearchForm()
search.ShowItemsPerPage = false
htv := PanelIndexVbs{torrents, model.TorrentReportsToJSON(torrentReports), users, comments, search, currentUser, r.URL}
err := panelIndex.ExecuteTemplate(w, "admin_index.html", htv) err := panelIndex.ExecuteTemplate(w, "admin_index.html", htv)
log.CheckError(err) log.CheckError(err)
} else { } else {

Voir le fichier

@ -196,14 +196,15 @@ type Navigation struct {
type SearchForm struct { type SearchForm struct {
common.SearchParam common.SearchParam
Category string Category string
HideAdvancedSearch bool ShowItemsPerPage bool
} }
// Some Default Values to ease things out // Some Default Values to ease things out
func NewSearchForm() SearchForm { func NewSearchForm() SearchForm {
return SearchForm{ return SearchForm{
Category: "_", Category: "_",
ShowItemsPerPage: true,
} }
} }

Voir le fichier

@ -31,6 +31,7 @@
<option value="2" {{if eq .Search.Status 2}}selected{{end}}>{{T "trusted"}}</option> <option value="2" {{if eq .Search.Status 2}}selected{{end}}>{{T "trusted"}}</option>
<option value="3" {{if eq .Search.Status 3}}selected{{end}}>A+</option> <option value="3" {{if eq .Search.Status 3}}selected{{end}}>A+</option>
</select> </select>
{{ if .Search.ShowItemsPerPage }}
<select id="max" name="max" class="form-control input-sm"> <select id="max" name="max" class="form-control input-sm">
<option value="5" {{if eq .Navigation.MaxItemPerPage 5}}selected{{end}}>5</option> <option value="5" {{if eq .Navigation.MaxItemPerPage 5}}selected{{end}}>5</option>
<option value="10" {{if eq .Navigation.MaxItemPerPage 10}}selected{{end}}>10</option> <option value="10" {{if eq .Navigation.MaxItemPerPage 10}}selected{{end}}>10</option>
@ -48,9 +49,26 @@
<option value="200" {{if eq .Navigation.MaxItemPerPage 200}}selected{{end}}>200</option> <option value="200" {{if eq .Navigation.MaxItemPerPage 200}}selected{{end}}>200</option>
<option value="300" {{if eq .Navigation.MaxItemPerPage 300}}selected{{end}}>300</option> <option value="300" {{if eq .Navigation.MaxItemPerPage 300}}selected{{end}}>300</option>
</select> </select>
{{ end }}
<input type="hidden" name="userID" value="{{ .Search.UserID }}"> <input type="hidden" name="userID" value="{{ .Search.UserID }}">
{{end}} {{end}}
{{/* this is used in the modpanel */}}
{{define "search_advanced"}}
<select name="sort" class="form-control input-sm">
<option value="0" {{if eq .Search.Sort 0}}selected{{end}}>{{T "id"}}</option>
<option value="1" {{if eq .Search.Sort 1}}selected{{end}}>{{T "name"}}</option>
<option value="2" {{if eq .Search.Sort 2}}selected{{end}}>{{T "date"}}</option>
<option value="3" {{if eq .Search.Sort 3}}selected{{end}}>{{T "downloads"}}</option>
<option value="4" {{if eq .Search.Sort 4}}selected{{end}}>{{T "size"}}</option>
<option value="5" {{if eq .Search.Sort 4}}selected{{end}}>{{T "seeders"}}</option>
<option value="6" {{if eq .Search.Sort 4}}selected{{end}}>{{T "leechers"}}</option>
<option value="7" {{if eq .Search.Sort 4}}selected{{end}}>{{T "completed"}}</option>
</select>
<select name="order" class="form-control input-sm">
<option value="false" {{if eq .Search.Order false}}selected{{end}}>{{T "descending"}}</option>
<option value="true" {{if eq .Search.Order true}}selected{{end}}>{{T "ascending"}}</option>
</select>
{{end}}
{{define "search_button"}} {{define "search_button"}}
<div class="input-group"> <div class="input-group">
<input name="q" class="form-control input-sm" placeholder="{{T "search"}}" type="text" value="{{.Search.Query}}"> <input name="q" class="form-control input-sm" placeholder="{{T "search"}}" type="text" value="{{.Search.Query}}">