Browse Source

Finish change issue’s milestone

pull/201/head
Unknown 11 years ago
parent
commit
16bddd593a
  1. 2
      models/issue.go
  2. 32
      routers/repo/issue.go
  3. 28
      templates/issue/create.tmpl
  4. 4
      templates/issue/view.tmpl

2
models/issue.go

@ -543,6 +543,7 @@ func ChangeMilestoneAssign(oldMid, mid int64, isIssueClosed bool) (err error) {
} }
} }
if mid > 0 {
m, err := GetMilestoneById(mid) m, err := GetMilestoneById(mid)
if err != nil { if err != nil {
return err return err
@ -556,6 +557,7 @@ func ChangeMilestoneAssign(oldMid, mid int64, isIssueClosed bool) (err error) {
sess.Rollback() sess.Rollback()
return err return err
} }
}
return sess.Commit() return sess.Commit()
} }

32
routers/repo/issue.go

@ -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()
if midx > 0 {
mile, err := models.GetMilestoneByIndex(ctx.Repo.Repository.Id, midx) mile, err := models.GetMilestoneByIndex(ctx.Repo.Repository.Id, midx)
if err != nil { if err != nil {
ctx.Handle(500, "issue.Issues(GetMilestoneByIndex): %v", err) ctx.Handle(500, "issue.Issues(GetMilestoneByIndex): %v", err)
return 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)

28
templates/issue/create.tmpl

@ -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>

4
templates/issue/view.tmpl

@ -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>
@ -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