From 1688a29023b834acd59379cf9555a119f45ae883 Mon Sep 17 00:00:00 2001 From: Robert Speicher <rspeicher@gmail.com> Date: Wed, 5 Mar 2014 23:24:03 -0500 Subject: [PATCH] Add GFM autocompletion for MergeRequests Requested [here](http://feedback.gitlab.com/forums/176466-general/suggestions/5507440-auto-complete-merge-requests-in-gitlab-markdown). --- app/assets/javascripts/gfm_auto_complete.js.coffee | 12 ++++++++++++ app/controllers/projects_controller.rb | 1 + 2 files changed, 13 insertions(+) diff --git a/app/assets/javascripts/gfm_auto_complete.js.coffee b/app/assets/javascripts/gfm_auto_complete.js.coffee index 77091da8f6..dd12000a1c 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 6ec109b914..f1c0336e6e 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 } } } -- 2.30.9