tree.html.twig 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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"></i>{% endif %}
  19. <i class="fa fa-code"></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"></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="box box-primary">
  41. <div class="box-header">
  42. <h1 class="box-title">
  43. {{ admin.trans('element.tree_site_label') }}
  44. <div class="btn-group">
  45. <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
  46. <strong class="text-info">{{ currentSite.name }}</strong> <span class="caret"></span>
  47. </button>
  48. <ul class="dropdown-menu" role="menu">
  49. {% for context in contexts %}
  50. <li>
  51. <a href="{{ admin.generateUrl('tree', { 'context': context.id }) }}">
  52. {% if currentContext and context.id == currentContext.id %}
  53. <span class="pull-right">
  54. <i class="fa fa-check"></i>
  55. </span>
  56. {% endif %}
  57. {{ site.name }}
  58. </a>
  59. </li>
  60. {% endfor%}
  61. </ul>
  62. </div>
  63. </h1>
  64. </div>
  65. <div class="box-content">
  66. {{ tree.navigate_child(collection, admin, true) }}
  67. </div>
  68. </div>
  69. {% endblock %}