{#

This file is part of the Sonata package.

(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.

#}

{% extends base_template %}

{% block actions %}
    <li>{% include 'SonataAdminBundle:Button:edit_button.html.twig' %}</li>
    <li>{% include 'SonataAdminBundle:Button:acl_button.html.twig' %}</li>
    <li>{% include 'SonataAdminBundle:Button:show_button.html.twig' %}</li>
    <li>{% include 'SonataAdminBundle:Button:list_button.html.twig' %}</li>
{% endblock %}

{% block content %}

    <div class="col-md-5">
        <table class="table" id="revisions">
            <thead>
                <tr>
                    <th>{{ "td_revision"|trans({}, 'SonataAdminBundle') }}</th>
                    <th>{{ "td_timestamp"|trans({}, 'SonataAdminBundle') }}</th>
                    <th>{{ "td_username"|trans({}, 'SonataAdminBundle') }}</th>
                    <th>{{ "td_action"|trans({}, 'SonataAdminBundle') }}</th>
                </tr>
            </thead>
            <tbody>
                {% for revision in revisions %}
                    <tr>
                        <td>{{ revision.rev}}</td>
                        <td>{% include admin.getTemplate('history_revision_timestamp') %}</td>
                        <td>{{ revision.username}}</td>
                        <td><a href="{{ admin.generateObjectUrl('history_view_revision', object, {'revision': revision.rev }) }}" class="revision-link" rel="{{ revision.rev }}">{{ "label_view_revision"|trans({}, 'SonataAdminBundle') }}</a></td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    <div id="revision-detail" class="col-md-7 revision-detail">

    </div>

    <script>
        jQuery(document).ready(function() {

            jQuery('a.revision-link').bind('click', function(event) {
                event.stopPropagation();
                event.preventDefault();

                jQuery('#revision-detail').html('');
                jQuery('table#revisions tbody tr').removeClass('current');
                jQuery(this).parent('').removeClass('current');

                jQuery.ajax({
                    url: jQuery(this).attr('href'),
                    dataType: 'html',
                    success: function(data) {
                        jQuery('#revision-detail').html(data);
                    }
                });

                return false;
            })
        });
    </script>
{% endblock %}
