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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
2fd7261d
Commit
2fd7261d
authored
Nov 23, 2018
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Render ordering button for opposite direction
parent
d136f84a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
10 deletions
+39
-10
ee/app/helpers/ee/sorting_helper.rb
ee/app/helpers/ee/sorting_helper.rb
+29
-1
ee/app/models/ee/epic.rb
ee/app/models/ee/epic.rb
+5
-0
ee/app/views/shared/epic/_sort_dropdown.html.haml
ee/app/views/shared/epic/_sort_dropdown.html.haml
+5
-8
ee/spec/features/epics/epics_list_spec.rb
ee/spec/features/epics/epics_list_spec.rb
+0
-1
No files found.
ee/app/helpers/ee/sorting_helper.rb
View file @
2fd7261d
...
...
@@ -3,6 +3,9 @@ module EE
module
SortingHelper
extend
::
Gitlab
::
Utils
::
Override
ORDER_ASC
=
'asc'
.
freeze
ORDER_DESC
=
'desc'
.
freeze
override
:sort_options_hash
def
sort_options_hash
{
...
...
@@ -16,13 +19,38 @@ module EE
def
epics_sort_options_hash
{
sort_value_oldest_created
=>
sort_title_created_date
,
sort_value_recently_created
=>
sort_title_created_date
,
sort_value_oldest_updated
=>
sort_title_recently_updated
,
sort_value_recently_updated
=>
sort_title_recently_updated
,
sort_value_start_date
=>
sort_title_start_date
,
sort_value_start_date_later
=>
sort_title_start_date
,
sort_value_start_date_soon
=>
sort_title_start_date
,
sort_value_end_date_later
=>
sort_title_end_date
,
sort_value_end_date
=>
sort_title_end_date
}
end
# This method is used to find the opposite ordering parameter for the sort button in the UI.
# Hash key is the descending sorting order and the sort value is the opposite of it for the same field.
# For example: created_at_asc => created_at_desc
def
epics_ordering_options_hash
{
sort_value_oldest_created
=>
sort_value_recently_created
,
sort_value_oldest_updated
=>
sort_value_recently_updated
,
sort_value_start_date_soon
=>
sort_value_start_date_later
,
sort_value_end_date
=>
sort_value_end_date_later
}
end
# Creates a button with the opposite ordering for the current field in UI.
def
sort_order_button
(
sort
)
opposite_sorting_param
=
epics_ordering_options_hash
[
sort
]
||
epics_ordering_options_hash
.
key
(
sort
)
sort_icon
=
sort
.
end_with?
(
'desc'
)
?
'sort-highest'
:
' sort-lowest'
link_to
sort_icon
,
page_filter_path
(
sort:
opposite_sorting_param
,
label:
true
)
end
def
sort_title_start_date
s_
(
'SortOptions|Start date'
)
end
...
...
ee/app/models/ee/epic.rb
View file @
2fd7261d
...
...
@@ -58,6 +58,10 @@ module EE
reorder
(
::
Gitlab
::
Database
.
nulls_last_order
(
'end_date'
,
'DESC'
),
'id DESC'
)
end
scope
:order_start_date_desc
,
->
do
reorder
(
::
Gitlab
::
Database
.
nulls_last_order
(
'start_date'
,
'DESC'
),
'id DESC'
)
end
def
etag_caching_enabled?
true
end
...
...
@@ -106,6 +110,7 @@ module EE
case
method
.
to_s
when
'start_or_end_date'
then
order_start_or_end_date_asc
when
'start_date_asc'
then
order_start_date_asc
when
'start_date_desc'
then
order_start_date_desc
when
'end_date_asc'
then
order_end_date_asc
when
'end_date_desc'
then
order_end_date_desc
else
...
...
ee/app/views/shared/epic/_sort_dropdown.html.haml
View file @
2fd7261d
...
...
@@ -9,12 +9,9 @@
%li
=
sortable_item
(
sort_title_created_date
,
page_filter_path
(
sort:
sort_value_recently_created
,
label:
true
),
sorted_by
)
=
sortable_item
(
sort_title_recently_updated
,
page_filter_path
(
sort:
sort_value_recently_updated
,
label:
true
),
sorted_by
)
=
sortable_item
(
sort_title_start_date
,
page_filter_path
(
sort:
sort_value_start_date
,
label:
true
),
sorted_by
)
=
sortable_item
(
sort_title_end_date
,
page_filter_path
(
sort:
sort_value_end_date
,
label:
true
),
sorted_by
)
=
sortable_item
(
sort_title_start_date
,
page_filter_path
(
sort:
sort_value_start_date
_later
,
label:
true
),
sorted_by
)
=
sortable_item
(
sort_title_end_date
,
page_filter_path
(
sort:
sort_value_end_date
_later
,
label:
true
),
sorted_by
)
%button
.dropdown-toggle-split.pt-2
{
type:
'button'
}
=
sprite_icon
(
'sort-highest'
,
size:
16
)
-# = sprite_icon('sort-lowest', size: 16)
=
sorted_by
=
|
=
@sort
=
sort_order_button
(
@sort
)
-#= sprite_icon('sort-highest', size: 16)
-#= sprite_icon('sort-lowest', size: 16)
ee/spec/features/epics/epics_list_spec.rb
View file @
2fd7261d
...
...
@@ -67,7 +67,6 @@ describe 'epics list', :js do
it
'sorts by the selected value and stores the selection for epic list & roadmap'
do
page
.
within
(
'.epics-other-filters'
)
do
live_debug
click_button
'Due date'
sort_options
=
find
(
'ul.dropdown-menu-sort li'
).
all
(
'a'
).
collect
(
&
:text
)
...
...
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