diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2017-02-01 10:36:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-01 10:36:08 +0800 |
commit | 081485ecfddc88a05fdea0b0230672271658c086 (patch) | |
tree | bbaaa55ede02f311056f5df6c8b56301be09982d /routers | |
parent | 10644d6dd7574b031118bf01b2bd737017230ffd (diff) | |
download | gitea-081485ecfddc88a05fdea0b0230672271658c086.tar.gz gitea-081485ecfddc88a05fdea0b0230672271658c086.zip |
add milestone changed traker on issue view (#804)
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/repo/issue.go | 2 | ||||
-rw-r--r-- | routers/api/v1/repo/pull.go | 2 | ||||
-rw-r--r-- | routers/repo/issue.go | 35 |
3 files changed, 24 insertions, 15 deletions
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index ac0289c412..c65f4b7063 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -168,7 +168,7 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) { issue.MilestoneID != *form.Milestone { oldMilestoneID := issue.MilestoneID issue.MilestoneID = *form.Milestone - if err = models.ChangeMilestoneAssign(issue, oldMilestoneID); err != nil { + if err = models.ChangeMilestoneAssign(issue, ctx.User, oldMilestoneID); err != nil { ctx.Error(500, "ChangeMilestoneAssign", err) return } diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index 4c10024bfb..9a38d37528 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -241,7 +241,7 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) { issue.MilestoneID != form.Milestone { oldMilestoneID := issue.MilestoneID issue.MilestoneID = form.Milestone - if err = models.ChangeMilestoneAssign(issue, oldMilestoneID); err != nil { + if err = models.ChangeMilestoneAssign(issue, ctx.User, oldMilestoneID); err != nil { ctx.Error(500, "ChangeMilestoneAssign", err) return } diff --git a/routers/repo/issue.go b/routers/repo/issue.go index b2490e242a..76440359ef 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -384,22 +384,27 @@ func ValidateRepoMetas(ctx *context.Context, form auth.CreateIssueForm) ([]int64 return nil, 0, 0 } - // Check labels. - labelIDs, err := base.StringsToInt64s(strings.Split(form.LabelIDs, ",")) - if err != nil { - return nil, 0, 0 - } - labelIDMark := base.Int64sToMap(labelIDs) + var labelIDs []int64 hasSelected := false - for i := range labels { - if labelIDMark[labels[i].ID] { - labels[i].IsChecked = true - hasSelected = true + // Check labels. + if len(form.LabelIDs) > 0 { + labelIDs, err = base.StringsToInt64s(strings.Split(form.LabelIDs, ",")) + if err != nil { + return nil, 0, 0 + } + labelIDMark := base.Int64sToMap(labelIDs) + + for i := range labels { + if labelIDMark[labels[i].ID] { + labels[i].IsChecked = true + hasSelected = true + } } } + + ctx.Data["Labels"] = labels ctx.Data["HasSelectedLabel"] = hasSelected ctx.Data["label_ids"] = form.LabelIDs - ctx.Data["Labels"] = labels // Check milestone. milestoneID := form.MilestoneID @@ -617,6 +622,11 @@ func ViewIssue(ctx *context.Context) { ctx.Handle(500, "LoadLabel", err) return } + } else if comment.Type == models.CommentTypeMilestone { + if err = comment.LoadMilestone(); err != nil { + ctx.Handle(500, "LoadMilestone", err) + return + } } } @@ -625,7 +635,6 @@ func ViewIssue(ctx *context.Context) { canDelete := false if ctx.IsSigned && pull.HeadBranch != "master" { - if err := pull.GetHeadRepo(); err != nil { log.Error(4, "GetHeadRepo: %v", err) } else if ctx.User.IsWriterOfRepo(pull.HeadRepo) { @@ -729,7 +738,7 @@ func UpdateIssueMilestone(ctx *context.Context) { // Not check for invalid milestone id and give responsibility to owners. issue.MilestoneID = milestoneID - if err := models.ChangeMilestoneAssign(issue, oldMilestoneID); err != nil { + if err := models.ChangeMilestoneAssign(issue, ctx.User, oldMilestoneID); err != nil { ctx.Handle(500, "ChangeMilestoneAssign", err) return } |