Skip to content

Commit

Permalink
Entry is immutable
Browse files Browse the repository at this point in the history
  • Loading branch information
DamienHarper committed Nov 30, 2020
1 parent 498d686 commit 320c3d2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
18 changes: 9 additions & 9 deletions src/Resources/views/Audit/entry.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@
<article class="timeline-entry">
<div class="timeline-entry-inner">
<time class="timeline-time" datetime="2014-01-10T03:45">
<span>{{ entry.created_at|date('H:i:s') }}</span> <span>{{ entry.created_at|date('l d F Y') }}</span>
<span>{{ entry.getCreatedAt()|date('H:i:s') }}</span> <span>{{ entry.getCreatedAt()|date('l d F Y') }}</span>
</time>

<div class="timeline-icon bg-{{ bootstrap.label_type(entry.type) }}">
{{ bootstrap.icon_type(entry.type) }}
<div class="timeline-icon bg-{{ bootstrap.label_type(entry.getType()) }}">
{{ bootstrap.icon_type(entry.getType()) }}
</div>

<div class="timeline-label">
<div class="row">
<div class="col-lg-8"><h2 class="mb-0">{{ helper.humanize(entity, entry) }}</h2></div>
<div class="col-lg-3" align="right">
{% if entry.transaction_hash is not empty %}
<a href="{{ path('dh_auditor_show_transaction', {hash: entry.transaction_hash}) }}" class="badge badge-pill badge-light font-weight-light transaction-hash" title="{% trans %}audit.audit_details.entry_title{% endtrans %}">
<i class="fas fa-tag"></i>&nbsp;{{ entry.transaction_hash }}
{% if entry.getTransactionHash() is not empty %}
<a href="{{ path('dh_auditor_show_transaction', {hash: entry.getTransactionHash()}) }}" class="badge badge-pill badge-light font-weight-light transaction-hash" title="{% trans %}audit.audit_details.entry_title{% endtrans %}">
<i class="fas fa-tag"></i>&nbsp;{{ entry.getTransactionHash() }}
</a>
{% endif %}
</div>
<div class="col-lg-1" align="center">{{ bootstrap.badge(entry.type, bootstrap.label_type(entry.type)) }}</div>
<div class="col-lg-1" align="center">{{ bootstrap.badge(entry.getType(), bootstrap.label_type(entry.getType())) }}</div>
</div>
{% if entry.type in ['insert', 'update'] %}
{% if entry.getType() in ['insert', 'update'] %}
<table class="table table-hover layout-fixed table-sm mt-2 mb-0">
<thead class="thead-light">
<th width="30%">{% trans %}audit.audit_details.property{% endtrans %}</th>
<th width="35%">{% trans %}audit.audit_details.old_value{% endtrans %}</th>
<th width="35%">{% trans %}audit.audit_details.new_value{% endtrans %}</th>
</thead>
<tbody>
{% set diffs = entry.diffs|json_decode(true) %}
{% set diffs = entry.getDiffs() %}
{% for key, values in diffs %}
<tr>
<td><code>{{ key }}</code></td>
Expand Down
22 changes: 11 additions & 11 deletions src/Resources/views/Audit/helpers/helper.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@
{% macro humanize(entity, entry) %}
{% import _self as helper %}

{% set diffs = entry.diffs|json_decode(true) %}
{% set subject = entity~'#'~entry.object_id %}
{% set diffs = entry.getDiffs() %}
{% set subject = entity~'#'~entry.getObjectId() %}

{% if entry.type == 'insert' %}
{% if entry.getType() == 'insert' %}
{% set action = 'inserted' %}
{% elseif entry.type == 'update' %}
{% elseif entry.getType() == 'update' %}
{% set action = 'updated' %}
{% elseif entry.type == 'remove' %}
{% elseif entry.getType() == 'remove' %}
{% set action = 'deleted' %}
{% set source = diffs %}
{% elseif entry.type == 'associate' %}
{% elseif entry.getType() == 'associate' %}
{% set action = 'associated' %}
{% set source = diffs.source %}
{% set target = diffs.target %}
{% set direction = 'to' %}
{% elseif entry.type == 'dissociate' %}
{% elseif entry.getType() == 'dissociate' %}
{% set action = 'dissociated' %}
{% set source = diffs.source %}
{% set target = diffs.target %}
Expand All @@ -49,7 +49,7 @@
{% set action = '???' %}
{% endif %}

<code><a href="{{ path('dh_auditor_show_entity_history', { 'entity': helper.namespaceToParam(entity), 'id': entry.object_id }) }}" class="code">{{ subject }}</a></code>
<code><a href="{{ path('dh_auditor_show_entity_history', { 'entity': helper.namespaceToParam(entity), 'id': entry.getObjectId() }) }}" class="code">{{ subject }}</a></code>
{% if source is defined and source is not null and subject != source.label %}
<em>({{ source.label }})</em>
{% endif %}
Expand All @@ -61,8 +61,8 @@
(<em>{{ helper.dump(target) }}</em>)
{% endif %}
{% endif %}
by <b>{{ entry.blame_user is null ? 'unknown user' : entry.blame_user }}</b>
{% if entry.ip is not empty %}
, IP: {{ entry.ip }}
by <b>{{ entry.getUsername() is null ? 'unknown user' : entry.getUsername() }}</b>
{% if entry.getIp() is not empty %}
, IP: {{ entry.getIp() }}
{% endif %}
{% endmacro %}

0 comments on commit 320c3d2

Please sign in to comment.