aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models/issue.go26
-rw-r--r--routers/repo/issue.go40
-rw-r--r--templates/issue/create.tmpl28
-rw-r--r--templates/issue/view.tmpl6
4 files changed, 70 insertions, 30 deletions
diff --git a/models/issue.go b/models/issue.go
index 26380b6033..3d3e433a42 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -543,18 +543,20 @@ func ChangeMilestoneAssign(oldMid, mid int64, isIssueClosed bool) (err error) {
}
}
- m, err := GetMilestoneById(mid)
- if err != nil {
- return err
- }
- m.NumIssues++
- if isIssueClosed {
- m.NumClosedIssues++
- }
- m.Completeness = m.NumClosedIssues * 100 / m.NumIssues
- if _, err = sess.Id(m.Id).Update(m); err != nil {
- sess.Rollback()
- return err
+ if mid > 0 {
+ m, err := GetMilestoneById(mid)
+ if err != nil {
+ return err
+ }
+ m.NumIssues++
+ if isIssueClosed {
+ m.NumClosedIssues++
+ }
+ m.Completeness = m.NumClosedIssues * 100 / m.NumIssues
+ if _, err = sess.Id(m.Id).Update(m); err != nil {
+ sess.Rollback()
+ return err
+ }
}
return sess.Commit()
}
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 2346539d0c..7b8c912e69 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -53,17 +53,21 @@ func Issues(ctx *middleware.Context) {
filterMode = models.FM_MENTION
}
+ var mid int64
midx, _ := base.StrTo(ctx.Query("milestone")).Int64()
- mile, err := models.GetMilestoneByIndex(ctx.Repo.Repository.Id, midx)
- if err != nil {
- ctx.Handle(500, "issue.Issues(GetMilestoneByIndex): %v", err)
- return
+ if midx > 0 {
+ mile, err := models.GetMilestoneByIndex(ctx.Repo.Repository.Id, midx)
+ if err != nil {
+ ctx.Handle(500, "issue.Issues(GetMilestoneByIndex): %v", err)
+ return
+ }
+ mid = mile.Id
}
page, _ := base.StrTo(ctx.Query("page")).Int()
// Get issues.
- issues, err := models.GetIssues(assigneeId, ctx.Repo.Repository.Id, posterId, mile.Id, page,
+ issues, err := models.GetIssues(assigneeId, ctx.Repo.Repository.Id, posterId, mid, page,
isShowClosed, ctx.Query("labels"), ctx.Query("sortType"))
if err != nil {
ctx.Handle(500, "issue.Issues(GetIssues): %v", err)
@@ -120,6 +124,19 @@ func CreateIssue(ctx *middleware.Context, params martini.Params) {
ctx.Data["IsRepoToolbarIssues"] = true
ctx.Data["IsRepoToolbarIssuesList"] = false
+ var err error
+ // Get all milestones.
+ ctx.Data["OpenMilestones"], err = models.GetMilestones(ctx.Repo.Repository.Id, false)
+ if err != nil {
+ ctx.Handle(500, "issue.ViewIssue(GetMilestones.1): %v", err)
+ return
+ }
+ ctx.Data["ClosedMilestones"], err = models.GetMilestones(ctx.Repo.Repository.Id, true)
+ if err != nil {
+ ctx.Handle(500, "issue.ViewIssue(GetMilestones.2): %v", err)
+ return
+ }
+
us, err := models.GetCollaborators(strings.TrimPrefix(ctx.Repo.RepoLink, "/"))
if err != nil {
ctx.Handle(500, "issue.CreateIssue(GetCollaborators)", err)
@@ -134,6 +151,19 @@ func CreateIssuePost(ctx *middleware.Context, params martini.Params, form auth.C
ctx.Data["IsRepoToolbarIssues"] = true
ctx.Data["IsRepoToolbarIssuesList"] = false
+ var err error
+ // Get all milestones.
+ ctx.Data["OpenMilestones"], err = models.GetMilestones(ctx.Repo.Repository.Id, false)
+ if err != nil {
+ ctx.Handle(500, "issue.ViewIssue(GetMilestones.1): %v", err)
+ return
+ }
+ ctx.Data["ClosedMilestones"], err = models.GetMilestones(ctx.Repo.Repository.Id, true)
+ if err != nil {
+ ctx.Handle(500, "issue.ViewIssue(GetMilestones.2): %v", err)
+ return
+ }
+
us, err := models.GetCollaborators(strings.TrimPrefix(ctx.Repo.RepoLink, "/"))
if err != nil {
ctx.Handle(500, "issue.CreateIssue(GetCollaborators)", err)
diff --git a/templates/issue/create.tmpl b/templates/issue/create.tmpl
index 4b43116cca..34cecc78bd 100644
--- a/templates/issue/create.tmpl
+++ b/templates/issue/create.tmpl
@@ -48,25 +48,33 @@
</ul>
<div class="tab-content">
<div class="tab-pane active" id="milestone-open">
+ {{if not .OpenMilestones}}
<p class="milestone-item">Nothing to show</p>
+ {{else}}
<ul class="list-unstyled">
- <li class="milestone-item" data-id="1">
- <p><strong>Milestone name</strong></p>
- <p>due to 3 days later</p>
- </li>
- <li class="milestone-item" data-id="1">
- <p><strong>Milestone name</strong></p>
- <p>due to 3 days later</p>
+ {{range .OpenMilestones}}
+ <li class="milestone-item" data-id="{{.Id}}">
+ <p><strong>{{.Name}}</strong></p>
+ <!-- <p>due to 3 days later</p> -->
</li>
+ {{end}}
</ul>
+ {{end}}
</div>
+
<div class="tab-pane" id="milestone-close">
+ {{if not .ClosedMilestones}}
+ <p class="milestone-item">Nothing to show</p>
+ {{else}}
<ul class="list-unstyled">
- <li class="milestone-item" data-id="1">
- <p><strong>Milestone name</strong></p>
- <p>closed 3 days ago</p>
+ {{range .ClosedMilestones}}
+ <li class="milestone-item" data-id="{{.Id}}">
+ <p><strong>{{.Name}}</strong></p>
+ <p>Closed {{TimeSince .ClosedDate}}</p>
</li>
+ {{end}}
</ul>
+ {{end}}
</div>
</div>
</li>
diff --git a/templates/issue/view.tmpl b/templates/issue/view.tmpl
index 5aeb9409e1..18ec5faf0e 100644
--- a/templates/issue/view.tmpl
+++ b/templates/issue/view.tmpl
@@ -100,7 +100,7 @@
</div>
<div class="issue-bar col-md-2">
- <div class="milestone" data-milestone="0" data-ajax="{{.Issue.Index}}/milestone">
+ <div class="milestone" data-milestone="{{.Milestone.Id}}" data-ajax="{{.Issue.Index}}/milestone">
<div class="pull-right action">
<button class="btn btn-default btn-sm" data-toggle="dropdown">
<i class="fa fa-check-square-o"></i>
@@ -108,7 +108,7 @@
</button>
<div class="dropdown-menu dropdown-menu-right">
<ul class="list-unstyled">
- <li data-id="0" class="clear-milestone milestone-item hidden"><i class="fa fa-times-circle-o"></i> Clear milestone </li>
+ <li data-id="0" class="clear-milestone milestone-item hidden"><i class="fa fa-times-circle-o"></i> Clear milestone </li>
<li class="milestone-list">
<ul class="nav nav-tabs" data-init="tabs">
<li class="active"><a href="#milestone-open" data-toggle="tab">Open</a></li>
@@ -138,7 +138,7 @@
{{range .ClosedMilestones}}
<li class="milestone-item" data-id="{{.Id}}">
<p><strong>{{.Name}}</strong></p>
- <p>{{TimeSince .ClosedDate}}</p>
+ <p>Closed {{TimeSince .ClosedDate}}</p>
</li>
{{end}}
</ul>