diff --git a/models/issue.go b/models/issue.go index 2c385fd066..32e6a5b66b 100644 --- a/models/issue.go +++ b/models/issue.go @@ -49,6 +49,7 @@ type Issue struct { IsPull bool `xorm:"INDEX"` // Indicates whether is a pull request or not. PullRequest *PullRequest `xorm:"-"` NumComments int + Ref string Deadline time.Time `xorm:"-"` DeadlineUnix int64 `xorm:"INDEX"` diff --git a/modules/auth/repo_form.go b/modules/auth/repo_form.go index 58dcf468ef..681a478d3b 100644 --- a/modules/auth/repo_form.go +++ b/modules/auth/repo_form.go @@ -194,6 +194,7 @@ func (f *NewSlackHookForm) Validate(ctx *macaron.Context, errs binding.Errors) b type CreateIssueForm struct { Title string `binding:"Required;MaxSize(255)"` LabelIDs string `form:"label_ids"` + Ref string `form:"ref"` MilestoneID int64 AssigneeID int64 Content string diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 9931d9152b..4a8a39963f 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -612,6 +612,7 @@ issues.new.closed_milestone = Closed Milestones issues.new.assignee = Assignee issues.new.clear_assignee = Clear assignee issues.new.no_assignee = No assignee +issues.no_ref = No Branch/Tag Specified issues.create = Create Issue issues.new_label = New Label issues.new_label_placeholder = Label name... diff --git a/public/js/index.js b/public/js/index.js index 90a61d7529..1b6f2f601e 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -86,6 +86,22 @@ function initEditForm() { initEditDiffTab($('.edit.form')); } +function initBranchSelector() { + var $selectBranch = $('.ui.select-branch') + var $branchMenu = $selectBranch.find('.reference-list-menu'); + $branchMenu.find('.item:not(.no-select)').click(function () { + var selectedValue = $(this).data('id'); + $($(this).data('id-selector')).val(selectedValue); + $selectBranch.find('.ui .branch-name').text(selectedValue); + }); + $selectBranch.find('.reference.column').click(function () { + $selectBranch.find('.scrolling.reference-list-menu').css('display', 'none'); + $selectBranch.find('.reference .text').removeClass('black'); + $($(this).data('target')).css('display', 'block'); + $(this).find('.text').addClass('black'); + return false; + }); +} function updateIssuesMeta(url, action, issueIds, elementId, afterSuccess) { $.ajax({ @@ -106,6 +122,7 @@ function initCommentForm() { return } + initBranchSelector(); initCommentPreviewTab($('.comment.form')); // Labels diff --git a/routers/repo/issue.go b/routers/repo/issue.go index e4ed10d980..d1c5e1fe71 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -292,6 +292,13 @@ func RetrieveRepoMetas(ctx *context.Context, repo *models.Repository) []*models. return nil } + brs, err := ctx.Repo.GitRepo.GetBranches() + if err != nil { + ctx.Handle(500, "GetBranches", err) + return nil + } + ctx.Data["Branches"] = brs + return labels } @@ -418,6 +425,7 @@ func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) { ctx.Data["PageIsIssueList"] = true ctx.Data["RequireHighlightJS"] = true ctx.Data["RequireSimpleMDE"] = true + ctx.Data["ReadOnly"] = false renderAttachmentSettings(ctx) var ( @@ -447,6 +455,7 @@ func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) { MilestoneID: milestoneID, AssigneeID: assigneeID, Content: form.Content, + Ref: form.Ref, } if err := models.NewIssue(repo, issue, labelIDs, attachments); err != nil { ctx.Handle(500, "NewIssue", err) @@ -668,6 +677,7 @@ func ViewIssue(ctx *context.Context) { ctx.Data["Participants"] = participants ctx.Data["NumParticipants"] = len(participants) ctx.Data["Issue"] = issue + ctx.Data["ReadOnly"] = true ctx.Data["IsIssueOwner"] = ctx.Repo.IsWriter() || (ctx.IsSigned && issue.IsPoster(ctx.User.ID)) ctx.Data["SignInLink"] = setting.AppSubURL + "/user/login?redirect_to=" + ctx.Data["Link"].(string) ctx.HTML(200, tplIssueView) diff --git a/templates/repo/issue/branch_selector_field.tmpl b/templates/repo/issue/branch_selector_field.tmpl new file mode 100644 index 0000000000..72b953b666 --- /dev/null +++ b/templates/repo/issue/branch_selector_field.tmpl @@ -0,0 +1,41 @@ + +