Skip to content

Commit 9860c27

Browse files
committed
Templates have been moved to the MenuBundle
1 parent 52af290 commit 9860c27

10 files changed

Lines changed: 306 additions & 6 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.idea/

src/Controller/MenuCategoryController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function indexAction(MenuCategoryRepository $menuCategoryRepository)
3030
'menu_category.menu_categories' => null
3131
]);
3232

33-
return $this->render('admin/menucategory/index.html.twig', [
33+
return $this->render('@TwinElementsMenu/menucategory/index.html.twig', [
3434
'menuCategories' => $menuCategories,
3535
]);
3636
}
@@ -72,7 +72,7 @@ public function newAction(Request $request)
7272
'menu_category.add_new_menu' => null
7373
]);
7474

75-
return $this->render('admin/menucategory/new.html.twig', array(
75+
return $this->render('@TwinElementsMenu/menucategory/new.html.twig', array(
7676
'menuCategory' => $menuCategory,
7777
'form' => $form->createView(),
7878
));
@@ -112,7 +112,7 @@ public function editAction(Request $request, MenuCategory $menuCategory)
112112
$menuCategory->getTitle() => null
113113
]);
114114

115-
return $this->render('admin/menucategory/edit.html.twig', array(
115+
return $this->render('@TwinElementsMenu/menucategory/edit.html.twig', array(
116116
'entity' => $menuCategory,
117117
'form' => $editForm->createView(),
118118
'delete_form' => $deleteForm->createView(),

src/Controller/MenuController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function indexAction(Request $request, MenuRepository $menuRepository)
5555
$menuCategory->getTitle() => null
5656
]);
5757

58-
return $this->render('admin/menu/index.html.twig', array(
58+
return $this->render('@TwinElementsMenu/menu/index.html.twig', array(
5959
'menus' => $menuItems,
6060
'menu_category' => $menuCategory
6161
));
@@ -146,7 +146,7 @@ public function newAction(Request $request, AdapterInterface $cache)
146146
'Dodawanie nowej pozycji' => null
147147
]);
148148

149-
return $this->render('admin/menu/new.html.twig', array(
149+
return $this->render('@TwinElementsMenu/menu/new.html.twig', array(
150150
'menu' => $menu,
151151
'menu_category' => $menuCategory,
152152
'form' => $form->createView(),
@@ -203,7 +203,7 @@ public function editAction(Request $request, Menu $menu, AdapterInterface $cache
203203
$menu->getTitle() => null
204204
]);
205205

206-
return $this->render('admin/menu/edit.html.twig', array(
206+
return $this->render('@TwinElementsMenu/menu/edit.html.twig', array(
207207
'entity' => $menu,
208208
'menu_category' => $menuCategory,
209209
'form' => $editForm->createView(),
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<select id="itemList" class="input form-control" style="margin-top: 20px;">
2+
<option>Wybierz z listy</option>
3+
{% for item in items %}
4+
<option value="{{ item.id }}" {% if checkedKey == item.id %}selected="selected"{% endif %}>{{ item.title }}</option>
5+
{% endfor %}
6+
</select>

src/templates/menu/edit.html.twig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{% extends '@TwinElementsAdmin/core/details_with_sidebar.html.twig' %}
2+
3+
{% set back_button_link = path('menu_index', {'category': menu_category.id}) %}
4+
5+
{% block title %}
6+
{% if entity.title %}
7+
{{ entity.title }}
8+
{% else %}
9+
{{ entity.translate(default_locale, false).title }}<br>
10+
<span class="badge badge-warning small">{{ "cms.no_translation_for_this_locale"|translate_admin }}</span>
11+
{% endif %}
12+
{% endblock %}
13+
{% block buttons %}
14+
{{ block('back_button') }}
15+
{% endblock %}
16+
17+
{% block right_sidebar %}
18+
{{ block('changes_details') }}
19+
{{ block('delete_form') }}
20+
{% endblock %}

src/templates/menu/index.html.twig

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
{% extends '@TwinElementsAdmin/core/list.html.twig' %}
2+
3+
{% set add_button_link = path('menu_new', {'category': menu_category.id }) %}
4+
5+
{% block title %}{{ menu_category.title }}{% endblock %}
6+
{% block buttons %}
7+
{{ block('add_button') }}
8+
{% endblock %}
9+
10+
{% block list %}
11+
<ul class="cms-list sortable">
12+
<li class="header">
13+
<div class="level_content row align-items-center">
14+
{{ block('id_header') }}
15+
<div class="col">{{ "menu.menu"|trans({},null,admin_locale) }}</div>
16+
{{ block('list_changes_header') }}
17+
{{ block('move_header') }}
18+
</div>
19+
</li>
20+
{% for menu in menus if menu.parent == null %}
21+
{% set id = menu.id %}
22+
{% set createdAt = menu.createdAt %}
23+
{% set createdBy = menu.createdBy %}
24+
{% set updatedAt = menu.updatedAt %}
25+
{% set updatedBy = menu.updatedBy %}
26+
27+
<li id="{{ menu.id }}" class="sortable-item">
28+
<div class="level_content row align-items-center">
29+
{{ block('id') }}
30+
<div class="col">
31+
<div class="title">
32+
<span>{{ menu.title }}</span>
33+
{% if menu.title is null %}
34+
<span class="badge badge-warning">{{ "cms.no_translations"|trans({},null,admin_locale) }}</span>
35+
{% endif %}
36+
<div class="hidden-bar">
37+
<a href="{{ path('menu_edit', { 'id': menu.id, 'category': menu_category.id }) }}">Edytuj</a>
38+
</div>
39+
</div>
40+
</div>
41+
{{ block('changes_box_in_list') }}
42+
{{ block('move') }}
43+
</div>
44+
{% if menu.children|length > 0 %}
45+
<ul class="cms-list level_2">
46+
{% for children in menu.children %}
47+
{% set id = children.id %}
48+
{% set createdAt = children.createdAt %}
49+
{% set createdBy = children.createdBy %}
50+
{% set updatedAt = children.updatedAt %}
51+
{% set updatedBy = children.updatedBy %}
52+
53+
<li id="{{ children.id }}" class="sortable-item_2">
54+
<div class="level_content row align-items-center">
55+
{{ block('id') }}
56+
<div class="col">
57+
<div class="title">
58+
<div class="d-flex align-items-center">
59+
<span class="arrow-right"></span>{{ children.title }}
60+
{% if children.title is null %}
61+
<span class="badge badge-warning">{{ "cms.no_translations"|trans({},null,admin_locale) }}</span>
62+
{% endif %}
63+
</div>
64+
<div class="hidden-bar">
65+
<a href="{{ path('menu_edit', { 'id': children.id, 'category': menu_category.id }) }}">Edytuj</a>
66+
</div>
67+
</div>
68+
</div>
69+
{{ block('changes_box_in_list') }}
70+
{{ block('move') }}
71+
</div>
72+
{# trzeci poziom #}
73+
74+
{% if children.children|length > 0 %}
75+
<ul class="cms-list level_3">
76+
{% for childrenLvl3 in children.children %}
77+
{% set id = childrenLvl3.id %}
78+
{% set createdAt = childrenLvl3.createdAt %}
79+
{% set createdBy = childrenLvl3.createdBy %}
80+
{% set updatedAt = childrenLvl3.updatedAt %}
81+
{% set updatedBy = childrenLvl3.updatedBy %}
82+
83+
<li id="{{ childrenLvl3.id }}" class="sortable-item_3">
84+
<div class="level_content row align-items-center">
85+
{{ block('id') }}
86+
<div class="col">
87+
<div class="title">
88+
<div class="d-flex align-items-center">
89+
<span class="arrow-right"></span><span
90+
class="arrow-right"></span>{{ childrenLvl3.title }}
91+
{% if childrenLvl3.title is null %}
92+
<span class="badge badge-warning">{{ "cms.no_translations"|trans({},null,admin_locale) }}</span>
93+
{% endif %}
94+
</div>
95+
<div class="hidden-bar">
96+
<a href="{{ path('menu_edit', { 'id': childrenLvl3.id, 'category': menu_category.id }) }}">Edytuj</a>
97+
</div>
98+
</div>
99+
</div>
100+
{{ block('changes_box_in_list') }}
101+
{{ block('move') }}
102+
</div>
103+
</li>
104+
{% endfor %}
105+
</ul>
106+
{% endif %}
107+
</li>
108+
{% endfor %}
109+
</ul>
110+
{% endif %}
111+
</li>
112+
{% endfor %}
113+
</ul>
114+
{% endblock %}
115+
116+
{% block javascripts %}
117+
{{ parent() }}
118+
<script>
119+
console.log(window.jQuery);
120+
$(window).on('load', function () {
121+
$('.sortable').sortable({
122+
axis: 'y',
123+
items: ".sortable-item",
124+
tolerance: 'pointer',
125+
cursor: 'move',
126+
handle: '.move',
127+
update: function () {
128+
var data = $(this).sortable('toArray');
129+
$.ajax({
130+
url: '{{ path('menu_sortable') }}',
131+
type: 'post',
132+
data: {data: data},
133+
success: function (e) {
134+
135+
}
136+
})
137+
}
138+
});
139+
140+
$('.level_2').sortable({
141+
axis: 'y',
142+
items: '.sortable-item_2',
143+
tolerance: 'pointer',
144+
cursor: 'move',
145+
handle: '.move',
146+
update: function () {
147+
var data = $(this).sortable('toArray');
148+
$.ajax({
149+
url: '{{ path('menu_sortable') }}',
150+
type: 'post',
151+
data: {data: data},
152+
success: function (e) {
153+
154+
}
155+
})
156+
}
157+
})
158+
159+
$('.level_3').sortable({
160+
axis: 'y',
161+
items: '.sortable-item_3',
162+
tolerance: 'pointer',
163+
cursor: 'move',
164+
handle: '.move',
165+
update: function () {
166+
var data = $(this).sortable('toArray');
167+
$.ajax({
168+
url: '{{ path('menu_sortable') }}',
169+
type: 'post',
170+
data: {data: data},
171+
success: function (e) {
172+
173+
}
174+
})
175+
}
176+
})
177+
})
178+
</script>
179+
180+
{% endblock %}

src/templates/menu/new.html.twig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{% extends '@TwinElementsAdmin/core/details.html.twig' %}
2+
3+
{% block title %}{{ 'menu.add_new_menu_item'|trans }}{% endblock %}
4+
{% block buttons %}
5+
{% set back_button_link = path('menu_index', {'category': menu_category.id}) %}
6+
{{ block('back_button') }}
7+
{% endblock %}
8+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{% extends '@TwinElementsAdmin/core/details_with_sidebar.html.twig' %}
2+
3+
{% set back_button_link = path('menucategory_index') %}
4+
5+
{% block title %}
6+
{% if entity.title %}
7+
{{ entity.title }}
8+
{% else %}
9+
{{ entity.translate(default_locale, false).title }}<br>
10+
<span class="badge badge-warning small">{{ "cms.no_translation_for_this_locale"|translate_admin }}</span>
11+
{% endif %}
12+
{% endblock %}
13+
14+
{% block buttons %}
15+
{{ block('back_button') }}
16+
{% endblock %}
17+
18+
{% block right_sidebar %}
19+
{{ block('changes_details') }}
20+
{{ block('delete_form') }}
21+
{% endblock %}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{% extends '@TwinElementsAdmin/core/list.html.twig' %}
2+
3+
{% block title %}{{ "menu_category.menu_categories"|translate_admin }}{% endblock %}
4+
{% block buttons %}
5+
{% if is_granted('ROLE_SUPER_ADMIN') %}
6+
{% set add_button_link = path('menucategory_new') %}
7+
{{ block('add_button') }}
8+
{% endif %}
9+
{% endblock %}
10+
11+
{% block list %}
12+
{% if menuCategories|length > 0 %}
13+
<ul class="cms-list">
14+
<li class="header ">
15+
<div class="level_content row align-items-center">
16+
{{ block('id_header') }}
17+
<div class="col">{{ "menu_category.title"|translate_admin }}</div>
18+
{% set circle_header_name = "menu_category.isCached"|translate_admin %}
19+
{{ block('list_changes_header') }}
20+
{{ block('circle_header') }}
21+
</div>
22+
</li>
23+
{% for menuCategory in menuCategories %}
24+
{% set id = menuCategory.id %}
25+
{% set createdAt = menuCategory.createdAt %}
26+
{% set createdBy = menuCategory.createdBy %}
27+
{% set updatedAt = menuCategory.updatedAt %}
28+
{% set updatedBy = menuCategory.updatedBy %}
29+
{% set circle_active = menuCategory.isCached %}
30+
31+
<li class="">
32+
<div class="level_content row align-items-center">
33+
{{ block('id') }}
34+
<div class="col">
35+
<div class="title">
36+
<span>{{ menuCategory.title }}</span>
37+
<br>
38+
<div class="hidden-bar">
39+
{% if is_granted('ROLE_EDIT') %}
40+
<a href="{{ path('menucategory_edit', { 'id': menuCategory.id }) }}">{{ "menu.edit_menu_category"|translate_admin }}</a>
41+
{% endif %}
42+
<span class="circle-separator"></span>
43+
<a href="{{ path('menu_index', { 'category': menuCategory.id }) }}">{{ "menu.menu_elements"|translate_admin }}</a>
44+
</div>
45+
</div>
46+
</div>
47+
{{ block('changes_box_in_list') }}
48+
{{ block('circle') }}
49+
</div>
50+
</li>
51+
{% endfor %}
52+
</ul>
53+
{% else %}
54+
{{ block('no_elements') }}
55+
{% endif %}
56+
{% endblock %}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{% extends '@TwinElementsAdmin/core/details.html.twig' %}
2+
3+
{% set back_button_link = path('menucategory_index') %}
4+
5+
{% block title %}{{ "menu_category.add_new_menu"|translate_admin }}{% endblock %}
6+
{% block buttons %}
7+
{{ block('back_button') }}
8+
{% endblock %}

0 commit comments

Comments
 (0)