From 7d58f640e89a89a4767e59883b864afcd4e9dad4 Mon Sep 17 00:00:00 2001 From: elijah Date: Mon, 17 Jun 2013 01:27:01 -0700 Subject: new ui - ticket navigation --- help/app/helpers/tickets_helper.rb | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'help/app/helpers/tickets_helper.rb') diff --git a/help/app/helpers/tickets_helper.rb b/help/app/helpers/tickets_helper.rb index bd2c069..8b4ff71 100644 --- a/help/app/helpers/tickets_helper.rb +++ b/help/app/helpers/tickets_helper.rb @@ -1,7 +1,7 @@ module TicketsHelper def status - params[:open_status] || 'open' + params[:open_status] end def admin @@ -14,8 +14,14 @@ module TicketsHelper end def link_to_status(new_status) - label = new_status + ' issues' - link_to label, :open_status => new_status, :admin_status => admin, :sort_order => order + if new_status == "open" + label = t(:open_tickets) + elsif new_status == "closed" + label = t(:closed_tickets) + elsif new_status == "all" + label = t(:all_tickets) + end + link_to label, tickets_path(:open_status => new_status, :admin_status => admin, :sort_order => order) end def link_to_order(order_field) @@ -35,8 +41,14 @@ module TicketsHelper direction = 'desc' end + if order_field == 'updated' + label = t(:updated) + elsif order_field == 'created' + label = t(:created) + end + link_to :sort_order => order_field + '_at_' + direction, :open_status => status, :admin_status => admin do - arrow + order_field + ' at' + arrow + label end end -- cgit v1.2.3 From 0cd386e0144601f5478f90bbdb401d55c019c828 Mon Sep 17 00:00:00 2001 From: elijah Date: Wed, 3 Jul 2013 11:11:10 -0700 Subject: better ticket view navigation: tickets are now either global in scope (for admins) or stay as a nested resource for a particular user (for normal users and when you visit the tickets list of a particular user). --- help/app/helpers/tickets_helper.rb | 41 ++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) (limited to 'help/app/helpers/tickets_helper.rb') diff --git a/help/app/helpers/tickets_helper.rb b/help/app/helpers/tickets_helper.rb index 8b4ff71..7af50d6 100644 --- a/help/app/helpers/tickets_helper.rb +++ b/help/app/helpers/tickets_helper.rb @@ -1,18 +1,39 @@ module TicketsHelper + # + # FORM HELPERS + # - def status - params[:open_status] + # + # hidden fields that should be added to ever ticket form. + # these are use for proper redirection after successful actions. + # + def hidden_ticket_fields + haml_concat hidden_field_tag('open_status', params[:open_status]) + haml_concat hidden_field_tag('sort_order', params[:sort_order]) + haml_concat hidden_field_tag('user_id', params[:user_id]) + "" end - def admin - # do we not want this set for non-admins? the param will be viewable in the url - params[:admin_status] || 'all' + # + # PARAM HELPERS + # + + def search_status + if action?(:index) + params[:open_status] || 'open' + else + nil + end end - def order + def search_order params[:sort_order] || 'updated_at_desc' end + # + # LINK HELPERS + # + def link_to_status(new_status) if new_status == "open" label = t(:open_tickets) @@ -21,13 +42,13 @@ module TicketsHelper elsif new_status == "all" label = t(:all_tickets) end - link_to label, tickets_path(:open_status => new_status, :admin_status => admin, :sort_order => order) + link_to label, auto_tickets_path(:open_status => new_status, :sort_order => search_order) end def link_to_order(order_field) - if order.start_with?(order_field) + if search_order.start_with?(order_field) # link for currently-filtered field. Link to other direction of this field. - if order.end_with? 'asc' + if search_order.end_with? 'asc' direction = 'desc' icon_direction = 'up' else @@ -47,7 +68,7 @@ module TicketsHelper label = t(:created) end - link_to :sort_order => order_field + '_at_' + direction, :open_status => status, :admin_status => admin do + link_to auto_tickets_path(:sort_order => order_field + '_at_' + direction, :open_status => search_status) do arrow + label end end -- cgit v1.2.3