{% extends 'base/two.column.8-4.html.twig' %}

{% set title = 'My Snips' %}

{% block column1 %}
    <h3>Snips</h3>
    <a class="btn btn-success" href="{{ path('snip_new') }}">
        <i class="fa fa-plus"></i> Add
    </a>

    <br><br>
    <div class="list-group">
        {% for snip in snips %}
            <a class="list-group-item list-group-item-action d-flex justify-content-between" href="{{ path('snip_single', {snip: snip.id}) }}">
                <span>
                    {{ snip }}
                </span>
                <span>
                    {% for tag in snip.tags %}
                        <span class="badge bg-{% if tag.name is same as(request.tag) %}primary{% else %}secondary{% endif %}">{{ tag }}</span>
                    {% endfor %}
                    {{ include('snip/badge.html.twig', {snip: snip}) }}
                </span>
            </a>
        {% endfor %}
    </div>
{% endblock %}

{% block column2 %}
    <h3>Filters</h3>
    <div class="list-group">
        <a href="{{ path('snip_index', {'reset': 1}) }}"
           class="list-group-item list-group-item-action">
            <i class="fa fa-refresh"></i> Reset
        </a>
    </div>

    <br>
    <h5>Sort by</h5>
    <div class="list-group">
        {% for sortOption in snipSortOptions() %}
            <a href="{{ path('snip_index', {sort: sortOption}) }}"
               class="list-group-item list-group-item-action {% if sortOption is same as(request.sort) %}list-group-item-primary{% endif %}">
                {{ sortOption|capitalize }}
            </a>
        {% endfor %}
    </div>

    <br>
    <h5>Visibility</h5>
    <div class="list-group">
        {% for visibilityOption in snipFilterOptions() %}
            <a href="{{ path('snip_index', {visibility: visibilityOption}) }}"
               class="list-group-item list-group-item-action {% if request.visibility is same as(visibilityOption) %}list-group-item-primary{% endif %}">
                Show {{ visibilityOption|capitalize }}
            </a>
        {% endfor %}
    </div>

    <br>
    <h5>Tags</h5>
    <div class="list-group">
        {% for key,tagOption in snipTagOptions() %}
            <a href="{{ path('snip_index', {tag: key}) }}"
               class="list-group-item list-group-item-action {% if request.tag is same as(key) %}list-group-item-primary{% endif %}">
                {{ tagOption|capitalize }}
            </a>
        {% endfor %}
    </div>
{% endblock %}