{% extends "SsoBackendBundle:token:base.html.twig" %}

{% block title %}Attributes{% endblock %}

{% block body %}
    <div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h2>Do you really want to delete this Attribute?</h2>
                </div>
                <div class="modal-body">
                    <p>You are about to delete one attribute, this procedure is irreversible.</p>
                    <p style="color:red;">ALL OBJECT VALUES WITH THIS ATTRIBUTE ARE DELETED, TOO!</p>
                    <p>Do you want to proceed?</p>
                    <p>We hope that you know what you do!</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                    <a href="#" class="btn btn-danger danger">Delete</a>
                </div>
            </div>
        </div>
    </div>

    <h2>Attributes</h2>
    <div class="row">
        <div class="col-md-12 col-ld-12">
            <a class="btn btn-primary dropdown-toggle" data-toggle="collapse" data-target="#filters">
                show filter
                <span class="caret"></span>
            </a>
        </div>
        <div class="col-md-12 col-ld-12">
            <div id="filters" class="collapse">
                <form class="well" method="get" action="">
                    {{ form_rest(form) }}
                    <p>
                        <button class="btn btn-primary" type="submit" name="filter_action"
                                value="filter">{% trans %}btn.filter{% endtrans %}</button>
                        <button id="reset" class="btn btn-danger" type="submit" name="filter_action"
                                value="reset">{% trans %}btn.reset{% endtrans %}</button>
                    </p>
                </form>
            </div>
        </div>
    </div>
    <hr/>

    <div class="row">
        <div class="col-md-12 col-ld-12">
            <div style="font-size: 20px;margin-bottom: 20px;" class="pull-right">
                <span class="label label-success label-as-badge">count: {{ pagination.getTotalItemCount }}</span>
            </div>
            <table class="table table-striped table-bordered table-condensed">
                <thead>
                <tr>
                    <th>Id</th>
                    <th>Attribute Group</th>
                    <th {% if pagination.isSorted('a.name') %} class="sorted"{% endif %}>{{ knp_pagination_sortable(pagination, 'Name', 'a.name') }}</th>
                    <th>Actions</th>
                </tr>
                </thead>
                <tbody>
                {% for entity in pagination %}
                    <tr>
                        <td class="infinitely-tooltip">
                            <span class="cutstring">{{ entity.id }}</span>
                        </td>
                        <td class="infinitely-tooltip">
                            {{ entity.attributeGroup.name }}
                        </td>
                        <td class="infinitely-tooltip">
                            {{ entity.name }}
                        </td>

                        <td>
                            <a class="btn btn-success btn-mini"
                               href="{{ path('_admin_backend_webservice_attributes_show', { 'attributeId': entity.id }) }}">
                                show
                            </a>&nbsp;
                            <a class="btn btn-danger"
                               href="{{ path('_admin_backend_webservice_attributes_edit', { 'attributeId': entity.id }) }}">
                                edit
                            </a>
                            <a class="btn btn-danger" data-toggle="modal" data-target="#confirm-delete"
                               data-href="{{ path('_admin_backend_webservice_attributes_delete', { 'attributeId': entity.id}) }}"
                               href="#">
                                Delete Attribute
                            </a>
                        </td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>

        <div class="col-md-12 col-ld-12">
            <div class="navigation">
                {{ knp_pagination_render(pagination) }}
            </div>
        </div>

        <div class="col-md-6 col-ld-6">
            <a class="btn btn-primary likepaginator" href="{{ path('_admin_backend_webservice_attributes_new') }}">
                new attribute
            </a>
        </div>

    </div>

    <script>
        $(function () {
            $(".tt").tooltip();
        });
        $('#confirm-delete').on('show.bs.modal', function (e) {
            $(this).find('.danger').attr('href', $(e.relatedTarget).data('href'));
        });
    </script>
{% endblock %}
