base_history.html.twig 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. {#
  2. This file is part of the Sonata package.
  3. (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  4. For the full copyright and license information, please view the LICENSE
  5. file that was distributed with this source code.
  6. #}
  7. {% extends base_template %}
  8. {%- block actions -%}
  9. {% include 'SonataAdminBundle:CRUD:action_buttons.html.twig' %}
  10. {%- endblock -%}
  11. {% block content %}
  12. <div class="row">
  13. <div class="col-md-5">
  14. <div class="box box-primary">
  15. <div class="box-body table-responsive no-padding">
  16. <table class="table" id="revisions">
  17. <thead>
  18. <tr>
  19. <th>{{ 'td_revision'|trans({}, 'SonataAdminBundle') }}</th>
  20. <th>{{ 'td_timestamp'|trans({}, 'SonataAdminBundle') }}</th>
  21. <th>{{ 'td_username'|trans({}, 'SonataAdminBundle') }}</th>
  22. <th>{{ 'td_action'|trans({}, 'SonataAdminBundle') }}</th>
  23. <th>{{ 'td_compare'|trans({}, 'SonataAdminBundle') }}</th>
  24. </tr>
  25. </thead>
  26. <tbody>
  27. {% for revision in revisions %}
  28. <tr class="{% if (currentRevision != false and revision.rev == currentRevision.rev) %}current-revision{% endif %}">
  29. <td>{{ revision.rev }}</td>
  30. <td>{% include admin.getTemplate('history_revision_timestamp') %}</td>
  31. <td>{{ revision.username|default('label_unknown_user'|trans({}, 'SonataAdminBundle')) }}</td>
  32. <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>
  33. <td>
  34. {% if (currentRevision == false or revision.rev == currentRevision.rev) %}
  35. /
  36. {% else %}
  37. <a href="{{ admin.generateObjectUrl('history_compare_revisions', object, {'base_revision': currentRevision.rev, 'compare_revision': revision.rev }) }}" class="revision-compare-link" rel="{{ revision.rev }}">{{ 'label_compare_revision'|trans({}, 'SonataAdminBundle') }}</a>
  38. {% endif %}
  39. </td>
  40. </tr>
  41. {% endfor %}
  42. </tbody>
  43. </table>
  44. </div>
  45. </div>
  46. </div>
  47. <div id="revision-detail" class="col-md-7 revision-detail">
  48. </div>
  49. </div>
  50. <script>
  51. jQuery(document).ready(function() {
  52. jQuery('a.revision-link, a.revision-compare-link').bind('click', function(event) {
  53. event.stopPropagation();
  54. event.preventDefault();
  55. action = jQuery(this).hasClass('revision-link')
  56. ? 'show'
  57. : 'compare';
  58. jQuery('#revision-detail').html('');
  59. if(action == 'show'){
  60. jQuery('table#revisions tbody tr').removeClass('current');
  61. jQuery(this).parent('').removeClass('current');
  62. }
  63. jQuery.ajax({
  64. url: jQuery(this).attr('href'),
  65. dataType: 'html',
  66. success: function(data) {
  67. jQuery('#revision-detail').html(data);
  68. }
  69. });
  70. return false;
  71. });
  72. });
  73. </script>
  74. {% endblock %}