<% max_position = @sub_disciplines.pluck(:position).max %>
<table class="table table-hover text-center sub-discipline-list-table">
  <thead class="thead-light">
  <tr>
    <th width="6%">序号</th>
    <th width="54%" class="text-left">课程</th>
    <th width="8%">实践课程</th>
    <th width="8%">实训</th>
    <th width="8%">题库</th>
    <th width="16%">操作</th>
  </tr>
  </thead>
  <tbody>
  <% if @sub_disciplines.present? %>
    <% @sub_disciplines.each do |sub| %>
      <tr class="sub-discipline-item sub-discipline-item-<%= sub.id %>">
        <td><%= sub.position %></td>
        <td class="text-left">
          <span><%= link_to sub.name, admins_tag_disciplines_path(sub_discipline_id: sub), :title => sub.name %></span>
        </td>
        <td><%= check_box_tag :subject,!sub.subject,sub.subject,disabled:!sub.discipline&.subject,remote:true,data:{id:sub.id},class:"sub-discipline-source-form" %></td>
        <td><%= check_box_tag :shixun,!sub.shixun,sub.shixun,disabled:!sub.discipline&.shixun,remote:true,data:{id:sub.id},class:"sub-discipline-source-form" %></td>
        <td><%= check_box_tag :question,!sub.question,sub.question,disabled:!sub.discipline&.question,remote:true,data:{id:sub.id},class:"sub-discipline-source-form" %></td>
        <td>
          <%= javascript_void_link('上移', class: 'move-action', data: { id: sub.id, opr: "up" }, style: sub.position == 1 ? 'display:none' : '') %>
          <%= javascript_void_link('下移', class: 'move-action', data: { id: sub.id, opr: "down" }, style: sub.position == max_position ? 'display:none' : '') %>

          <%= link_to '编辑', edit_admins_sub_discipline_path(sub), remote: true, class: 'action' %>
          <%= delete_link '删除', admins_sub_discipline_path(sub, element: ".sub-discipline-item-#{sub.id}"), class: 'delete-sub-discipline-action' %>
        </td>
      </tr>
    <% end %>
  <% else %>
    <%= render 'admins/shared/no_data_for_table' %>
  <% end %>
  </tbody>
</table>