summaryrefslogtreecommitdiff
path: root/app/views/pms
diff options
context:
space:
mode:
Diffstat (limited to 'app/views/pms')
-rw-r--r--app/views/pms/_form.html.erb8
-rw-r--r--app/views/pms/index.html.erb83
-rw-r--r--app/views/pms/show.html.erb9
3 files changed, 66 insertions, 34 deletions
diff --git a/app/views/pms/_form.html.erb b/app/views/pms/_form.html.erb
index 80781a5..a885e27 100644
--- a/app/views/pms/_form.html.erb
+++ b/app/views/pms/_form.html.erb
@@ -12,13 +12,13 @@
<% end %>
<div class="field">
- <%= f.label :author_id %><br>
- <%= f.text_field :author_id %>
- </div>
- <div class="field">
<%= f.label :recipient_id %><br>
<%= f.text_field :recipient_id %>
</div>
+ <div class="field">
+ <%= f.label :subject %><br>
+ <%= f.text_field :subject %>
+ </div>
<div class="field">
<%= f.label :message %><br>
<%= f.text_area :message %>
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>
diff --git a/app/views/pms/show.html.erb b/app/views/pms/show.html.erb
index 2f3b944..6f81d1b 100644
--- a/app/views/pms/show.html.erb
+++ b/app/views/pms/show.html.erb
@@ -1,18 +1,16 @@
-<p id="notice"><%= notice %></p>
-
<p>
<strong>Author:</strong>
- <%= @pm.author %>
+ <%# @conversation.last_sender.user_name %>
</p>
<p>
<strong>Recipient:</strong>
- <%= @pm.recipient %>
+ <%#@pm.recipient.user_name %>
</p>
<p>
<strong>Message:</strong>
- <%= @pm.message %>
+ <%# @pm.message %>
</p>
<p>
@@ -25,5 +23,4 @@
<%= @pm.conversation %>
</p>
-<%= link_to 'Edit', edit_pm_path(@pm) %> |
<%= link_to 'Back', pms_path %>