<table class="table table-hover text-center subject-list-table">
  <thead class="thead-light">
    <tr>
      <th width="4%">序号</th>
      <th width="4%">ID</th>
      <th width="15%" class="text-left">项目名称</th>
      <th width="6%">公开</th>
      <th width="8%">项目类别</th>
      <th width="8%">特殊协议</th>
      <th width="5%">issue</th>
      <th width="5%">Fork</th>
      <th width="5%">Pulls</th>
      <th width="6%">关注数</th>
      <th width="6%">点赞数</th>
      <th width="6%">平台内提交数</th>
      <th width="6%">里程碑</th>
      <th width="5%">成员</th>
      <th width="10%">管理员</th>
      <th width="12%"><%= sort_tag('创建时间', name: 'created_on', path: admins_projects_path) %></th>
      <th width="12%">操作</th>
    </tr>
  </thead>
  <tbody>
    <% if projects.present? %>
    <% projects.each_with_index do |project, index| %>
    <tr class="project-item-<%= project.id %>">
      <td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
      <td><%= project.id %></td>
      <td class="text-left">
        <%= link_to(project.name, "/#{project.owner&.login}/#{project.identifier}", target: '_blank') %>
      </td>
      <td><%= project.is_public ? '√' : '' %></td>
      <td><%= project.project_category.present? ? project.project_category.name : '' %></td>
      <td><%= project.is_secret ? '√' : '' %></td>
      <td><%= project.issues.where(issue_classify: 'issue').count %></td>
      <td><%= project.forked_count.to_i %></td>
      <td><%= project&.issues.issue_pull_request.count %></td>
      <td><%= project&.watchers_count %></td>
      <td><%= project&.praises_count %></td>
      <td><%= project&.commit_logs.count %></td>
      <td><%= project.versions.size %></td>
      <td><%= project.members.size %></td>
      <td>
        <%= link_to_project(project) %>
      </td>
      <td><%= project.created_on&.strftime('%Y-%m-%d %H:%M') %></td>
      <td class="action-container">
        <% if current_user.admin? %>
          <% if project.is_public %>
            <%= javascript_void_link '推荐', class: 'action recommend-action', data: { id: project.id }, style: project.recommend ? 'display: none;' : '' %>
            <%= javascript_void_link '取消推荐', class: 'action unrecommend-action', data: { id: project.id }, style: project.recommend ? '' : 'display: none;' %>
            <%= link_to "设置推荐等级", edit_admins_project_path(project.id), remote: true, class: "action edit-recommend-action", style: project.recommend ? '' : 'display: none;' %>
          <% end %>
          <%= link_to "删除", admins_project_path(project.id), method: :delete, data:{confirm: "确认删除的吗？"}, class: "delete-project-action" %>
        <% end %>
      </td> 
    </tr>
    <% end %>
    <% else %>
    <%= render 'admins/shared/no_data_for_table' %>
    <% end %>
  </tbody>
</table>

<%= render partial: 'admins/shared/paginate', locals: { objects: projects } %>
