{% extends 'dashboard/layout.html' %}
{% load category_tags %}
{% load i18n %}

{% block body_class %}catalogue{% endblock %}

{% block title %}
{% trans "Category management" %} | {{ block.super }}
{% endblock %}

{% block breadcrumbs %}
<ul class="breadcrumb">
    <li>
        <a href="{% url dashboard:index %}">{% trans "Dashboard" %}</a>
        <span class="divider">/</span>
    </li>
    <li class="active">{% trans "Categories" %}</li>
</ul>
{% endblock %}

{% block headertext %}
{% trans "Category management" %}
{% endblock %}

{% block dashboard_content %}
<div class="table-header">
    <h3><i class="icon-sitemap icon-large"></i>{% trans 'Create new category' %}</h3>
</div>
<div class="well">
    <p><a class="btn btn-large btn-primary" href="{% url dashboard:catalogue-category-create %}"><i class="icon-plus"></i> {% trans "New category" %}</a></p>
</div>


<div class="alert alert-info">
    <p>{% trans "You are editing:" %}
    <strong><a href="{% url dashboard:catalogue-category-list %}">Home</a></strong>
    {% if ancestors %}
    	&gt;
    	{% for ancestor in ancestors %}
            <strong><a href="{% url dashboard:catalogue-category-detail-list pk=ancestor.pk %}">{{ ancestor.name }}</a></strong>{% if not forloop.last %} > {% endif %}
    	{% endfor %}
    {% endif %}
    </p>
</div>

<table class="table table-striped table-bordered table-hover">
    <caption><i class="icon-sitemap icon-large"></i>{% trans 'Categories' %}</caption>
	<thead>
		<tr>
			<th>{% trans "Name" %}</th>
			<th>{% trans "Description" %}</th>
			<th>{% trans "Number of child categories" %}</th>
			<th></th>
		</tr>
	</thead>
	<tbody>
    {% for category in child_categories %}
        <tr>
            <td>{{ category.name }}</td>
			<td>{{ category.description|default:""|striptags|cut:"&nbsp;"|truncatewords:6 }}</td>
			<td>{{ category.get_num_children }}</td>
            <td>
                <div class="btn-toolbar">
                    <div class="btn-group">
                      <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
                        Actions
                        <span class="caret"></span>
                      </a>
                      <ul class="nav dropdown-menu pull-right">
                         <li><a href="{% url dashboard:catalogue-category-update category.id %}">{% trans "Edit category" %}</a></li>
          				 <li class="{% if not category.has_children %}disabled{% endif %}"><a href="{% url dashboard:catalogue-category-detail-list pk=category.pk %}">{% trans "Edit children" %}</a></li>
          				  <li><a href="{{ category.get_absolute_url }}">{% trans "View on site" %}</a></li>
          				  <li><a href="{% url dashboard:catalogue-category-delete category.id %}">{% trans "Delete" %}</a></li>
                      </ul>
                    </div>
                </div>
            </td>
        </tr>
    {% endfor %}
	</tbody>
</table>



{% endblock dashboard_content %}
