{% extends "portfolios/base.html" %}

{% from "components/sticky_cta.html" import StickyCTA %}
{% from "components/modal.html" import Modal %}

{% block portfolio_content %}
  <to-form inline-template {% if form.clins %}v-bind:initial-clin-count="{{ form.clins.data | length }}"{% endif %} :enable-save="true">
    <form id="to_form" action='{{ action }}' method="POST" autocomplete="off" enctype="multipart/form-data">
      {{ form.csrf_token }}

      {% call StickyCTA(text=('task_orders.form.sticky_header_text' | translate({"step": step}) )) %}
        <span class="action-group">
          {% block next_button %}
            <input
              type="submit"
              tabindex="0"
              :disabled="!canSave"
              value="{{ next_button_text }}"
              form="to_form"
              class="usa-button usa-button-primary">
          {% endblock %}

          {% if step != "1" %}
            <a class="usa-button usa-button-secondary" href="{{ previous_button_link }}">
              Previous
            </a>
          {% endif %}

          <a
            v-on:click="openModal('cancel')"
            class="action-group__action icon-link">
            {{ "common.cancel" | translate }}
          </a>
        </span>
      {% endcall %}

      {% call Modal(name='cancel', dismissable=True) %}
        <div class="task-order__modal-cancel">
          <h1>Do you want to save this draft?</h1>
          <div class="action-group">
            <button formaction="{{ cancel_discard_url }}" class="usa-button usa-button-primary" type="submit">No, delete it</button>
            <button formaction="{{ cancel_save_url }}" class="usa-button usa-button-primary" type="submit">Yes, save for later</button>
          </div>
        </div>
      {% endcall %}

      {% include "fragments/flash.html" %}

      <div class="task-order">
        {% block to_builder_form_field %}{% endblock %}
      </div>

    </form>
  </to-form>
{% endblock %}
