Refactor app/views/messages templates

This commit is contained in:
Gregory Igelmund 2023-12-13 13:01:40 -05:00
parent f49c815cb5
commit 3e69a4512f
6 changed files with 45 additions and 60 deletions

View file

@ -0,0 +1,16 @@
<% content_for :heading_class, "pb-0" %>
<% content_for :heading do %>
<h1><%= t("users.show.my messages") %></h1>
<ul class="nav nav-tabs">
<% { ".my_inbox" => inbox_messages_path, ".my_outbox" => outbox_messages_path }.each do |i18n_key, path| %>
<li class="nav-item">
<% if path == active_link_path %>
<a class="nav-link active"><%= t(i18n_key) %></a>
<% else %>
<%= link_to t(i18n_key), path, :class => "nav-link" %>
<% end %>
</li>
<% end %>
</ul>
<% end %>

View file

@ -0,0 +1,13 @@
<table class="table table-sm align-middle">
<thead>
<tr>
<% columns.each do |column| %>
<th><%= t ".#{column}" %></th>
<% end %>
<th class="d-flex justify-content-end"><%= t ".actions" %></th>
</tr>
</thead>
<tbody>
<%= render :partial => inner_partial, :collection => messages %>
</tbody>
</table>

View file

@ -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 %>
<h1><%= t("users.show.my messages") %></h1>
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active"><%= t ".my_inbox" %></a>
</li>
<li class="nav-item">
<%= link_to t(".my_outbox"), outbox_messages_path, :class => "nav-link" %>
</li>
</ul>
<% end %>
<h4><%= render :partial => "message_count" %></h4>
<h4><%= render :partial => "message_count" %></h4>
<% if current_user.messages.size > 0 %>
<table class="table table-sm align-middle">
<thead>
<tr>
<th><%= t ".from" %></th>
<th><%= t ".subject" %></th>
<th><%= t ".date" %></th>
</tr>
</thead>
<tbody>
<%= render :partial => "message_summary", :collection => current_user.messages %>
</tbody>
</table>
<%= render :partial => "messages_table", :locals => { :columns => %w[from subject date], :messages => current_user.messages, :inner_partial => "message_summary" } %>
<% else %>
<div><%= t(".no_messages_yet_html", :people_mapping_nearby_link => link_to(t(".people_mapping_nearby"), user_path(current_user))) %></div>
<% end %>

View file

@ -2,36 +2,12 @@
<%= javascript_include_tag "messages" %>
<% end %>
<% content_for :heading_class, "pb-0" %>
<% content_for :heading do %>
<h1><%= t("users.show.my messages") %></h1>
<ul class="nav nav-tabs">
<li class="nav-item">
<%= link_to t(".my_inbox"), inbox_messages_path, :class => "nav-link" %>
</li>
<li class="nav-item">
<a class="nav-link active"><%= t ".my_outbox" %></a>
</li>
</ul>
<% end %>
<%= render :partial => "heading", :locals => { :active_link_path => outbox_messages_path } %>
<h4><%= t ".messages", :count => current_user.sent_messages.size %></h4>
<% if current_user.sent_messages.size > 0 %>
<table class="table table-sm align-middle">
<thead>
<tr>
<th><%= t ".to" %></th>
<th><%= t ".subject" %></th>
<th><%= t ".date" %></th>
</tr>
</thead>
<tbody>
<%= render :partial => "sent_message_summary", :collection => current_user.sent_messages %>
</tbody>
</table>
<%= render :partial => "messages_table", :locals => { :columns => %w[to subject date], :messages => current_user.sent_messages, :inner_partial => "sent_message_summary" } %>
<% else %>
<div class="messages"><%= t(".no_sent_messages_html", :people_mapping_nearby_link => link_to(t(".people_mapping_nearby"), user_path(current_user))) %></div>
<% end %>

View file

@ -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" %>
</div>