This commit is contained in:
Toks
2013-05-07 22:18:11 -04:00
parent a5418bcbb4
commit 3d98d4b4ec
4 changed files with 13 additions and 2 deletions

View File

@@ -14,6 +14,7 @@ class DmailsController < ApplicationController
end
def index
cookies[:dmail_folder] = params[:folder]
@search = Dmail.visible.search(params[:search])
@dmails = @search.order("dmails.created_at desc").paginate(params[:page])
respond_with(@dmails) do |format|

View File

@@ -1,2 +1,12 @@
module DmailsHelper
def dmails_current_folder_path
case cookies[:dmail_folder]
when "sent"
dmails_path(:search => {:owner_id => CurrentUser.id, :from_id => CurrentUser.id}, :folder => "sent")
when "all"
dmails_path(:search => {:owner_id => CurrentUser.id}, :folder => "all")
else
dmails_path(:search => {:owner_id => CurrentUser.id, :to_id => CurrentUser.id}, :folder => "received")
end
end
end

View File

@@ -1,6 +1,6 @@
<% content_for(:secondary_links) do %>
<menu>
<li><%= link_to "All", dmails_path %></li>
<li><%= link_to "All", dmails_path(:search => {:owner_id => CurrentUser.id}, :folder => "all") %></li>
<li><%= link_to "Received", dmails_path(:search => {:owner_id => CurrentUser.id, :to_id => CurrentUser.id}, :folder => "received") %></li>
<li><%= link_to "Sent", dmails_path(:search => {:owner_id => CurrentUser.id, :from_id => CurrentUser.id}, :folder => "sent") %></li>
<li><%= link_to "New", new_dmail_path %></li>

View File

@@ -16,7 +16,7 @@
<li><%= link_to "Edit subscriptions", tag_subscriptions_path %></li>
<% end %>
<li><%= link_to "Profile", user_path(CurrentUser.user) %></li>
<li><%= link_to "Messages #{CurrentUser.dmail_count}", dmails_path(:search => {:owner_id => CurrentUser.id, :to_id => CurrentUser.id}, :folder => "received") %></li>
<li><%= link_to "Messages #{CurrentUser.dmail_count}", dmails_current_folder_path %></li>
<% else %>
<li><%= link_to "Send message", new_dmail_path(:dmail => {:to_id => @user.id}) %></li>
<% end %>