<% unless @synchronised_deletions.nil? %>
<% if @synchronised_deletions.include?(@school.id.to_i) && !@synchronised_deletions[@school.id.to_i].empty? %>
<p class="genericWarning"><%= t('users.index.synchronised_deletions', :systems => @synchronised_deletions[@school.id.to_i].join(', ')) %></p>
<% end %>
<% end %>

<% content_for :javascript do %>
<script>
const SUPERTABLE_WORKER_FILE = "<%= javascript_path 'supertable3_worker' %>";
let GLOBAL_SUPERTABLE_INSTANCE = null;
</script>

<%= javascript_include_tag 'javascripts/modal_popup' %>
<%= javascript_include_tag 'javascripts/supertable3' %>
<% end %>

<%= render 'shared/supertable_controls' %>

<div class="superTable" id="tableUsers"></div>

<% @is_organisation = false %>

<% content_for :post_load_javascript do %>
<script>
"use strict;"

<%= render partial: 'shared/supertable_translations', formats: [:js] %>
<%= render partial: 'shared/user_tables_common', formats: [:js] %>

const DEFAULT_COLUMNS = ["uid", "name", "role", "eid"];
const DEFAULT_SORTING = { column: "name", dir: ST.SortOrder.ASCENDING };

document.addEventListener("DOMContentLoaded", () => {
    modalPopup.setupGlobalEvents();

    GLOBAL_SUPERTABLE_INSTANCE = new ST.SuperTable(
        // Main container DIV
        document.getElementById("tableUsers"),

        // Settings
        {
            id: "users",
            locale: "<%= supertable_sorting_locale %>",
            csvPrefix: `<%= LdapOrganisation.current.o %>-<%= @school.cn %>-users`,
            columnDefinitions: COLUMN_DEFINITIONS,
            columnOrder: COLUMN_ORDER,
            actions: userActions,
            openCallback: openCallback,
            massSelects: MASS_SELECTS,
            massOperations: MASS_OPERATIONS,
            massOperationsEndpoint: "<%= users_mass_operations_path %>",
            defaultColumns: DEFAULT_COLUMNS,
            defaultSorting: DEFAULT_SORTING,
            filterPresets: FILTER_PRESETS,
            dynamicData: "/users/<%= @school.id %>/get_school_users_list",
            preFilterFunction: expandUserData,
        }
    );
});

</script>

<% content_for :page_tools do %>
<%=
toolbar do |tb|
  if @permit_user_creation
    tb.link t('link.new_user'),
            href: new_user_path,
            icon: 'plus'
  end
end %>
<% end %>
<% end %>
