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

{% from "components/pagination.html" import Pagination %}
{% from "components/text_input.html" import TextInput %}
{% from 'components/save_button.html' import SaveButton %}

{% set secondary_breadcrumb = "navigation.portfolio_navigation.portfolio_admin" | translate %}

{% block portfolio_content %}

  <div v-cloak class="portfolio-admin portfolio-content">

    <div class="panel">
      <div class="panel__content">

        {% if user_can(permissions.VIEW_PORTFOLIO_NAME) %}
        <base-form inline-template>
          <form method="POST" action="{{ url_for('portfolios.edit', portfolio_id=portfolio.id) }}" autocomplete="false">
            {{ portfolio_form.csrf_token }}
            <div class='form-row'>
              <div class='form-col form-col--half'>
                {{ TextInput(portfolio_form.name, validation="portfolioName") }}
              </div>

                <div class='edit-portfolio-name action-group'>
                  {{ SaveButton(text='Save', additional_classes='usa-button-big') }}
                </div>
              </div>
                <div class='defense-row'>
                  <div>
                    <div class='admin-title'>{{ "forms.task_order.defense_component_label" | translate }}</div>
                    {% if portfolio.defense_component %}
                      <div class='admin-content'>{{ portfolio.defense_component }}</div>
                    {% else %}
                      <div class='admin-content'>{{ "fragments.portfolio_admin.none" | translate }}</div>
                    {% endif %}
                  </div>
                </div>
            </form>
          </base-form>
        {% endif %}
      </div>
    </div>

    {% if user_can(permissions.VIEW_PORTFOLIO_POC) %}
      {% include "fragments/primary_point_of_contact.html" %}
    {% endif %}

    {% if user_can(permissions.VIEW_PORTFOLIO_USERS) %}
      {% include "fragments/admin/portfolio_members.html" %}
    {% endif %}

    {% if user_can(permissions.VIEW_PORTFOLIO_ACTIVITY_LOG) %}
      {% include "fragments/audit_events_log.html" %}
      {{ Pagination(audit_events, 'portfolios.admin', portfolio_id=portfolio.id) }}
    {% endif %}
  </div>
{% endblock %}
