{% extends 'layouts/base.html' %}
{% load static %}
{% load i18n %}

{% block content %}
  {% include 'header.html' %}
  <main id="main-content">
    <section>
      <div class="form-view">
        {% if failure_mode_exist %}
          <h1>{% translate 'Define which objects are affected for a failure mode' %}</h1>
          <form action="{% if editing_view %}{% url 'fmea_failure_mode_affected_object_update' id %}{% else %}{% url 'fmea_failure_mode_affected_object_create' %}{% endif %}"  
          method="post" 
          class="horizontal-view help">
            {% csrf_token %}
            {% translate 'Failure mode affected objects' as fieldset_legend %}
            {% include 'partials/form/fieldset.html' with legend=fieldset_legend fieldset='failure_mode affected_department affected_ooi_type' fields=form  %}
            {% if editing_view %}
                <button class="cta" type="submit">{% translate 'Save' %}</button>
            {% else %}
                <button type="submit">{% translate 'Submit' %}</button>
            {% endif %}
          </form>
        {% else %}
          <p>{% translate 'No failure mode yet defined.' %}</p>
          <p>{% translate 'To add affected objects to a failure mode, first create one.' %}</p>
          <a class="button" href="{% url 'fmea_failure_mode_create' %}">{% translate 'Create failure mode' %}</a>
        {% endif %}
      </div>
    </section>
  </main>
{% endblock %}
