folder list sidebar refactoring

This commit is contained in:
Eugene Korbut 2009-02-08 08:14:00 +10:00
parent 5bd2ac5197
commit e7d134fa28
3 changed files with 23 additions and 25 deletions

View file

@ -40,28 +40,13 @@ module WebmailHelper
end
def folder_link(folder)
if folder.attribs.include? :Noselect
return folder.name
return folder.name if folder.attribs.include?(:Noselect)
title = folder.unseen > 0 ? "#{short_fn(folder)} (#{folder.unseen})" : "#{short_fn(folder)}"
link = link_to title, :controller => 'webmail', :action => 'messages', :folder_name => folder.name
link = content_tag('b', link) if folder.name == @folder_name
link += ' ' + empty_trash_link(folder.name) if folder.trash?
link
end
unseen_messages = folder.unseen
if unseen_messages > 0
fn = "#{short_fn(folder)} (#{folder.unseen})"
else
fn = "#{short_fn(folder)}"
end
if folder.name == CDF::CONFIG[:mail_trash]
(unseen_messages > 0 ? "<b>" : "" ) <<
link_to( fn, :controller=>"webmail", :action=>"messages", :params=>{"folder_name"=>folder.name}) <<
"&nbsp;" << link_to(_('(Empty)'), {:controller=>"webmail", :action=>"empty", :params=>{"folder_name"=>folder.name}}, :confirm => _('Do you really want to empty trash?')) <<
(unseen_messages > 0 ? "</b>" : "" )
else
(unseen_messages > 0 ? "<b>" : "" ) <<
link_to( fn, :controller=>"webmail", :action=>"messages", :params=>{"folder_name"=>folder.name}) <<
(unseen_messages > 0 ? "</b>" : "" )
end
end
def message_date(datestr)
t = Time.now
@ -172,5 +157,12 @@ module WebmailHelper
return "#{size}&nbsp;B"
end
end
end
private
def empty_trash_link(folder_name)
link_to(_('(Empty)'),
{ :controller => "webmail", :action => "empty", :params=>{"folder_name"=>folder_name}},
:confirm => _('Do you really want to empty trash?'))
end
end

View file

@ -1,8 +1,10 @@
<div id="folders">
<h4><%=_('Folders')%><br/><%= link_to 'add/edit', folders_path %></h4>
<hr/>
<ul> <% for folder in @folders %>
<li><%=folder_link(folder)%></li> <% end %>
<ul>
<% @folders.each do |folder| -%>
<li><%= folder_link(folder) %></li>
<% end -%>
</ul>
</div>
<div style="text-align: center; padding: 10px;">

View file

@ -498,4 +498,8 @@ class IMAPFolder
def subscribe
@mailbox.imap.subscribe(@utf7_name)
end
def trash?
self.name == CDF::CONFIG[:mail_trash]
end
end