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
Tatuya Kamada
gitlab-ce
Commits
3ee3cb24
Commit
3ee3cb24
authored
Jun 24, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow user to filter by Issues/Merge Requests without a Milestone
parent
ea565653
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
104 additions
and
4 deletions
+104
-4
app/finders/issuable_finder.rb
app/finders/issuable_finder.rb
+7
-2
app/helpers/milestones_helper.rb
app/helpers/milestones_helper.rb
+2
-0
app/models/no_milestone.rb
app/models/no_milestone.rb
+13
-0
app/views/shared/issuable/_filter.html.haml
app/views/shared/issuable/_filter.html.haml
+6
-2
spec/features/issues/filter_by_milestone_spec.rb
spec/features/issues/filter_by_milestone_spec.rb
+38
-0
spec/features/merge_requests/filter_by_milestone_spec.rb
spec/features/merge_requests/filter_by_milestone_spec.rb
+38
-0
No files found.
app/finders/issuable_finder.rb
View file @
3ee3cb24
...
@@ -76,7 +76,7 @@ class IssuableFinder
...
@@ -76,7 +76,7 @@ class IssuableFinder
return
@milestones
if
defined?
(
@milestones
)
return
@milestones
if
defined?
(
@milestones
)
@milestones
=
@milestones
=
if
milestones?
&&
params
[
:milestone_title
]
!=
N
ONE
if
milestones?
&&
params
[
:milestone_title
]
!=
N
oMilestone
.
title
Milestone
.
where
(
title:
params
[
:milestone_title
])
Milestone
.
where
(
title:
params
[
:milestone_title
])
else
else
nil
nil
...
@@ -183,7 +183,12 @@ class IssuableFinder
...
@@ -183,7 +183,12 @@ class IssuableFinder
def
by_milestone
(
items
)
def
by_milestone
(
items
)
if
milestones?
if
milestones?
items
=
items
.
where
(
milestone_id:
milestones
.
try
(
:pluck
,
:id
))
# `milestone_title` will still be present when "No Milestone" is selected
if
params
[
:milestone_title
]
!=
NoMilestone
.
title
items
=
items
.
where
(
milestone_id:
milestones
.
try
(
:pluck
,
:id
))
else
items
=
items
.
where
(
milestone_id:
NoMilestone
.
id
)
end
end
end
items
items
...
...
app/helpers/milestones_helper.rb
View file @
3ee3cb24
...
@@ -29,6 +29,8 @@ module MilestonesHelper
...
@@ -29,6 +29,8 @@ module MilestonesHelper
end
.
active
end
.
active
grouped_milestones
=
Milestones
::
GroupService
.
new
(
milestones
).
execute
grouped_milestones
=
Milestones
::
GroupService
.
new
(
milestones
).
execute
grouped_milestones
.
unshift
(
NoMilestone
)
options_from_collection_for_select
(
grouped_milestones
,
'title'
,
'title'
,
params
[
:milestone_title
])
options_from_collection_for_select
(
grouped_milestones
,
'title'
,
'title'
,
params
[
:milestone_title
])
end
end
end
end
app/models/no_milestone.rb
0 → 100644
View file @
3ee3cb24
# NoMilestone
#
# Represents a "No Milestone" state used for filtering Issues and Merge Requests
# that have no milestone assigned.
class
NoMilestone
def
self
.
id
nil
end
def
self
.
title
'No Milestone'
end
end
app/views/shared/issuable/_filter.html.haml
View file @
3ee3cb24
...
@@ -43,11 +43,15 @@
...
@@ -43,11 +43,15 @@
placeholder:
'Author'
,
class:
'trigger-submit'
,
any_user:
true
,
first_user:
true
)
placeholder:
'Author'
,
class:
'trigger-submit'
,
any_user:
true
,
first_user:
true
)
.filter-item.inline.milestone-filter
.filter-item.inline.milestone-filter
=
select_tag
(
'milestone_title'
,
projects_milestones_options
,
class:
"select2 trigger-submit"
,
prompt:
'Milestone'
)
=
select_tag
(
'milestone_title'
,
projects_milestones_options
,
class:
'select2 trigger-submit'
,
include_blank:
true
,
data:
{
placeholder:
'Milestone'
})
-
if
@project
-
if
@project
.filter-item.inline.labels-filter
.filter-item.inline.labels-filter
=
select_tag
(
'label_name'
,
project_labels_options
(
@project
),
class:
"select2 trigger-submit"
,
prompt:
'Label'
)
=
select_tag
(
'label_name'
,
project_labels_options
(
@project
),
class:
'select2 trigger-submit'
,
include_blank:
true
,
data:
{
placeholder:
'Label'
})
.pull-right
.pull-right
=
render
'shared/sort_dropdown'
=
render
'shared/sort_dropdown'
...
...
spec/features/issues/filter_by_milestone_spec.rb
0 → 100644
View file @
3ee3cb24
require
'spec_helper'
feature
'Issue filtering by Milestone'
do
include
Select2Helper
let
(
:project
)
{
create
(
:empty_project
)
}
before
do
login_as
(
:admin
)
end
scenario
'User filters by Issues without a Milestone'
,
js:
true
do
create
(
:issue
,
project:
project
)
visit_issues
filter_by_milestone
(
NoMilestone
.
title
)
expect
(
page
).
to
have_css
(
'.issue-title'
,
count:
1
)
end
scenario
'User filters by Issues with a specific Milestone'
,
js:
true
do
milestone
=
create
(
:milestone
,
project:
project
)
create
(
:issue
,
project:
project
,
milestone:
milestone
)
visit_issues
filter_by_milestone
(
milestone
.
title
)
expect
(
page
).
to
have_css
(
'.issue-title'
,
count:
1
)
end
def
visit_issues
visit
namespace_project_issues_path
(
project
.
namespace
,
project
)
end
def
filter_by_milestone
(
title
)
select2
(
title
,
from:
'#milestone_title'
)
end
end
spec/features/merge_requests/filter_by_milestone_spec.rb
0 → 100644
View file @
3ee3cb24
require
'spec_helper'
feature
'Merge Request filtering by Milestone'
do
include
Select2Helper
let
(
:project
)
{
create
(
:project
)
}
before
do
login_as
(
:admin
)
end
scenario
'User filters by Merge Requests without a Milestone'
,
js:
true
do
create
(
:merge_request
,
:simple
,
source_project:
project
)
visit_merge_requests
filter_by_milestone
(
NoMilestone
.
title
)
expect
(
page
).
to
have_css
(
'.merge-request-title'
,
count:
1
)
end
scenario
'User filters by Merge Requests with a specific Milestone'
,
js:
true
do
milestone
=
create
(
:milestone
,
project:
project
)
create
(
:merge_request
,
:simple
,
source_project:
project
,
milestone:
milestone
)
visit_merge_requests
filter_by_milestone
(
milestone
.
title
)
expect
(
page
).
to
have_css
(
'.merge-request-title'
,
count:
1
)
end
def
visit_merge_requests
visit
namespace_project_merge_requests_path
(
project
.
namespace
,
project
)
end
def
filter_by_milestone
(
title
)
select2
(
title
,
from:
'#milestone_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