diff options
Diffstat (limited to 'app/controllers/concerns/sorting_preference.rb')
-rw-r--r-- | app/controllers/concerns/sorting_preference.rb | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/app/controllers/concerns/sorting_preference.rb b/app/controllers/concerns/sorting_preference.rb index 8d8845e2f41..6278b489028 100644 --- a/app/controllers/concerns/sorting_preference.rb +++ b/app/controllers/concerns/sorting_preference.rb @@ -5,10 +5,12 @@ module SortingPreference include CookiesHelper def set_sort_order(field = sorting_field, default_order = default_sort_order) - set_sort_order_from_user_preference(field) || - set_sort_order_from_cookie(field) || - params[:sort] || - default_order + sort_order = set_sort_order_from_user_preference(field) || set_sort_order_from_cookie(field) || params[:sort] + + # some types of sorting might not be available on the dashboard + return default_order unless valid_sort_order?(sort_order) + + sort_order end # Implement sorting_field method on controllers @@ -85,4 +87,11 @@ module SortingPreference else value end end + + def valid_sort_order?(sort_order) + return false unless sort_order + return can_sort_by_issue_weight?(action_name == 'issues') if sort_order.include?('weight') + + true + end end |