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
1dbebd54
Commit
1dbebd54
authored
Dec 03, 2018
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CE backport]Add sort direction button with sort dropdown for epics
parent
8cd5004b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletion
+28
-1
app/controllers/concerns/issuable_collections.rb
app/controllers/concerns/issuable_collections.rb
+27
-1
spec/controllers/concerns/issuable_collections_spec.rb
spec/controllers/concerns/issuable_collections_spec.rb
+1
-0
No files found.
app/controllers/concerns/issuable_collections.rb
View file @
1dbebd54
...
...
@@ -91,7 +91,7 @@ module IssuableCollections
options
=
{
scope:
params
[
:scope
],
state:
params
[
:state
],
sort:
set_sort_order
_from_cookie
||
default_sort_order
sort:
set_sort_order
}
# Used by view to highlight active option
...
...
@@ -113,6 +113,32 @@ module IssuableCollections
'opened'
end
def
set_sort_order
set_sort_order_from_user_preference
||
set_sort_order_from_cookie
||
default_sort_order
end
def
set_sort_order_from_user_preference
return
unless
current_user
return
unless
issuable_sorting_field
user_preference
=
current_user
.
user_preference
sort_param
=
params
[
:sort
]
sort_param
||=
user_preference
[
issuable_sorting_field
]
if
user_preference
[
issuable_sorting_field
]
!=
sort_param
user_preference
.
update_attribute
(
issuable_sorting_field
,
sort_param
)
end
sort_param
end
# Implement default_sorting_field method on controllers
# to choose which column to store the sorting parameter.
def
issuable_sorting_field
nil
end
def
set_sort_order_from_cookie
sort_param
=
params
[
:sort
]
if
params
[
:sort
].
present?
# fallback to legacy cookie value for backward compatibility
...
...
spec/controllers/concerns/issuable_collections_spec.rb
View file @
1dbebd54
...
...
@@ -86,6 +86,7 @@ describe IssuableCollections do
it
'only allows whitelisted params'
do
allow
(
controller
).
to
receive
(
:cookies
).
and_return
({})
allow
(
controller
).
to
receive
(
:current_user
).
and_return
(
nil
)
finder_options
=
controller
.
send
(
:finder_options
)
...
...
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