add gfm autocomplete for labels
This commit is contained in:
parent
f0c4f72735
commit
14964308dc
|
@ -14,6 +14,10 @@ GitLab.GfmAutoComplete =
|
|||
Members:
|
||||
template: '<li>${username} <small>${title}</small></li>'
|
||||
|
||||
Labels:
|
||||
template: '<li>${title} <div style="background-color:${color};height:15px;width:15px;display:inline-block;float:right">
|
||||
</div></li>'
|
||||
|
||||
# Issues and MergeRequests
|
||||
Issues:
|
||||
template: '<li><small>${id}</small> ${title}</li>'
|
||||
|
@ -94,6 +98,25 @@ GitLab.GfmAutoComplete =
|
|||
title: sanitize(m.title)
|
||||
search: "#{m.iid} #{m.title}"
|
||||
|
||||
@input.atwho
|
||||
at: '~'
|
||||
alias: 'labels'
|
||||
searchKey: 'search'
|
||||
displayTpl: @Labels.template
|
||||
insertTpl: '${atwho-at}${title}'
|
||||
callbacks:
|
||||
beforeSave: (merges) ->
|
||||
sanitizeLabelTitle = (title)->
|
||||
if /\w+\s+\w+/g.test(title)
|
||||
"\"#{sanitize(title)}\""
|
||||
else
|
||||
sanitize(title)
|
||||
|
||||
$.map merges, (m) ->
|
||||
title: sanitizeLabelTitle(m.title)
|
||||
color: m.color
|
||||
search: "#{m.title}"
|
||||
|
||||
destroyAtWho: ->
|
||||
@input.atwho('destroy')
|
||||
|
||||
|
@ -109,3 +132,5 @@ GitLab.GfmAutoComplete =
|
|||
@input.atwho 'load', 'mergerequests', data.mergerequests
|
||||
# load emojis
|
||||
@input.atwho 'load', ':', data.emojis
|
||||
# load labels
|
||||
@input.atwho 'load', '~', data.labels
|
||||
|
|
|
@ -148,6 +148,7 @@ class ProjectsController < Projects::ApplicationController
|
|||
emojis: AwardEmoji.urls,
|
||||
issues: autocomplete.issues,
|
||||
mergerequests: autocomplete.merge_requests,
|
||||
labels: autocomplete.labels,
|
||||
members: participants
|
||||
}
|
||||
|
||||
|
|
|
@ -7,5 +7,9 @@ module Projects
|
|||
def merge_requests
|
||||
@project.merge_requests.opened.select([:iid, :title])
|
||||
end
|
||||
|
||||
def labels
|
||||
@project.labels.select([:title, :color])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue