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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
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
Hide 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 =
...
@@ -18,6 +18,10 @@ GitLab.GfmAutoComplete =
Issues
:
Issues
:
template
:
'<li><small>${id}</small> ${title}</li>'
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.
# Add GFM auto-completion to all input fields, that accept GFM input.
setup
:
(
wrap
)
->
setup
:
(
wrap
)
->
@
input
=
$
(
'.js-gfm-input'
)
@
input
=
$
(
'.js-gfm-input'
)
...
@@ -81,6 +85,19 @@ GitLab.GfmAutoComplete =
...
@@ -81,6 +85,19 @@ GitLab.GfmAutoComplete =
title
:
sanitize
(
i
.
title
)
title
:
sanitize
(
i
.
title
)
search
:
"
#{
i
.
iid
}
#{
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
@
input
.
atwho
at
:
'!'
at
:
'!'
alias
:
'mergerequests'
alias
:
'mergerequests'
...
@@ -105,6 +122,8 @@ GitLab.GfmAutoComplete =
...
@@ -105,6 +122,8 @@ GitLab.GfmAutoComplete =
@
input
.
atwho
'load'
,
'@'
,
data
.
members
@
input
.
atwho
'load'
,
'@'
,
data
.
members
# load issues
# load issues
@
input
.
atwho
'load'
,
'issues'
,
data
.
issues
@
input
.
atwho
'load'
,
'issues'
,
data
.
issues
# load milestones
@
input
.
atwho
'load'
,
'milestones'
,
data
.
milestones
# load merge requests
# load merge requests
@
input
.
atwho
'load'
,
'mergerequests'
,
data
.
mergerequests
@
input
.
atwho
'load'
,
'mergerequests'
,
data
.
mergerequests
# load emojis
# load emojis
...
...
app/controllers/projects_controller.rb
View file @
4cab66e3
...
@@ -147,6 +147,7 @@ class ProjectsController < Projects::ApplicationController
...
@@ -147,6 +147,7 @@ class ProjectsController < Projects::ApplicationController
@suggestions
=
{
@suggestions
=
{
emojis:
AwardEmoji
.
urls
,
emojis:
AwardEmoji
.
urls
,
issues:
autocomplete
.
issues
,
issues:
autocomplete
.
issues
,
milestones:
autocomplete
.
milestones
,
mergerequests:
autocomplete
.
merge_requests
,
mergerequests:
autocomplete
.
merge_requests
,
members:
participants
members:
participants
}
}
...
...
app/services/projects/autocomplete_service.rb
View file @
4cab66e3
...
@@ -4,6 +4,10 @@ module Projects
...
@@ -4,6 +4,10 @@ module Projects
@project
.
issues
.
visible_to_user
(
current_user
).
opened
.
select
([
:iid
,
:title
])
@project
.
issues
.
visible_to_user
(
current_user
).
opened
.
select
([
:iid
,
:title
])
end
end
def
milestones
@project
.
milestones
.
active
.
select
([
:iid
,
:title
])
end
def
merge_requests
def
merge_requests
@project
.
merge_requests
.
opened
.
select
([
:iid
,
:title
])
@project
.
merge_requests
.
opened
.
select
([
:iid
,
:title
])
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