<fieldset>
  <legend style="margin-bottom: -10px;">
    <%= model.class.human_attribute_name(:contents) %> <abbr title="obrigatório">*</abbr>
  </legend>
  <div class="alert alert-danger"
       id="lesson_plan_copy_from_teaching_plan_alert"
       style="display: none;"
  >
    <i class="fa-fw fa fa-times"></i>
    Não foi possível copiar do(a) <%= Translator.t('navigation.teaching_plans_menu').downcase %>
    pois não existem registros para a data informada.
  </div>

  <% if f.object.errors[:contents].any? %>
    <div class="alert alert-danger fade in">
      <i class="fa-fw fa fa-times"></i>
      <%= f.object.errors[:contents].first %>
    </div>
  <% end %>

  <% if action_name != 'show' %>
    <a href="#" id="copy-from-teaching-plan-link">
      Copiar de <%= Translator.t('navigation.teaching_plans_menu').downcase %>
    </a>
  <% end %>

  <div class="well" style="max-height: 300px;overflow-y: auto; margin-top: 10px;">
    <ul class="list-group checked-list-box" id="contents-list">

      <% contents.each do |content| %>
        <li class="list-group-item manual" style="display: flex;" id="lesson_plan_<%= content.id %>">
          <%= check_box_tag("#{model.class.model_name.singular}[lesson_plan_attributes][content_ids][]",
              content.id, content.id.in?(model.contents.collect(&:id)),
              hidden: true, 'data-content_description': content.to_s ) %>
          <span style="margin-left: 5px;display: block;width: calc(100% - 85px);"><%= content %></span>
          <% if content.is_editable && action_name != 'show' %>
            <div style="width: 80px;">
              <a class="btn new-btn-success" onclick="editContent('lesson_plan_<%= content.id %>')">
                <i class="fa fa-pencil"></i>
              </a>
              <a class="btn new-btn-danger" onclick="removeContent('lesson_plan_<%= content.id %>')">
                <i class="fa fa-trash"></i>
              </a>
            </div>
          <% end %>
        </li>
      <% end %>
    </ul>
  </div>

  <% if action_name != 'show' %>
    <div class="row textarea">
      <div class="col col-sm-12 contents-select2-container">
        <% translation = Translator.t("activerecord.attributes.#{model.class.to_s.underscore}.contents") %>
        <%= f.input :contents_tags,
            as: :string,
            label: "Adicionar #{translation}",
            input_html: {
              'data-content-type': 'conteúdo',
              class: 'select2-tags',
              value: ''
            }
        %>
      </div>
    </div>
  <% end %>
</fieldset>

<% unless f.object.decorator.removed_objectives? %>
  <fieldset>
    <legend style="margin-bottom: -10px;">
      <%= model.class.human_attribute_name(:objectives) %>
    </legend>

    <div class="alert alert-danger"
         id="lesson_plan_copy_from_objectives_teaching_plan_alert"
         style="display: none;"
    >
      <i class="fa-fw fa fa-times"></i>
      Não foi possível copiar do(a) <%= Translator.t('navigation.teaching_plans_menu').downcase %>
      pois não existem registros para a data informada.
    </div>

    <% if f.object.errors[:objectives].any? %>
      <div class="alert alert-danger fade in">
        <i class="fa-fw fa fa-times"></i>
        <%= f.object.errors[:objectives].first %>
      </div>
    <% end %>

    <% if action_name != 'show' %>
      <a href="#" id="copy-from-objectives-teaching-plan-link">
        Copiar de <%= Translator.t('navigation.teaching_plans_menu').downcase %>
      </a>|
      <a href="#" data-toggle="modal" data-target="<%= modal_id %>">
        Copiar objetivos/habilidades por área
      </a>
      <% if @allows_copy_experience_fields_in_lesson_plans %>
        |<a href="#" data-toggle="modal" data-target="#experience-modal">
          Copiar objetivos por campos de experiência
        </a>
      <% end %>
    <% end %>

    <div class="well" style="max-height: 300px;overflow-y: auto; margin-top: 10px;">
      <ul class="list-group checked-list-box" id="objectives-list">

        <% objectives.each do |objective| %>
          <li class="list-group-item manual" style="display: flex;" id="lesson_plan_<%= objective.id %>">
            <%= check_box_tag("#{model.class.model_name.singular}[lesson_plan_attributes][objective_ids][]",
                              objective.id, objective.id.in?(model.objectives.collect(&:id)),
                              hidden: true, 'data-objective_description': objective.to_s ) %>
            <span style="margin-left: 5px;display: block;width: calc(100% - 85px);"><%= objective %></span>
            <% if objective.is_editable && action_name != 'show' %>
              <div style="width: 80px;">
                <a class="btn new-btn-success" onclick="editObjective('lesson_plan_<%= objective.id %>')">
                  <i class="fa fa-pencil"></i>
                </a>
                <a class="btn new-btn-danger" onclick="removeObjective('lesson_plan_<%= objective.id %>')">
                  <i class="fa fa-trash"></i>
                </a>
              </div>
            <% end %>
          </li>
        <% end %>
      </ul>
    </div>
    <% if action_name != 'show' %>
      <div class="row textarea">
        <div class="col col-sm-12 objectives-select2-container">
          <% translation = Translator.t("activerecord.attributes.#{model.class.to_s.underscore}.objectives") %>
          <%= f.input :objectives_tags,
                      as: :string,
                      label: "Adicionar #{translation}",
                      input_html: {
                        class: 'select2-content-tags-ajax',
                        value: '',
                        data: {
                          url: contents_path,
                          data: []
                        }
                      }
          %>
        </div>
      </div>
    <% end %>
  </fieldset>
<% end %>
<fieldset>

<% key_prefix = @discipline_lesson_plan.present? ? 'discipline' : 'knowledge_area' %>

<% @methodology_translation = Translation.find_by(key: "navigation.actives_methodology_by_#{key_prefix}", group: 'lesson_plans')&.translation %>
<% @resources_translation = Translation.find_by(key: "navigation.resources_by_#{key_prefix}", group: 'lesson_plans')&.translation %>
<% @evaluation_translation = Translation.find_by(key: "navigation.avaliation_by_#{key_prefix}", group: 'lesson_plans')&.translation %>
<% @references_translation = Translation.find_by(key: "navigation.references_by_#{key_prefix}", group: 'lesson_plans')&.translation %>
<% @curriculum_adaptation = Translation.find_by(key: "navigation.curriculum_adaptation_by_#{key_prefix}", group: 'lesson_plans')&.translation %>

<div class="row textarea">
  <div class="col col-sm-12">
    <%= f.input :activities, label: @methodology_translation, input_html: { class: 'col col-sm-12 summernote-field', data: { disabled: action_name.eql?('show') }} %>
  </div>
</div>

<div class="row textarea">
  <div class="col col-sm-12">
    <%= f.input :resources, label: @resources_translation, input_html: { class: 'col col-sm-12 summernote-field', data: { disabled: action_name.eql?('show') }} %>
  </div>
</div>

<div class="row textarea">
  <div class="col col-sm-12">
    <%= f.input :evaluation, label: @evaluation_translation, input_html: { class: 'col col-sm-12 summernote-field', data: { disabled: action_name.eql?('show') }} %>
  </div>
</div>

<div class="row textarea">
  <div class="col col-sm-12">
    <%= f.input :bibliography, label: @references_translation, input_html: { class: 'col col-sm-12 summernote-field', data: { disabled: action_name.eql?('show') }} %>
  </div>
</div>

<div class="row textarea">
  <div class="col col-sm-12">
    <%= f.input :curriculum_adaptation, label: @curriculum_adaptation, input_html: { class: 'col col-sm-12 summernote-field', data: { disabled: action_name.eql?('show') }} %>
  </div>
</div>

<div class="row textarea">
  <div class="col col-sm-12">
    <legend>Anexos</legend>
    <div class="alert alert-info fade in">
      <i class="fa-fw fa fa-info"></i>
      Somente arquivos nos formatos jpeg, jpg, png, gif, pdf, odt, doc, docx, ods, xls, xlsx, odp, ppt, pptx, odg, xml, csv. Tamanho máximo por arquivo: 3MB
    </div>
    <br>
    <% if f.object.errors[:lesson_plan_attachments].present? %>
      <div class="alert alert-danger alert-block ">
        <i class="fa-fw fa fa-times"></i>
        <span class="help-inline">
          <%= f.object.errors[:lesson_plan_attachments].join "<br />" %>
        </span>
      </div>
    <% end %>
    <table class="table table-striped table-bordered table-condensed records">
      <thead>
        <tr>
          <th scope="col">Anexo</th>
          <% if action_name != 'show' %>
            <th scope="col" style="width: 73px"></th>
          <% end %>
        </tr>
      </thead>

      <tbody id="lesson-plan-attachments">
        <% if action_name == 'show' && f.object.lesson_plan_attachments.blank? %>
          <tr class="nested-fields">
            <td><span>Nenhum documento anexado</span></td>
          </tr>
        <% else %>
          <%= f.simple_fields_for :lesson_plan_attachments, f.object.lesson_plan_attachments do |attachment| %>
            <% if attachment.object.persisted? %>
              <%= render 'lesson_plan_attachment_show', f: attachment %>
            <% else %>
              <%= render 'lesson_plan_attachment_fields', f: attachment %>
            <% end %>
          <% end %>
        <% end %>
      </tbody>
      <% if action_name != 'show'%>
        <tfoot class="links">
          <tr>
            <td colspan="2">
              <%= link_to_add_association t('.add_attachment'), f, :lesson_plan_attachments,
                class: 'btn btn-success btn-sm',
                :"data-association-insertion-method" => "append",
                :"data-association-insertion-node" => "#lesson-plan-attachments" %>
            </td>
          </tr>
        </tfoot>
      <% end %>
    </table>
  </div>
</div>

</fieldset>
