Skip to content
Permalink
Browse files

Add feedback buttons on a post

  • Loading branch information
ArtOfCode- committed Mar 28, 2018
1 parent 35f5f89 commit 912f997ea3a6569757702f200f06c11874c1b061
Showing with 17 additions and 3 deletions.
  1. +5 −3 app/javascript/review.js
  2. +12 −0 app/views/posts/show.html.erb
@@ -1,6 +1,8 @@
$(() => {
$(document).on('ajax:success', 'a[data-remote]', e => {
$('.post-cell-' + e.target.dataset.postId).remove();
e.target.closest('tr').remove();
$(document).on('ajax:success', 'a.feedback-button[data-remote]', e => {
if (!$(e.target).hasClass('on-post')) {
$('.post-cell-' + e.target.dataset.postId).remove();
e.target.closest('tr').remove();
}
});
});
@@ -22,6 +22,18 @@
<% end %>
</h4>

<p>
<strong>Add feedback:</strong>
<%= link_to raw('&#x2713'), review_feedback_path(post_id: @post.id, feedback_type: 'tpu'),
class: 'feedback-button on-post text-success', remote: true, method: :post, data: { post_id: @post.id } %>
<%= link_to raw('&#x2717'), review_feedback_path(post_id: @post.id, feedback_type: 'fp'),
class: 'feedback-button on-post text-danger', remote: true, method: :post, data: { post_id: @post.id } %>
<% if @post.link.nil? or @post.link.include? '/a/' %>
<%= link_to raw('&#x1f4a9'), review_feedback_path(post_id: @post.id, feedback_type: 'naa'), class: 'feedback-button on-post text-warning',
remote: true, method: :post, data: { post_id: @post.id } %>
<% end %>
</p>

<% unless @post.body.nil? %>
<div data-postid="<%= @post.id.to_s %>" class="post-body">
<hr>

0 comments on commit 912f997

Please sign in to comment.
You can’t perform that action at this time.