summaryrefslogtreecommitdiffstats
path: root/routers/repo/issue.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-07-24 23:13:42 +0800
committerUnknwon <u@gogs.io>2015-07-24 23:13:42 +0800
commitdc4aab9925b46f8ad4b18f7926e2904163c1c5b5 (patch)
tree77bb65a5407f7daddf2166054d0abf757dc32715 /routers/repo/issue.go
parent3426ae42b3eadd5acd43e20470a8f1dd45bb55b0 (diff)
downloadgitea-dc4aab9925b46f8ad4b18f7926e2904163c1c5b5.tar.gz
gitea-dc4aab9925b46f8ad4b18f7926e2904163c1c5b5.zip
UI: CURD labels
- fix update lable break connection with repository
Diffstat (limited to 'routers/repo/issue.go')
-rw-r--r--routers/repo/issue.go44
1 files changed, 20 insertions, 24 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index d6fa000b5d..bb82647739 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -936,44 +936,40 @@ func NewLabel(ctx *middleware.Context, form auth.CreateLabelForm) {
}
func UpdateLabel(ctx *middleware.Context, form auth.CreateLabelForm) {
- id := com.StrTo(ctx.Query("id")).MustInt64()
- if id == 0 {
- ctx.Error(404)
+ l, err := models.GetLabelById(form.ID)
+ if err != nil {
+ switch err {
+ case models.ErrLabelNotExist:
+ ctx.Error(404)
+ default:
+ ctx.Handle(500, "UpdateLabel", err)
+ }
return
}
- l := &models.Label{
- ID: id,
- Name: form.Title,
- Color: form.Color,
- }
+ l.Name = form.Title
+ l.Color = form.Color
if err := models.UpdateLabel(l); err != nil {
- ctx.Handle(500, "issue.UpdateLabel(UpdateLabel)", err)
+ ctx.Handle(500, "UpdateLabel", err)
return
}
- ctx.Redirect(ctx.Repo.RepoLink + "/issues")
+ ctx.Redirect(ctx.Repo.RepoLink + "/labels")
}
func DeleteLabel(ctx *middleware.Context) {
- removes := ctx.Query("remove")
- if len(strings.TrimSpace(removes)) == 0 {
- ctx.JSON(200, map[string]interface{}{
- "ok": true,
- })
- return
- }
-
- strIds := strings.Split(removes, ",")
- for _, strId := range strIds {
- if err := models.DeleteLabel(ctx.Repo.Repository.Id, strId); err != nil {
- ctx.Handle(500, "issue.DeleteLabel(DeleteLabel)", err)
- return
+ id := ctx.QueryInt64("id")
+ if id > 0 {
+ if err := models.DeleteLabel(ctx.Repo.Repository.Id, id); err != nil {
+ ctx.Flash.Error("DeleteLabel: " + err.Error())
+ } else {
+ ctx.Flash.Success(ctx.Tr("repo.issues.label_deletion_success"))
}
}
ctx.JSON(200, map[string]interface{}{
- "ok": true,
+ "redirect": ctx.Repo.RepoLink + "/labels",
})
+ return
}
func Milestones(ctx *middleware.Context) {