{% extends "misago/admin/generic/list.html" %}
{% load i18n %}


{% block page-actions %}
<div class="col-auto page-action">
  <a href="{% url 'misago:admin:themes:import' %}" class="btn btn-primary btn-sm">
    <span class="fa fa-upload"></span>
    {% trans "Import theme" %}
  </a>
</div>
<div class="col-auto page-action">
  <a href="{% url 'misago:admin:themes:new' %}" class="btn btn-primary btn-sm">
    <span class="fa fa-plus-circle"></span>
    {% trans "Create theme" %}
  </a>
</div>
{% endblock %}


{% block table-header %}
<th>{% trans "Theme" %}</th>
<th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th>
{% endblock table-header %}


{% block table-row %}
<td class="pr-0">
  {% if item.is_default %}
    <span class="item-name small">
      {{ item }}
    </span>
  {% else %}
    {% for i in item.level_range %}
      &nbsp;&nbsp;&nbsp;&nbsp;
    {% endfor %}
    <a href="{% url 'misago:admin:themes:edit' pk=item.pk %}" class="item-name small">
      {{ item }}
    </a>
    {% if item.version %}
      <span class="text-muted  small">
        {{ item.version }}
      </span>
    {% endif %}
  {% endif %}
</td>
<td class="badges-list">
  {% if item.is_active %}
    <span class="badge badge-success">
      {% trans "Active" %}
    </span>
  {% endif %}
</td>
<td>
  <div class="dropdown">
    <button class="btn btn-light btn-sm dropdown-toggle" type="button" id="item-optioms-{{ item.pk }}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      <i class="fas fa-ellipsis-h"></i>
    </button>
    <div class="dropdown-menu dropdown-menu-right" aria-labelledby="item-optioms-{{ item.pk }}">
      {% if not item.is_default %}
        <a class="dropdown-item" href="{% url 'misago:admin:themes:assets' pk=item.pk %}">
          {% trans "Edit assets" %}
        </a>
      {% endif %}
      {% if not item.is_default %}
        <a class="dropdown-item" href="{% url 'misago:admin:themes:edit' pk=item.pk %}">
          {% trans "Edit information" %}
        </a>
      {% endif %}
      <a class="dropdown-item" href="{% url 'misago:admin:themes:new' %}?parent={{ item.pk }}">
        {% trans "Create child theme" %}
      </a>
      {% if not item.is_active %}
        <form action="{% url 'misago:admin:themes:activate' pk=item.pk %}" method="post">
          {% csrf_token %}
          <button class="dropdown-item">
            {% trans "Set as active" %}
          </button>
        </form>
      {% endif %}
      {% if not item.is_default %}
        <form action="{% url 'misago:admin:themes:export' pk=item.pk %}" method="post">
          {% csrf_token %}
          <button class="dropdown-item">
            {% trans "Export theme" %}
          </button>
        </form>
      {% endif %}
      {% if not item.is_active and not item.is_default %}
        <form action="{% url 'misago:admin:themes:delete' pk=item.pk %}" method="post" data-delete-confirmation="true">
          {% csrf_token %}
          <button class="dropdown-item">
            {% trans "Delete theme" %}
          </button>
        </form>
      {% endif %}
    </div>
  </div>
</td>
{% endblock %}


{% block javascripts %}
{{ block.super }}
<script type="text/javascript">
  window.misago.initConfirmation(
    "[data-delete-confirmation]",
    "{% trans 'Are you sure you want to delete this theme? Deleting theme will also delete its child themes.' %}"
  )
</script>
{% endblock %}