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
4cab66e3
Commit
4cab66e3
authored
Apr 04, 2016
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implementing autocomplete for GFM milestone references
parent
1ff896f2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
0 deletions
+24
-0
app/assets/javascripts/gfm_auto_complete.js.coffee
app/assets/javascripts/gfm_auto_complete.js.coffee
+19
-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 @
4cab66e3
...
...
@@ -18,6 +18,10 @@ GitLab.GfmAutoComplete =
Issues
:
template
:
'<li><small>${id}</small> ${title}</li>'
# Milestones
Milestones
:
template
:
'<li>${title}</li>'
# Add GFM auto-completion to all input fields, that accept GFM input.
setup
:
(
wrap
)
->
@
input
=
$
(
'.js-gfm-input'
)
...
...
@@ -81,6 +85,19 @@ GitLab.GfmAutoComplete =
title
:
sanitize
(
i
.
title
)
search
:
"
#{
i
.
iid
}
#{
i
.
title
}
"
@
input
.
atwho
at
:
'%'
alias
:
'milestones'
searchKey
:
'search'
displayTpl
:
@
Milestones
.
template
insertTpl
:
'${atwho-at}${id}'
callbacks
:
beforeSave
:
(
milestones
)
->
$
.
map
milestones
,
(
m
)
->
id
:
m
.
iid
title
:
sanitize
(
m
.
title
)
search
:
"
#{
m
.
title
}
"
@
input
.
atwho
at
:
'!'
alias
:
'mergerequests'
...
...
@@ -105,6 +122,8 @@ GitLab.GfmAutoComplete =
@
input
.
atwho
'load'
,
'@'
,
data
.
members
# load issues
@
input
.
atwho
'load'
,
'issues'
,
data
.
issues
# load milestones
@
input
.
atwho
'load'
,
'milestones'
,
data
.
milestones
# load merge requests
@
input
.
atwho
'load'
,
'mergerequests'
,
data
.
mergerequests
# load emojis
...
...
app/controllers/projects_controller.rb
View file @
4cab66e3
...
...
@@ -147,6 +147,7 @@ class ProjectsController < Projects::ApplicationController
@suggestions
=
{
emojis:
AwardEmoji
.
urls
,
issues:
autocomplete
.
issues
,
milestones:
autocomplete
.
milestones
,
mergerequests:
autocomplete
.
merge_requests
,
members:
participants
}
...
...
app/services/projects/autocomplete_service.rb
View file @
4cab66e3
...
...
@@ -4,6 +4,10 @@ module Projects
@project
.
issues
.
visible_to_user
(
current_user
).
opened
.
select
([
:iid
,
:title
])
end
def
milestones
@project
.
milestones
.
active
.
select
([
:iid
,
:title
])
end
def
merge_requests
@project
.
merge_requests
.
opened
.
select
([
:iid
,
:title
])
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