mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-01 05:36:19 +01:00
Almost done issue label #200
This commit is contained in:
parent
b1bdbd7f94
commit
dce17c86ac
4 changed files with 43 additions and 8 deletions
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
|||
"github.com/gogits/gogs/modules/base"
|
||||
)
|
||||
|
||||
const APP_VER = "0.3.5.0523 Alpha"
|
||||
const APP_VER = "0.3.5.0524 Alpha"
|
||||
|
||||
func init() {
|
||||
base.AppVer = APP_VER
|
||||
|
|
|
@ -183,6 +183,13 @@ func GetIssues(uid, rid, pid, mid int64, page int, isClosed bool, labelIds, sort
|
|||
return issues, err
|
||||
}
|
||||
|
||||
type IssueStatus int
|
||||
|
||||
const (
|
||||
IS_OPEN = iota + 1
|
||||
IS_CLOSE
|
||||
)
|
||||
|
||||
// GetIssuesByLabel returns a list of issues by given label and repository.
|
||||
func GetIssuesByLabel(repoId int64, label string) ([]*Issue, error) {
|
||||
issues := make([]*Issue, 0, 10)
|
||||
|
|
|
@ -445,7 +445,7 @@ func UpdateIssueLabel(ctx *middleware.Context, params martini.Params) {
|
|||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, idx)
|
||||
if err != nil {
|
||||
if err == models.ErrIssueNotExist {
|
||||
ctx.Handle(404, "issue.UpdateIssueLabel", err)
|
||||
ctx.Handle(404, "issue.UpdateIssueLabel(GetIssueByIndex)", err)
|
||||
} else {
|
||||
ctx.Handle(500, "issue.UpdateIssueLabel(GetIssueByIndex)", err)
|
||||
}
|
||||
|
@ -454,6 +454,17 @@ func UpdateIssueLabel(ctx *middleware.Context, params martini.Params) {
|
|||
|
||||
isAttach := ctx.Query("action") == "attach"
|
||||
labelStrId := ctx.Query("id")
|
||||
labelId, _ := base.StrTo(labelStrId).Int64()
|
||||
label, err := models.GetLabelById(labelId)
|
||||
if err != nil {
|
||||
if err == models.ErrLabelNotExist {
|
||||
ctx.Handle(404, "issue.UpdateIssueLabel(GetLabelById)", err)
|
||||
} else {
|
||||
ctx.Handle(500, "issue.UpdateIssueLabel(GetLabelById)", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
isHad := strings.Contains(issue.LabelIds, "$"+labelStrId+"|")
|
||||
isNeedUpdate := false
|
||||
if isAttach {
|
||||
|
@ -473,6 +484,22 @@ func UpdateIssueLabel(ctx *middleware.Context, params martini.Params) {
|
|||
ctx.Handle(500, "issue.UpdateIssueLabel(UpdateIssue)", err)
|
||||
return
|
||||
}
|
||||
|
||||
if isAttach {
|
||||
label.NumIssues++
|
||||
if issue.IsClosed {
|
||||
label.NumClosedIssues++
|
||||
}
|
||||
} else {
|
||||
label.NumIssues--
|
||||
if issue.IsClosed {
|
||||
label.NumClosedIssues--
|
||||
}
|
||||
}
|
||||
if err = models.UpdateLabel(label); err != nil {
|
||||
ctx.Handle(500, "issue.UpdateIssueLabel(UpdateLabel)", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
"ok": true,
|
||||
|
|
|
@ -17,12 +17,13 @@
|
|||
<h4>Label</h4>
|
||||
<ul class="list-unstyled" id="label-list" data-ajax="{{$.RepoLink}}/issues/labels/delete">
|
||||
{{range .Labels}}
|
||||
<li class="label-item" id="label-{{.Id}}" data-id="{{.Id}}"><a href="#">
|
||||
<span class="pull-right count">{{if $.IsShowClosed}}{{.NumClosedIssues}}{{else}}{{.NumOpenIssues}}{{end}}</span>
|
||||
<span class="color" style="background-color: {{.Color}}" data-color="{{.Color}}"></span>
|
||||
<span class="name">{{.Name}}</span>
|
||||
</a>
|
||||
<a class="del pull-right" href="#" data-id="{{.Id}}"><i class="fa fa-times-circle-o"></i></a>
|
||||
<li class="label-item" id="label-{{.Id}}" data-id="{{.Id}}">
|
||||
<a href="#">
|
||||
<span class="pull-right count">{{if $.IsShowClosed}}{{.NumClosedIssues}}{{else}}{{.NumOpenIssues}}{{end}}</span>
|
||||
<span class="color" style="background-color: {{.Color}}" data-color="{{.Color}}"></span>
|
||||
<span class="name">{{.Name}}</span>
|
||||
</a>
|
||||
<a class="del pull-right" href="#" data-id="{{.Id}}"><i class="fa fa-times-circle-o"></i></a>
|
||||
</li>
|
||||
{{end}}
|
||||
<li class="label-change-li" style="display: none">
|
||||
|
|
Loading…
Reference in a new issue