Skip to content

Commit

Permalink
Trash conversation added
Browse files Browse the repository at this point in the history
  • Loading branch information
Roendal committed Mar 21, 2011
1 parent 62945df commit 3a52efd
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 10 deletions.
24 changes: 24 additions & 0 deletions app/controllers/mailbox/conversation_controller.rb
Expand Up @@ -64,6 +64,10 @@ def update
return
end

if params[:untrash].present?
@conversation.untrash(@actor)
end

if params[:reply_all].present?
if params[:body].present?
last_mail = @conversation.mails(@actor).last
Expand All @@ -76,6 +80,26 @@ def update
end

def destroy
@actor = Actor.normalize(current_subject)
@conversation = MailboxerConversation.find_by_id(params[:id])
if @conversation.nil? or !@conversation.is_participant?(@actor)
redirect_to mailbox_index_path
return
end

@conversation.move_to_trash(@actor)

if params[:location].present?
case params[:location]
when 'conversation'
redirect_to mailbox_path(:id => :trash)
else
redirect_to mailbox_path(:id => params[:location])
end

return
end
redirect_to mailbox_index_path
end

private
Expand Down
12 changes: 10 additions & 2 deletions app/views/mailbox/_conversation.html.erb
@@ -1,5 +1,14 @@
<%= div_for (conversation) do %>
<h3><%= link_to(conversation.subject, mailbox_conversation_path(conversation.id,:box => params[:id])) %></h3>
<h3>
<%= link_to(conversation.subject, mailbox_conversation_path(conversation.id,:box => params[:id])) %>
<% unless params[:id].present? and params[:id].eql?'trash' %>
<%= link_to ( image_tag('btn/btn_delete.png', :atl => "Delete", :title => "Delete"),
mailbox_conversation_path(conversation, :location => params[:id]),
:confirm => 'Do you want to move "' + conversation.subject + '" to trash?',
:method => :delete, :remote => true) %>
<% end %>
</h3>
<%= conversation.updated_at %>
<br>
<b>From:</b><br>
<%= link_to image_tag(conversation.last_sender.logo.url(:actor),
Expand All @@ -11,5 +20,4 @@ conversation.last_sender.subject
<%next if Actor.normalize(conversation.last_sender)==Actor.normalize(recp)%>
<%= link_to image_tag(recp.logo.url(:tie), :atl => recp.name, :title => recp.name), recp.subject %>
<% end %><br>
<% link_to ( image_tag('btn/btn_delete.png', :class=>"btn_config"), "", :confirm => 'Are you sure?', :method => :delete) %>
<% end %>
8 changes: 0 additions & 8 deletions app/views/mailbox/_show.html.erb
@@ -1,12 +1,4 @@
<% content_for :sidebar do %>
<%= render :partial => 'home/sidebar' %>
<% end %>

<% toolbar_menu(:mailbox) do %>
<%= render :partial => 'menu_options' %>
<% end %>
<%= render :partial => 'location' %>

<br class="clearfloat" />
<div class="space_center">
Expand Down
5 changes: 5 additions & 0 deletions app/views/mailbox/conversation/_conversation.html.erb
@@ -1,6 +1,11 @@
<%= div_for (conversation) do %>
<h2><%= conversation.subject %></h2>
<hr>
Actions: <%= link_to ( image_tag('btn/btn_delete.png', :atl => "Delete", :title => "Delete"),
mailbox_conversation_path(conversation, :location => 'conversation'),
:confirm => 'Do you want to move "' + conversation.subject + '" to trash?',
:method => :delete, :remote => true) %>
<hr>
<% conversation.get_recipients.each do |recp| %>
<%= link_to image_tag(recp.logo.url(:tie), :title=>recp.name, :alt => recp.name), recp.subject %>
<% end %><br>
Expand Down
10 changes: 10 additions & 0 deletions app/views/mailbox/show.html.erb
@@ -1 +1,11 @@
<% content_for :sidebar do %>
<%= render :partial => 'home/sidebar' %>
<% end %>
<% toolbar_menu(:mailbox) do %>
<%= render :partial => 'menu_options' %>
<% end %>
<%= render :partial => 'location' %>
<%= render :partial => 'show' %>

0 comments on commit 3a52efd

Please sign in to comment.