{% extends "brillixy/base.html" %}
{% load brillixytags admin_urls admin_list i18n %}
{% load url from future %}

{% block extrastyle %}
    <link href="{{ STATIC_URL }}brillixy/css/changelist.css" rel="stylesheet" type="text/css" />
{% endblock %}

{% block extrahead %}
    <script type="text/javascript">
        $(function() {
            $('#action-toggle').change(function(e) {
                var checked = $(this).prop('checked');
                $('td.action-checkbox input[type=checkbox]').prop('checked', checked);
            });
        });
    </script>
{% endblock %}

{% block content_title %}{% endblock %}

{% block content %}
    <!-- Errors -->
    {% if cl.formset.errors %}
        <div class="alert alert-danger">
            {% blocktrans count cl.formset.errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
        
            {{ cl.formset.non_form_errors }}
        </div>
    {% endif %}

    <div class="row">
        {% block filters %}
            {% if cl.has_filters or cl.search_fields %}
            <div class="span3">
                <!-- Search -->
                {% if cl.search_fields %}
                <div id="changelist-search" class="well well-condensed">
                    <h2>{% trans 'Search' %}</h2>
                    {% block search %}{% search_form cl %}{% endblock %}
                    {% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %}
                </div>
                {% endif %}

                <!-- Filters -->
                {% if cl.has_filters %}
                <div id="changelist-filter" class="well well-condensed">
                    <h2>{% trans 'Filter' %} {% if cl.params %}<small><a href="?" class="btn">{% trans 'reset' %}</a></small>{% endif %}</h2>
                    {% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}
                </div>
                {% endif %}
            </div>
            {% endif %}
        {% endblock %}

        {% block result_list %}
        <div class="{% if cl.has_filters or cl.search_fields %}span9{% else %}span12{% endif %}">
            <form id="changelist-form" class="form-horizontal" action="" method="post"{% if cl.formset.is_multipart %} enctype="multipart/form-data"{% endif %}>

                <!-- Hidden data -->                
                {% csrf_token %}
                {% if cl.formset %}
                    <div style="display:none;">{{ cl.formset.management_form }}</div>
                {% endif %}

                <!-- Actions -->
                <div id="changelist-actions">
                    {% block object-tools %}
                        {% if has_add_permission %}
                        <span>
                            <a href="{% url cl.opts|admin_urlname:'add' %}{% if is_popup %}?_popup=1{% endif %}" class="btn btn-primary addlink">
                                <i class="icon-file"></i>
                                {% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}
                            </a>
                        </span>
                        {% endif %}

                        {% if action_form and actions_on_top and cl.full_result_count %}{% admin_actions %}{% endif %}
                    {% endblock %}
                </div>

            <!-- Objects -->
            {% result_list cl %}

            <!-- Pagination -->
            {% block pagination %}{% pagination cl %}{% endblock %}
        </form>

        </div>
        {% endblock %}
    </div>
{% endblock %}
