diff options
author | jessib <jessib@leap.se> | 2012-12-03 16:06:17 -0800 |
---|---|---|
committer | jessib <jessib@leap.se> | 2012-12-03 16:06:17 -0800 |
commit | a335b840359b17dd2f2e2e1a8a19adcd36b1283c (patch) | |
tree | 61e82567a166f8dcd20c85042973663193e0c434 /help/app/helpers | |
parent | 4bbf03761852ea5dfcfd1384b98d2606842e95ad (diff) |
Ticket sorting functionality. Needs to be refactored, but works.
Diffstat (limited to 'help/app/helpers')
-rw-r--r-- | help/app/helpers/tickets_helper.rb | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/help/app/helpers/tickets_helper.rb b/help/app/helpers/tickets_helper.rb index c683be3..bd2c069 100644 --- a/help/app/helpers/tickets_helper.rb +++ b/help/app/helpers/tickets_helper.rb @@ -5,11 +5,39 @@ module TicketsHelper end def admin + # do we not want this set for non-admins? the param will be viewable in the url params[:admin_status] || 'all' end + def order + params[:sort_order] || 'updated_at_desc' + end + def link_to_status(new_status) label = new_status + ' issues' - link_to label, :open_status => new_status, :admin_status => admin + link_to label, :open_status => new_status, :admin_status => admin, :sort_order => order + end + + def link_to_order(order_field) + if order.start_with?(order_field) + # link for currently-filtered field. Link to other direction of this field. + if order.end_with? 'asc' + direction = 'desc' + icon_direction = 'up' + else + direction = 'asc' + icon_direction = 'down' + end + arrow = content_tag(:i, '', class: 'icon-arrow-'+ icon_direction) + else + # for not-currently-filtered field, don't display an arrow, and link to descending direction + arrow = '' + direction = 'desc' + end + + link_to :sort_order => order_field + '_at_' + direction, :open_status => status, :admin_status => admin do + arrow + order_field + ' at' + end end + end |