{% from "modifications/form.html" import modifications_add_form %}


{% macro pane_details(modification, form) %}

  <li>

  <span class="date">
    <b>{{ modification.user.username }}</b>
  </span>
  <span class="float-right">
    <b>{{ modification.date }}</b>
    &nbsp;
    {% if modification.user_id == current_user.id %}
    <a class="text-primary"
       data-toggle="modal"
       data-target="#modal-edit-modification-{{ modification.id }}">
      <i class="fa-solid fa-pen"></i>
    </a>
    {% endif %}
    &nbsp;
    <a class="text-danger"
       onclick="delete_entity('{{ url_for("flystocks.modifications.delete", id=modification.id, flystock_id=modification.fly_id) }}')">
      <i class="fa-solid fa-trash"></i>
      </a>
  </span>

  <hr style="margin: 3px 0px;">

  <p class="info" style="font-size: unset;">
    {{ modification.description }}
  </p>

  </li>

  {{ modifications_add_form(form(None, obj=modification), "flystocks.modifications.edit", "PUT", modification.id, modification.fly_id) }}

{% endmacro %}


{% macro modifications_pane(status, pane_id, flystock, form) %}
  <div class="tab-pane container {{ status }}" id="{{ pane_id }}">

    <div class="text-right">
    <button
        type="button"
        class="btn btn-success btn-sm"
        data-toggle="modal"
        data-target="#modal-edit-modification--1">
      <i class="fa-solid fa-plus"></i>
    </button>
  </div>

    <br>

    <ul class="ul-complex-attribute">
      {% for modification in flystock.modifications %}
        {{ pane_details(modification, form) }}
      {% endfor %}
    </ul>

  {{ modifications_add_form(form(), "flystocks.modifications.add", "POST", -1, flystock.id) }}

  </div>
{% endmacro %}
