<% max_position = @disciplines.pluck(:position).max %>
<table class="table table-hover text-center 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 @disciplines.present? %>
    <% @disciplines.each do |discipline| %>
      <tr class="discipline-item discipline-item-<%= discipline.id %>">
        <td><%= discipline.position %></td>
        <td class="text-left">
          <span><%= link_to discipline.name, admins_sub_disciplines_path(discipline_id: discipline), :title => discipline.name %></span>
        </td>
        <td><%= check_box_tag :subject,!discipline.subject,discipline.subject,remote:true,data:{id:discipline.id},class:"discipline-source-form" %></td>
        <td><%= check_box_tag :shixun,!discipline.shixun,discipline.shixun,remote:true,data:{id:discipline.id},class:"discipline-source-form" %></td>
        <td><%= check_box_tag :question,!discipline.question,discipline.question,remote:true,data:{id:discipline.id},class:"discipline-source-form" %></td>
        <td>
          <%= javascript_void_link('上移', class: 'move-action', data: { id: discipline.id, opr: "up" }, style: discipline.position == 1 ? 'display:none' : '') %>
          <%= javascript_void_link('下移', class: 'move-action', data: { id: discipline.id, opr: "down" }, style: discipline.position == max_position ? 'display:none' : '') %>

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