diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/pms_controller.rb | 2 | ||||
-rw-r--r-- | app/models/pm.rb | 1 | ||||
-rw-r--r-- | app/views/pms/_form.html.erb | 8 | ||||
-rw-r--r-- | app/views/pms/index.html.erb | 70 | ||||
-rw-r--r-- | app/views/pms/index.json.jbuilder | 2 | ||||
-rw-r--r-- | app/views/pms/show.html.erb | 11 | ||||
-rw-r--r-- | app/views/pms/show.json.jbuilder | 2 |
7 files changed, 22 insertions, 74 deletions
diff --git a/app/controllers/pms_controller.rb b/app/controllers/pms_controller.rb index 9dbe760..c83d2ae 100644 --- a/app/controllers/pms_controller.rb +++ b/app/controllers/pms_controller.rb @@ -77,6 +77,6 @@ class PmsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def pm_params - params.require(:pm).permit(:author_id, :recipient_id, :message) + params.require(:pm).permit(:author_id, :recipient_id, :message, :subject, :conversation_id) end end diff --git a/app/models/pm.rb b/app/models/pm.rb index 3ebb69d..8b06181 100644 --- a/app/models/pm.rb +++ b/app/models/pm.rb @@ -1,6 +1,7 @@ class Pm < ActiveRecord::Base belongs_to :author, class_name: "User" belongs_to :recipient, class_name: "User" + belongs_to :conversation def name return current_user.name diff --git a/app/views/pms/_form.html.erb b/app/views/pms/_form.html.erb index b329e24..a885e27 100644 --- a/app/views/pms/_form.html.erb +++ b/app/views/pms/_form.html.erb @@ -23,6 +23,14 @@ <%= f.label :message %><br> <%= f.text_area :message %> </div> + <div class="field"> + <%= f.label :subject %><br> + <%= f.text_area :subject %> + </div> + <div class="field"> + <%= f.label :conversation_id %><br> + <%= f.text_field :conversation_id %> + </div> <div class="actions"> <%= f.submit %> </div> diff --git a/app/views/pms/index.html.erb b/app/views/pms/index.html.erb index ee31e08..b5f4884 100644 --- a/app/views/pms/index.html.erb +++ b/app/views/pms/index.html.erb @@ -68,73 +68,3 @@ <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.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', @pm.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', conversation %></td> - </tr> - <% end %> - <% end %> - - <% else %> - <td><p> No Messages </p></td> - <% end %> - </tr> - - </tbody> -</table> - -<br> - -<%= link_to 'New Pm', new_pm_path %> diff --git a/app/views/pms/index.json.jbuilder b/app/views/pms/index.json.jbuilder index fcfca84..3dc1abb 100644 --- a/app/views/pms/index.json.jbuilder +++ b/app/views/pms/index.json.jbuilder @@ -1,4 +1,4 @@ json.array!(@pms) do |pm| - json.extract! pm, :id, :author_id, :recipient_id, :message + json.extract! pm, :id, :author_id, :recipient_id, :message, :subject, :conversation_id json.url pm_url(pm, format: :json) end diff --git a/app/views/pms/show.html.erb b/app/views/pms/show.html.erb index aec160f..6f81d1b 100644 --- a/app/views/pms/show.html.erb +++ b/app/views/pms/show.html.erb @@ -13,5 +13,14 @@ <%# @pm.message %> </p> -<%# link_to 'Edit', edit_pm_path(@pm) %> | +<p> + <strong>Subject:</strong> + <%= @pm.subject %> +</p> + +<p> + <strong>Conversation:</strong> + <%= @pm.conversation %> +</p> + <%= link_to 'Back', pms_path %> diff --git a/app/views/pms/show.json.jbuilder b/app/views/pms/show.json.jbuilder index 94252e9..4e69026 100644 --- a/app/views/pms/show.json.jbuilder +++ b/app/views/pms/show.json.jbuilder @@ -1 +1 @@ -json.extract! @pm, :id, :author_id, :recipient_id, :message, :created_at, :updated_at +json.extract! @pm, :id, :author_id, :recipient_id, :message, :subject, :conversation_id, :created_at, :updated_at |