mailr/app/helpers/folder_helper.rb

41 lines
1.3 KiB
Ruby
Raw Normal View History

2011-07-29 20:05:47 +02:00
module FolderHelper
def folder_link(folder)
2011-08-16 20:05:58 +02:00
2011-07-29 20:05:47 +02:00
folder.parent.empty? ? name = folder.name : name = folder.parent.gsub(/\./,'#') + "#" + folder.name
2011-08-18 19:57:12 +02:00
s = link_to folder.name.capitalize, folders_select_path(:id => name)
2011-08-16 20:05:58 +02:00
if folder.full_name.downcase == $defaults["mailbox_trash"].downcase
if not folder.total.zero?
s <<' ('
2011-08-18 19:57:12 +02:00
s << link_to(t(:emptybin,:scope=>:folder),folders_emptybin_path)
2011-08-16 20:05:58 +02:00
s << ')'
end
else
if !folder.unseen.zero?
s += ' (' + folder.unseen.to_s + ')'
end
2011-07-29 20:05:47 +02:00
end
s
end
def pretty_folder_name(folder)
2011-08-16 20:05:58 +02:00
folder.nil? ? t(:no_selected,:scope=>:folder) : folder.name.capitalize
2011-07-29 20:05:47 +02:00
end
def select_for_folders(name,id,object,label,blank)
html = ""
html << "<div class=\"group\">"
html << "<label class=\"label\">#{label}</label>"
2011-08-16 20:05:58 +02:00
html << simple_select_for_folders(name,id,object,blank)
2011-07-29 20:05:47 +02:00
html << "</div>"
end
2011-08-16 20:05:58 +02:00
def simple_select_for_folders(name,id,object,blank)
html = ""
html << select(name, id, object.all.collect {|p| [ p.parent.empty? ? p.name : p.parent+p.delim+p.name, p.id ] }, { :include_blank => (blank == true ? true : false)})
html
end
2011-07-29 20:05:47 +02:00
end