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,29 +40,14 @@ module WebmailHelper
end end
def folder_link(folder) def folder_link(folder)
if folder.attribs.include? :Noselect return folder.name if folder.attribs.include?(:Noselect)
return folder.name title = folder.unseen > 0 ? "#{short_fn(folder)} (#{folder.unseen})" : "#{short_fn(folder)}"
end link = link_to title, :controller => 'webmail', :action => 'messages', :folder_name => folder.name
unseen_messages = folder.unseen link = content_tag('b', link) if folder.name == @folder_name
if unseen_messages > 0 link += ' ' + empty_trash_link(folder.name) if folder.trash?
fn = "#{short_fn(folder)} (#{folder.unseen})" link
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 end
def message_date(datestr) def message_date(datestr)
t = Time.now t = Time.now
begin begin
@ -172,5 +157,12 @@ module WebmailHelper
return "#{size}&nbsp;B" return "#{size}&nbsp;B"
end end
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"> <div id="folders">
<h4><%=_('Folders')%><br/><%= link_to 'add/edit', folders_path %></h4> <h4><%=_('Folders')%><br/><%= link_to 'add/edit', folders_path %></h4>
<hr/> <hr/>
<ul> <% for folder in @folders %> <ul>
<li><%=folder_link(folder)%></li> <% end %> <% @folders.each do |folder| -%>
<li><%= folder_link(folder) %></li>
<% end -%>
</ul> </ul>
</div> </div>
<div style="text-align: center; padding: 10px;"> <div style="text-align: center; padding: 10px;">

View file

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