summaryrefslogtreecommitdiff
path: root/app/views/pms
diff options
context:
space:
mode:
authornfoy <nfoy@purdue.edu>2014-04-27 00:05:51 -0400
committernfoy <nfoy@purdue.edu>2014-04-27 00:05:51 -0400
commit353e0b387b8e76d407f9451c236efbb4bd3a19ef (patch)
treeed9f5751b842a3bb0691e44eb34c76b71c04da94 /app/views/pms
parent6f19b51f0adf95b1d9bd8317388ecdbcb3756be7 (diff)
Even better index page for messages.
Diffstat (limited to 'app/views/pms')
-rw-r--r--app/views/pms/index.html.erb100
1 files changed, 54 insertions, 46 deletions
diff --git a/app/views/pms/index.html.erb b/app/views/pms/index.html.erb
index 560cf38..a1feb42 100644
--- a/app/views/pms/index.html.erb
+++ b/app/views/pms/index.html.erb
@@ -11,32 +11,36 @@
<col width="250">
<col width="300">
<tbody>
- <tr>
+ <% if conversations.reject { |c| c.is_unread?(current_user) && (c.receipts_for current_user).last.message.sender != current_user }.empty? %>
<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) %>
+ <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 %>
<% 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>
+ </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 %>
- <% end %>
- </tr>
+ </tr>
+ <% else %>
+ <h4> No unread conversations </h4>
+ <% end %>
</tbody>
</table>
@@ -49,31 +53,35 @@
<col width="250">
<col width="300">
<tbody>
- <tr>
+ <% if conversations.reject { |c| c.is_read?(current_user) || (c.receipts_for current_user).last.message.sender == current_user }.empty? %>
<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) %>
+ <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 %>
- <% 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>
+ </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 %>
- <% end %>
- </tr>
+ </tr>
+ <% else %>
+ <h4> No unread conversations </h4>
+ <% end %>
</tbody>
</table> \ No newline at end of file