<% dtext_data = DText.preprocess(bulk_update_requests.map(&:processor).map(&:to_dtext)) %>

<%= table_for bulk_update_requests, width: "100%" do |t| %>
  <% t.column "Request" do |request| %>
      <% if request.forum_post.present? %>
        <p><%= link_to "Topic ##{request.forum_topic_id}: #{request.forum_topic.title}", request.forum_post %></p>
      <% elsif request.forum_topic.present? %>
        <p><%= link_to "Topic ##{request.forum_topic_id}: #{request.forum_topic.title}", request.forum_topic %></p>
      <% end %>

      <div class="prose">
        <%= format_text(request.processor.to_dtext, data: dtext_data) %>
      </div>
  <% end %>
  <% t.column "Votes" do |request| %>
    <% 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 %>
  <% end %>
  <% t.column "Status" do |request| %>
    <%= request.status %>
    <% if request.is_approved? %>
      <br>by <%= link_to_user request.approver %>
    <% end %>
  <% end %>
  <% t.column "Created" do |request| %>
    <%= 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>
  <% end %>
  <% t.column column: "control" do |request| %>
    <%= link_to "Show", bulk_update_request_path(request) %> |
    <%= render "bulk_update_requests/bur_edit_links", bur: request %>
  <% end %>
<% end %>

