diff options
-rw-r--r-- | app/views/pms/index.html.erb | 97 | ||||
-rw-r--r-- | app/views/pms/show.html.erb | 8 |
2 files changed, 68 insertions, 37 deletions
diff --git a/app/views/pms/index.html.erb b/app/views/pms/index.html.erb index a13705a..560cf38 100644 --- a/app/views/pms/index.html.erb +++ b/app/views/pms/index.html.erb @@ -1,4 +1,10 @@ -<h1>Conversations</h1> +<h1> Your Conversations </h1> + +<%= link_to 'Start a new conversation', new_pm_path %> +<br> + +<h3>Unread Conversations</h3> +<% conversations = current_user.mailbox.conversations %> <table> <col width="150"> @@ -6,43 +12,68 @@ <col width="300"> <tbody> <tr> - <% conversations = current_user.mailbox.conversations %> - <% if !conversations.empty? %> - <%# require 'pp' %> - <%= conversations.class %> - <tr> - <td><b>With</b></td> - <td><b>Subject</b></td> - <td><b>Body</b></td> - </tr> - <% conversations.each do |conversation| %> - <% receipts = conversation.receipts_for current_user %> - <%# receipts.each do |receipt| %> - <% message = receipts.last.message %> - <tr> - <td> - <% people = conversation.participants %> - <% people.each do |person| %> - <% unless person == current_user %> - <%= truncate(person.user_name, length: 20) %> - <% end %> + <tr> + <td><b>With</b></td> + <td><b>Subject</b></td> + <td><b>Body</b></td> + </tr> + <% conversations.each do |conversation| %> + <% receipts = conversation.receipts_for current_user %> + <% if conversation.is_unread?(current_user) && receipts.last.message.sender != current_user %> + <% message = receipts.last.message %> + <tr> + <td> + <% people = conversation.participants %> + <% people.each do |person| %> + <% unless person == current_user %> + <%= truncate(person.user_name, length: 20) %> <% end %> - </td> - <td><%= truncate(conversation.subject, length: 30) %></td> - <td><%= truncate(message.body, length: 42) %></td> - <td><%= link_to 'View', @pms.find_by(conversation: conversation) %></td> - </tr> - <%# end %> + <% end %> + </td> + <td><%= truncate(conversation.subject, length: 30) %></td> + <td><%= truncate(message.body, length: 42) %></td> + <td><%= link_to 'View', @pms.find_by(conversation: conversation) %></td> + </tr> <% end %> - - <% else %> - <td><p> No Messages </p></td> <% end %> - </tr> - + </tr> </tbody> </table> <br> +<h3>Read Conversations</h3> +<% conversations = current_user.mailbox.conversations %> -<%= link_to 'New Pm', new_pm_path %> +<table> + <col width="150"> + <col width="250"> + <col width="300"> + <tbody> + <tr> + <tr> + <td><b>With</b></td> + <td><b>Subject</b></td> + <td><b>Body</b></td> + </tr> + <% conversations.each do |conversation| %> + <% receipts = conversation.receipts_for current_user %> + <% if conversation.is_read?(current_user) || receipts.last.message.sender == current_user %> + <% message = receipts.last.message %> + <tr> + <td> + <% people = conversation.participants %> + <% people.each do |person| %> + <% unless person == current_user %> + <%= truncate(person.user_name, length: 20) %> + <% end %> + <% end %> + </td> + <td><%= truncate(conversation.subject, length: 30) %></td> + <td><%= truncate(message.body, length: 42) %></td> + <td><%= link_to 'View', @pms.find_by(conversation: conversation) %></td> + </tr> + <% end %> + <% end %> + </tr> + </tbody> +</table>
\ No newline at end of file diff --git a/app/views/pms/show.html.erb b/app/views/pms/show.html.erb index 64dd66e..ca8d9bf 100644 --- a/app/views/pms/show.html.erb +++ b/app/views/pms/show.html.erb @@ -4,10 +4,10 @@ <% receps.each do |recep| %> <% #unless recep == @pm.conversation.last_sender %> <%= recep.user_name %> - <%= "and" %> + <%= "," %> <% #end %> <% end %> - <%= "the NSA" %> + <%= "and the NSA" %> </p> <p> @@ -22,7 +22,7 @@ <p> ________________________________________________ </p> <p> - <%= message.sender.user_name %> + <b><%= message.sender.user_name %></b> <%= ":" %> <%= message.body %> </p> @@ -43,5 +43,5 @@ <% end %> </p> - +<% @pm.conversation.mark_as_read(current_user) %> <%= link_to 'Back', pms_path %> |