move html from callbacks to twig

This commit is contained in:
envoyr
2022-02-23 16:27:13 +01:00
parent 9177273484
commit 4e4e4eca94
6 changed files with 81 additions and 50 deletions

View File

@@ -0,0 +1,19 @@
{% macro progressbar(data) %}
<div class="progress progress-thin">
<div class="progress-bar {{ data.style }}" style="width: {{ data.percent }}%;"></div>
</div>
<div class="text-end">
{% if data.infotext is not empty %}
<i class="fa-solid fa-circle-info" data-toggle="tooltip" data-placement="right" title="{{ data.infotext|raw }}"></i>
{% endif %}
{{ data.text }}
</div>
{% endmacro %}
{% macro boolean(data) %}
{% if (data) %}
<i class="fa fa-check-circle"></i>
{% else %}
<i class="fa fa-times-circle"></i>
{% endif %}
{% endmacro %}

View File

@@ -1,5 +1,7 @@
{% macro table(listing) %}
{% import "Froxlor/table/callbacks.html.twig" as callbacks %}
<form action="{{ action|default("") }}" method="post" enctype="application/x-www-form-urlencoded" class="form">
{% if listing.title is not empty %}
<h3 class="page-header">
@@ -24,7 +26,17 @@
<tr>
{% for value in td %}
<td class="p-3">
{{ value|raw }}
{% if value is iterable %}
{% if value.type == 'progressbar' %}
{{ callbacks.progressbar(value.data) }}
{% elseif value.type == 'boolean' %}
{{ callbacks.boolean(value.data) }}
{% else %}
Callback '{{ value|json_encode }}' is not implemented!
{% endif %}
{% else %}
{{ value|raw }}
{% endif %}
</td>
{% endfor %}
</tr>