2015-07-04 18:10:58 +00:00
|
|
|
module PreferencesHelper
|
|
|
|
|
|
|
|
# filter data on first letter
|
|
|
|
def initial_filter
|
|
|
|
["UPPER(sort) LIKE ?", session[:initial] + "%"] if session[:initial]
|
|
|
|
end
|
|
|
|
|
2015-08-02 09:12:04 +00:00
|
|
|
# update preferences (per_page, initial, sort)
|
2015-07-04 18:10:58 +00:00
|
|
|
def preferences
|
|
|
|
session[:current_per_page] = params[:per_page] ? params[:per_page].to_i : (session[:current_per_page] || WillPaginate.per_page)
|
|
|
|
if params[:initial]
|
2015-07-31 16:43:18 +00:00
|
|
|
session[:initial] = (params[:initial] == "reset" ? nil : params[:initial])
|
2015-07-04 18:10:58 +00:00
|
|
|
end
|
2015-08-02 09:12:04 +00:00
|
|
|
session[:sort] = params[:sort]
|
2015-07-04 18:10:58 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|