summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-04-30 21:12:49 +0800
committerGitHub <noreply@github.com>2023-04-30 09:12:49 -0400
commit3f0651d4d61d62a16e1bb672056014ab02db5746 (patch)
tree035e1fd9edf7383b0abad6e89c2db4cd2b8a2355 /routers
parente3750370df3be1413b1526668cbee60dc2a39f03 (diff)
downloadgitea-3f0651d4d61d62a16e1bb672056014ab02db5746.tar.gz
gitea-3f0651d4d61d62a16e1bb672056014ab02db5746.zip
Improve milestone filter on issues page (#22423)
Now we have `All milestones`, `No milestones`, `Open milestones` and `Closed milestones`. Fix #11924 Fix #22411 <img width="1166" alt="image" src="https://user-images.githubusercontent.com/81045/212243375-95eea035-a972-44b8-8088-53db614cb07e.png">
Diffstat (limited to 'routers')
-rw-r--r--routers/web/repo/issue.go31
1 files changed, 24 insertions, 7 deletions
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go
index 49ea4f2a1f..5c96d326a7 100644
--- a/routers/web/repo/issue.go
+++ b/routers/web/repo/issue.go
@@ -241,7 +241,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
pager := context.NewPagination(total, setting.UI.IssuePagingNum, page, 5)
var mileIDs []int64
- if milestoneID > 0 {
+ if milestoneID > 0 || milestoneID == db.NoConditionID { // -1 to get those issues which have no any milestone assigned
mileIDs = []int64{milestoneID}
}
@@ -438,20 +438,37 @@ func Issues(ctx *context.Context) {
return
}
- var err error
+ renderMilestones(ctx)
+ if ctx.Written() {
+ return
+ }
+
+ ctx.Data["CanWriteIssuesOrPulls"] = ctx.Repo.CanWriteIssuesOrPulls(isPullList)
+
+ ctx.HTML(http.StatusOK, tplIssues)
+}
+
+func renderMilestones(ctx *context.Context) {
// Get milestones
- ctx.Data["Milestones"], _, err = issues_model.GetMilestones(issues_model.GetMilestonesOption{
+ milestones, _, err := issues_model.GetMilestones(issues_model.GetMilestonesOption{
RepoID: ctx.Repo.Repository.ID,
- State: api.StateType(ctx.FormString("state")),
+ State: api.StateAll,
})
if err != nil {
ctx.ServerError("GetAllRepoMilestones", err)
return
}
- ctx.Data["CanWriteIssuesOrPulls"] = ctx.Repo.CanWriteIssuesOrPulls(isPullList)
-
- ctx.HTML(http.StatusOK, tplIssues)
+ openMilestones, closedMilestones := issues_model.MilestoneList{}, issues_model.MilestoneList{}
+ for _, milestone := range milestones {
+ if milestone.IsClosed {
+ closedMilestones = append(closedMilestones, milestone)
+ } else {
+ openMilestones = append(openMilestones, milestone)
+ }
+ }
+ ctx.Data["OpenMilestones"] = openMilestones
+ ctx.Data["ClosedMilestones"] = closedMilestones
}
// RetrieveRepoMilestonesAndAssignees find all the milestones and assignees of a repository