Finish change issue’s milestone

tokarchuk/v1.17
Unknown 11 years ago
parent e880a2fa48
commit 16bddd593a
  1. 26
      models/issue.go
  2. 40
      routers/repo/issue.go
  3. 28
      templates/issue/create.tmpl
  4. 6
      templates/issue/view.tmpl

@ -543,18 +543,20 @@ func ChangeMilestoneAssign(oldMid, mid int64, isIssueClosed bool) (err error) {
} }
} }
m, err := GetMilestoneById(mid) if mid > 0 {
if err != nil { m, err := GetMilestoneById(mid)
return err if err != nil {
} return err
m.NumIssues++ }
if isIssueClosed { m.NumIssues++
m.NumClosedIssues++ if isIssueClosed {
} m.NumClosedIssues++
m.Completeness = m.NumClosedIssues * 100 / m.NumIssues }
if _, err = sess.Id(m.Id).Update(m); err != nil { m.Completeness = m.NumClosedIssues * 100 / m.NumIssues
sess.Rollback() if _, err = sess.Id(m.Id).Update(m); err != nil {
return err sess.Rollback()
return err
}
} }
return sess.Commit() return sess.Commit()
} }

@ -53,17 +53,21 @@ func Issues(ctx *middleware.Context) {
filterMode = models.FM_MENTION filterMode = models.FM_MENTION
} }
var mid int64
midx, _ := base.StrTo(ctx.Query("milestone")).Int64() midx, _ := base.StrTo(ctx.Query("milestone")).Int64()
mile, err := models.GetMilestoneByIndex(ctx.Repo.Repository.Id, midx) if midx > 0 {
if err != nil { mile, err := models.GetMilestoneByIndex(ctx.Repo.Repository.Id, midx)
ctx.Handle(500, "issue.Issues(GetMilestoneByIndex): %v", err) if err != nil {
return ctx.Handle(500, "issue.Issues(GetMilestoneByIndex): %v", err)
return
}
mid = mile.Id
} }
page, _ := base.StrTo(ctx.Query("page")).Int() page, _ := base.StrTo(ctx.Query("page")).Int()
// Get issues. // 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")) isShowClosed, ctx.Query("labels"), ctx.Query("sortType"))
if err != nil { if err != nil {
ctx.Handle(500, "issue.Issues(GetIssues): %v", err) 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["IsRepoToolbarIssues"] = true
ctx.Data["IsRepoToolbarIssuesList"] = false 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, "/")) us, err := models.GetCollaborators(strings.TrimPrefix(ctx.Repo.RepoLink, "/"))
if err != nil { if err != nil {
ctx.Handle(500, "issue.CreateIssue(GetCollaborators)", err) 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["IsRepoToolbarIssues"] = true
ctx.Data["IsRepoToolbarIssuesList"] = false 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, "/")) us, err := models.GetCollaborators(strings.TrimPrefix(ctx.Repo.RepoLink, "/"))
if err != nil { if err != nil {
ctx.Handle(500, "issue.CreateIssue(GetCollaborators)", err) ctx.Handle(500, "issue.CreateIssue(GetCollaborators)", err)

@ -48,25 +48,33 @@
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<div class="tab-pane active" id="milestone-open"> <div class="tab-pane active" id="milestone-open">
{{if not .OpenMilestones}}
<p class="milestone-item">Nothing to show</p> <p class="milestone-item">Nothing to show</p>
{{else}}
<ul class="list-unstyled"> <ul class="list-unstyled">
<li class="milestone-item" data-id="1"> {{range .OpenMilestones}}
<p><strong>Milestone name</strong></p> <li class="milestone-item" data-id="{{.Id}}">
<p>due to 3 days later</p> <p><strong>{{.Name}}</strong></p>
</li> <!-- <p>due to 3 days later</p> -->
<li class="milestone-item" data-id="1">
<p><strong>Milestone name</strong></p>
<p>due to 3 days later</p>
</li> </li>
{{end}}
</ul> </ul>
{{end}}
</div> </div>
<div class="tab-pane" id="milestone-close"> <div class="tab-pane" id="milestone-close">
{{if not .ClosedMilestones}}
<p class="milestone-item">Nothing to show</p>
{{else}}
<ul class="list-unstyled"> <ul class="list-unstyled">
<li class="milestone-item" data-id="1"> {{range .ClosedMilestones}}
<p><strong>Milestone name</strong></p> <li class="milestone-item" data-id="{{.Id}}">
<p>closed 3 days ago</p> <p><strong>{{.Name}}</strong></p>
<p>Closed {{TimeSince .ClosedDate}}</p>
</li> </li>
{{end}}
</ul> </ul>
{{end}}
</div> </div>
</div> </div>
</li> </li>

@ -100,7 +100,7 @@
</div> </div>
<div class="issue-bar col-md-2"> <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"> <div class="pull-right action">
<button class="btn btn-default btn-sm" data-toggle="dropdown"> <button class="btn btn-default btn-sm" data-toggle="dropdown">
<i class="fa fa-check-square-o"></i> <i class="fa fa-check-square-o"></i>
@ -108,7 +108,7 @@
</button> </button>
<div class="dropdown-menu dropdown-menu-right"> <div class="dropdown-menu dropdown-menu-right">
<ul class="list-unstyled"> <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"> <li class="milestone-list">
<ul class="nav nav-tabs" data-init="tabs"> <ul class="nav nav-tabs" data-init="tabs">
<li class="active"><a href="#milestone-open" data-toggle="tab">Open</a></li> <li class="active"><a href="#milestone-open" data-toggle="tab">Open</a></li>
@ -138,7 +138,7 @@
{{range .ClosedMilestones}} {{range .ClosedMilestones}}
<li class="milestone-item" data-id="{{.Id}}"> <li class="milestone-item" data-id="{{.Id}}">
<p><strong>{{.Name}}</strong></p> <p><strong>{{.Name}}</strong></p>
<p>{{TimeSince .ClosedDate}}</p> <p>Closed {{TimeSince .ClosedDate}}</p>
</li> </li>
{{end}} {{end}}
</ul> </ul>

Loading…
Cancel
Save