diff options
author | Fatih Acet <acetfatih@gmail.com> | 2018-12-06 19:57:19 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-12-06 19:57:19 +0300 |
commit | fbb4f15d1b656e23ff1700b40101cad1537b54ca (patch) | |
tree | f161993297cd31fd10bcc624a0179fae539fe59d /app/helpers/sorting_helper.rb | |
parent | dc9c1f3a143664984b47bd1dd33876874d43b38e (diff) |
Sort issues and merge requests in ascending and descending order
Diffstat (limited to 'app/helpers/sorting_helper.rb')
-rw-r--r-- | app/helpers/sorting_helper.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/app/helpers/sorting_helper.rb b/app/helpers/sorting_helper.rb index 74113aee89d..f51b96ba8ce 100644 --- a/app/helpers/sorting_helper.rb +++ b/app/helpers/sorting_helper.rb @@ -136,6 +136,53 @@ module SortingHelper link_to item, path, class: sorted_by == item ? 'is-active' : '' end + def issuable_sort_option_overrides + { + sort_value_oldest_created => sort_value_created_date, + sort_value_oldest_updated => sort_value_recently_updated, + sort_value_milestone_later => sort_value_milestone + } + end + + def issuable_reverse_sort_order_hash + { + sort_value_created_date => sort_value_oldest_created, + sort_value_recently_created => sort_value_oldest_created, + sort_value_recently_updated => sort_value_oldest_updated, + sort_value_milestone => sort_value_milestone_later + }.merge(issuable_sort_option_overrides) + end + + def issuable_sort_option_title(sort_value) + sort_value = issuable_sort_option_overrides[sort_value] || sort_value + + sort_options_hash[sort_value] + 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] + + if reverse_sort + reverse_url = page_filter_path(sort: reverse_sort) + else + reverse_url = '#' + link_class += ' disabled' + 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) + end + end + # Titles. def sort_title_access_level_asc s_('SortOptions|Access level, ascending') |