From 9823642115ef52f0a21b9466cef412098a124f3d Mon Sep 17 00:00:00 2001 From: nfoy Date: Thu, 24 Apr 2014 19:03:36 -0400 Subject: Mailboxer progress without generate changes. --- app/controllers/pms_controller.rb | 10 +++- app/views/pms/_form.html.erb | 4 ++ app/views/pms/index.html.erb | 117 ++++++++++++++++++++++---------------- app/views/pms/show.html.erb | 2 +- 4 files changed, 80 insertions(+), 53 deletions(-) diff --git a/app/controllers/pms_controller.rb b/app/controllers/pms_controller.rb index 1d6540d..9dbe760 100644 --- a/app/controllers/pms_controller.rb +++ b/app/controllers/pms_controller.rb @@ -24,11 +24,11 @@ class PmsController < ApplicationController def create @pm = Pm.new(pm_params) @pm.author = current_user - require 'pp' - pp @pm.message + #require 'pp' + #pp @pm.message @pm.recipient = User.find_by_user_name(pm_params['recipient_id']) - @pm.author.send_message(@pm.recipient, @pm.message, 'Default') + @pm.conversation = @pm.author.send_message(@pm.recipient, @pm.message, @pm.subject).conversation respond_to do |format| if @pm.save @@ -41,6 +41,10 @@ class PmsController < ApplicationController end end + #def reply + # current_user.reply_to_conversation(conversation, message) + #end + # PATCH/PUT /pms/1 # PATCH/PUT /pms/1.json def update diff --git a/app/views/pms/_form.html.erb b/app/views/pms/_form.html.erb index e9a7c08..b329e24 100644 --- a/app/views/pms/_form.html.erb +++ b/app/views/pms/_form.html.erb @@ -14,6 +14,10 @@
<%= f.label :recipient_id %>
<%= f.text_field :recipient_id %> +
+
+ <%= f.label :subject %>
+ <%= f.text_field :subject %>
<%= f.label :message %>
diff --git a/app/views/pms/index.html.erb b/app/views/pms/index.html.erb index 1175cb2..ee31e08 100644 --- a/app/views/pms/index.html.erb +++ b/app/views/pms/index.html.erb @@ -1,66 +1,85 @@ -

Listing pms

+

Conversations

- - - - - - - - - - - - - + + + <% conversations = current_user.mailbox.inbox %> + <% if !conversations.empty? %> + <%# require 'pp' %> + <%= conversations.class %> + + + + + + <% conversations.each do |conversation| %> + <% receipts = conversation.receipts_for current_user %> + <% receipts.each do |receipt| %> + <% message = receipt.message %> + + + + + + + <% end %> + <% end %> - <% message = @pms.where(recipient: current_user) %> - <% unless message.empty? then message.each do |pm| %> - - - - - - - - + <% else %> + <% end %> - <% else %> - - <% end %> + - - + + - - <% message = @pms.where(author: current_user) %> - <% unless message.empty? then message.each do |pm| %> - - - - - - - - + + <% conversations = current_user.mailbox.sentbox %> + <% if !conversations.empty? %> + + + + + + <% conversations.each do |conversation| %> + <% receipts = conversation.receipts_for current_user %> + <% receipts.each do |receipt| %> + <% message = receipt.message %> + + + + + + + <% end %> + <% end %> + + <% else %> + <% end %> - <% else %> - - <% end %> + - - - + +
AuthorRecipientMessage

Inbox

Inbox

FromSubjectBody
<%= conversation.last_sender.user_name %><%= message.subject %><%= message.body %><%# link_to 'Show', @pms.where(conversation: conversation) %>
<%= pm.author.user_name %><%= pm.recipient.user_name %><%= pm.message %><%= link_to 'Show', pm %><%# link_to 'Edit', edit_pm_path(pm) %><%= link_to 'Delete', pm, method: :delete, data: { confirm: 'Are you sure (also deletes the author\'s copy)?' } %>

No Messages

No New Messages

Outbox

Outbox

<%= pm.author.user_name %><%= pm.recipient.user_name %><%= pm.message %><%= link_to 'Show', pm %><%# link_to 'Edit', edit_pm_path(pm) %><%= link_to 'Delete', pm, method: :delete, data: { confirm: 'Are you sure (also deletes the recipient\'s copy)?'} %>
ToSubjectBody
Doesn't work<%= message.subject %><%= message.body %><%# link_to 'Show', @pms.where(conversation: conversation) %>

No Messages

No New Messages

Conversations

+ +
+ +<%= link_to 'New Pm', new_pm_path %> +

Conversations

+ + + <% conversations = current_user.mailbox.inbox %> - <% if !conversations.nil? %> + <% if !conversations.empty? %> + <%# require 'pp' %> + <%= conversations.class %> @@ -74,7 +93,7 @@ - + <% end %> <% end %> @@ -89,7 +108,7 @@ <% conversations = current_user.mailbox.sentbox %> - <% if !conversations.nil? %> + <% if !conversations.empty? %> diff --git a/app/views/pms/show.html.erb b/app/views/pms/show.html.erb index cfaf00d..aec160f 100644 --- a/app/views/pms/show.html.erb +++ b/app/views/pms/show.html.erb @@ -1,6 +1,6 @@

Author: - <%= @conversation.last_sender.user_name %> + <%# @conversation.last_sender.user_name %>

-- cgit v1.2.3-54-g00ecf

Inbox

From Subject<%= conversation.last_sender.user_name %> <%= message.subject %> <%= message.body %><%# link_to 'Show', pm %><%# link_to 'Show', @pm.where(conversation: conversation) %>
To Subject