mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-08-02 01:04:41 +02:00
Show a table with the old data in log entry details page
This commit is contained in:
parent
4c6ceab8e8
commit
1534f780aa
12 changed files with 435 additions and 84 deletions
|
@ -0,0 +1,11 @@
|
|||
{# @var entry \App\Entity\LogSystem\ElementCreatedLogEntry #}
|
||||
|
||||
{% import "log_system/details/helper.macro.html.twig" as log_helper %}
|
||||
|
||||
{{ log_helper.comment_field(entry) }}
|
||||
{% if entry.creationInstockValue %}
|
||||
<p>
|
||||
<b>{% trans %}log.element_created.original_instock{% endtrans %}:</b>
|
||||
{{ entry.creationInstockValue }}
|
||||
</p>
|
||||
{% endif %}
|
|
@ -0,0 +1,8 @@
|
|||
{# @var entry \App\Entity\LogSystem\ElementDeletedLogEntry #}
|
||||
|
||||
{% import "log_system/details/helper.macro.html.twig" as log_helper %}
|
||||
|
||||
<span class="badge badge-notice"></span>
|
||||
|
||||
{{ log_helper.comment_field(entry) }}
|
||||
{{ log_helper.data_change_table(entry) }}
|
11
templates/log_system/details/_extra_element_edited.html.twig
Normal file
11
templates/log_system/details/_extra_element_edited.html.twig
Normal file
|
@ -0,0 +1,11 @@
|
|||
{# @var entry \App\Entity\LogSystem\ElementDeletedLogEntry #}
|
||||
|
||||
{% import "log_system/details/helper.macro.html.twig" as log_helper %}
|
||||
|
||||
{% if entry.undoEvent %}
|
||||
<span class="badge badge-info bg-info">Test</span>
|
||||
{% endif %}
|
||||
|
||||
{{ log_helper.comment_field(entry) }}
|
||||
|
||||
{{ log_helper.data_change_table(entry) }}
|
77
templates/log_system/details/helper.macro.html.twig
Normal file
77
templates/log_system/details/helper.macro.html.twig
Normal file
|
@ -0,0 +1,77 @@
|
|||
|
||||
{% macro comment_field(entry) %}
|
||||
{# @var entry \App\Entity\Contracts\LogWithComment #}
|
||||
<p class="mb-0">
|
||||
<b>{% trans %}edit.log_comment{% endtrans %}:</b>
|
||||
{% if entry.comment %}
|
||||
{{ entry.comment }}
|
||||
{% else %}
|
||||
<span class="text-muted">{% trans %}log.no_comment{% endtrans %}</span>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro data_change_table(entry) %}
|
||||
{# @var entry \App\Entity\LogSystem\ElementEditedLogEntry|\App\Entity\LogSystem\ElementDeletedLogEntry entry #}
|
||||
|
||||
{% set fields, old_data, new_data = {}, {}, {} %}
|
||||
|
||||
{# For log entries where only the changed fields are saved, this is the last executed assignment #}
|
||||
{% if attribute(entry, 'changedFieldInfo') is defined and entry.changedFieldsInfo %}
|
||||
{% set fields = entry.changedFields %}
|
||||
{% endif %}
|
||||
|
||||
{# For log entries, where we know the old data, this is the last exectuted assignment #}
|
||||
{% if attribute(entry, 'oldDataInformations') is defined and entry.oldDataInformations %}
|
||||
{# We have to use the keys of oldData here, as changedFields might not be available #}
|
||||
{% set fields = entry.oldData | keys %}
|
||||
{% set old_data = entry.oldData %}
|
||||
{% endif %}
|
||||
|
||||
{% if fields is not empty %}
|
||||
<table class="table table-hover table-striped table-sm table-bordered mt-2">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans %}log.element_changed.field{% endtrans %}</th>
|
||||
{% if old_data is not empty %}
|
||||
<th>{% trans %}log.element_changed.data_before{% endtrans %}</th>
|
||||
{% endif %}
|
||||
{% if new_data is not empty %}
|
||||
<th>{% trans %}log.element_changed.data_after{% endtrans %}</th>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for field in fields %}
|
||||
<tr>
|
||||
<td title="{{ field }}">
|
||||
{% set trans_key = 'log.element_edited.changed_fields.'~field %}
|
||||
{# If the translation key is not found, the translation key is returned, and we dont show the translation #}
|
||||
{% if trans_key|trans != trans_key %}
|
||||
{{ ('log.element_edited.changed_fields.'~field) | trans }}
|
||||
<span class="text-muted">({{ field }})</span>
|
||||
{% else %}
|
||||
{{ field }}
|
||||
{% endif %}
|
||||
|
||||
</td>
|
||||
{% if old_data is not empty %}
|
||||
<td>
|
||||
{% if old_data[field] is defined %}
|
||||
{{ format_log_data(old_data[field], entry, field) }}
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endif %}
|
||||
{% if new_data is not empty %}
|
||||
<td>
|
||||
{% if new_data[field] is defined %}
|
||||
{{ format_log_data(new_data[field], entry, field) }}
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
|
@ -62,6 +62,12 @@
|
|||
{% set entry = log_entry %}
|
||||
{% if log_entry is instanceof('App\\Entity\\LogSystem\\DatabaseUpdatedLogEntry') %}
|
||||
{% include "log_system/details/_extra_database_updated.html.twig" %}
|
||||
{% elseif log_entry is instanceof('App\\Entity\\LogSystem\\ElementCreatedLogEntry') %}
|
||||
{% include "log_system/details/_extra_element_created.html.twig" %}
|
||||
{% elseif log_entry is instanceof('App\\Entity\\LogSystem\\ElementEditedLogEntry') %}
|
||||
{% include "log_system/details/_extra_element_edited.html.twig" %}
|
||||
{% elseif log_entry is instanceof('App\\Entity\\LogSystem\\ElementDeletedLogEntry') %}
|
||||
{% include "log_system/details/_extra_element_deleted.html.twig" %}
|
||||
{% elseif log_entry is instanceof('App\\Entity\\LogSystem\\UserLoginLogEntry')
|
||||
or log_entry is instanceof('App\\Entity\\LogSystem\\UserLogoutLogEntry') %}
|
||||
{% include "log_system/details/_extra_user_login.html.twig" %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue