adds moderation to comments and debates [#136]

This commit is contained in:
rgarcia
2015-08-17 13:39:31 +02:00
parent cd0a64ea3e
commit f31ed2940d
35 changed files with 315 additions and 45 deletions

View File

@@ -0,0 +1,5 @@
<span id="moderator-comment-actions">
&nbsp;|&nbsp;
<%= link_to t("admin.actions.hide").capitalize, hide_moderation_comment_path(comment),
method: :put, remote: true, data: { confirm: t('admin.actions.confirm') } %>
</span>

View File

@@ -1,30 +1,44 @@
<div class="row">
<div id="comment-<%= comment.id %>" class="comment small-12 column">
<div id="<%= dom_id(comment) %>" class="comment small-12 column">
<%= avatar_image(comment.user, size: 32, class: 'left') %>
<% if comment.hidden? %>
This comment has been deleted
<% else %>
<div class="comment-body">
<span class="comment-info">
<span><%= comment.user.name %></span>&nbsp;&bullet;&nbsp;<%= time_ago_in_words(comment.created_at) %>
</span>
<p><%= comment.body %></p>
<%= avatar_image(comment.user, size: 32, class: 'left') %>
<span id="<%= dom_id(comment) %>_votes" class="comment-votes right">
<%= render 'comments/votes', comment: comment %>
</span>
<div class="comment-body">
<span class="comment-info">
<span><%= comment.user.name %></span>&nbsp;&bullet;&nbsp;<%= time_ago_in_words(comment.created_at) %>
</span>
<p><%= comment.body %></p>
<p class="reply">
<%= t("debates.comment.responses", count: comment.children_count) %>
<% if user_signed_in? %>
&nbsp;|&nbsp;
<%= render 'comments/form', {parent: comment, toggeable: true} %>
<% end %>
</p>
</div>
<span id="<%= dom_id(comment) %>_votes" class="comment-votes right">
<%= render 'comments/votes', comment: comment %>
</span>
<div class="comment-children">
<%= render comment.children.reorder('id DESC, lft') %>
</div>
<p class="reply">
<%= t("debates.comment.responses", count: comment.children_count) %>
<% if user_signed_in? %>
&nbsp;|&nbsp;
<%= link_to(comment_link_text(comment), "",
class: "js-add-comment-link", data: {'id': dom_id(comment)}) %>
<% if moderator? %>
<%= render 'comments/actions', comment: comment %>
<% end %>
<%= render 'comments/form', {parent: comment, toggeable: true} %>
<% end %>
</p>
</div>
<% end %>
<div class="comment-children">
<%= render comment.children.with_deleted.reorder('id DESC, lft') %>
</div>
</div>
</div>
</div>

View File

@@ -1,5 +1,3 @@
<%= link_to(comment_link_text(parent), "", class: "js-add-comment-link", data: {'id': dom_id(parent)}) if toggeable %>
<div id="js-comment-form-<%= dom_id(parent) %>" <%= "style='display:none'".html_safe if toggeable %>>
<%= form_for [@debate, Comment.new], remote: true do |f| %>
<%= f.text_area :body %>

View File

@@ -1,9 +1,10 @@
var parent_id = '<%= dom_id(@parent) %>';
var parent_id = "<%= dom_id(@parent) %>";
var comment_html = "<%= j(render @comment) %>"
<% if @parent.is_a?(Debate) -%>
App.Comments.reset_form(parent_id);
App.Comments.add_comment(parent_id, comment_html);
<% else -%>
App.Comments.reset_and_hide_form(parent_id);
App.Comments.add_reply(parent_id, comment_html);
<% end -%>
App.Comments.add_response(parent_id, "<%= j(render @comment) %>");