add gfm autocomplete for labels
This commit is contained in:
parent
f0c4f72735
commit
14964308dc
3 changed files with 30 additions and 0 deletions
|
@ -14,6 +14,10 @@ GitLab.GfmAutoComplete =
|
||||||
Members:
|
Members:
|
||||||
template: '<li>${username} <small>${title}</small></li>'
|
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 and MergeRequests
|
||||||
Issues:
|
Issues:
|
||||||
template: '<li><small>${id}</small> ${title}</li>'
|
template: '<li><small>${id}</small> ${title}</li>'
|
||||||
|
@ -94,6 +98,25 @@ GitLab.GfmAutoComplete =
|
||||||
title: sanitize(m.title)
|
title: sanitize(m.title)
|
||||||
search: "#{m.iid} #{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: ->
|
destroyAtWho: ->
|
||||||
@input.atwho('destroy')
|
@input.atwho('destroy')
|
||||||
|
|
||||||
|
@ -109,3 +132,5 @@ GitLab.GfmAutoComplete =
|
||||||
@input.atwho 'load', 'mergerequests', data.mergerequests
|
@input.atwho 'load', 'mergerequests', data.mergerequests
|
||||||
# load emojis
|
# load emojis
|
||||||
@input.atwho 'load', ':', data.emojis
|
@input.atwho 'load', ':', data.emojis
|
||||||
|
# load labels
|
||||||
|
@input.atwho 'load', '~', data.labels
|
||||||
|
|
|
@ -148,6 +148,7 @@ class ProjectsController < Projects::ApplicationController
|
||||||
emojis: AwardEmoji.urls,
|
emojis: AwardEmoji.urls,
|
||||||
issues: autocomplete.issues,
|
issues: autocomplete.issues,
|
||||||
mergerequests: autocomplete.merge_requests,
|
mergerequests: autocomplete.merge_requests,
|
||||||
|
labels: autocomplete.labels,
|
||||||
members: participants
|
members: participants
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,5 +7,9 @@ module Projects
|
||||||
def merge_requests
|
def merge_requests
|
||||||
@project.merge_requests.opened.select([:iid, :title])
|
@project.merge_requests.opened.select([:iid, :title])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def labels
|
||||||
|
@project.labels.select([:title, :color])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue