block_admin_list.html.twig 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 sonata_block.templates.block_base %}
  8. {% block block %}
  9. {% for group in groups %}
  10. {% set display = (group.roles is empty or is_granted('ROLE_SUPER_ADMIN') ) %}
  11. {% for role in group.roles if not display %}
  12. {% set display = is_granted(role)%}
  13. {% endfor %}
  14. {% if display %}
  15. <div class="box">
  16. <div class="box-header">
  17. <h3 class="box-title">{{ group.label|trans({}, group.label_catalogue) }}</h3>
  18. </div>
  19. <div class="box-body">
  20. <table class="table table-hover">
  21. <tbody>
  22. {% for admin in group.items %}
  23. {% if admin.hasRoute('create') and admin.isGranted('CREATE') or admin.hasroute('list') and admin.isGranted('LIST') %}
  24. <tr>
  25. <td class="sonata-ba-list-label" width="40%">
  26. {{ admin.label|trans({}, admin.translationdomain) }}
  27. </td>
  28. <td>
  29. <div class="btn-group">
  30. {% if admin.hasroute('create') and admin.isGranted('CREATE') %}
  31. {% if admin.subClasses is empty %}
  32. <a class="btn btn-link btn-flat" href="{{ admin.generateUrl('create')}}">
  33. <i class="fa fa-plus-circle"></i>
  34. {% trans from 'SonataAdminBundle' %}link_add{% endtrans %}
  35. </a>
  36. {% else %}
  37. <a class="btn btn-link btn-flat dropdown-toggle" data-toggle="dropdown" href="#">
  38. <i class="fa fa-plus-circle"></i>
  39. {% trans from 'SonataAdminBundle' %}link_add{% endtrans %}
  40. <span class="caret"></span>
  41. </a>
  42. <ul class="dropdown-menu">
  43. {% for subclass in admin.subclasses|keys %}
  44. <li>
  45. <a href="{{ admin.generateUrl('create', {'subclass': subclass}) }}">{{ subclass|trans({}, admin.translationdomain) }}</a>
  46. </li>
  47. {% endfor %}
  48. </ul>
  49. {% endif %}
  50. {% endif %}
  51. {% if admin.hasroute('list') and admin.isGranted('LIST') %}
  52. <a class="btn btn-link btn-flat" href="{{ admin.generateUrl('list')}}">
  53. <i class="fa fa-list"></i>
  54. {% trans from 'SonataAdminBundle' %}link_list{% endtrans -%}
  55. </a>
  56. {% endif %}
  57. </div>
  58. </td>
  59. </tr>
  60. {% endif %}
  61. {% endfor %}
  62. </tbody>
  63. </table>
  64. </div>
  65. </div>
  66. {% endif %}
  67. {% endfor %}
  68. {% endblock %}