<%= errors_summary_for music_release %>
<%= bootstrap_form_with model: model, local: true do |form| %>
  <%= field_set_tag content_tag(:span, t(".music_details.heading"), class: "h6 text-muted text-uppercase") do %>
    <div class="form-row">
      <%= form.text_field :name, required: true, wrapper_class: "col-12" %>
    </div>
  <% end %>

  <hr>

  <%= field_set_tag content_tag(:span, t(".files.heading"), class: "h6 text-muted text-uppercase") do %>
    <div class="alert alert-warning text-center text-md-left">
      <%= fa_icon "warning" %>
      <strong>For optimal accuracy, please ensure music file names match the source file name in the editing
        sequence.</strong>
    </div>
    <%= render "shared/file_infos_dropzone", form: form, releasable: music_release %>
  <% end %>

  <hr>

  <%= field_set_tag content_tag(:span, t(".contract_and_rights.heading"), class: "h6 text-muted text-uppercase") do %>
    <%= render "shared/contract_fields", form: form, release: music_release %>
    <%= render "shared/exploitable_rights_fields", form: form %>
  <% end %>

  <hr>

  <%= field_set_tag content_tag(:span, t(".composers.heading"), class: "h6 text-muted text-uppercase") do %>
    <%= form.fields_for :composers do |composer_form| %>
      <div>
        <%= composer_form.label "Composer #{composer_form.index+1}" %>
        <div class="form-row">
          <%= composer_form.text_field :name, placeholder: true, hide_label: true, wrapper_class: "col-sm-3" %>
          <%= composer_form.text_field :cae_number, placeholder: "CAE / IPI #", hide_label: true, wrapper_class: "col-sm-3" %>
          <%= composer_form.text_field :affiliation, placeholder: true, hide_label: true, wrapper_class: "col-sm-3" %>
          <%= composer_form.number_field :percentage, placeholder: true, hide_label: true, wrapper_class: "col-sm-3" %>
        </div>
      </div>
    <% end %>
  <% end %>

  <hr>

  <%= field_set_tag content_tag(:span, t(".publishers.heading"), class: "h6 text-muted text-uppercase") do %>
    <%= form.fields_for :publishers do |publisher_form| %>
      <div>
        <%= publisher_form.label "Publisher #{publisher_form.index+1}" %>
        <div class="form-row">
          <%= publisher_form.text_field :name, placeholder: true, hide_label: true, wrapper_class: "col-sm-6" %>
          <%= publisher_form.text_field :affiliation, placeholder: true, hide_label: true, wrapper_class: "col-sm-3" %>
          <%= publisher_form.number_field :percentage, placeholder: true, hide_label: true, wrapper_class: "col-sm-3" %>
        </div>
      </div>
    <% end %>
  <% end %>

  <hr>

  <%= field_set_tag content_tag(:span, t(".signer_details.heading"), class: "h6 text-muted text-uppercase") do %>
    <div class="form-row">
      <%= form.text_field :person_first_name, wrapper_class: "col-sm-3" %>
      <%= form.text_field :person_last_name, wrapper_class: "col-sm-3" %>
      <%= form.phone_field :person_phone, wrapper_class: "col-sm-6" %>
      <%= form.email_field :person_email, wrapper_class: "col-sm-6" %>
    </div>
    <div class="form-row">
      <%= form.text_field :person_company, wrapper_class: "col-sm-6" %>
      <%= form.text_field :person_title, wrapper_class: "col-sm-6" %>
    </div>
    <%= render "shared/address_fields", form: form, subject: "person" %>
  <% end %>

  <div class="row align-items-center text-center mt-4">
    <%= link_to t("shared.cancel"), [music_release.project, :music_releases], class: "col-3 text-reset" %>
    <div class="col-9">
      <%= form.button id: "submit_release", class: class_string("btn btn-block", ["btn-success", "btn-primary"] => music_release.new_record?), data: { disable_with: t("shared.disable_with") } %>
    </div>
  </div>
<% end %>
