refactors comment form
This commit is contained in:
committed by
Juanjo Bazán
parent
df5ef2dc29
commit
eb689d7c7e
@@ -1,11 +1,11 @@
|
||||
module CommentsHelper
|
||||
|
||||
def comment_link_text(parent)
|
||||
parent.is_a? Comment ? t("comments_helper.reply_link") : t("comments_helper.comment_link")
|
||||
def comment_link_text(parent_id)
|
||||
parent_id.present? ? t("comments_helper.reply_link") : t("comments_helper.comment_link")
|
||||
end
|
||||
|
||||
def comment_button_text(parent)
|
||||
parent.is_a? Comment ? t("comments_helper.reply_button") : t("comments_helper.comment_button")
|
||||
def comment_button_text(parent_id)
|
||||
parent_id.present? ? t("comments_helper.reply_button") : t("comments_helper.comment_button")
|
||||
end
|
||||
|
||||
end
|
||||
@@ -88,14 +88,14 @@
|
||||
|
||||
<%= render 'comments/actions', comment: comment %>
|
||||
|
||||
<%= render 'comments/form', {parent: comment, toggeable: true} %>
|
||||
<%= render 'comments/form', {commentable: @debate, parent_id: comment.id, toggeable: true} %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="comment-children">
|
||||
<%= render comment.children.for_render.reorder('id DESC, lft') %>
|
||||
<%= render comment.children.for_render.reorder('id DESC') %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
<div id="js-comment-form-<%= dom_id(parent) %>" <%= "style='display:none'".html_safe if toggeable %>>
|
||||
<%= form_for [@debate, Comment.new], remote: true do |f| %>
|
||||
<%= label_tag "comment-body-#{dom_id(parent)}", t("comments.form.leave_comment") %>
|
||||
<%= f.text_area :body, id: "comment-body-#{dom_id(parent)}", label: false %>
|
||||
<%= f.hidden_field :commentable_type, value: parent.class %>
|
||||
<%= f.hidden_field :commentable_id, value: parent.id %>
|
||||
<div id="js-comment-form-<%= dom_id(commentable) %>" <%= "style='display:none'".html_safe if toggeable %>>
|
||||
<%= form_for [commentable, Comment.new], remote: true do |f| %>
|
||||
<%= label_tag "comment-body-#{dom_id(commentable)}", t("comments.form.leave_comment") %>
|
||||
<%= f.text_area :body, id: "comment-body-#{dom_id(commentable)}", label: false %>
|
||||
<%= f.hidden_field :commentable_type, value: commentable.class %>
|
||||
<%= f.hidden_field :commentable_id, value: commentable.id %>
|
||||
<%= f.hidden_field :parent_id, value: parent_id %>
|
||||
|
||||
<%= f.submit comment_button_text(parent), class: "button radius small inline-block" %>
|
||||
<%= f.submit comment_button_text(parent_id), class: "button radius small inline-block" %>
|
||||
|
||||
<% if can? :comment_as_moderator, @debate %>
|
||||
<% if can? :comment_as_moderator, commentable %>º
|
||||
<div class="right">
|
||||
<%= f.check_box :as_moderator, id: "comment-as-moderator-#{dom_id(parent)}", label: false %>
|
||||
<%= label_tag "comment-as-moderator-#{dom_id(parent)}", t("comments.form.comment_as_moderator"), class: "checkbox" %>
|
||||
<%= f.check_box :as_moderator, id: "comment-as-moderator-#{dom_id(commentable)}", label: false %>
|
||||
<%= label_tag "comment-as-moderator-#{dom_id(commentable)}", t("comments.form.comment_as_moderator"), class: "checkbox" %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if can? :comment_as_administrator, @debate %>
|
||||
<% if can? :comment_as_administrator, commentable %>
|
||||
<div class="right">
|
||||
<%= f.check_box :as_administrator, id: "comment-as-administrator-#{dom_id(parent)}",label: false %>
|
||||
<%= label_tag "comment-as-administrator-#{dom_id(parent)}", t("comments.form.comment_as_admin"), class: "checkbox" %>
|
||||
<%= f.check_box :as_administrator, id: "comment-as-administrator-#{dom_id(commentable)}",label: false %>
|
||||
<%= label_tag "comment-as-administrator-#{dom_id(commentable)}", t("comments.form.comment_as_admin"), class: "checkbox" %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
<span>(<%= @debate.comments_count %>)</span>
|
||||
</h2>
|
||||
<% if user_signed_in? %>
|
||||
<%= render 'comments/form', {parent: @debate, toggeable: false} %>
|
||||
<%= render 'comments/form', {commentable: @debate, parent_id: nil, toggeable: false} %>
|
||||
<% else %>
|
||||
<br>
|
||||
<div class="alert-box radius info">
|
||||
|
||||
Reference in New Issue
Block a user