err error
orderBy models.SearchOrderBy
)
- ctx.Data["SortType"] = ctx.Query("sort")
+ ctx.Data["SortType"] = ctx.Query("sort")
switch ctx.Query("sort") {
+ case "newest":
+ orderBy = models.SearchOrderByNewest
case "oldest":
orderBy = models.SearchOrderByOldest
case "recentupdate":
case "size":
orderBy = models.SearchOrderBySize
default:
- orderBy = models.SearchOrderByNewest
+ ctx.Data["SortType"] = "recentupdate"
+ orderBy = models.SearchOrderByRecentUpdated
}
keyword := strings.Trim(ctx.Query("q"), " ")
ctx.Data["SortType"] = ctx.Query("sort")
switch ctx.Query("sort") {
+ case "newest":
+ orderBy = "id DESC"
case "oldest":
orderBy = "id ASC"
case "recentupdate":
case "alphabetically":
orderBy = "name ASC"
default:
- orderBy = "id DESC"
+ ctx.Data["SortType"] = "alphabetically"
+ orderBy = "name ASC"
}
keyword := strings.Trim(ctx.Query("q"), " ")
orderBy = models.SearchOrderByAlphabetically
default:
ctx.Data["SortType"] = "recentupdate"
- orderBy = models.SearchOrderByNewest
- }
-
- // set default sort value if sort is empty.
- if ctx.Query("sort") == "" {
- ctx.Data["SortType"] = "recentupdate"
+ orderBy = models.SearchOrderByRecentUpdated
}
keyword := strings.Trim(ctx.Query("q"), " ")
<i class="dropdown icon"></i>
</span>
<div class="menu">
- <a class="{{if or (eq .SortType "newest") (not .SortType)}}active{{end}} item" href="{{$.Link}}?sort=newest&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.latest"}}</a>
+ <a class="{{if eq .SortType "newest"}}active{{end}} item" href="{{$.Link}}?sort=newest&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.latest"}}</a>
<a class="{{if eq .SortType "oldest"}}active{{end}} item" href="{{$.Link}}?sort=oldest&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.oldest"}}</a>
<a class="{{if eq .SortType "alphabetically"}}active{{end}} item" href="{{$.Link}}?sort=alphabetically&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.label.filter_sort.alphabetically"}}</a>
<a class="{{if eq .SortType "reversealphabetically"}}active{{end}} item" href="{{$.Link}}?sort=reversealphabetically&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.label.filter_sort.reverse_alphabetically"}}</a>