<div class="container">
  <div class="row dashboard">
    <div class="col-7">
      <div class="welcome">Welcome, <%= current_user.editor.full_name %></div>
      <div class="hero-small dashboard">
        <div class="hero-title">
          <%= image_tag "icon_papers.svg", height: "32px" %>
          <h1>Editor dashboard <%= " - @#{@editor.login}" if @editor != current_user.editor%></h1>
        </div>
      </div>
    </div>
    <div class="col-5">
      <div class="my-statistics">
        <div class="banner">
          <span class="text-left">Statistics</span>
          <span class="float-right"><%= link_to "View more &raquo;".html_safe, dashboard_path %></span>
        </div>

        <div class="row">
          <div class="stat col">
            <div class="count"><%= @editor.papers.visible.since(1.month.ago).count %></div>
            <div class="message">Papers last month</div>
          </div>
          <div class="stat col">
            <div class="count"><%= @editor.three_month_average %><span class="sub">(3M average)</span></div>
            <div class="message">Papers per month</div>
          </div>
          <div class="stat col">
            <div class="count"><%= Editor.global_three_month_average %><span class="sub">(Editor average)</span></div>
            <div class="message">Papers per month</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<%= render partial: "menu" %>

<div class="container">
  <table class="dashboard-table">
    <thead>
      <tr>
        <th scope="col" width="11%">Status</th>
        <th scope="col">Paper title</th>
        <% unless params[:editor]%>
        <th scope="col" class="text-center" width="10%">Scope</th>
        <th scope="col" class="text-center" width="10%">Invites</th>
        <% end %>
        <th scope="col" class="text-center" width="10%">Reviews</th>
        <th class="mobile-hide text-center" scope="col" width="8%">Reviewers</th>
        <th class="mobile-hide" scope="col" width="11%">Last activity <%= sort_activity(params[:order]) %></th>
      </tr>
    </thead>
    <tbody>
      <% @papers.each do |paper| %>
      <tr>
        <td class="state"><%= paper.state.titleize %></td>
        <td><%= link_to paper.title, paper_url(paper), title: paper.title, class: "d-inline-block text-truncate", style: "max-width: 450px;" %><div class="time">Submitted <%= time_ago_in_words(paper.created_at) %> ago <%= pretty_labels_for(paper) %></div></td>
        <% unless params[:editor]%>
        <td class="text-center"><%= vote_summary(paper, @votes_by_paper_from_editor) %></td>
        <td class="text-center"><%= open_invites_for_paper(paper) %></td>   
        <% end %>
        <td class="text-center"><%= review_issue_links(paper) %></td>
        <td class="text-center mobile-hide">
          <%- paper.reviewers.each do |reviewer| %>
            <%= link_to image_tag(avatar(reviewer), size: "24x24", class: "avatar", title: reviewer), github_user_link(reviewer).html_safe %>
          <%- end %>
        </td>
        <td class="mobile-hide"><%= comment_activity(paper) %></td>
      </tr>
      <% end %>
    </tbody>
  </table>

  <div class="row">
    <div class="pagination_helper">
      <%== pagy_info(@pagy, item_name: t("paper", count: @papers.size)) %>
    </div>
    <%= pagy_pagination @pagy %>
  </div>
</div>
