Add dashboard milestone search and repo milestone search by name (#14866)
Feature for issue #13845: - Add milestones search by name on dashboard milestones page. - Add milestones search by name on repo issue/milestones page.
This commit is contained in:
parent
0d1a5e0ffc
commit
fa06e98553
5 changed files with 165 additions and 58 deletions
|
@ -6,6 +6,7 @@ package repo
|
|||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
|
@ -44,6 +45,9 @@ func Milestones(ctx *context.Context) {
|
|||
ctx.Data["ClosedCount"] = stats.ClosedCount
|
||||
|
||||
sortType := ctx.Query("sort")
|
||||
|
||||
keyword := strings.Trim(ctx.Query("q"), " ")
|
||||
|
||||
page := ctx.QueryInt("page")
|
||||
if page <= 1 {
|
||||
page = 1
|
||||
|
@ -67,6 +71,7 @@ func Milestones(ctx *context.Context) {
|
|||
RepoID: ctx.Repo.Repository.ID,
|
||||
State: state,
|
||||
SortType: sortType,
|
||||
Name: keyword,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetMilestones", err)
|
||||
|
@ -90,10 +95,12 @@ func Milestones(ctx *context.Context) {
|
|||
}
|
||||
|
||||
ctx.Data["SortType"] = sortType
|
||||
ctx.Data["Keyword"] = keyword
|
||||
ctx.Data["IsShowClosed"] = isShowClosed
|
||||
|
||||
pager := context.NewPagination(total, setting.UI.IssuePagingNum, page, 5)
|
||||
pager.AddParam(ctx, "state", "State")
|
||||
pager.AddParam(ctx, "q", "Keyword")
|
||||
ctx.Data["Page"] = pager
|
||||
|
||||
ctx.HTML(http.StatusOK, tplMilestone)
|
||||
|
|
|
@ -202,6 +202,7 @@ func Milestones(ctx *context.Context) {
|
|||
isShowClosed = ctx.Query("state") == "closed"
|
||||
sortType = ctx.Query("sort")
|
||||
page = ctx.QueryInt("page")
|
||||
keyword = strings.Trim(ctx.Query("q"), " ")
|
||||
)
|
||||
|
||||
if page <= 1 {
|
||||
|
@ -234,15 +235,15 @@ func Milestones(ctx *context.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
counts, err := models.CountMilestonesByRepoCond(userRepoCond, isShowClosed)
|
||||
counts, err := models.CountMilestonesByRepoCondAndKw(userRepoCond, keyword, isShowClosed)
|
||||
if err != nil {
|
||||
ctx.ServerError("CountMilestonesByRepoIDs", err)
|
||||
return
|
||||
}
|
||||
|
||||
milestones, err := models.SearchMilestones(repoCond, page, isShowClosed, sortType)
|
||||
milestones, err := models.SearchMilestones(repoCond, page, isShowClosed, sortType, keyword)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetMilestonesByRepoIDs", err)
|
||||
ctx.ServerError("SearchMilestones", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -277,7 +278,7 @@ func Milestones(ctx *context.Context) {
|
|||
i++
|
||||
}
|
||||
|
||||
milestoneStats, err := models.GetMilestonesStatsByRepoCond(repoCond)
|
||||
milestoneStats, err := models.GetMilestonesStatsByRepoCondAndKw(repoCond, keyword)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetMilestoneStats", err)
|
||||
return
|
||||
|
@ -287,7 +288,7 @@ func Milestones(ctx *context.Context) {
|
|||
if len(repoIDs) == 0 {
|
||||
totalMilestoneStats = milestoneStats
|
||||
} else {
|
||||
totalMilestoneStats, err = models.GetMilestonesStatsByRepoCond(userRepoCond)
|
||||
totalMilestoneStats, err = models.GetMilestonesStatsByRepoCondAndKw(userRepoCond, keyword)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetMilestoneStats", err)
|
||||
return
|
||||
|
@ -310,12 +311,14 @@ func Milestones(ctx *context.Context) {
|
|||
ctx.Data["Counts"] = counts
|
||||
ctx.Data["MilestoneStats"] = milestoneStats
|
||||
ctx.Data["SortType"] = sortType
|
||||
ctx.Data["Keyword"] = keyword
|
||||
if milestoneStats.Total() != totalMilestoneStats.Total() {
|
||||
ctx.Data["RepoIDs"] = repoIDs
|
||||
}
|
||||
ctx.Data["IsShowClosed"] = isShowClosed
|
||||
|
||||
pager := context.NewPagination(pagerCount, setting.UI.IssuePagingNum, page, 5)
|
||||
pager.AddParam(ctx, "q", "Keyword")
|
||||
pager.AddParam(ctx, "repos", "RepoIDs")
|
||||
pager.AddParam(ctx, "sort", "SortType")
|
||||
pager.AddParam(ctx, "state", "State")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue