<%- subject = laboratory_subject.subject -%>

<td class="text-left">
  <%= link_to(subject.name, "/paths/#{subject.id}", target: '_blank') %>
  <span class="badge badge-pill badge-success homepage-badge" style="<%= laboratory_subject.homepage? ? '' : 'display:none' %>">首页</span>
  <span class="badge badge-pill badge-success ownership-badge" style="<%= laboratory_subject.ownership? ? '' : 'display:none' %>">自建</span>
</td>
<td><%= display_text subject.repertoire&.name %></td>
<td><%= display_text subject.subject_level_system&.name %></td>
<td class="image-preview-container">
  <% image_exists = Util::FileManage.exists?(subject) %>
  <%= image_tag(image_exists ? Util::FileManage.source_disk_file_url(subject) : '', height: 40, class: "w-100 preview-image subject-image-#{subject.id}", style: image_exists ? '' : 'display:none') %>
  <% if laboratory_subject.ownership? %>
    <%= javascript_void_link image_exists ? '重新上传' : '上传图片', class: 'action upload-subject-image-action', data: { source_id: subject.id, source_type: 'Subject', toggle: 'modal', target: '.cooperative-upload-file-modal' } %>
  <% end %>
</td>
<td><%= link_to subject.user&.real_name, "/users/#{subject.user&.login}", target:'_blank' %></td>
<td><%= subject.user.school_name %></td>
<td><%= display_subject_status(subject) %></td>

<td class="action-container">
  <% if laboratory_subject.ownership? %>
    <%= link_to('修改', edit_cooperative_laboratory_subject_path(laboratory_subject), remote: true) %>
  <% end %>

  <%= javascript_void_link('首页展示', class: 'action homepage-show-action', data: { id: laboratory_subject.id }, style: laboratory_subject.homepage? ? 'display:none' : '') %>
  <%= javascript_void_link('取消首页展示', class: 'action homepage-hide-action', data: { id: laboratory_subject.id }, style: laboratory_subject.homepage? ? '' : 'display:none') %>

  <% unless laboratory_subject.ownership? %>
    <%= delete_link '删除', cooperative_laboratory_subject_path(laboratory_subject, element: ".laboratory-subject-item-#{laboratory_subject.id}") %>
  <% end %>
</td>