<% @page_title = "Board Settings" %>

<% content_for :header do %>
  <div class="header__actions header__actions--start">
    <%= link_to @collection, class: "btn borderless txt-medium", data: { controller: "hotkey", action: "keydown.esc@document->hotkey#click" } do %>
      <span class="overflow-ellipsis">
        &larr;
        <strong><%= @collection.name %></strong>
      </span>
    <% end %>
  </div>

  <h1 class="header__title"><%= @page_title %></h1>
<% end %>

<section class="settings">
  <div class="settings__panel settings__panel--users panel shadow center">
    <%= form_with model: @collection, class: "display-contents", data: {
          controller: "form collections-form",
          collections_form_self_removal_prompt_message_value: "Are you sure you want to remove yourself from this collection? You won’t be able to get back in unless someone invites you.",
          action: "turbo:submit-start->collections-form#submitWithWarning" } do |form| %>
      <%= render "collections/edit/name", form: form %>
      <%= render "collections/edit/users", collection: @collection, selected_users: @selected_users, unselected_users: @unselected_users, form: form %>

      <button type="submit" id="log_in" class="btn btn--link center txt-normal">
        <span>Save changes</span>
      </button>

      <%= link_to "Cancel and go back", @collection, data: { form_target: "cancel", turbo_frame: "_top" }, hidden: true %>
    <% end %>
  </div>

  <div class="settings__panel panel shadow center">
    <%= render "collections/edit/auto_close", collection: @collection %>
    <%= render "collections/edit/publication", collection: @collection %>
    <%= render "collections/edit/delete", collection: @collection %>
  </div>
</section>
