2012-04-29 15:39:28 +00:00
|
|
|
module OrbitBackendHelper
|
|
|
|
|
|
|
|
def sortable(column)
|
|
|
|
direction = (column == params[:sort] && params[:direction] == "asc") ? "desc" : "asc"
|
|
|
|
{:sort => column, :direction => direction}
|
|
|
|
end
|
|
|
|
|
|
|
|
def is_sort_active?(name)
|
|
|
|
res = ''
|
|
|
|
res << ' select' if params[:sort].eql?(name)
|
|
|
|
res << ' active' if params[:sort].eql?(name) && params[:direction].eql?('asc')
|
|
|
|
res
|
|
|
|
end
|
|
|
|
|
|
|
|
def is_sort?(name)
|
|
|
|
' web-symbol' if params[:sort].eql?(name)
|
|
|
|
end
|
|
|
|
|
|
|
|
def is_filter_active?(type, id)
|
|
|
|
' active' if (@filter[type].include?(id.to_s) rescue nil)
|
|
|
|
end
|
|
|
|
|
2012-04-29 16:16:37 +00:00
|
|
|
def render_sort_bar(delete_all, *titles)
|
2012-04-29 15:39:28 +00:00
|
|
|
content_tag :table, :class => "table main-list" do
|
|
|
|
content_tag :thead do
|
|
|
|
content_tag :tr, :class => "sort-header" do
|
|
|
|
concat (content_tag :th, :class => "span1 strong" do
|
|
|
|
check_box_tag :check_all
|
|
|
|
link_to content_tag(:i, nil, :class => "icon-trash"), '#', :class => "list-remove"
|
|
|
|
end) if delete_all
|
|
|
|
titles.each do |title|
|
2012-04-29 16:16:37 +00:00
|
|
|
concat render_title(title[0], title[1], title[2], title[3])
|
2012-04-29 15:39:28 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-04-29 16:16:37 +00:00
|
|
|
def render_title(title, fields, span, translation)
|
2012-04-29 15:39:28 +00:00
|
|
|
content_tag :th, :class => "sort #{span} #{is_sort_active?(title)}" do
|
|
|
|
link_to (t(translation) + content_tag(:b, nil, :class => is_sort?(title))).html_safe, url_for({:filter => @filter}.merge(sortable(title).merge(:sort_options => fields))), :class => 'js_history'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|