Skip to content

Commit e68d5ca

Browse files
committed
made sorting type titles configurable & adjusted titles for flag queue sorting to match
1 parent 8f07f1f commit e68d5ca

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

app/views/flags/handled.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<%= render 'shared/sorting', default_order: @default_sort_order,
1616
default_type: @default_sort_type,
17-
types: %w[age handled] %>
17+
types: ['age', { type: 'handled', title: 'time handled' }] %>
1818
</div>
1919

2020
<% @flags.each do |flag| %>

app/views/flags/queue.html.erb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@
1919
<% end %>
2020
</div>
2121

22+
<% sorting_types = current_page?(escalated_flags_path) ?
23+
['age', { type: 'escalated', title: 'time escalated' }] :
24+
%w[age] %>
25+
2226
<%= render 'shared/sorting', default_order: @default_sort_order,
2327
default_type: @default_sort_type,
24-
types: current_page?(escalated_flags_path) ? %w[age escalated] : %w[age] %>
28+
types: sorting_types %>
2529
</div>
2630

2731
<% @flags.each do |flag| %>

app/views/shared/_sorting.html.erb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"Renders a sorting widget
33
44
Variables:
5-
types : Array<String> of available sorting types
5+
types : list of available sorting types
66
? default_order : Defualt sorting order, if any
77
? default_type : Default sorting type, if any
88
"%>
@@ -16,13 +16,15 @@
1616

1717
<div class="button-list is-gutterless">
1818

19-
<% types.each do |type| %>
19+
<% types.each do |option| %>
20+
<% type = option.is_a?(String) ? option : option[:type] %>
21+
<% title = "Sort by #{option.is_a?(String) ? option.humanize.downcase : option[:title]}" %>
2022
<% is_active = params[:sort] == type || (params[:sort].nil? && default_type.to_s == type) %>
2123
<%= link_to request.params.merge(sort: type, order: is_active ? reverse_order : nil),
2224
class: "button is-muted is-outlined #{'is-active' if is_active}",
2325
role: 'button',
24-
title: "Sort by #{type.humanize.downcase}",
25-
aria: { label: "Sort by #{type.humanize.downcase}" } do %>
26+
title: title,
27+
aria: { label: title } do %>
2628
<% if is_active %>
2729
<i class="has-margin-right-1 fa fa-caret-<%= order == :asc ? 'up' : 'down' %>"></i> <%= type.humanize %>
2830
<% else %>

0 commit comments

Comments
 (0)