From 3e69a4512f2d1b39f48719882a0d112d042da73a Mon Sep 17 00:00:00 2001 From: Gregory Igelmund Date: Wed, 13 Dec 2023 13:01:40 -0500 Subject: [PATCH] Refactor app/views/messages templates --- app/views/messages/_heading.html.erb | 16 ++++++++++++ app/views/messages/_messages_table.html.erb | 13 +++++++++ app/views/messages/inbox.html.erb | 29 +++------------------ app/views/messages/outbox.html.erb | 28 ++------------------ app/views/messages/show.html.erb | 3 +-- config/locales/en.yml | 14 ++++++---- 6 files changed, 44 insertions(+), 59 deletions(-) create mode 100644 app/views/messages/_heading.html.erb create mode 100644 app/views/messages/_messages_table.html.erb diff --git a/app/views/messages/_heading.html.erb b/app/views/messages/_heading.html.erb new file mode 100644 index 000000000..12c77d3f5 --- /dev/null +++ b/app/views/messages/_heading.html.erb @@ -0,0 +1,16 @@ +<% content_for :heading_class, "pb-0" %> + +<% content_for :heading do %> +

<%= t("users.show.my messages") %>

+ +<% end %> diff --git a/app/views/messages/_messages_table.html.erb b/app/views/messages/_messages_table.html.erb new file mode 100644 index 000000000..2e3396232 --- /dev/null +++ b/app/views/messages/_messages_table.html.erb @@ -0,0 +1,13 @@ + + + + <% columns.each do |column| %> + + <% end %> + + + + + <%= render :partial => inner_partial, :collection => messages %> + +
<%= t ".#{column}" %><%= t ".actions" %>
diff --git a/app/views/messages/inbox.html.erb b/app/views/messages/inbox.html.erb index 54089c34a..db807d2df 100644 --- a/app/views/messages/inbox.html.erb +++ b/app/views/messages/inbox.html.erb @@ -2,35 +2,12 @@ <%= javascript_include_tag "messages" %> <% end %> -<% content_for :heading_class, "pb-0" %> +<%= render :partial => "heading", :locals => { :active_link_path => inbox_messages_path } %> -<% content_for :heading do %> -

<%= t("users.show.my messages") %>

- -<% end %> - -

<%= render :partial => "message_count" %>

+

<%= render :partial => "message_count" %>

<% if current_user.messages.size > 0 %> - - - - - - - - - - <%= render :partial => "message_summary", :collection => current_user.messages %> - -
<%= t ".from" %><%= t ".subject" %><%= t ".date" %>
+ <%= render :partial => "messages_table", :locals => { :columns => %w[from subject date], :messages => current_user.messages, :inner_partial => "message_summary" } %> <% else %>
<%= t(".no_messages_yet_html", :people_mapping_nearby_link => link_to(t(".people_mapping_nearby"), user_path(current_user))) %>
<% end %> diff --git a/app/views/messages/outbox.html.erb b/app/views/messages/outbox.html.erb index e246f9292..ae8a899c4 100644 --- a/app/views/messages/outbox.html.erb +++ b/app/views/messages/outbox.html.erb @@ -2,36 +2,12 @@ <%= javascript_include_tag "messages" %> <% end %> -<% content_for :heading_class, "pb-0" %> - -<% content_for :heading do %> -

<%= t("users.show.my messages") %>

- - -<% end %> +<%= render :partial => "heading", :locals => { :active_link_path => outbox_messages_path } %>

<%= t ".messages", :count => current_user.sent_messages.size %>

<% if current_user.sent_messages.size > 0 %> - - - - - - - - - - <%= render :partial => "sent_message_summary", :collection => current_user.sent_messages %> - -
<%= t ".to" %><%= t ".subject" %><%= t ".date" %>
+ <%= render :partial => "messages_table", :locals => { :columns => %w[to subject date], :messages => current_user.sent_messages, :inner_partial => "sent_message_summary" } %> <% else %>
<%= t(".no_sent_messages_html", :people_mapping_nearby_link => link_to(t(".people_mapping_nearby"), user_path(current_user))) %>
<% end %> diff --git a/app/views/messages/show.html.erb b/app/views/messages/show.html.erb index 4761aac60..f0742280f 100644 --- a/app/views/messages/show.html.erb +++ b/app/views/messages/show.html.erb @@ -22,9 +22,8 @@ <%= link_to t(".reply_button"), message_reply_path(@message), :class => "btn btn-primary" %> <%= link_to t(".unread_button"), message_mark_path(@message, :mark => "unread"), :method => "post", :class => "btn btn-primary" %> <%= link_to t(".destroy_button"), message_path(@message), :method => "delete", :class => "btn btn-danger" %> - <%= link_to t(".back"), inbox_messages_path, :class => "btn btn-link" %> <% else %> <%= link_to t(".destroy_button"), message_path(@message), :method => "delete", :class => "btn btn-danger" %> - <%= link_to t(".back"), outbox_messages_path, :class => "btn btn-link" %> <% end %> + <%= link_to t(".back"), :back, :class => "btn btn-link" %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 18beafa13..c68e67622 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1682,11 +1682,14 @@ en: old_messages: one: "%{count} old message" other: "%{count} old messages" + no_messages_yet_html: "You have no messages yet. Why not get in touch with some of the %{people_mapping_nearby_link}?" + people_mapping_nearby: "people mapping nearby" + messages_table: from: "From" + to: "To" subject: "Subject" date: "Date" - no_messages_yet_html: "You have no messages yet. Why not get in touch with some of the %{people_mapping_nearby_link}?" - people_mapping_nearby: "people mapping nearby" + actions: "Actions" message_summary: unread_button: "Mark as unread" read_button: "Mark as read" @@ -1707,12 +1710,10 @@ en: title: "Outbox" my_inbox: "My Inbox" my_outbox: "My Outbox" + actions: "Actions" messages: one: "You have %{count} sent message" other: "You have %{count} sent messages" - to: "To" - subject: "Subject" - date: "Date" no_sent_messages_html: "You have no sent messages yet. Why not get in touch with some of the %{people_mapping_nearby_link}?" people_mapping_nearby: "people mapping nearby" reply: @@ -1726,6 +1727,9 @@ en: wrong_user: "You are logged in as `%{user}' but the message you have asked to read was not sent by or to that user. Please login as the correct user in order to read it." sent_message_summary: destroy_button: "Delete" + heading: + my_inbox: "My Inbox" + my_outbox: "My Outbox" mark: as_read: "Message marked as read" as_unread: "Message marked as unread" -- 2.39.5