Skip to content

Commit 77f6425

Browse files
author
roadiz-ci
committed
style(nodes/edit.html.twig): update form and table integration
1 parent b27d296 commit 77f6425

1 file changed

Lines changed: 95 additions & 80 deletions

File tree

templates/nodes/edit.html.twig

Lines changed: 95 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -28,90 +28,105 @@
2828
{% import "@RoadizRozier/macros/rz_actions_menu.html.twig" as actions_menu %}
2929
{{ actions_menu.saveItem('#edit-node-form') }}
3030
{{ form_end(form) }}
31+
</article>
3132

32-
{% include '@RoadizRozier/includes/rz_meta_item_table.html.twig' with {
33-
item: node,
34-
additional_rows: [[{ tag: 'th', content: 'position'|trans }, { tag: 'td', content: node.position }]],
35-
} only %}
36-
</article>
37-
38-
{% if node.isHidingChildren %}
39-
<article>
40-
<h2 id="add-node-translation">{% trans %}stack.types{% endtrans %}</h2>
33+
{% if node.isHidingChildren %}
34+
<hr />
35+
<article>
36+
<h2 class="text-h1-sm">{% trans %}stack.types{% endtrans %}</h2>
37+
{% embed '@RoadizRozier/includes/rz_table.html.twig' with {
38+
selection_available: false,
39+
actions_available: true,
40+
node: node,
41+
stackTypesForm: stackTypesForm,
42+
} only %}
43+
{% block thead_cells %}
44+
<th>{% trans %}nodeType{% endtrans %}</th>
45+
{% endblock %}
46+
{% block tbody_content %}
47+
{% for type in node.stackTypes %}
48+
{% set nodeType = getNodeType(type) %}
49+
{% if nodeType is not null %}
50+
<tr>
51+
<td>{{ nodeType.displayName }}</td>
52+
{% if actions_available %}
53+
<td>
54+
{% embed '@RoadizRozier/includes/rz_table_actions.html.twig' %}
55+
{% block other_actions %}
56+
<form
57+
action="{{ path('nodesRemoveStackTypePage', {nodeId:node.id, typeName:nodeType.name}) }}"
58+
method="POST"
59+
>
60+
{{ _self.button({
61+
icon: 'rz-icon-ri--delete-bin-7-line',
62+
color: 'danger',
63+
attributes: {
64+
type: 'submit',
65+
title: 'delete'|trans,
66+
}
67+
}) }}
68+
</form>
69+
{% endblock %}
70+
{% endembed %}
71+
</td>
72+
{% endif %}
73+
</tr>
74+
{% endif %}
75+
{% else %}
76+
<tr><td colspan="2">{% trans %}no.stack.types{% endtrans %}</td></tr>
77+
{% endfor %}
78+
{% endblock %}
4179

42-
{% form_theme stackTypesForm '@RoadizRozier/horizontalForms.html.twig' %}
43-
{{ form_start(stackTypesForm) }}
44-
{{ form_widget(stackTypesForm) }}
45-
{% import '@RoadizRozier/macros/rz_button.html.twig' as rz_button %}
46-
{{ rz_button.root({
47-
icon: 'rz-icon-ri--add-line',
48-
emphasis: 'primary',
49-
label: 'add.stack.type'|trans,
50-
attributes: {
51-
type: 'submit',
52-
}
53-
}) }}
54-
{{ form_end(stackTypesForm) }}
80+
{% block tfoot_content %}
81+
{% if stackTypesForm %}
82+
<td>
83+
{% form_theme stackTypesForm '@RoadizRozier/forms.html.twig' %}
84+
{{ form_start(stackTypesForm) }}
85+
{{ form_widget(stackTypesForm) }}
86+
{{ form_end(stackTypesForm) }}
87+
</td>
88+
<td class="rz-table__cell--align-right">
89+
{% import '@RoadizRozier/macros/rz_button.html.twig' as rz_button %}
90+
{{ rz_button.root({
91+
icon: 'rz-icon-ri--add-line',
92+
emphasis: 'primary',
93+
label: 'add.stack.type'|trans,
94+
attributes: {
95+
type: 'submit',
96+
form: field_id(stackTypesForm),
97+
}
98+
}) }}
99+
</td>
100+
{% endif %}
101+
{% endblock %}
102+
{% endembed %}
103+
</article>
104+
{% endif %}
55105

56-
{% embed '@RoadizRozier/includes/rz_table.html.twig' with {
57-
selection_available: false,
58-
actions_available: true,
59-
node: node,
60-
} only %}
61-
{% block thead_cells %}
62-
<th>{% trans %}nodeType{% endtrans %}</th>
63-
{% endblock %}
64-
{% block tbody_content %}
65-
{% for type in node.stackTypes %}
66-
{% set nodeType = getNodeType(type) %}
67-
{% if nodeType is not null %}
68-
<tr>
69-
<td>{{ nodeType.displayName }}</td>
70-
{% if actions_available %}
71-
<td>
72-
{% embed '@RoadizRozier/includes/rz_table_actions.html.twig' %}
73-
{% block other_actions %}
74-
<form
75-
action="{{ path('nodesRemoveStackTypePage', {nodeId:node.id, typeName:nodeType.name}) }}"
76-
method="POST"
77-
>
78-
{{ _self.button({
79-
icon: 'rz-icon-ri--delete-bin-7-line',
80-
color: 'danger',
81-
attributes: {
82-
type: 'submit',
83-
title: 'delete'|trans,
84-
}
85-
}) }}
86-
</form>
87-
{% endblock %}
88-
{% endembed %}
89-
</td>
90-
{% endif %}
91-
</tr>
92-
{% endif %}
93-
{% else %}
94-
<tr><td colspan="2">{% trans %}no.stack.types{% endtrans %}</td></tr>
95-
{% endfor %}
96-
{% endblock %}
97-
{% endembed %}
98-
</article>
99-
{% endif %}
106+
{% if translationForm %}
107+
<hr />
108+
<article>
109+
<h2 class="text-h1-sm">{% trans %}translate.node{% endtrans %}</h2>
110+
{% form_theme translationForm '@RoadizRozier/forms.html.twig' %}
111+
{{ form_start(translationForm) }}
112+
{{ form_widget(translationForm) }}
113+
{% import '@RoadizRozier/macros/rz_button.html.twig' as rz_button %}
114+
{{ rz_button.root({
115+
icon: 'rz-icon-ri--flag-line',
116+
emphasis: 'primary',
117+
label: 'translate'|trans,
118+
attributes: {
119+
type: 'submit',
120+
}
121+
}) }}
122+
{{ form_end(translationForm) }}
123+
</article>
124+
{% endif %}
100125

101-
{% if translationForm %}
102-
<article>
103-
<h2 id="add-node-translation">{% trans %}translate.node{% endtrans %}</h2>
104-
{% form_theme translationForm '@RoadizRozier/forms.html.twig' %}
105-
{{ form_start(translationForm) }}
106-
{{ form_widget(translationForm) }}
107-
<fieldset data-uk-margin>
108-
<button class="uk-button uk-button-primary" type="submit">
109-
<i class="uk-icon-flag"></i> {% trans %}translate{% endtrans %}
110-
</button>
111-
</fieldset>
112-
{{ form_end(translationForm) }}
113-
</article>
114-
{% endif %}
126+
{% include '@RoadizRozier/includes/rz_meta_item_table.html.twig' with {
127+
item: node,
128+
additional_rows: [[{ tag: 'th', content: 'position'|trans }, { tag: 'td', content: node.position }]],
129+
} only %}
115130

116131
{% include '@RoadizRozier/nodes/actionsMenu.html.twig' %}
117132
</section>

0 commit comments

Comments
 (0)