diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 9024959087..a6331368a7 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -67,6 +67,7 @@ class IncomingMessage < ApplicationRecord has_many :info_request_events, dependent: :destroy, inverse_of: :incoming_message + has_many :notes, as: :notable belongs_to :raw_email, inverse_of: :incoming_message, diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index dfa8e2d94a..28c5643f1a 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -67,6 +67,7 @@ class OutgoingMessage < ApplicationRecord has_many :info_request_events, inverse_of: :outgoing_message, dependent: :destroy + has_many :notes, as: :notable delegate :public_body, to: :info_request, private: true, allow_nil: true diff --git a/app/views/admin_incoming_message/edit.html.erb b/app/views/admin_incoming_message/edit.html.erb index e8938304c9..9c3ce04265 100644 --- a/app/views/admin_incoming_message/edit.html.erb +++ b/app/views/admin_incoming_message/edit.html.erb @@ -44,3 +44,8 @@ <%= render partial: 'foi_attachments', locals: { foi_attachments: @incoming_message.foi_attachments } %> +<hr> +<h2>Notes</h2> +<%= render partial: 'admin/notes/show', + locals: { notes: @incoming_message.notes, notable: @incoming_message } %> + diff --git a/app/views/admin_outgoing_message/edit.html.erb b/app/views/admin_outgoing_message/edit.html.erb index cff4725b50..04831ebbfc 100644 --- a/app/views/admin_outgoing_message/edit.html.erb +++ b/app/views/admin_outgoing_message/edit.html.erb @@ -113,4 +113,8 @@ </div> </div> <% end %> +<hr> +<h2>Notes</h2> +<%= render partial: 'admin/notes/show', + locals: { notes: @outgoing_message.notes, notable: @outgoing_message } %> diff --git a/app/views/request/_incoming_correspondence.html.erb b/app/views/request/_incoming_correspondence.html.erb index 6d05b5178c..db5ef70345 100644 --- a/app/views/request/_incoming_correspondence.html.erb +++ b/app/views/request/_incoming_correspondence.html.erb @@ -14,6 +14,8 @@ <% end %> </div> + <%= render_notes(incoming_message.notes, class: 'message-notes') %> + <%= render partial: 'request/prominence', locals: { prominenceable: incoming_message } %> <%- if can?(:read, incoming_message) %> diff --git a/app/views/request/_outgoing_correspondence.html.erb b/app/views/request/_outgoing_correspondence.html.erb index 16d332c781..78a168078f 100644 --- a/app/views/request/_outgoing_correspondence.html.erb +++ b/app/views/request/_outgoing_correspondence.html.erb @@ -27,6 +27,8 @@ <p><%= link_to _('Try opening the logs in a new window.'), outgoing_message_delivery_status_path(outgoing_message), :target => '_blank' %></p> </div> + <%= render_notes(outgoing_message.notes, class: 'message-notes') %> + <div class="correspondence_text"> <div><%= outgoing_message.get_body_for_html_display %></div> </div> diff --git a/config/routes.rb b/config/routes.rb index 86db651a05..98e78d6c03 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -553,6 +553,10 @@ def matches?(request) direct :admin_note_parent do |note| if note.notable_tag admin_tag_path(tag: note.notable_tag) + elsif note.notable.is_a?(OutgoingMessage) + edit_admin_outgoing_message_path(note.notable) + elsif note.notable.is_a?(IncomingMessage) + edit_admin_incoming_message_path(note.notable) elsif note.notable url_for([:admin, note.notable]) else