{#
 # Display Column Header
 #
 # Parameters:
 #   admin_list: AdminList object
 #   column:     ColumnConfiguration object
 #   route:      Route to use, else current route is used
 #   
 #}  

{% if column.Sortable %}
    {% set base_params = admin_list.getParams() %}
    {% set current_page = admin_list.getCurrentPage() %}
    {% if column.Field == admin_list.OrderField %}
        {% set order_direction = (admin_list.OrderDir == 'ASC') ? 'DESC' : 'ASC' %}
    {% else %}
        {% set order_direction = 'ASC' %}
    {% endif %}
{% endif %}


{% if column.Sortable %}
    {% set header_class = column.HeaderClass ~ ' sortable' %}
    {% if column.Field == admin_list.OrderField %}
        {% set header_class = header_class ~ ' sort' %}
        {% if admin_list.OrderDir == 'ASC' %}
            {% set header_class = header_class ~ ' sort-asc' %}
        {% elseif admin_list.OrderDir == 'DESC' %}
            {% set header_class = header_class ~ ' sort-desc' %}
        {% endif %}
    {% endif %}
{% else %}
    {% set header_class = column.HeaderClass %}
{% endif %}


<th class="{{header_class|trim}}">
    {% block container %}
        {% if column.Sortable %}
            <a href="{{ path(route, base_params|merge({ page: current_page, orderDir : order_direction, orderBy : column.Field }) ) }}">
                {{ column.Title }}
                <i class="icon-arrow-up"></i>
                <i class="icon-arrow-down"></i>
            </a>
        {%else%}
            {{ column.Title }}   
        {%endif%}
    {% endblock container %}
</th>
