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
Léo-Paul Géneau
gitlab-ce
Commits
8ca880c3
Commit
8ca880c3
authored
Mar 08, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly fitlers remotely
parent
562a09c1
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
23 deletions
+64
-23
app/assets/javascripts/gl_dropdown.js.coffee
app/assets/javascripts/gl_dropdown.js.coffee
+24
-12
app/assets/javascripts/labels_select.js.coffee
app/assets/javascripts/labels_select.js.coffee
+1
-1
app/assets/javascripts/milestone_select.js.coffee
app/assets/javascripts/milestone_select.js.coffee
+2
-2
app/assets/javascripts/users_select.js.coffee
app/assets/javascripts/users_select.js.coffee
+28
-7
app/helpers/dropdowns_helper.rb
app/helpers/dropdowns_helper.rb
+1
-1
app/views/shared/issuable/_filter.html.haml
app/views/shared/issuable/_filter.html.haml
+8
-0
No files found.
app/assets/javascripts/gl_dropdown.js.coffee
View file @
8ca880c3
class
GitLabDropdownFilter
class
GitLabDropdownFilter
BLUR_KEYCODES
=
[
27
,
40
]
BLUR_KEYCODES
=
[
27
,
40
]
constructor
:
(
@
dropdown
,
@
remote
,
@
data
,
@
callback
)
->
constructor
:
(
@
dropdown
,
@
remote
,
@
query
,
@
data
,
@
callback
)
->
@
input
=
@
dropdown
.
find
(
".dropdown-input-field"
)
@
input
=
@
dropdown
.
find
(
".dropdown-input-field"
)
# Key events
# Key events
timeout
=
""
@
input
.
on
"keyup"
,
(
e
)
=>
@
input
.
on
"keyup"
,
(
e
)
=>
clearTimeout
timeout
timeout
=
setTimeout
=>
blur_field
=
@
shouldBlur
e
.
keyCode
blur_field
=
@
shouldBlur
e
.
keyCode
search_text
=
@
input
.
val
()
search_text
=
@
input
.
val
()
...
@@ -13,10 +16,11 @@ class GitLabDropdownFilter
...
@@ -13,10 +16,11 @@ class GitLabDropdownFilter
@
input
.
blur
()
@
input
.
blur
()
if
@
remote
if
@
remote
@
remote
search_text
,
(
data
)
=>
@
query
search_text
,
(
data
)
=>
@
callback
(
data
)
@
callback
(
data
)
else
else
@
filter
search_text
@
filter
search_text
,
250
shouldBlur
:
(
keyCode
)
->
shouldBlur
:
(
keyCode
)
->
return
BLUR_KEYCODES
.
indexOf
(
keyCode
)
>=
0
return
BLUR_KEYCODES
.
indexOf
(
keyCode
)
>=
0
...
@@ -38,7 +42,7 @@ class GitLabDropdownRemote
...
@@ -38,7 +42,7 @@ class GitLabDropdownRemote
@
options
.
beforeSend
()
@
options
.
beforeSend
()
# Fetch the data by calling the data funcfion
# Fetch the data by calling the data funcfion
@
dataEndpoint
(
data
)
=>
@
dataEndpoint
""
,
(
data
)
=>
if
@
options
.
success
if
@
options
.
success
@
options
.
success
(
data
)
@
options
.
success
(
data
)
...
@@ -86,13 +90,14 @@ class GitLabDropdown
...
@@ -86,13 +90,14 @@ class GitLabDropdown
# Init filiterable
# Init filiterable
if
@
options
.
filterable
if
@
options
.
filterable
@
filter
=
new
GitLabDropdownFilter
@
dropdown
,
@
options
.
query
,
=>
@
filter
=
new
GitLabDropdownFilter
@
dropdown
,
@
options
.
filterRemote
,
@
options
.
data
,
=>
return
@
fullData
return
@
fullData
,
(
data
)
=>
,
(
data
)
=>
@
parseData
data
@
parseData
data
# Event listeners
# Event listeners
$
(
@
el
).
parent
().
on
"shown.bs.dropdown"
,
@
opened
$
(
@
el
).
parent
().
on
"shown.bs.dropdown"
,
@
opened
$
(
@
el
).
parent
().
on
"hidden.bs.dropdown"
,
@
hidden
if
@
options
.
selectable
if
@
options
.
selectable
@
dropdown
.
on
"click"
,
"a"
,
(
e
)
->
@
dropdown
.
on
"click"
,
"a"
,
(
e
)
->
...
@@ -124,6 +129,13 @@ class GitLabDropdown
...
@@ -124,6 +129,13 @@ class GitLabDropdown
if
@
remote
if
@
remote
@
remote
.
execute
()
@
remote
.
execute
()
if
@
options
.
filterable
@
dropdown
.
find
(
".dropdown-input-field"
).
focus
()
hidden
:
=>
if
@
options
.
filterable
@
dropdown
.
find
(
".dropdown-input-field"
).
blur
().
val
(
""
)
# Render the full menu
# Render the full menu
renderMenu
:
(
html
)
->
renderMenu
:
(
html
)
->
menu_html
=
""
menu_html
=
""
...
...
app/assets/javascripts/labels_select.js.coffee
View file @
8ca880c3
...
@@ -5,7 +5,7 @@ class @LabelsSelect
...
@@ -5,7 +5,7 @@ class @LabelsSelect
selectedLabel
=
$
(
dropdown
).
data
(
'selected'
)
selectedLabel
=
$
(
dropdown
).
data
(
'selected'
)
$
(
dropdown
).
glDropdown
(
$
(
dropdown
).
glDropdown
(
data
:
(
callback
)
->
data
:
(
term
,
callback
)
->
Api
.
projectLabels
8
,
callback
Api
.
projectLabels
8
,
callback
renderRow
:
(
label
)
->
renderRow
:
(
label
)
->
selected
=
if
label
.
name
is
selectedLabel
then
"is-active"
else
""
selected
=
if
label
.
name
is
selectedLabel
then
"is-active"
else
""
...
...
app/assets/javascripts/milestone_select.js.coffee
View file @
8ca880c3
...
@@ -5,11 +5,11 @@ class @MilestoneSelect
...
@@ -5,11 +5,11 @@ class @MilestoneSelect
selectedMilestone
=
$
(
dropdown
).
data
(
'selected'
)
selectedMilestone
=
$
(
dropdown
).
data
(
'selected'
)
$
(
dropdown
).
glDropdown
(
$
(
dropdown
).
glDropdown
(
data
:
(
callback
)
->
data
:
(
term
,
callback
)
->
Api
.
milestones
projectId
,
callback
Api
.
milestones
projectId
,
callback
filterable
:
true
filterable
:
true
search
:
search
:
fields
:
[
'
nam
e'
]
fields
:
[
'
titl
e'
]
selectable
:
true
selectable
:
true
fieldName
:
$
(
dropdown
).
data
(
'field-name'
)
fieldName
:
$
(
dropdown
).
data
(
'field-name'
)
text
:
(
milestone
)
->
text
:
(
milestone
)
->
...
...
app/assets/javascripts/users_select.js.coffee
View file @
8ca880c3
...
@@ -6,20 +6,41 @@ class @UsersSelect
...
@@ -6,20 +6,41 @@ class @UsersSelect
$
(
'.js-user-search'
).
each
(
i
,
dropdown
)
=>
$
(
'.js-user-search'
).
each
(
i
,
dropdown
)
=>
projectId
=
$
(
dropdown
).
data
(
'project-id'
)
projectId
=
$
(
dropdown
).
data
(
'project-id'
)
showNullUser
=
$
(
dropdown
).
data
(
'null-user'
)
showNullUser
=
$
(
dropdown
).
data
(
'null-user'
)
showAnyUser
=
$
(
dropdown
).
data
(
'any-user'
)
firstUser
=
$
(
dropdown
).
data
(
'first-user'
)
selectedId
=
$
(
dropdown
).
data
(
'selected'
)
selectedId
=
$
(
dropdown
).
data
(
'selected'
)
$
(
dropdown
).
glDropdown
(
$
(
dropdown
).
glDropdown
(
data
:
(
callback
)
=>
data
:
(
term
,
callback
)
=>
@
users
""
,
(
users
)
=>
@
users
term
,
(
users
)
=>
if
term
.
length
is
0
if
firstUser
# Move current user to the front of the list
for
obj
,
index
in
users
if
obj
.
username
==
firstUser
users
.
splice
(
index
,
1
)
users
.
unshift
(
obj
)
break
if
showNullUser
if
showNullUser
users
.
unshift
(
users
.
unshift
(
name
:
'Unassigned'
,
name
:
'Unassigned'
,
id
:
0
id
:
0
)
)
if
showAnyUser
name
=
showAnyUser
name
=
'Any User'
if
name
==
true
anyUser
=
{
name
:
name
,
id
:
null
}
users
.
unshift
(
anyUser
)
# Send the data back
# Send the data back
callback
users
callback
users
filterable
:
true
filterable
:
true
filterRemote
:
true
search
:
search
:
fields
:
[
'name'
,
'username'
]
fields
:
[
'name'
,
'username'
]
selectable
:
true
selectable
:
true
...
...
app/helpers/dropdowns_helper.rb
View file @
8ca880c3
...
@@ -17,7 +17,7 @@ module DropdownsHelper
...
@@ -17,7 +17,7 @@ module DropdownsHelper
output
+=
content_tag
:div
,
class:
"dropdown-title"
do
output
+=
content_tag
:div
,
class:
"dropdown-title"
do
title_output
=
content_tag
(
:span
,
title
)
title_output
=
content_tag
(
:span
,
title
)
title_output
+=
content_tag
:button
,
class:
"dropdown-title-button dropdown-menu-close"
,
aria:
{
label:
"close"
}
do
title_output
+=
content_tag
:button
,
class:
"dropdown-title-button dropdown-menu-close"
,
aria:
{
label:
"close"
}
,
type:
"button"
do
icon
(
'times'
)
icon
(
'times'
)
end
.
html_safe
end
.
html_safe
end
end
...
...
app/views/shared/issuable/_filter.html.haml
View file @
8ca880c3
...
@@ -7,18 +7,26 @@
...
@@ -7,18 +7,26 @@
class:
"check_all_issues left"
class:
"check_all_issues left"
.issues-other-filters
.issues-other-filters
.filter-item.inline
.filter-item.inline
-
if
params
[
:author_id
]
=
hidden_field_tag
(
:author_id
,
params
[
:author_id
])
=
dropdown_tag
(
"Author"
,
toggle_class:
"js-user-search"
,
title:
"Filter by author"
,
filter:
true
,
dropdown_class:
"dropdown-menu-user dropdown-menu-selectable"
,
=
dropdown_tag
(
"Author"
,
toggle_class:
"js-user-search"
,
title:
"Filter by author"
,
filter:
true
,
dropdown_class:
"dropdown-menu-user dropdown-menu-selectable"
,
placeholder:
"Search authors"
,
data:
{
any_user:
"Any Author"
,
first_user:
true
,
current_user:
true
,
project_id:
@project
.
id
,
selected:
params
[
:author_id
],
field_name:
"author_id"
})
placeholder:
"Search authors"
,
data:
{
any_user:
"Any Author"
,
first_user:
true
,
current_user:
true
,
project_id:
@project
.
id
,
selected:
params
[
:author_id
],
field_name:
"author_id"
})
.filter-item.inline
.filter-item.inline
-
if
params
[
:assignee_id
]
=
hidden_field_tag
(
:assignee_id
,
params
[
:assignee_id
])
=
dropdown_tag
(
"Assignee"
,
toggle_class:
"js-user-search"
,
title:
"Filter by assignee"
,
filter:
true
,
dropdown_class:
"dropdown-menu-user dropdown-menu-selectable"
,
=
dropdown_tag
(
"Assignee"
,
toggle_class:
"js-user-search"
,
title:
"Filter by assignee"
,
filter:
true
,
dropdown_class:
"dropdown-menu-user dropdown-menu-selectable"
,
placeholder:
"Search assignee"
,
data:
{
any_user:
"Any Author"
,
first_user:
true
,
null_user:
true
,
current_user:
true
,
project_id:
@project
.
id
,
selected:
params
[
:assignee_id
],
field_name:
"assignee_id"
})
placeholder:
"Search assignee"
,
data:
{
any_user:
"Any Author"
,
first_user:
true
,
null_user:
true
,
current_user:
true
,
project_id:
@project
.
id
,
selected:
params
[
:assignee_id
],
field_name:
"assignee_id"
})
.filter-item.inline.milestone-filter
.filter-item.inline.milestone-filter
-
if
params
[
:milestone_title
]
=
hidden_field_tag
(
:milestone_title
,
params
[
:milestone_title
])
=
dropdown_tag
(
"Milestone"
,
title:
"Filter by milestone"
,
toggle_class:
'js-milestone-select'
,
filter:
true
,
dropdown_class:
"dropdown-menu-selectable"
,
=
dropdown_tag
(
"Milestone"
,
title:
"Filter by milestone"
,
toggle_class:
'js-milestone-select'
,
filter:
true
,
dropdown_class:
"dropdown-menu-selectable"
,
placeholder:
"Search milestones"
,
data:
{
field_name:
"milestone_title"
,
selected:
params
[
:milestone_title
],
project_id:
@project
.
id
})
placeholder:
"Search milestones"
,
data:
{
field_name:
"milestone_title"
,
selected:
params
[
:milestone_title
],
project_id:
@project
.
id
})
.filter-item.inline.labels-filter
.filter-item.inline.labels-filter
-
if
params
[
:label_name
]
=
hidden_field_tag
(
:label_name
,
params
[
:label_name
])
=
dropdown_tag
(
"Label"
,
title:
"Filter by label"
,
toggle_class:
"js-label-select"
,
filter:
true
,
dropdown_class:
"dropdown-menu-labels dropdown-menu-selectable"
,
=
dropdown_tag
(
"Label"
,
title:
"Filter by label"
,
toggle_class:
"js-label-select"
,
filter:
true
,
dropdown_class:
"dropdown-menu-labels dropdown-menu-selectable"
,
placeholder:
"Search labels"
,
footer_content:
true
,
data:
{
field_name:
"label_name"
,
selected:
params
[
:label_name
],
project_id:
@project
.
id
})
do
placeholder:
"Search labels"
,
footer_content:
true
,
data:
{
field_name:
"label_name"
,
selected:
params
[
:label_name
],
project_id:
@project
.
id
})
do
%ul
.dropdown-footer-list
%ul
.dropdown-footer-list
...
...
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