<table class="table table-hover text-center shixuns-list-table">
  <thead class="thead-light">
  <th width="4%">序号</th>
  <th width="8%">ID</th>
  <th width="38%" class="text-left">课程名称</th>
  <th width="10%">课堂数</th>
  <th width="10%">创建者</th>
  <th width="12%"><%= sort_tag('创建时间', name: 'created_at', path: admins_course_lists_path) %></th>
  <th width="18%">操作</th>
  </thead>
  <tbody>
  <% if courses.present? %>
    <% courses.each_with_index do |course_list,index| %>
      <tr id="course-list-item-<%= course_list.id %>">
        <td><%= list_index_no(@params_page.to_i, index) %></td>
        <td><%= course_list.id %></td>
        <td class="text-left"><%= course_list.name %></td>
        <% course_count = course_list.courses.size %>
        <td><%= course_count %></td>
        <td><%= link_to course_list.user.try(:real_name),"/users/#{course_list.user.try(:login)}",target:'_blank' %></td>
        <td><%= format_time course_list.created_at %></td>
        <td class="operate">
          <% if course_count == 0 %>
            <%= delete_link '删除', admins_course_list_path(course_list, element: ".course-list-item-#{course_list.id}"), class: 'delete-department-action' %>
          <% end %>
          <%= javascript_void_link '修改', class: 'action', data: { course_list_id: course_list.id,
                                                                  toggle: 'modal', target: '.admin-merge-course-list-modal', url: merge_admins_course_lists_path } %>
        </td>
      </tr>
    <% end %>
  <% else %>
    <%= render 'admins/shared/no_data_for_table' %>
  <% end %>
  </tbody>
</table>

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