forked from sonata-project/SonataPageBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompose_preview.html.twig
89 lines (79 loc) · 3.59 KB
/
compose_preview.html.twig
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
<li class="page-composer__container__child"
data-block-id="{{ child.id }}"
data-parent-block-id="{{ container.id }}"
data-block-enabled="{{ child.enabled|default('0') }}"
data-block-type="{{ child.type }}"
>
{% set service = attribute(blockServices, child.type) ?? null %}
{% if service %}
<a
class="page-composer__container__child__edit"
href="{{ blockAdmin.generateUrl('edit', { 'id': child.id, 'composer': true }) }}"
>
{% else %}
<div class="page-composer__container__child__error">
{% endif %}
{% if service %}
{% set metadataTitle = service.metadata.title|trans({}, service.metadata.domain|default('SonataPageBundle')) %}
{% set blockTitle = child.name|default(metadataTitle) %}
{% set blockImage = service.metadata.image ? asset(service.metadata.image) : null %}
{% set blockClass = service.metadata.option('class') %}
{% else %}
{% set metadataTitle = child.type %}
{% set blockTitle = child.name %}
{% set blockImage = null %}
{% set blockClass = null %}
{% endif %}
<h4 class="page-composer__container__child__name">{{ blockTitle }}</h4>
{% if blockImage %}
<img src="{{ blockImage }}" style="max-height: 20px; max-width: 100px;"/>
{% elseif blockClass %}
<i class="{{ blockClass }}" ></i>
{% endif %}
<small>{{ metadataTitle }}</small>
{% if service %}
<span class="page-composer__container__child__toggle">
<i class="fa fa-chevron-down"></i>
<i class="fa fa-chevron-up"></i>
</span>
{% endif %}
{% if service %}
</a>
{% else %}
</div>
{% endif %}
<div class="page-composer__container__child__right">
<div class="page-composer__container__child__remove">
<a class="badge" href="{{ blockAdmin.generateUrl('delete', { 'id': child.id }) }}">{{ 'composer.remove'|trans({}, 'SonataPageBundle') }} <i class="fa fa-times"></i> </a>
</div>
<div
class="page-composer__container__child__switch-enabled"
data-label-enable="{{ ('composer.enable'|trans({}, 'SonataPageBundle') ~ ' <i class="fa fa-toggle-on"></i>')|e }}"
data-label-disable="{{ ('composer.disable'|trans({}, 'SonataPageBundle') ~ ' <i class="fa fa-toggle-off"></i>')|e }}"
>
<a
class="badge bg-{{ child.enabled ? 'yellow' : 'green' }}"
href="{{ path('sonata_admin_set_object_field_value', {
'objectId': child.id,
'context': 'list',
'field': 'enabled',
'_sonata_admin': 'sonata.page.admin.block'
}) }}"
>
{% if child.enabled %}{{ 'composer.disable'|trans({}, 'SonataPageBundle') }}
<i class="fa fa-toggle-off"></i>
{% else %}
{{ 'composer.enable'|trans({}, 'SonataPageBundle') }}
<i class="fa fa-toggle-on"></i>
{% endif %}
</a>
</div>
<div class="page-composer__container__child__enabled">
<small class="badge bg-{{ child.enabled ? 'green' : 'yellow' }}"><i class="fa fa-{{ child.enabled ? 'check' : 'times' }}"></i></small>
</div>
</div>
<div class="page-composer__container__child__content"></div>
<div class="page-composer__container__child__loader">
<span>{{ 'loading'|trans({}, 'SonataPageBundle') }}</span>
</div>
</li>