Commit c1d070cf authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #6475 from tsigo/merge-request-autocomplete

Add GFM autocompletion for MergeRequests
parents 4c132ed4 1688a290
......@@ -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 @@ 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 } }
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment