orbit-basic/app/helpers/orbit_backend_helper.rb

49 lines
1.6 KiB
Ruby
Raw Normal View History

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-08-13 16:59:01 +00:00
def render_sort_bar(delete_all, url, *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
concat check_box_tag :check_all
2012-08-13 16:59:01 +00:00
concat link_to content_tag(:i, nil, :class => "icon-trash"), '#', :class => "list-remove", :rel => url
end) if (delete_all && (is_admin? || (is_manager? rescue nil)))
2012-04-29 15:39:28 +00:00
titles.each do |title|
concat render_title(title[0], title[1], title[2], title[3])
2012-04-29 15:39:28 +00:00
end
end
end
end
end
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
2012-07-05 08:00:45 +00:00
def show_toggle_archive_btn(object)
object.disable ? t("object_disable.change_to_false") : t("object_disable.change_to_true")
end
2012-04-29 15:39:28 +00:00
end