Modified sort_link helper method to allo non ajax links.
This commit is contained in:
parent
45c7e29ebb
commit
8fb4334610
3 changed files with 17 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue