Permalink
Browse files

Add GFM autocompletion for MergeRequests

  • Loading branch information...
1 parent 4c132ed commit 1688a29023b834acd59379cf9555a119f45ae883 @rspeicher rspeicher committed Mar 6, 2014
Showing with 13 additions and 0 deletions.
  1. +12 −0 app/assets/javascripts/gfm_auto_complete.js.coffee
  2. +1 −0 app/controllers/projects_controller.rb
@@ -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
@@ -108,6 +108,7 @@ def autocomplete_sources
@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 } }
}

0 comments on commit 1688a29

Please sign in to comment.