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-16 20:05:58 +02:00
|
|
|
|
2011-09-03 13:07:40 +02:00
|
|
|
if folder.isInbox?
|
|
|
|
name_shown = t(:inbox_name,:scope => :folder)
|
|
|
|
elsif folder.isSent?
|
|
|
|
name_shown = t(:sent_name,:scope => :folder)
|
|
|
|
elsif folder.isDrafts?
|
|
|
|
name_shown = t(:drafts_name,:scope => :folder)
|
|
|
|
elsif folder.isTrash?
|
|
|
|
name_shown = t(:trash_name,:scope => :folder)
|
|
|
|
else
|
|
|
|
name_shown = folder.name.capitalize
|
|
|
|
end
|
|
|
|
s = link_to name_shown, folders_select_path(:id => name)
|
|
|
|
|
|
|
|
if folder.isTrash?
|
2011-08-16 20:05:58 +02:00
|
|
|
if not folder.total.zero?
|
|
|
|
s <<' ('
|
2011-08-24 19:20:13 +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-09-03 13:07:40 +02:00
|
|
|
if folder.nil?
|
|
|
|
t(:no_selected,:scope=>:folder)
|
|
|
|
else
|
|
|
|
if folder.isInbox?
|
|
|
|
t(:inbox_name,:scope => :folder)
|
|
|
|
elsif folder.isSent?
|
|
|
|
t(:sent_name,:scope => :folder)
|
|
|
|
elsif folder.isDrafts?
|
|
|
|
t(:drafts_name,:scope => :folder)
|
|
|
|
elsif folder.isTrash?
|
|
|
|
t(:trash_name,:scope => :folder)
|
|
|
|
else
|
|
|
|
folder.name.capitalize
|
|
|
|
end
|
|
|
|
end
|
2011-07-29 20:05:47 +02:00
|
|
|
end
|
|
|
|
|
2011-09-03 13:07:40 +02:00
|
|
|
def select_for_folders(name,id,collection,label,choice,blank)
|
2011-07-29 20:05:47 +02:00
|
|
|
html = ""
|
2011-09-03 13:07:40 +02:00
|
|
|
html << "<div class=\"param_group\">"
|
2011-07-29 20:05:47 +02:00
|
|
|
html << "<label class=\"label\">#{label}</label>"
|
2011-09-03 13:07:40 +02:00
|
|
|
html << simple_select_for_folders(name,id,collection,choice,blank)
|
2011-07-29 20:05:47 +02:00
|
|
|
html << "</div>"
|
|
|
|
end
|
|
|
|
|
2011-09-03 13:07:40 +02:00
|
|
|
def simple_select_for_folders(name,id,collection,choice,blank)
|
2011-08-16 20:05:58 +02:00
|
|
|
html = ""
|
2011-09-03 13:07:40 +02:00
|
|
|
html << select(name , id, options_from_collection_for_select(collection, 'id', 'full_name', choice),{ :include_blank => (blank == true ? true : false)})
|
2011-08-16 20:05:58 +02:00
|
|
|
html
|
|
|
|
end
|
|
|
|
|
2011-07-29 20:05:47 +02:00
|
|
|
end
|