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
Jérome Perrin
gitlab-ce
Commits
bc0666b3
Commit
bc0666b3
authored
Apr 19, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Filter issuables by any user
Closes #2836
parent
adc64e45
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
12 deletions
+46
-12
app/assets/javascripts/users_select.js.coffee
app/assets/javascripts/users_select.js.coffee
+7
-5
app/helpers/issuables_helper.rb
app/helpers/issuables_helper.rb
+2
-6
app/views/shared/issuable/_filter.html.haml
app/views/shared/issuable/_filter.html.haml
+1
-1
spec/features/issues/filter_issues_spec.rb
spec/features/issues/filter_issues_spec.rb
+36
-0
No files found.
app/assets/javascripts/users_select.js.coffee
View file @
bc0666b3
...
@@ -93,7 +93,9 @@ class @UsersSelect
...
@@ -93,7 +93,9 @@ class @UsersSelect
$dropdown
.
glDropdown
(
$dropdown
.
glDropdown
(
data
:
(
term
,
callback
)
=>
data
:
(
term
,
callback
)
=>
@
users
term
,
(
users
)
=>
isAuthorFilter
=
$
(
'.js-author-search'
)
@
users
term
,
term
is
''
and
isAuthorFilter
,
(
users
)
=>
if
term
.
length
is
0
if
term
.
length
is
0
showDivider
=
0
showDivider
=
0
...
@@ -138,7 +140,7 @@ class @UsersSelect
...
@@ -138,7 +140,7 @@ class @UsersSelect
toggleLabel
:
(
selected
)
->
toggleLabel
:
(
selected
)
->
if
selected
&&
'id'
of
selected
if
selected
&&
'id'
of
selected
selected
.
name
if
selected
.
text
then
selected
.
text
else
selected
.
name
else
else
defaultLabel
defaultLabel
...
@@ -219,7 +221,7 @@ class @UsersSelect
...
@@ -219,7 +221,7 @@ class @UsersSelect
multiple
:
$
(
select
).
hasClass
(
'multiselect'
)
multiple
:
$
(
select
).
hasClass
(
'multiselect'
)
minimumInputLength
:
0
minimumInputLength
:
0
query
:
(
query
)
=>
query
:
(
query
)
=>
@
users
query
.
term
,
(
users
)
=>
@
users
query
.
term
,
false
,
(
users
)
=>
data
=
{
results
:
users
}
data
=
{
results
:
users
}
if
query
.
term
.
length
==
0
if
query
.
term
.
length
==
0
...
@@ -302,7 +304,7 @@ class @UsersSelect
...
@@ -302,7 +304,7 @@ class @UsersSelect
# Return users list. Filtered by query
# Return users list. Filtered by query
# Only active users retrieved
# Only active users retrieved
users
:
(
query
,
callback
)
=>
users
:
(
query
,
fromProject
,
callback
)
=>
url
=
@
buildUrl
(
@
usersPath
)
url
=
@
buildUrl
(
@
usersPath
)
$
.
ajax
(
$
.
ajax
(
...
@@ -311,7 +313,7 @@ class @UsersSelect
...
@@ -311,7 +313,7 @@ class @UsersSelect
search
:
query
search
:
query
per_page
:
20
per_page
:
20
active
:
true
active
:
true
project_id
:
@
projectId
project_id
:
@
projectId
if
fromProject
group_id
:
@
groupId
group_id
:
@
groupId
current_user
:
@
showCurrentUser
current_user
:
@
showCurrentUser
author_id
:
@
authorId
author_id
:
@
authorId
...
...
app/helpers/issuables_helper.rb
View file @
bc0666b3
...
@@ -50,14 +50,10 @@ module IssuablesHelper
...
@@ -50,14 +50,10 @@ module IssuablesHelper
end
end
def
user_dropdown_label
(
user_id
,
default_label
)
def
user_dropdown_label
(
user_id
,
default_label
)
return
default_label
if
user_id
.
nil?
return
"Unassigned"
if
user_id
==
"0"
return
"Unassigned"
if
user_id
==
"0"
if
@project
member
=
@project
.
team
.
find_member
(
user_id
)
user
=
member
.
user
if
member
else
user
=
User
.
find_by
(
id:
user_id
)
user
=
User
.
find_by
(
id:
user_id
)
end
if
user
if
user
user
.
name
user
.
name
...
...
app/views/shared/issuable/_filter.html.haml
View file @
bc0666b3
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
-
if
params
[
:author_id
].
present?
-
if
params
[
:author_id
].
present?
=
hidden_field_tag
(
:author_id
,
params
[
:author_id
])
=
hidden_field_tag
(
:author_id
,
params
[
:author_id
])
=
dropdown_tag
(
user_dropdown_label
(
params
[
:author_id
],
"Author"
),
options:
{
toggle_class:
"js-user-search js-filter-submit js-author-search"
,
title:
"Filter by author"
,
filter:
true
,
dropdown_class:
"dropdown-menu-user dropdown-menu-selectable dropdown-menu-author js-filter-submit"
,
=
dropdown_tag
(
user_dropdown_label
(
params
[
:author_id
],
"Author"
),
options:
{
toggle_class:
"js-user-search js-filter-submit js-author-search"
,
title:
"Filter by author"
,
filter:
true
,
dropdown_class:
"dropdown-menu-user dropdown-menu-selectable dropdown-menu-author js-filter-submit"
,
placeholder:
"Search authors"
,
data:
{
any_user:
"Any Author"
,
first_user:
(
current_user
.
username
if
current_user
),
current_user:
true
,
project_id:
(
@project
.
id
if
@project
),
selected:
params
[
:author
_id
],
field_name:
"author_id"
,
default_label:
"Author"
}
})
placeholder:
"Search authors"
,
data:
{
any_user:
"Any Author"
,
first_user:
(
current_user
.
username
if
current_user
),
current_user:
true
,
project_id:
(
@project
.
id
if
@project
),
selected:
params
[
:author
],
field_name:
"author_id"
,
default_label:
"Author"
}
})
.filter-item.inline
.filter-item.inline
-
if
params
[
:assignee_id
].
present?
-
if
params
[
:assignee_id
].
present?
...
...
spec/features/issues/filter_issues_spec.rb
View file @
bc0666b3
...
@@ -294,4 +294,40 @@ describe 'Filter issues', feature: true do
...
@@ -294,4 +294,40 @@ describe 'Filter issues', feature: true do
end
end
end
end
end
end
describe
'filter by any author'
,
js:
true
do
before
do
user2
=
create
(
:user
,
name:
"tester"
)
create
(
:issue
,
project:
project
,
author:
user
)
create
(
:issue
,
project:
project
,
author:
user2
)
visit
namespace_project_issues_path
(
project
.
namespace
,
project
)
end
it
'should show filter by any author link'
do
click_button
"Author"
fill_in
"Search authors"
,
with:
"tester"
page
.
within
".dropdown-menu-author"
do
expect
(
page
).
to
have_content
"tester"
end
end
it
'should show filter issues by any author'
do
page
.
within
'.issues-list'
do
expect
(
page
).
to
have_selector
".issue"
,
count:
2
end
click_button
"Author"
fill_in
"Search authors"
,
with:
"tester"
page
.
within
".dropdown-menu-author"
do
click_link
"tester"
end
page
.
within
'.issues-list'
do
expect
(
page
).
to
have_selector
".issue"
,
count:
1
end
end
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