= form_for(@exercise_collection, multipart: true) do |f|
  = render('shared/form_errors', object: @exercise_collection)
  .form-group
    = f.label(t('activerecord.attributes.exercise_collections.name'))
    = f.text_field(:name, class: 'form-control', required: true)
  .form-check.form-group
    label.form-check-label
      = f.check_box(:use_anomaly_detection, class: 'form-check-input')
      = t('activerecord.attributes.exercise_collections.use_anomaly_detection')
  .form-group
    = f.label(t('activerecord.attributes.exercise_collections.user'))
    = f.collection_select(:user_id, InternalUser.order(:name), :id, :name, {}, {class: 'form-control'})

  .table-responsive#exercise-list
    table.table
      thead
        tr
          th
          th = t('activerecord.attributes.exercise_collection_item.exercise')
          th colspan=2 = t('shared.actions')
      tbody#sortable
        - @exercise_collection.items.order(:position).each do |item|
          tr data-id=item.exercise.id
            td
              span.fa.fa-bars
            td = item.exercise.title
            td = link_to(t('shared.show'), item.exercise, 'data-turbolinks' => "false")
            td
              a.remove-exercise href='#' = t('shared.destroy')
  .d-none
    = f.collection_select(:exercise_ids, Exercise.all, :id, :title, {}, {id: 'exercise-select', class: 'form-control', multiple: true})
  .exercise-actions
    button.btn.btn-outline-primary type='button' data-toggle='modal' data-target='#add-exercise-modal' = t('exercise_collections.form.add_exercises')
    button.btn.btn-secondary#sort-button type='button' = t('exercise_collections.form.sort_by_title')

  .actions = render('shared/submit_button', f: f, object: @exercise_collection)

= render('shared/modal', id: 'add-exercise-modal', title: t('.add_exercises'), template: 'exercise_collections/_add_exercise_modal')
