From 9d83092405745f6d1b07a57fd8d2aa8e9bffd9fa Mon Sep 17 00:00:00 2001 From: Azul Date: Sat, 5 Jul 2014 13:10:50 +0200 Subject: minor: cleanup some links only submit the params that differ from the defaults --- engines/support/app/helpers/auto_tickets_path_helper.rb | 6 ++---- engines/support/app/helpers/tickets_helper.rb | 8 +++++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'engines/support/app/helpers') diff --git a/engines/support/app/helpers/auto_tickets_path_helper.rb b/engines/support/app/helpers/auto_tickets_path_helper.rb index 5638222..c26aac7 100644 --- a/engines/support/app/helpers/auto_tickets_path_helper.rb +++ b/engines/support/app/helpers/auto_tickets_path_helper.rb @@ -45,10 +45,8 @@ module AutoTicketsPathHelper private def ticket_view_options - hsh = {} - hsh[:open_status] = params[:open_status] if params[:open_status] && !params[:open_status].empty? - hsh[:sort_order] = params[:sort_order] if params[:sort_order] && !params[:sort_order].empty? - hsh + hash = params.slice(:open_status, :sort_order) + hash.reject {|k,v| v.blank?} end end diff --git a/engines/support/app/helpers/tickets_helper.rb b/engines/support/app/helpers/tickets_helper.rb index 7db31dc..58b67ea 100644 --- a/engines/support/app/helpers/tickets_helper.rb +++ b/engines/support/app/helpers/tickets_helper.rb @@ -36,7 +36,8 @@ module TicketsHelper def link_to_status(new_status) label = ".#{new_status}" - link_to_navigation label, auto_tickets_path(open_status: new_status, sort_order: search_order) + link_to_navigation label, auto_tickets_path(open_status: new_status), + active: search_status == new_status end def link_to_order(order_field) @@ -45,11 +46,12 @@ module TicketsHelper # for not-currently-filtered field link to descending direction direction ||= 'desc' label = ".#{order_field}" - link_to_navigation label, auto_tickets_path(sort_order: order_field + '_at_' + direction, open_status: search_status), + link_to_navigation label, + auto_tickets_path(sort_order: order_field + '_at_' + direction), + active: search_order.start_with?(order_field), icon: icon end - def new_direction_for_order(order_field) # return if we're not filtering by this field return unless search_order.start_with?(order_field) -- cgit v1.2.3 From ace262b61703318d377752c863c48ac3f880f7e6 Mon Sep 17 00:00:00 2001 From: Azul Date: Wed, 9 Jul 2014 22:02:54 +0200 Subject: only use user ticket(s) path for real users --- engines/support/app/helpers/auto_tickets_path_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/support/app/helpers') diff --git a/engines/support/app/helpers/auto_tickets_path_helper.rb b/engines/support/app/helpers/auto_tickets_path_helper.rb index c26aac7..bc98a0a 100644 --- a/engines/support/app/helpers/auto_tickets_path_helper.rb +++ b/engines/support/app/helpers/auto_tickets_path_helper.rb @@ -15,7 +15,7 @@ module AutoTicketsPathHelper def auto_tickets_path(options={}) return unless options.class == Hash options = ticket_view_options.merge options - if @user + if @user.is_a? User user_tickets_path(@user, options) else tickets_path(options) @@ -25,7 +25,7 @@ module AutoTicketsPathHelper def auto_ticket_path(ticket, options={}) return unless ticket.persisted? options = ticket_view_options.merge options - if @user + if @user.is_a? User user_ticket_path(@user, ticket, options) else ticket_path(ticket, options) -- cgit v1.2.3