tree.html.twig 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. {#
  8. This template is not used at all, it is just a template that you can use to create
  9. your own custom tree view.
  10. #}
  11. {% extends 'SonataAdminBundle:CRUD:base_list.html.twig' %}
  12. {% import _self as tree %}
  13. {% macro navigate_child(collection, admin, root) %}
  14. <ul{% if root %} class="sonata-tree"{% endif %}>
  15. {% for element in collection if not root %}
  16. <li>
  17. <div class="sonata-tree__item">
  18. {% if element.parent %}<i class="fa fa-caret-right" aria-hidden="true"></i>{% endif %}
  19. <i class="fa fa-code" aria-hidden="true"></i>
  20. <a class="sonata-tree__item__edit" href="{{ admin.generateObjectUrl('edit', element) }}">{{ element.name }}</a>
  21. <i class="text-muted">{{ element.description }}</i>
  22. <a class="label label-default pull-right" href="{{ admin.generateObjectUrl('edit', element) }}">edit <i class="fa fa-magic" aria-hidden="true"></i></a>
  23. {% if true %}<span class="label label-warning pull-right">true</span>{% endif %}
  24. </div>
  25. {% if element.children|length %}
  26. {{ _self.navigate_child(element.children, admin, false) }}
  27. {% endif %}
  28. </li>
  29. {% endfor %}
  30. </ul>
  31. {% endmacro %}
  32. {% block tab_menu %}
  33. {% include 'SonataAdminBundle:CRUD:list_tab_menu.html.twig' with {
  34. 'mode': 'tree',
  35. 'action': action,
  36. 'admin': admin,
  37. } only %}
  38. {% endblock %}
  39. {% block list_table %}
  40. <div class="col-xs-12 col-md-12">
  41. <div class="box box-primary">
  42. <div class="box-header">
  43. <h1 class="box-title">
  44. {{ 'element.tree_site_label'|trans({}, admin.translationdomain) }}
  45. <div class="btn-group">
  46. <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
  47. <strong class="text-info">{{ currentSite.name }}</strong> <span class="caret"></span>
  48. </button>
  49. <ul class="dropdown-menu" role="menu">
  50. {% for context in contexts %}
  51. <li>
  52. <a href="{{ admin.generateUrl('tree', { 'context': context.id }) }}">
  53. {% if currentContext and context.id == currentContext.id %}
  54. <span class="pull-right">
  55. <i class="fa fa-check" aria-hidden="true"></i>
  56. </span>
  57. {% endif %}
  58. {{ site.name }}
  59. </a>
  60. </li>
  61. {% endfor%}
  62. </ul>
  63. </div>
  64. </h1>
  65. </div>
  66. <div class="box-content">
  67. {{ tree.navigate_child(collection, admin, true) }}
  68. </div>
  69. </div>
  70. </div>
  71. {% endblock %}