Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
14964308
Commit
14964308
authored
May 03, 2016
by
Arinde Eniola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add gfm autocomplete for labels
parent
f0c4f727
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
0 deletions
+30
-0
app/assets/javascripts/gfm_auto_complete.js.coffee
app/assets/javascripts/gfm_auto_complete.js.coffee
+25
-0
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+1
-0
app/services/projects/autocomplete_service.rb
app/services/projects/autocomplete_service.rb
+4
-0
No files found.
app/assets/javascripts/gfm_auto_complete.js.coffee
View file @
14964308
...
...
@@ -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
app/controllers/projects_controller.rb
View file @
14964308
...
...
@@ -148,6 +148,7 @@ class ProjectsController < Projects::ApplicationController
emojis:
AwardEmoji
.
urls
,
issues:
autocomplete
.
issues
,
mergerequests:
autocomplete
.
merge_requests
,
labels:
autocomplete
.
labels
,
members:
participants
}
...
...
app/services/projects/autocomplete_service.rb
View file @
14964308
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment