bulk update requests: list upvotes/downvotes on index page.

This commit is contained in:
evazion
2019-10-27 23:47:17 -05:00
parent 0e159960a2
commit b5a40aa233
2 changed files with 29 additions and 13 deletions

View File

@@ -42,7 +42,7 @@ class BulkUpdateRequestsController < ApplicationController
end
def index
@bulk_update_requests = BulkUpdateRequest.paginated_search(params)
@bulk_update_requests = BulkUpdateRequest.includes(:user, :approver, :forum_topic, forum_post: [:votes]).paginated_search(params)
respond_with(@bulk_update_requests)
end

View File

@@ -1,28 +1,44 @@
<table class="striped" width="100%">
<thead>
<tr>
<th>Creator</th>
<th>Approver</th>
<th>Forum</th>
<th>Script</th>
<th>Request</th>
<th>Votes</th>
<th>Status</th>
<th>Created</th>
<th></th>
</tr>
</thead>
<tbody>
<% bulk_update_requests.each do |request| %>
<tr id="request-<%= request.id %>">
<td><%= link_to_user(request.user) %></td>
<td><% if request.approver %><%= link_to_user(request.approver) %><% end %></td>
<td>
<% if request.forum_post_id %>
<%= link_to(request.forum_topic_id, forum_topic_path(request.forum_topic_id, page: request.forum_post.forum_topic_page, :anchor => "forum_post_#{request.forum_post.id}")) %>
<% elsif request.forum_topic_id %>
<%= link_to(request.forum_topic_id, forum_topic_path(request.forum_topic_id)) %>
<% if request.forum_post.present? %>
<p><%= link_to "Topic ##{request.forum_topic_id}: #{request.forum_topic.title}", forum_topic_path(request.forum_topic_id, page: request.forum_post.forum_topic_page, anchor: "forum_post_#{request.forum_post_id}") %></p>
<% elsif request.forum_topic.present? %>
<p><%= link_to "Topic ##{request.forum_topic_id}: #{request.forum_topic.title}", request.forum_topic %></p>
<% end %>
<%= script_with_line_breaks(request.script) %>
</td>
<td>
<% if request.forum_post.present? %>
<%= link_to forum_post_votes_path(search: { forum_post_id: request.forum_post_id }) do %>
+<%= request.forum_post.votes.select(&:up?).count %> /
-<%= request.forum_post.votes.select(&:down?).count %>
<% end %>
<% end %>
</td>
<td><%= script_with_line_breaks(request.script) %></td>
<td id="request-status-for-<%= request.id %>"><%= request.status %></td>
<td id="request-status-for-<%= request.id %>">
<%= request.status %>
<% if request.is_approved? %>
<br>by <%= link_to_user request.approver %>
<% end %>
</td>
<td>
<%= link_to_user request.user %>
<%= link_to "»", bulk_update_requests_path(search: { user_name: request.user.name }) %>
<div><%= time_ago_in_words_tagged(request.created_at) %></div>
</td>
<td>
<%= link_to "Show", bulk_update_request_path(request) %> |
<%= render "bulk_update_requests/bur_edit_links", bur: request %>