Use CSS to hide reply forms

We were using inline styles and passing local variables around, while
the rule we were following is very simple: it's only hidden if it's a
form to reply to a comment.
This commit is contained in:
Javi Martín
2020-05-11 17:17:12 +02:00
parent 61a63ddd59
commit ae41becd3a
9 changed files with 11 additions and 8 deletions

View File

@@ -2180,6 +2180,11 @@ table {
display: inline-block;
padding-left: rem-calc(8);
width: 100%;
}
.comment-form {
display: none;
}
&:empty {

View File

@@ -107,7 +107,6 @@
<% if !valuation || can?(:comment_valuation, comment.commentable) %>
<%= render "comments/form", { commentable: comment.commentable,
parent_id: comment.id,
toggeable: true,
valuation: valuation } %>
<% end %>
<% end %>

View File

@@ -27,7 +27,6 @@
<% elsif !valuation || can?(:comment_valuation, commentable) %>
<%= render "comments/form", { commentable: commentable,
parent_id: nil,
toggeable: false,
valuation: valuation } %>
<% end %>
<% else %>

View File

@@ -1,7 +1,7 @@
<% valuation = local_assigns.fetch(:valuation, false) %>
<% cache [locale_and_user_status, parent_id, commentable_cache_key(commentable), valuation] do %>
<% css_id = parent_or_commentable_dom_id(parent_id, commentable) %>
<div id="js-comment-form-<%= css_id %>" <%= raw("style='display:none'") if toggeable %> class="comment-form">
<div id="js-comment-form-<%= css_id %>" class="comment-form">
<%= form_for Comment.new, remote: true, html: { id: "new_comment_#{css_id}" } do |f| %>
<%= f.text_area :body,
id: "comment-body-#{css_id}",

View File

@@ -9,7 +9,7 @@
<%= render "shared/wide_order_selector", i18n_namespace: "comments" %>
<% if user_signed_in? %>
<%= render "comments/form", { commentable: @debate, parent_id: nil, toggeable: false } %>
<%= render "comments/form", { commentable: @debate, parent_id: nil } %>
<% else %>
<br>
<%= render "shared/login_to_comment" %>

View File

@@ -4,7 +4,7 @@
<%= render "shared/wide_order_selector", i18n_namespace: "comments" %>
<% if user_signed_in? %>
<%= render "comments/form", { commentable: @proposal, parent_id: nil, toggeable: false } %>
<%= render "comments/form", { commentable: @proposal, parent_id: nil } %>
<% else %>
<br>
<%= render "shared/login_to_comment" %>

View File

@@ -4,7 +4,7 @@
<%= render "shared/wide_order_selector", i18n_namespace: "comments" %>
<% if user_signed_in? %>
<%= render "comments/form", { commentable: @poll, parent_id: nil, toggeable: false } %>
<%= render "comments/form", { commentable: @poll, parent_id: nil } %>
<% else %>
<br>
<%= render "shared/login_to_comment" %>

View File

@@ -4,7 +4,7 @@
<%= render "shared/wide_order_selector", i18n_namespace: "comments" %>
<% if user_signed_in? %>
<%= render "comments/form", { commentable: @proposal, parent_id: nil, toggeable: false } %>
<%= render "comments/form", { commentable: @proposal, parent_id: nil } %>
<% else %>
<br>
<%= render "shared/login_to_comment" %>

View File

@@ -8,7 +8,7 @@
<%= paginate @comment_tree.root_comments %>
<% if user_signed_in? %>
<%= render "comments/form", { commentable: @topic, parent_id: nil, toggeable: false } %>
<%= render "comments/form", { commentable: @topic, parent_id: nil } %>
<% else %>
<%= render "shared/login_to_comment" %>
<% end %>