Use common settings for all element history tables

This commit is contained in:
Jan Böhmer 2022-10-09 20:27:31 +02:00
parent f50959837f
commit 38ff9bae4a
8 changed files with 36 additions and 18 deletions

View file

@ -152,7 +152,8 @@
{% if datatable is defined and datatable is not null %} {% if datatable is defined and datatable is not null %}
<div id="history" class="tab-pane fade"> <div id="history" class="tab-pane fade">
{% include "LogSystem/_log_table.html.twig" %} {% import "components/history_log_macros.html.twig" as log %}
{{ log.element_history_component(datatable) }}
</div> </div>
{% endif %} {% endif %}

View file

@ -1,11 +0,0 @@
{% import "components/datatables.macro.html.twig" as datatables %}
<form method="post" action="{{ path("log_undo") }}"
{{ stimulus_controller('elements/delete_btn') }} {{ stimulus_action('elements/delete_btn', "submit", "submit") }}
data-delete-title="{% trans %}log.undo.confirm_title{% endtrans %}"
data-delete-message="{% trans %}log.undo.confirm_message{% endtrans %}">
<input type="hidden" name="redirect_back" value="{{ app.request.uri }}">
{{ datatables.logDataTable(datatable) }}
</form>

View file

@ -51,5 +51,6 @@
</div> </div>
</div> </div>
{% include "LogSystem/_log_table.html.twig" %} {% import "components/history_log_macros.html.twig" as log %}
{{ log.system_log_component(datatable) }}
{% endblock %} {% endblock %}

View file

@ -1,5 +1,6 @@
<div class="mt-2"> <div class="mt-2">
{% if datatable is not null %} {% if datatable is not null %}
{% include "LogSystem/_log_table.html.twig" %} {% import "components/history_log_macros.html.twig" as log %}
{{ log.element_history_component(datatable) }}
{% endif %} {% endif %}
</div> </div>

View file

@ -75,7 +75,8 @@
<div class="mt-2"> <div class="mt-2">
{% if datatable is defined and datatable is not null %} {% if datatable is defined and datatable is not null %}
{% include "LogSystem/_log_table.html.twig" %} {% import "components/history_log_macros.html.twig" as log %}
{{ log.element_history_component(datatable) }}
{% endif %} {% endif %}
</div> </div>
{% endblock %} {% endblock %}

View file

@ -13,8 +13,8 @@
</div> </div>
{% endmacro %} {% endmacro %}
{% macro logDataTable(dt) %} {% macro logDataTable(dt, state_save_tag = null) %}
{{ _self.datatable(dt, 'elements/datatables/log') }} {{ _self.datatable(dt, 'elements/datatables/log', state_save_tag) }}
{% endmacro %} {% endmacro %}
{% macro partsDatatableWithForm(datatable, state_save_tag = 'parts') %} {% macro partsDatatableWithForm(datatable, state_save_tag = 'parts') %}

View file

@ -0,0 +1,24 @@
{% macro last_activity_component(datatable) %}
{{ _self.log_component(datatable, 'last_activity') }}
{% endmacro %}
{% macro element_history_component(datatable) %}
{{ _self.log_component(datatable, 'element_history') }}
{% endmacro %}
{% macro system_log_component(datatable) %}
{{ _self.log_component(datatable, 'system_log') }}
{% endmacro %}
{% macro log_component(datatable, tag = null) %}
{% import "components/datatables.macro.html.twig" as datatables %}
<form method="post" action="{{ path("log_undo") }}"
{{ stimulus_controller('elements/delete_btn') }} {{ stimulus_action('elements/delete_btn', "submit", "submit") }}
data-delete-title="{% trans %}log.undo.confirm_title{% endtrans %}"
data-delete-message="{% trans %}log.undo.confirm_message{% endtrans %}">
<input type="hidden" name="redirect_back" value="{{ app.request.uri }}">
{{ datatables.logDataTable(datatable, tag) }}
</form>
{% endmacro %}

View file

@ -44,7 +44,8 @@
<div class="card mt-3"> <div class="card mt-3">
<div class="card-header"><i class="fas fa-fw fa-history"></i> {% trans %}homepage.last_activity{% endtrans %}</div> <div class="card-header"><i class="fas fa-fw fa-history"></i> {% trans %}homepage.last_activity{% endtrans %}</div>
<div class="card-body"> <div class="card-body">
{% include "LogSystem/_log_table.html.twig" %} {% import "components/history_log_macros.html.twig" as log %}
{{ log.last_activity_component(datatable) }}
</div> </div>
</div> </div>
{% endif %} {% endif %}