{% extends 'generic/object.html' %}
{% load helpers %}
{% load plugins %}
{% load i18n %}

{% block content %}
  <div class="row mb-3">
    <div class="col col-12 col-md-6">
      <div class="card">
        <h2 class="card-header">{% trans "Event Rule" %}</h2>
        <table class="table table-hover attr-table">
          <tr>
            <th scope="row">{% trans "Name" %}</th>
            <td>{{ object.name }}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "Enabled" %}</th>
            <td>{% checkmark object.enabled %}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "Description" %}</th>
            <td>{{ object.description|placeholder }}</td>
          </tr>
        </table>
      </div>
      <div class="card">
        <h2 class="card-header">{% trans "Object Types" %}</h2>
        <table class="table table-hover attr-table">
          {% for object_type in object.object_types.all %}
            <tr>
              <td>{{ object_type }}</td>
            </tr>
          {% endfor %}
        </table>
      </div>
      <div class="card">
        <h2 class="card-header">{% trans "Event Types" %}</h2>
        <ul class="list-group list-group-flush">
          {% for name, event in registry.event_types.items %}
            <li class="list-group-item">
              <div class="row align-items-center">
                <div class="col-auto">
                  {% if name in object.event_types %}
                    {% checkmark True %}
                  {% else %}
                    {{ ''|placeholder }}
                  {% endif %}
                </div>
                <div class="col">
                  {{ event }}
                </div>
              </div>
            </li>
          {% endfor %}
        </ul>
      </div>
      {% plugin_left_page object %}
    </div>
    <div class="col col-12 col-md-6">
      <div class="card">
        <h2 class="card-header">{% trans "Conditions" %}</h2>
        <div class="card-body">
          {% if object.conditions %}
            <pre>{{ object.conditions|json }}</pre>
          {% else %}
            <p class="text-muted">{% trans "None" %}</p>
          {% endif %}
        </div>
      </div>
      <div class="card">
        <h2 class="card-header">{% trans "Action" %}</h2>
        <table class="table table-hover attr-table">
          <tr>
            <th scope="row">{% trans "Type" %}</th>
            <td>{{ object.get_action_type_display }}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "Object" %}</th>
            <td>
                {{ object.action_object|linkify }}
            </td>
          </tr>
          <tr>
            <th scope="row">{% trans "Data" %}</th>
            <td>
              {% if object.action_data %}
                <pre>{{ object.action_data|json }}</pre>
              {% else %}
                {{ ''|placeholder }}
              {% endif %}
            </td>
          </tr>
        </table>
      </div>
      {% include 'inc/panels/custom_fields.html' %}
      {% include 'inc/panels/tags.html' %}
      {% plugin_right_page object %}
    </div>
  </div>
  <div class="row">
    <div class="col col-md-12">
      {% plugin_full_width_page object %}
    </div>
  </div>
{% endblock %}
