diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 261595f6..0ad1bb94 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -58,10 +58,13 @@ module ApplicationHelper return result end - def sort_link_helper(text, param, per_page = (@per_page || 10), action = "list" ) - key = param - key += "_reverse" if params[:sort] == param - options = { + def sort_link_helper(text, key, options = {}) + per_page = options[:per_page] || 10 + action = options[:action] || "list" + remote = options[:remote].nil? ? true : options[:remote] + key += "_reverse" if params[:sort] == key + + link_options = { :url => url_for(:params => params.merge({:sort => key, :page => nil, :per_page => per_page})), :before => "Element.show('loader')", :success => "Element.hide('loader')", @@ -71,7 +74,12 @@ module ApplicationHelper :title => _("Nach #{text} sortieren"), :href => url_for(:action => action, :params => params.merge({:sort => key, :page => nil, :per_page => per_page})) } - link_to_remote(text, options, html_options) + + if remote + link_to_remote(text, link_options, html_options) + else + link_to(text, link_options[:url], html_options) + end end # Generates a link to the top of the website diff --git a/app/views/finance/balancing/_edit_results_by_articles.html.haml b/app/views/finance/balancing/_edit_results_by_articles.html.haml index 699321c7..c33de047 100644 --- a/app/views/finance/balancing/_edit_results_by_articles.html.haml +++ b/app/views/finance/balancing/_edit_results_by_articles.html.haml @@ -7,9 +7,9 @@ %thead %tr %th[sort_td_class_helper "name"]{:colspan => "1"} - = sort_link_helper "Artikel", "name", 1000, "new" + = sort_link_helper "Artikel", "name", :action => "new", :remote => false %th[sort_td_class_helper "order_number"] - = sort_link_helper "Nr.", "order_number", 1000, "new" + = sort_link_helper "Nr.", "order_number", :action => "new", :remote => false %th Menge %th GebGr * Einheit %th Netto diff --git a/app/views/finance/transactions/_ordergroups.html.haml b/app/views/finance/transactions/_ordergroups.html.haml index 4a145fb8..daa37180 100644 --- a/app/views/finance/transactions/_ordergroups.html.haml +++ b/app/views/finance/transactions/_ordergroups.html.haml @@ -12,9 +12,9 @@ %table.list %thead %tr - %th= sort_link_helper "Name", "name", @per_page + %th= sort_link_helper "Name", "name", :per_page => @per_page %th Kontakt - %th= sort_link_helper "Kontostand", "account_balance", @per_page + %th= sort_link_helper "Kontostand", "account_balance", :per_page => @per_page %th %tbody - for group in @groups