Added sorting to the labels & milestones page (#199)

This commit is contained in:
Bwko 2016-12-24 15:41:09 +01:00 committed by Lunny Xiao
parent f27d87d93b
commit a345a03d99
7 changed files with 82 additions and 13 deletions

View file

@ -15,7 +15,7 @@ import (
// ListLabels list all the labels of a repository
func ListLabels(ctx *context.APIContext) {
labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID)
labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, ctx.Query("sort"))
if err != nil {
ctx.Error(500, "GetLabelsByRepoID", err)
return

View file

@ -82,7 +82,7 @@ func MustAllowPulls(ctx *context.Context) {
// RetrieveLabels find all the labels of a repository
func RetrieveLabels(ctx *context.Context) {
labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID)
labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, ctx.Query("sort"))
if err != nil {
ctx.Handle(500, "RetrieveLabels.GetLabels", err)
return
@ -92,6 +92,7 @@ func RetrieveLabels(ctx *context.Context) {
}
ctx.Data["Labels"] = labels
ctx.Data["NumLabels"] = len(labels)
ctx.Data["SortType"] = ctx.Query("sort")
}
// Issues render issues page
@ -274,12 +275,12 @@ func renderAttachmentSettings(ctx *context.Context) {
// RetrieveRepoMilestonesAndAssignees find all the milestones and assignees of a repository
func RetrieveRepoMilestonesAndAssignees(ctx *context.Context, repo *models.Repository) {
var err error
ctx.Data["OpenMilestones"], err = models.GetMilestones(repo.ID, -1, false)
ctx.Data["OpenMilestones"], err = models.GetMilestones(repo.ID, -1, false, "")
if err != nil {
ctx.Handle(500, "GetMilestones", err)
return
}
ctx.Data["ClosedMilestones"], err = models.GetMilestones(repo.ID, -1, true)
ctx.Data["ClosedMilestones"], err = models.GetMilestones(repo.ID, -1, true, "")
if err != nil {
ctx.Handle(500, "GetMilestones", err)
return
@ -298,7 +299,7 @@ func RetrieveRepoMetas(ctx *context.Context, repo *models.Repository) []*models.
return nil
}
labels, err := models.GetLabelsByRepoID(repo.ID)
labels, err := models.GetLabelsByRepoID(repo.ID, "")
if err != nil {
ctx.Handle(500, "GetLabelsByRepoID", err)
return nil
@ -583,7 +584,7 @@ func ViewIssue(ctx *context.Context) {
for i := range issue.Labels {
labelIDMark[issue.Labels[i].ID] = true
}
labels, err := models.GetLabelsByRepoID(repo.ID)
labels, err := models.GetLabelsByRepoID(repo.ID, "")
if err != nil {
ctx.Handle(500, "GetLabelsByRepoID", err)
return
@ -1079,6 +1080,7 @@ func Milestones(ctx *context.Context) {
ctx.Data["OpenCount"] = openCount
ctx.Data["ClosedCount"] = closedCount
sortType := ctx.Query("sort")
page := ctx.QueryInt("page")
if page <= 1 {
page = 1
@ -1092,7 +1094,7 @@ func Milestones(ctx *context.Context) {
}
ctx.Data["Page"] = paginater.New(total, setting.UI.IssuePagingNum, page, 5)
miles, err := models.GetMilestones(ctx.Repo.Repository.ID, page, isShowClosed)
miles, err := models.GetMilestones(ctx.Repo.Repository.ID, page, isShowClosed, sortType)
if err != nil {
ctx.Handle(500, "GetMilestones", err)
return
@ -1108,6 +1110,7 @@ func Milestones(ctx *context.Context) {
ctx.Data["State"] = "open"
}
ctx.Data["SortType"] = sortType
ctx.Data["IsShowClosed"] = isShowClosed
ctx.HTML(200, tplMilestone)
}