summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2014-03-05 23:24:03 -0500
committerRobert Speicher <rspeicher@gmail.com>2014-03-05 23:24:03 -0500
commit1688a29023b834acd59379cf9555a119f45ae883 (patch)
treef401bab5b078cb1b7ddf4d8a3acbafc498625be1
parent4c132ed48e5ddc81bb28bd07e92024ab3bf4d86e (diff)
downloadgitlab-ce-1688a29023b834acd59379cf9555a119f45ae883.tar.gz
Add GFM autocompletion for MergeRequests
Requested [here](http://feedback.gitlab.com/forums/176466-general/suggestions/5507440-auto-complete-merge-requests-in-gitlab-markdown).
-rw-r--r--app/assets/javascripts/gfm_auto_complete.js.coffee12
-rw-r--r--app/controllers/projects_controller.rb1
2 files changed, 13 insertions, 0 deletions
diff --git a/app/assets/javascripts/gfm_auto_complete.js.coffee b/app/assets/javascripts/gfm_auto_complete.js.coffee
index 77091da8f61..dd12000a1cf 100644
--- a/app/assets/javascripts/gfm_auto_complete.js.coffee
+++ b/app/assets/javascripts/gfm_auto_complete.js.coffee
@@ -13,6 +13,7 @@ GitLab.GfmAutoComplete =
Members:
template: '<li data-value="${username}">${username} <small>${name}</small></li>'
+ # Issues and MergeRequests
Issues:
template: '<li data-value="${id}"><small>${id}</small> ${title} </li>'
@@ -46,11 +47,22 @@ GitLab.GfmAutoComplete =
before_save: (issues) ->
$.map issues, (i) -> id: i.iid, title: sanitize(i.title), search: "#{i.iid} #{i.title}"
+ input.atwho
+ at: '!'
+ alias: 'mergerequests'
+ search_key: 'search'
+ tpl: @Issues.template
+ callbacks:
+ before_save: (merges) ->
+ $.map merges, (m) -> id: m.iid, title: sanitize(m.title), search: "#{m.iid} #{m.title}"
+
input.one "focus", =>
$.getJSON(@dataSource).done (data) ->
# load members
input.atwho 'load', "@", data.members
# load issues
input.atwho 'load', "issues", data.issues
+ # load merge requests
+ input.atwho 'load', "mergerequests", data.mergerequests
# load emojis
input.atwho 'load', ":", data.emojis
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 6ec109b9145..f1c0336e6ea 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -108,6 +108,7 @@ class ProjectsController < ApplicationController
@suggestions = {
emojis: Emoji.names,
issues: @project.issues.select([:iid, :title, :description]),
+ mergerequests: @project.merge_requests.select([:iid, :title, :description]),
members: @project.team.members.sort_by(&:username).map { |user| { username: user.username, name: user.name } }
}