Commit e21b38b7 authored by Mario de la Ossa's avatar Mario de la Ossa

Reinstate sorting by weight in issues

We accidentally removed the ability to sort issues by weight when
porting a sorting change to EE, so this fixes that.
parent 853a365c
......@@ -200,5 +200,3 @@ module IssuableCollections
end
end
end
IssuableCollections.prepend(EE::IssuableCollections)
......@@ -161,6 +161,15 @@ module SortingHelper
sort_options_hash[sort_value]
end
def issuable_sort_icon_suffix(sort_value)
case sort_value
when sort_value_milestone, sort_value_due_date, /_asc\z/
'lowest'
else
'highest'
end
end
def issuable_sort_direction_button(sort_value)
link_class = 'btn btn-default has-tooltip reverse-sort-btn qa-reverse-sort'
reverse_sort = issuable_reverse_sort_order_hash[sort_value]
......@@ -173,15 +182,7 @@ module SortingHelper
end
link_to(reverse_url, type: 'button', class: link_class, title: 'Sort direction') do
icon_suffix =
case sort_value
when sort_value_milestone, sort_value_due_date, /_asc\z/
'lowest'
else
'highest'
end
sprite_icon("sort-#{icon_suffix}", size: 16)
sprite_icon("sort-#{issuable_sort_icon_suffix(sort_value)}", size: 16)
end
end
......
......@@ -17,4 +17,5 @@
= sortable_item(sort_title_due_date, page_filter_path(sort: sort_value_due_date), sort_title) if viewing_issues
= sortable_item(sort_title_popularity, page_filter_path(sort: sort_value_popularity), sort_title)
= sortable_item(sort_title_label_priority, page_filter_path(sort: sort_value_label_priority), sort_title)
= render_if_exists('shared/ee/issuable/sort_dropdown', viewing_issues: viewing_issues, sort_title: sort_title)
= issuable_sort_direction_button(sort_value)
# frozen_string_literal: true
module EE
module IssuableCollections
extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
# Update old values to the actual ones.
override :update_cookie_value
def update_cookie_value(value)
if value == 'weight_asc' || value == 'weight_desc'
sort_value_weight
else
super
end
end
end
end
......@@ -41,6 +41,29 @@ module EE
}
end
override :issuable_reverse_sort_order_hash
def issuable_reverse_sort_order_hash
{
sort_value_weight => sort_value_more_weight
}.merge(super)
end
override :issuable_sort_option_overrides
def issuable_sort_option_overrides
{
sort_value_more_weight => sort_value_weight
}.merge(super)
end
override :issuable_sort_icon_suffix
def issuable_sort_icon_suffix(sort_value)
if sort_value == sort_value_weight
'lowest'
else
super
end
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)
......
- allow_weight_sort = viewing_issues && (@project || @group)&.feature_available?(:issue_weights)
= sortable_item(sort_title_weight, page_filter_path(sort: sort_value_weight), sort_title) if allow_weight_sort
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment