<% page_title t('titles.organisation'), t('titles.owners') %>

<h1><%= t('.title') %></h1>

<%= start_box t('.current') %>
  <table id="currentOwners">
    <% @current_owners.each do |user| %>
    <% if user[:user].puavoRemovalRequestTime %>
    <tr class="groupUserMarkedForDeletion">
    <% else %>
    <tr>
    <% end %>
      <td>
        <%= render(partial: 'shared/owners_and_admins', locals: { user: user[:user] }) %>
      </td>
      <td>
        <% if @logged_in_user == user[:user].dn.to_s %>
        <span class="noOwnerSelfRemove"><%= t('organisations.owners.cant_remove_yourself') %></span>
        <% else %>
        <%= link_to(t('link.remove') + ' ►',
                      remove_owner_organisations_path(user[:user]),
                      method: :put,
                      id: "remove_user_#{user[:user].id}",
                      class: 'btn') %>
        <% end %>
      </td>
    </tr>
    <% end %>
  </table>
<%= end_box %>

<%= start_box t('.available') %>
  <table id="availableAdmins">
    <% if @available_owners.empty? %>
    <tr>
      <td><%= t('.none_left') %></td>
    </tr>
    <% else %>
    <% @available_owners.each do |user| %>
    <% if user[:user].puavoRemovalRequestTime %>
    <tr class="groupUserMarkedForDeletion">
    <% else %>
    <tr>
    <% end %>
      <td>
        <%= render(partial: 'shared/owners_and_admins', locals: { user: user[:user] }) %>
      </td>
      <td>
        <%= link_to('◄ ' + t('link.add'),
                    add_owner_organisations_path(user[:user]),
                    method: :put,
                    id: "add_user_#{user[:user].id}",
                    class: 'btn') %>
      </td>
    </tr>
    <% end %>
    <% end %>
  </table>
<%= end_box %>

<hr>
