summaryrefslogtreecommitdiff
path: root/app/views/pms/index.html.erb
diff options
context:
space:
mode:
Diffstat (limited to 'app/views/pms/index.html.erb')
-rw-r--r--app/views/pms/index.html.erb83
1 files changed, 59 insertions, 24 deletions
diff --git a/app/views/pms/index.html.erb b/app/views/pms/index.html.erb
index b5169f5..b5f4884 100644
--- a/app/views/pms/index.html.erb
+++ b/app/views/pms/index.html.erb
@@ -1,32 +1,67 @@
-<h1>Listing pms</h1>
+<h1>Conversations</h1>
<table>
- <thead>
+ <tbody>
<tr>
- <th>Author</th>
- <th>Recipient</th>
- <th>Message</th>
- <th>Subject</th>
- <th>Conversation</th>
- <th></th>
- <th></th>
- <th></th>
+ <td><h3>Inbox<h3></td>
</tr>
- </thead>
+ <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 %>
+
+ <% else %>
+ <td><p> No Messages </p></td>
+ <% end %>
+ </tr>
+
+ <tr>
+ <td><h3>Outbox<h3></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 %>
+ </tr>
- <tbody>
- <% @pms.each do |pm| %>
- <tr>
- <td><%= pm.author %></td>
- <td><%= pm.recipient %></td>
- <td><%= pm.message %></td>
- <td><%= pm.subject %></td>
- <td><%= pm.conversation %></td>
- <td><%= link_to 'Show', pm %></td>
- <td><%= link_to 'Edit', edit_pm_path(pm) %></td>
- <td><%= link_to 'Destroy', pm, method: :delete, data: { confirm: 'Are you sure?' } %></td>
- </tr>
- <% end %>
</tbody>
</table>