From 00f3d70445d7cae0976ec9794e555c52a1765b24 Mon Sep 17 00:00:00 2001 From: nfoy Date: Sat, 26 Apr 2014 20:57:21 -0400 Subject: Messages is working (besides default permissions)! --- app/controllers/pms_controller.rb | 1 + app/views/pms/_form.html.erb | 8 ------ app/views/pms/index.html.erb | 60 +++++++++++++-------------------------- app/views/pms/show.html.erb | 51 +++++++++++++++++++++++---------- 4 files changed, 56 insertions(+), 64 deletions(-) diff --git a/app/controllers/pms_controller.rb b/app/controllers/pms_controller.rb index c83d2ae..3368663 100644 --- a/app/controllers/pms_controller.rb +++ b/app/controllers/pms_controller.rb @@ -57,6 +57,7 @@ class PmsController < ApplicationController format.json { render json: @pm.errors, status: :unprocessable_entity } end end + current_user.reply_to_conversation(@pm.conversation, @pm.message) end # DELETE /pms/1 diff --git a/app/views/pms/_form.html.erb b/app/views/pms/_form.html.erb index a885e27..b329e24 100644 --- a/app/views/pms/_form.html.erb +++ b/app/views/pms/_form.html.erb @@ -23,14 +23,6 @@ <%= f.label :message %>
<%= f.text_area :message %> -
- <%= f.label :subject %>
- <%= f.text_area :subject %> -
-
- <%= f.label :conversation_id %>
- <%= f.text_field :conversation_id %> -
<%= f.submit %>
diff --git a/app/views/pms/index.html.erb b/app/views/pms/index.html.erb index b5f4884..a13705a 100644 --- a/app/views/pms/index.html.erb +++ b/app/views/pms/index.html.erb @@ -1,31 +1,38 @@

Conversations

+ + + - - - - <% conversations = current_user.mailbox.inbox %> + <% conversations = current_user.mailbox.conversations %> <% if !conversations.empty? %> <%# require 'pp' %> <%= conversations.class %> - + <% conversations.each do |conversation| %> <% receipts = conversation.receipts_for current_user %> - <% receipts.each do |receipt| %> - <% message = receipt.message %> + <%# receipts.each do |receipt| %> + <% message = receipts.last.message %> - - - - + + + + - <% end %> + <%# end %> <% end %> <% else %> @@ -33,35 +40,6 @@ <% end %> - - - - - <% 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 %> - -

Inbox

FromWith Subject Body
<%= conversation.last_sender.user_name %><%= message.subject %><%= message.body %><%# link_to 'Show', @pms.where(conversation: conversation) %> + <% people = conversation.participants %> + <% people.each do |person| %> + <% unless person == current_user %> + <%= truncate(person.user_name, length: 20) %> + <% end %> + <% end %> + <%= truncate(conversation.subject, length: 30) %><%= truncate(message.body, length: 42) %><%= link_to 'View', @pms.find_by(conversation: conversation) %>

Outbox

ToSubjectBody
Doesn't work<%= message.subject %><%= message.body %><%# link_to 'Show', @pms.where(conversation: conversation) %>

No Messages

diff --git a/app/views/pms/show.html.erb b/app/views/pms/show.html.erb index 6f81d1b..64dd66e 100644 --- a/app/views/pms/show.html.erb +++ b/app/views/pms/show.html.erb @@ -1,26 +1,47 @@

- Author: - <%# @conversation.last_sender.user_name %> + Participants: + <% receps = @pm.conversation.participants %> + <% receps.each do |recep| %> + <% #unless recep == @pm.conversation.last_sender %> + <%= recep.user_name %> + <%= "and" %> + <% #end %> + <% end %> + <%= "the NSA" %>

- Recipient: - <%#@pm.recipient.user_name %> + Subject: + <%= @pm.conversation.subject %>

-

- Message: - <%# @pm.message %> -

+<% receipts = @pm.conversation.receipts_for current_user %> +<% receipts.each do |receipt| %> + <% message = receipt.message %> -

- Subject: - <%= @pm.subject %> -

+

________________________________________________

-

- Conversation: - <%= @pm.conversation %> +

+ <%= message.sender.user_name %> + <%= ":" %> + <%= message.body %> +

+ +<% end %> + +

________________________________________________

+

+ <%= form_for(@pm) do |f| %> +

+ <%= f.text_area :message %> +
+ +
+ <%= submit_tag("Reply", :class => "signup") %> +
+ + <% end %>

+ <%= link_to 'Back', pms_path %> -- cgit v1.1-4-g5e80