Implement forum topic voting and tag change pruning (#3580)
This commit is contained in:
11
app/views/forum_post_votes/_add_vote.html.erb
Normal file
11
app/views/forum_post_votes/_add_vote.html.erb
Normal file
@@ -0,0 +1,11 @@
|
||||
<%-
|
||||
# forum_post
|
||||
%>
|
||||
|
||||
<li>
|
||||
<%= link_to content_tag(:i, nil, class: "far fa-thumbs-up"), forum_post_votes_path(forum_post_id: forum_post.id, format: "js"), remote: true, method: :post, data: {params: "forum_post_vote[score]=1"}, title: "Vote up" %>
|
||||
|
||||
<%= link_to content_tag(:i, nil, class: "far fa-meh"), forum_post_votes_path(forum_post_id: forum_post.id, format: "js"), remote: true, method: :post, data: {params: "forum_post_vote[score]=0"}, title: "Vote meh" %>
|
||||
|
||||
<%= link_to content_tag(:i, nil, class: "far fa-thumbs-down"), forum_post_votes_path(forum_post_id: forum_post.id, format: "js"), remote: true, method: :post, data: {params: "forum_post_vote[score]=-1"}, title: "Vote down" %>
|
||||
</li>
|
||||
16
app/views/forum_post_votes/_list.html.erb
Normal file
16
app/views/forum_post_votes/_list.html.erb
Normal file
@@ -0,0 +1,16 @@
|
||||
<%-
|
||||
# votes
|
||||
# forum_post
|
||||
%>
|
||||
|
||||
<% votes.by(CurrentUser.user.id).each do |vote| %>
|
||||
<%= render "forum_post_votes/vote", vote: vote, forum_post: forum_post %>
|
||||
<% end %>
|
||||
|
||||
<% votes.excluding(CurrentUser.user.id).each do |vote| %>
|
||||
<%= render "forum_post_votes/vote", vote: vote, forum_post: forum_post %>
|
||||
<% end %>
|
||||
|
||||
<% if !votes.by(CurrentUser.user.id).exists? %>
|
||||
<%= render "forum_post_votes/add_vote", vote: votes.by(CurrentUser.user.id).first, forum_post: forum_post %>
|
||||
<% end %>
|
||||
14
app/views/forum_post_votes/_vote.html.erb
Normal file
14
app/views/forum_post_votes/_vote.html.erb
Normal file
@@ -0,0 +1,14 @@
|
||||
<%-
|
||||
# vote
|
||||
# forum_post
|
||||
%>
|
||||
|
||||
<li class="vote-score-<%= vote.vote_type %>">
|
||||
<% if vote.creator_id == CurrentUser.id %>
|
||||
<%= link_to content_tag(:i, nil, class: "far #{vote.fa_class}"), forum_post_votes_path(forum_post_id: forum_post.id, format: "js"), remote: true, method: :delete %>
|
||||
<%= link_to_user vote.creator %>
|
||||
<% else %>
|
||||
<%= content_tag(:i, nil, class: "far #{vote.fa_class}") %>
|
||||
<%= link_to_user vote.creator %>
|
||||
<% end %>
|
||||
</li>
|
||||
7
app/views/forum_post_votes/create.js.erb
Normal file
7
app/views/forum_post_votes/create.js.erb
Normal file
@@ -0,0 +1,7 @@
|
||||
<% if @forum_post_vote.invalid? %>
|
||||
Danbooru.error(<%= raw @forum_post_vote.errors.full_messages.join("; ").to_json %>);
|
||||
<% else %>
|
||||
Danbooru.notice("Voted");
|
||||
var code = <%= raw render(partial: "forum_post_votes/list", locals: {forum_post: @forum_post, votes: @forum_post.votes}).to_json %>;
|
||||
$("#forum-post-votes-for-<%= @forum_post.id %>").html(code);
|
||||
<% end %>
|
||||
3
app/views/forum_post_votes/destroy.js.erb
Normal file
3
app/views/forum_post_votes/destroy.js.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
Danbooru.notice("Unvoted");
|
||||
var code = <%= raw render(partial: "forum_post_votes/list", locals: {forum_post: @forum_post, votes: @forum_post.votes}).to_json %>;
|
||||
$("#forum-post-votes-for-<%= @forum_post.id %>").html(code);
|
||||
Reference in New Issue
Block a user