Commit 1688a29023b834acd59379cf9555a119f45ae883
1 parent
4c132ed4
Exists in
spb-stable
and in
3 other branches
Add GFM autocompletion for MergeRequests
Requested [here](http://feedback.gitlab.com/forums/176466-general/suggestions/5507440-auto-complete-merge-requests-in-gitlab-markdown).
Showing
2 changed files
with
13 additions
and
0 deletions
Show diff stats
app/assets/javascripts/gfm_auto_complete.js.coffee
@@ -13,6 +13,7 @@ GitLab.GfmAutoComplete = | @@ -13,6 +13,7 @@ GitLab.GfmAutoComplete = | ||
13 | Members: | 13 | Members: |
14 | template: '<li data-value="${username}">${username} <small>${name}</small></li>' | 14 | template: '<li data-value="${username}">${username} <small>${name}</small></li>' |
15 | 15 | ||
16 | + # Issues and MergeRequests | ||
16 | Issues: | 17 | Issues: |
17 | template: '<li data-value="${id}"><small>${id}</small> ${title} </li>' | 18 | template: '<li data-value="${id}"><small>${id}</small> ${title} </li>' |
18 | 19 | ||
@@ -46,11 +47,22 @@ GitLab.GfmAutoComplete = | @@ -46,11 +47,22 @@ GitLab.GfmAutoComplete = | ||
46 | before_save: (issues) -> | 47 | before_save: (issues) -> |
47 | $.map issues, (i) -> id: i.iid, title: sanitize(i.title), search: "#{i.iid} #{i.title}" | 48 | $.map issues, (i) -> id: i.iid, title: sanitize(i.title), search: "#{i.iid} #{i.title}" |
48 | 49 | ||
50 | + input.atwho | ||
51 | + at: '!' | ||
52 | + alias: 'mergerequests' | ||
53 | + search_key: 'search' | ||
54 | + tpl: @Issues.template | ||
55 | + callbacks: | ||
56 | + before_save: (merges) -> | ||
57 | + $.map merges, (m) -> id: m.iid, title: sanitize(m.title), search: "#{m.iid} #{m.title}" | ||
58 | + | ||
49 | input.one "focus", => | 59 | input.one "focus", => |
50 | $.getJSON(@dataSource).done (data) -> | 60 | $.getJSON(@dataSource).done (data) -> |
51 | # load members | 61 | # load members |
52 | input.atwho 'load', "@", data.members | 62 | input.atwho 'load', "@", data.members |
53 | # load issues | 63 | # load issues |
54 | input.atwho 'load', "issues", data.issues | 64 | input.atwho 'load', "issues", data.issues |
65 | + # load merge requests | ||
66 | + input.atwho 'load', "mergerequests", data.mergerequests | ||
55 | # load emojis | 67 | # load emojis |
56 | input.atwho 'load', ":", data.emojis | 68 | input.atwho 'load', ":", data.emojis |
app/controllers/projects_controller.rb
@@ -108,6 +108,7 @@ class ProjectsController < ApplicationController | @@ -108,6 +108,7 @@ class ProjectsController < ApplicationController | ||
108 | @suggestions = { | 108 | @suggestions = { |
109 | emojis: Emoji.names, | 109 | emojis: Emoji.names, |
110 | issues: @project.issues.select([:iid, :title, :description]), | 110 | issues: @project.issues.select([:iid, :title, :description]), |
111 | + mergerequests: @project.merge_requests.select([:iid, :title, :description]), | ||
111 | members: @project.team.members.sort_by(&:username).map { |user| { username: user.username, name: user.name } } | 112 | members: @project.team.members.sort_by(&:username).map { |user| { username: user.username, name: user.name } } |
112 | } | 113 | } |
113 | 114 |