[AIBUR] Link to forum post & show votes in show action (#601)

* [AIBUR] Link to forum post & show votes in `show` action

* Use strict locals, they are pretty cool

Also clarify the purpose of the new parameter

* Only show voting box when any votes are present

Looks weird otherwise

* Move the list into the partial

* Remove voting link on show page

* Uniform display on forum/show page

Display the votes inline, like on forum posts

---------

Co-authored-by: Earlopain <14981592+Earlopain@users.noreply.github.com>
This commit is contained in:
Donovan Daniels 2024-02-14 12:17:54 -06:00 committed by GitHub
parent 5759cc4103
commit 0702b4fd19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 53 additions and 36 deletions

View File

@ -38,18 +38,26 @@ div.list-of-forum-posts {
menu {
margin-top: 0.5em;
ul.votes {
margin: 0.5em 0;
}
li {
margin-right: 1em;
}
}
.forum-post-votes-list {
margin-top: 0.5em;
margin-left: 0.2em;
}
}
}
}
.forum-post-votes-list {
li {
display: inline;
margin-right: 1em;
}
}
div#c-forum-topics {
span.new {
font-size: 80%;

View File

@ -3,9 +3,7 @@
<h1>Bulk Update Request: <%= @bulk_update_request.title %></h1>
<ul>
<% if @bulk_update_request.forum_topic_id %>
<li><strong>Reference</strong> <%= link_to "topic ##{@bulk_update_request.forum_topic_id}", forum_topic_path(@bulk_update_request.forum_topic_id) %></li>
<% end %>
<%= render "tag_change_requests/reference", tag_change_request: @bulk_update_request %>
<li><strong>Creator</strong> <%= link_to_user @bulk_update_request.user %></li>
<li><strong>Date</strong> <%= @bulk_update_request.created_at %></li>
<li><strong>Status</strong>: <%= @bulk_update_request.status %></li>
@ -18,6 +16,8 @@
<%= render "bur_edit_links", bur: @bulk_update_request %>
</div>
<%= render "tag_change_requests/votes", tag_change_request: @bulk_update_request %>
</div>
</div>

View File

@ -1,19 +1,18 @@
<%-
# votes
# forum_post
%>
<%# locals: (votes:, forum_post:, votable: true) -%>
<% own_vote = votes.find { |vote| vote.creator == CurrentUser.user } %>
<% other_votes = votes.reject { |vote| vote.creator == CurrentUser.user } %>
<% if own_vote %>
<%= render "forum_post_votes/vote", vote: own_vote, forum_post: forum_post %>
<% end %>
<ul class="forum-post-votes-list" id="forum-post-votes-for-<%= forum_post.id %>">
<% if own_vote %>
<%= render "forum_post_votes/vote", vote: own_vote, forum_post: forum_post, votable: votable %>
<% end %>
<% other_votes.each do |vote| %>
<%= render "forum_post_votes/vote", vote: vote, forum_post: forum_post %>
<% end %>
<% other_votes.each do |vote| %>
<%= render "forum_post_votes/vote", vote: vote, forum_post: forum_post, votable: false %>
<% end %>
<% if forum_post.tag_change_request&.is_pending? && !own_vote %>
<%= render "forum_post_votes/add_vote", forum_post: forum_post %>
<% end %>
<% if forum_post.tag_change_request&.is_pending? && !own_vote && votable %>
<%= render "forum_post_votes/add_vote", forum_post: forum_post %>
<% end %>
</ul>

View File

@ -1,10 +1,7 @@
<%-
# vote
# forum_post
%>
<%# locals: (vote:, forum_post:, votable:) -%>
<li class="vote-score-<%= vote.vote_type %> <%= 'own-forum-vote' if vote.creator_id == CurrentUser.id %>">
<% if forum_post.tag_change_request&.is_pending? && vote.creator_id == CurrentUser.id %>
<% if votable && forum_post.tag_change_request&.is_pending? && vote.creator_id == CurrentUser.id %>
<%= link_to tag.i(class: "fa-regular #{vote.fa_class}"), "#", class: "forum-vote-remove", 'data-forum-id': forum_post.id %>
<%= link_to_user vote.creator %>
<% else %>

View File

@ -73,12 +73,10 @@
<span><%= link_to_ip forum_post.creator_ip_addr %></span>
</li>
<% end %>
<% if forum_post.votable? %>
<ul class="votes" id="forum-post-votes-for-<%= forum_post.id %>">
<%= render "forum_post_votes/list", votes: forum_post.votes, forum_post: forum_post %>
</ul>
<% end %>
</menu>
<% if forum_post.votable? %>
<%= render "forum_post_votes/list", votes: forum_post.votes, forum_post: forum_post %>
<% end %>
<% if forum_post.editable_by?(CurrentUser.user) %>
<% if forum_post.is_original_post?(original_forum_post_id) %>
<%= render "forum_topics/form", :forum_topic => forum_post.topic %>

View File

@ -5,9 +5,7 @@
<ul>
<li><strong>From</strong> <%= link_to @tag_alias.antecedent_name, show_or_new_wiki_pages_path(:title => @tag_alias.antecedent_name) %></li>
<li><strong>To</strong> <%= link_to @tag_alias.consequent_name, show_or_new_wiki_pages_path(:title => @tag_alias.consequent_name) %></li>
<% if @tag_alias.forum_topic_id %>
<li><strong>Reference</strong> <%= link_to "topic ##{@tag_alias.forum_topic_id}", forum_topic_path(@tag_alias.forum_topic_id) %></li>
<% end %>
<%= render "tag_change_requests/reference", tag_change_request: @tag_alias %>
<li><strong>Creator</strong> <%= link_to_user @tag_alias.creator %></li>
<li><strong>Date</strong> <%= @tag_alias.created_at %></li>
<% if @tag_alias.respond_to?(:reason) && @tag_alias.reason.present? %>
@ -32,6 +30,8 @@
<%= render "tag_relationships/command_buttons", tag_relation: @tag_alias, with_show_link: false %>
</li>
</ul>
<%= render "tag_change_requests/votes", tag_change_request: @tag_alias %>
</div>
</div>

View File

@ -0,0 +1,9 @@
<% if tag_change_request.forum_topic_id %>
<li><strong>Reference</strong>
<% if tag_change_request.forum_post_id %>
<%= link_to "forum ##{tag_change_request.forum_post_id}", forum_topic_path(tag_change_request.forum_topic_id, page: tag_change_request.forum_post.forum_topic_page, anchor: "forum_post_#{tag_change_request.forum_post_id}") %>
<% else %>
<%= link_to "topic ##{tag_change_request.forum_topic_id}", forum_topic_path(tag_change_request.forum_topic_id) %>
<% end %>
</li>
<% end %>

View File

@ -0,0 +1,6 @@
<% if tag_change_request.forum_post&.votes&.any? %>
<div style="margin: 1em 0;">
<h2>Votes</h2>
<%= render "forum_post_votes/list", votes: tag_change_request.forum_post.votes, forum_post: tag_change_request.forum_post, votable: false %>
</div>
<% end %>

View File

@ -5,9 +5,7 @@
<ul>
<li><strong>From</strong> <%= link_to @tag_implication.antecedent_name, show_or_new_wiki_pages_path(:title => @tag_implication.antecedent_name) %></li>
<li><strong>To</strong> <%= link_to @tag_implication.consequent_name, show_or_new_wiki_pages_path(:title => @tag_implication.consequent_name) %></li>
<% if @tag_implication.forum_topic_id %>
<li><strong>Reference</strong> <%= link_to "topic ##{@tag_implication.forum_topic_id}", forum_topic_path(@tag_implication.forum_topic_id) %></li>
<% end %>
<%= render "tag_change_requests/reference", tag_change_request: @tag_implication %>
<li><strong>Creator</strong> <%= link_to_user @tag_implication.creator %></li>
<li><strong>Date</strong> <%= @tag_implication.created_at %></li>
<% if @tag_implication.respond_to?(:reason) && @tag_implication.reason.present? %>
@ -20,6 +18,8 @@
<%= render "tag_relationships/command_buttons", tag_relation: @tag_implication, with_show_link: false %>
</li>
</ul>
<%= render "tag_change_requests/votes", tag_change_request: @tag_implication %>
</div>
</div>