Skip to content

Commit

Permalink
[Admin] Improve history details (#11286)
Browse files Browse the repository at this point in the history
  • Loading branch information
Remg authored Jan 8, 2025
1 parent 45542b3 commit 4c3632d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/Admin/AdministratorActionHistoryAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ protected function configureListFields(ListMapper $list): void
])
->add('data', null, [
'label' => 'Données',
'template' => 'admin/administrator_action_history/list_data.html.twig',
])
;
}
Expand Down
30 changes: 30 additions & 0 deletions templates/admin/administrator_action_history/list_data.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% extends '@SonataAdmin/CRUD/base_list_field.html.twig' %}

{% block field %}
{% if object.data %}
<ul>
{% for key, value in object.data %}
<li>
{% if key is same as('adherent_uuid') %}
{% set adherent = get_adherent_by_uuid(value) %}

<b>Adhérent:</b>
{% if is_granted('ROLE_APP_ADMIN_ADHERENT_EDIT') %}
<a href="{{ path('admin_app_administrator_edit', {id: adherent.id}) }}">
{{ adherent.fullName }}
</a>
{% else %}
{{ adherent.fullName }}
{% endif %}
{% else %}
{% if not (key matches '/^\\d+$/') %}
<b>{{ key }}:</b>
{% endif %}

{{ value|json_encode(constant('JSON_PRETTY_PRINT'))|raw }}
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
{% endblock %}
30 changes: 17 additions & 13 deletions templates/admin/user_action_history/list_data.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,32 @@
<ul>
{% for key, value in object.data %}
<li>
{% if not (key matches '/^\\d+$/') %}
<b>{{ key }}:</b>
&nbsp;
{% endif %}
{% if key is same as('adherent_uuid') %}
{% set adherent = get_adherent_by_uuid(value) %}

{% if adherent %}
{{ adherent.emailAddress }}
<b>Adhérent:</b>
{% if is_granted('ROLE_APP_ADMIN_ADHERENT_EDIT') %}
<a href="{{ path('admin_app_administrator_edit', {id: adherent.id}) }}">
{{ adherent.fullName }}
</a>
{% else %}
{{ value }} (inconnu)
{{ adherent.fullName }}
{% endif %}
{% elseif key is same as('role') %}
{{ ('role.' ~ value)|trans }}
{% elseif key is same as('zones') %}
{{ value|join(', ') }}
{% else %}
{{ value|json_encode(constant('JSON_PRETTY_PRINT'))|raw }}
{% if not (key matches '/^\\d+$/') %}
<b>{{ key }}:</b>
{% endif %}

{% if key is same as('role') %}
{{ ('role.' ~ value)|trans }}
{% elseif key is same as('zones') %}
{{ value|join(', ') }}
{% else %}
{{ value|json_encode(constant('JSON_PRETTY_PRINT'))|raw }}
{% endif %}
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}

{% endblock %}

0 comments on commit 4c3632d

Please sign in to comment.