Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7302 add notes to outgoing and incoming messages #8133

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/incoming_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions app/models/outgoing_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions app/views/admin_incoming_message/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 } %>

4 changes: 4 additions & 0 deletions app/views/admin_outgoing_message/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,8 @@
</div>
</div>
<% end %>
<hr>
<h2>Notes</h2>
<%= render partial: 'admin/notes/show',
locals: { notes: @outgoing_message.notes, notable: @outgoing_message } %>

2 changes: 2 additions & 0 deletions app/views/request/_incoming_correspondence.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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) %>
Expand Down
2 changes: 2 additions & 0 deletions app/views/request/_outgoing_correspondence.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 4 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down