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
a4e41107
Commit
a4e41107
authored
Nov 27, 2016
by
Semyon Pupkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor issuable_filters_present to reduce duplications
https://gitlab.com/gitlab-org/gitlab-ce/issues/23546
parent
70d4d2fb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
7 deletions
+42
-7
app/helpers/issuables_helper.rb
app/helpers/issuables_helper.rb
+15
-5
app/views/shared/issuable/_filter.html.haml
app/views/shared/issuable/_filter.html.haml
+2
-2
changelogs/unreleased/issuable_filters_present-refactor.yml
changelogs/unreleased/issuable_filters_present-refactor.yml
+4
-0
spec/helpers/issuables_helper_spec.rb
spec/helpers/issuables_helper_spec.rb
+21
-0
No files found.
app/helpers/issuables_helper.rb
View file @
a4e41107
...
...
@@ -143,6 +143,20 @@ module IssuablesHelper
end
end
def
issuable_filter_params
[
:search
,
:author_id
,
:assignee_id
,
:milestone_title
,
:label_name
]
end
def
issuable_filter_present?
issuable_filter_params
.
any?
{
|
k
|
params
.
key?
(
k
)
}
end
private
def
assigned_issuables_count
(
assignee
,
issuable_type
,
state
)
...
...
@@ -165,10 +179,6 @@ module IssuablesHelper
end
end
def
issuable_filters_present
params
[
:search
]
||
params
[
:author_id
]
||
params
[
:assignee_id
]
||
params
[
:milestone_title
]
||
params
[
:label_name
]
end
def
issuables_count_for_state
(
issuable_type
,
state
)
issuables_finder
=
public_send
(
"
#{
issuable_type
}
_finder"
)
...
...
app/views/shared/issuable/_filter.html.haml
View file @
a4e41107
...
...
@@ -29,9 +29,9 @@
.filter-item.inline.labels-filter
=
render
"shared/issuable/label_dropdown"
,
selected:
finder
.
labels
.
select
(
:title
).
uniq
,
use_id:
false
,
selected_toggle:
params
[
:label_name
],
data_options:
{
field_name:
"label_name[]"
}
-
if
issuable_filter
s_present
-
if
issuable_filter
_present?
.filter-item.inline.reset-filters
%a
{
href:
page_filter_path
(
without:
[
:assignee_id
,
:author_id
,
:milestone_title
,
:label_name
,
:search
]
)}
Reset filters
%a
{
href:
page_filter_path
(
without:
issuable_filter_params
)}
Reset filters
.pull-right
-
if
boards_page
...
...
changelogs/unreleased/issuable_filters_present-refactor.yml
0 → 100644
View file @
a4e41107
---
title
:
Refactor issuable_filters_present to reduce duplications
merge_request
:
7776
author
:
Semyon Pupkov
spec/helpers/issuables_helper_spec.rb
View file @
a4e41107
...
...
@@ -114,4 +114,25 @@ describe IssuablesHelper do
end
end
end
describe
'#issuable_filter_present?'
do
it
'returns true when any key is present'
do
allow
(
helper
).
to
receive
(
:params
).
and_return
(
ActionController
::
Parameters
.
new
(
milestone_title:
'Velit consectetur asperiores natus delectus.'
,
project_id:
'gitlabhq'
,
scope:
'all'
)
)
expect
(
helper
.
issuable_filter_present?
).
to
be_truthy
end
it
'returns false when no key is present'
do
allow
(
helper
).
to
receive
(
:params
).
and_return
(
ActionController
::
Parameters
.
new
(
project_id:
'gitlabhq'
,
scope:
'all'
)
)
expect
(
helper
.
issuable_filter_present?
).
to
be_falsey
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