Put button to add content next to its related form

This way the relationship between the two elements is more obvious. And
since now the button and the form are siblings, it's easier to find one
based on the other using CSS or JavaScript.
This commit is contained in:
Javi Martín
2021-06-22 20:54:58 +02:00
parent 767b65e7d6
commit 089fe3cd1f
3 changed files with 8 additions and 10 deletions

View File

@@ -2462,6 +2462,7 @@ table {
.add-related-content { .add-related-content {
display: block; display: block;
margin-bottom: $line-height;
@include breakpoint(medium) { @include breakpoint(medium) {
float: right; float: right;

View File

@@ -1,3 +1,7 @@
<button type="button" data-toggle="related_content" class="add-related-content">
<%= t("related_content.add") %>
</button>
<%= form_tag related_contents_path, method: :post, id: "related_content", class: "hide", "data-toggler": ".hide" do %> <%= form_tag related_contents_path, method: :post, id: "related_content", class: "hide", "data-toggler": ".hide" do %>
<label><%= t("related_content.label") %></label> <label><%= t("related_content.label") %></label>

View File

@@ -1,15 +1,8 @@
<div class="related-content padding"> <div class="related-content padding">
<div class="margin-bottom"> <h2 class="inline-block">
<h2 class="inline-block"> <%= t("related_content.title") %>&nbsp;<span>(<%= relationable.relationed_contents.count %>)</span>
<%= t("related_content.title") %>&nbsp;<span>(<%= relationable.relationed_contents.count %>)</span> </h2>
</h2>
<% if current_user %>
<button type="button" data-toggle="related_content" class="add-related-content">
<%= t("related_content.add") %>
</button>
<% end %>
</div>
<% if current_user %> <% if current_user %>
<%= render "relationable/form", relationable: relationable %> <%= render "relationable/form", relationable: relationable %>