-
-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathtree.html.twig
More file actions
93 lines (84 loc) · 4.5 KB
/
tree.html.twig
File metadata and controls
93 lines (84 loc) · 4.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
{#
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.
#}
{#
This template is not used at all, it is just a template that you can use to create
your own custom tree view.
#}
{% extends '@SonataAdmin/CRUD/base_list.html.twig' %}
{% import _self as tree %}
{% macro navigate_child(collection, admin, root, depth) %}
{% import _self as tree %}
<ul{% if root %} class="sonata-tree sonata-tree--toggleable js-treeview"{% endif %}>
{% for element in collection %}
<li class="sonata-ba-list-field" objectId="{{ element.id }}" >
<div class="sonata-tree__item"{% if depth < 2 %} data-treeview-toggled{% endif %}>
{% if element.parent or root %}<i class="fa fa-caret-right" data-treeview-toggler></i>{% endif %}
{% if admin.hasRoute('edit') and admin.hasAccess('edit') %}
<a class="sonata-tree__item__edit" href="{{ admin.generateObjectUrl('edit', element) }}">{{ element.name }}</a>
{% elseif admin.hasRoute('show') and admin.hasAccess('show') %}
<a class="sonata-tree__item__edit" href="{{ admin.generateObjectUrl('show', element) }}">{{ element.name }}</a>
{% else %}
{{ element.name }}
{% endif %}
<i class="text-muted">{{ element.description }}</i>
{#<a class="label label-default pull-right" href="{{ admin.generateObjectUrl('edit', element) }}">edit <i class="fa fa-magic"></i></a>#}
{% if element.enabled %}<span class="label label-success pull-right"><i class="fa fa-check"></i> {{ 'active'|trans({}, admin.translationDomain) }}</span>{% endif %}
{% if not element.enabled %}<span class="label label-danger pull-right"><i class="fa fa-times"></i> {{ 'disabled'|trans({}, admin.translationDomain) }}</span>{% endif %}
</div>
{% if element.children|length %}
{{ tree.navigate_child(element.children, admin, false, depth + 1) }}
{% endif %}
</li>
{% endfor %}
</ul>
{% endmacro %}
{% block tab_menu %}
{% include '@SonataClassification/CategoryAdmin/list_tab_menu.html.twig' with {
'mode': 'tree',
'action': action,
'admin': admin,
} only %}
{% endblock %}
{% block list_table %}
<div class="col-xs-12 col-md-12">
<div class="box box-primary">
<div class="box-header">
<h1 class="box-title">
{{ 'tree_catalog_title'|trans({}, admin.translationdomain) }}
{% if not app.request.query.get('hide_context') and current_context is not empty %}
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<strong class="text-info">{{ current_context.name }}</strong> <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
{% for context_id, categories in root_categories %}
<li>
<a href="{{ admin.generateUrl('tree', { 'context': context_id }) }}">
{% if current_context and context_id == current_context.id %}
<span class="pull-right">
<i class="fa fa-check"></i>
</span>
{% endif %}
{{ categories|join(', ') }}
</a>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
</h1>
</div>
<div class="box-content">
{% if current_categories is empty %}
{{ tree.navigate_child([], admin, true, 0) }}
{% else %}
{{ tree.navigate_child(current_categories, admin, true, 0) }}
{% endif %}
</div>
</div>
</div>
{% endblock %}