summaryrefslogtreecommitdiff
path: root/app/views/pms/index.html.erb
diff options
context:
space:
mode:
authornfoy <nfoy@purdue.edu>2014-04-24 19:03:36 -0400
committernfoy <nfoy@purdue.edu>2014-04-24 19:03:36 -0400
commit9823642115ef52f0a21b9466cef412098a124f3d (patch)
tree0710fd0910f9a0b2c23cfff24c9c3e6422d9c8b3 /app/views/pms/index.html.erb
parent62780a89fb04e1d96c3bbc8c8dd2db9efdc656f1 (diff)
Mailboxer progress without generate changes.
Diffstat (limited to 'app/views/pms/index.html.erb')
-rw-r--r--app/views/pms/index.html.erb117
1 files changed, 68 insertions, 49 deletions
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 @@
-<h1>Listing pms</h1>
+<h1>Conversations</h1>
<table>
- <thead>
- <tr>
- <th>Author</th>
- <th>Recipient</th>
- <th>Message</th>
- <th></th>
- <th></th>
- <th></th>
- </tr>
- </thead>
-
<tbody>
-
<tr>
- <td><h2>Inbox<h2></td>
+ <td><h3>Inbox<h3></td>
</tr>
+ <tr>
+ <% conversations = current_user.mailbox.inbox %>
+ <% if !conversations.empty? %>
+ <%# require 'pp' %>
+ <%= conversations.class %>
+ <tr>
+ <td><b>From</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 = receipt.message %>
+ <tr>
+ <td><%= conversation.last_sender.user_name %></td>
+ <td><%= message.subject %></td>
+ <td><%= message.body %></td>
+ <td><%# link_to 'Show', @pms.where(conversation: conversation) %></td>
+ </tr>
+ <% end %>
+ <% end %>
- <% message = @pms.where(recipient: current_user) %>
- <% unless message.empty? then message.each do |pm| %>
- <tr>
- <td><%= pm.author.user_name %></td>
- <td><%= pm.recipient.user_name %></td>
- <td><%= pm.message %></td>
- <td><%= link_to 'Show', pm %></td>
- <td><%# link_to 'Edit', edit_pm_path(pm) %></td>
- <td><%= link_to 'Delete', pm, method: :delete, data: { confirm: 'Are you sure (also deletes the author\'s copy)?' } %></td>
- </tr>
+ <% else %>
+ <td><p> No Messages </p></td>
<% end %>
- <% else %>
- <td><h3>No New Messages</h3></td>
- <% end %>
+ </tr>
- <tr>
- <td><h2>Outbox<h2></td>
+ <tr>
+ <td><h3>Outbox<h3></td>
</tr>
-
- <% message = @pms.where(author: current_user) %>
- <% unless message.empty? then message.each do |pm| %>
- <tr>
- <td><%= pm.author.user_name %></td>
- <td><%= pm.recipient.user_name %></td>
- <td><%= pm.message %></td>
- <td><%= link_to 'Show', pm %></td>
- <td><%# link_to 'Edit', edit_pm_path(pm) %></td>
- <td><%= link_to 'Delete', pm, method: :delete, data: { confirm: 'Are you sure (also deletes the recipient\'s copy)?'} %></td>
- </tr>
+ <tr>
+ <% conversations = current_user.mailbox.sentbox %>
+ <% if !conversations.empty? %>
+ <tr>
+ <td><b>To</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 = receipt.message %>
+ <tr>
+ <td>Doesn't work</td>
+ <td><%= message.subject %></td>
+ <td><%= message.body %></td>
+ <td><%# link_to 'Show', @pms.where(conversation: conversation) %></td>
+ </tr>
+ <% end %>
+ <% end %>
+
+ <% else %>
+ <td><p> No Messages </p></td>
<% end %>
- <% else %>
- <td><h3>No New Messages</h3></td>
- <% end %>
+ </tr>
- <tr>
- <td><h2>Conversations<h2></td>
- </tr>
+ </tbody>
+</table>
+
+<br>
+
+<%= link_to 'New Pm', new_pm_path %>
+<h1>Conversations</h1>
+
+<table>
+ <tbody>
<tr>
<td><h3>Inbox<h3></td>
</tr>
<tr>
<% conversations = current_user.mailbox.inbox %>
- <% if !conversations.nil? %>
+ <% if !conversations.empty? %>
+ <%# require 'pp' %>
+ <%= conversations.class %>
<tr>
<td><b>From</b></td>
<td><b>Subject</b></td>
@@ -74,7 +93,7 @@
<td><%= conversation.last_sender.user_name %></td>
<td><%= message.subject %></td>
<td><%= message.body %></td>
- <td><%# link_to 'Show', pm %></td>
+ <td><%# link_to 'Show', @pm.where(conversation: conversation) %></td>
</tr>
<% end %>
<% end %>
@@ -89,7 +108,7 @@
</tr>
<tr>
<% conversations = current_user.mailbox.sentbox %>
- <% if !conversations.nil? %>
+ <% if !conversations.empty? %>
<tr>
<td><b>To</b></td>
<td><b>Subject</b></td>