<table class="table table-hover users-list-table">
  <thead class="thead-light">
    <tr>
      <th width="10%" class="text-left">真实姓名</th>
      <th width="16%">邮件地址</th>
      <th width="10%">手机号码</th>
      <th width="14%">单位</th>
      <th width="10%"><%= sort_tag('创建于', name: 'created_on', path: admins_users_path) %></th>
      <th width="10%"><%= sort_tag('最后登录', name: 'last_login_on', path: admins_users_path) %></th>
      <th width="6%"><%= sort_tag('经验值', name: 'experience', path: admins_users_path) %></th>
      <th width="6%"><%= sort_tag('金币', name: 'grade', path: admins_users_path) %></th>
      <th width="20%">操作</th>
    </tr>
  </thead>
  <tbody>
    <% if users.present? %>
      <% users.each do |user| %>
        <tr class="user-item-<%= user.id %>">
          <td class="text-left">
            <%= link_to "/users/#{user.login}", target: '_blank' do %>
              <%= overflow_hidden_span user.real_name, width: 100 %>
            <% end %>
          </td>
          <td><%= overflow_hidden_span display_text(user.mail), width: 150 %></td>
          <td><%= overflow_hidden_span display_text(user.phone), width: 100 %></td>
          <td><%= overflow_hidden_span display_text(user.school_name), width: 150 %></td>
          <td><%= display_text(user.created_on&.strftime('%Y-%m-%d %H:%M')) %></td>
          <td><%= display_text(user.last_login_on&.strftime('%Y-%m-%d %H:%M')) %></td>
          <td><%= user.experience.to_i %></td>
          <td class="grade-content"><%= user.grade.to_i %></td>
          <td class="action-container">
            <%= link_to '编辑', edit_admins_user_path(user), class: 'action' %>

            <%= javascript_void_link('奖励', class: 'action reward-grade-action', data: { toggle: 'modal', target: '.admin-users-reward-grade-modal', id: user.id }) %>

            <%= javascript_void_link '解锁', class: 'action unlock-action', data: { id: user.id, confirm: '确认解锁吗？' }, style: user.locked? ? '' : 'display: none;' %>

            <% if user.registered? %>
              <%= javascript_void_link '激活', class: 'action active-action', data: { id: user.id, confirm: '确认激活吗？' } %>
            <% end %>

            <% if user.id != current_user.id %>
              <%= javascript_void_link '加锁', class: 'action lock-action', data: { id: user.id, confirm: '确认加锁吗？' }, style: user.locked? || user.registered? ? 'display: none;' : '' %>
            <% end %>

            <%= delete_link '删除', admins_user_path(user, element: ".user-item-#{user.id}"), class: 'delete-user-action' %>
          </td>
        </tr>
      <% end %>
    <% else %>
      <%= render 'admins/shared/no_data_for_table' %>
    <% end %>
  </tbody>
</table>

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