{% from "components/icon.html" import Icon %}
{% from "components/text_input.html" import TextInput %}
{% from "components/multi_step_modal_form.html" import MultiStepModalForm %}
{% from "components/alert.html" import Alert %}
{% from "components/options_input.html" import OptionsInput %}

{% set step_one %}
  <hr>
  <h1>{{ "fragments.ppoc.update_ppoc_title" | translate }}</h1>

  {{
    Alert(
      level="warning",
      title=("fragments.ppoc.alert.title" | translate),
      message=("fragments.ppoc.alert.message" | translate),
    )
  }}

  <div class='form-row'>
    <div class='form-col form-col--half'>
      {{
        OptionsInput(
          assign_ppoc_form.role_id,
          optional=False
        )
      }}
    </div>
    <div class='form-col form-col--half'>
    </div>
  </div>
  <div class='action-group'>
    <input
        type='button'
        v-on:click="next()"
        v-bind:disabled="!canSave"
        class='action-group__action usa-button'
        value='{{ "fragments.ppoc.assign_user_button_text" | translate }}'>
    <a class='action-group__action icon-link icon-link--default' v-on:click="closeModal('change-ppoc-form')">
      {{ "common.cancel" | translate }}
    </a>
  </div>
{% endset %}

{% set step_two %}
  <hr>
  <h1>{{ "fragments.ppoc.update_ppoc_confirmation_title" | translate }}</h1>

  {{
    Alert(
      level="info",
      title=("fragments.ppoc.confirm_alert.title" | translate),
    )
  }}

  <div class='action-group'>
    <input
      type="submit"
      class='action-group__action usa-button'
      form="change-ppoc-form"
      value='{{ "common.confirm" | translate }}'>
    <a class='action-group__action icon-link icon-link--default' v-on:click="closeModal('change-ppoc-form')">
      {{ "common.cancel" | translate }}
    </a>
  </div>
{% endset %}

<div class="flex-reverse-row">
  {% set disable_ppoc_button = 1 == portfolio.members |length %}
  <button type="button" class="usa-button usa-button-primary" v-on:click="openModal('change-ppoc-form')" {% if disable_ppoc_button %}disabled{% endif %}>
    {{ "fragments.ppoc.update_btn" | translate }}
  </button>
  {{
    MultiStepModalForm(
      'change-ppoc-form',
      assign_ppoc_form,
      form_action=url_for("portfolios.update_ppoc", portfolio_id=portfolio.id),
      steps=[step_one, step_two],
    )
  }}
</div>
