summaryrefslogtreecommitdiff
path: root/app/views
diff options
context:
space:
mode:
Diffstat (limited to 'app/views')
-rw-r--r--app/views/pms/_form.html.erb4
-rw-r--r--app/views/pms/index.html.erb117
-rw-r--r--app/views/pms/show.html.erb2
3 files changed, 73 insertions, 50 deletions
diff --git a/app/views/pms/_form.html.erb b/app/views/pms/_form.html.erb
index e9a7c08..b329e24 100644
--- a/app/views/pms/_form.html.erb
+++ b/app/views/pms/_form.html.erb
@@ -15,6 +15,10 @@
<%= 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 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>
diff --git a/app/views/pms/show.html.erb b/app/views/pms/show.html.erb
index cfaf00d..aec160f 100644
--- a/app/views/pms/show.html.erb
+++ b/app/views/pms/show.html.erb
@@ -1,6 +1,6 @@
<p>
<strong>Author:</strong>
- <%= @conversation.last_sender.user_name %>
+ <%# @conversation.last_sender.user_name %>
</p>
<p>