{% extends 'base.html' %}
{% block content %}
<div class="toolbar">
  <h1>Historie: {{ asset.name }}</h1>
  <div class="toolbar-actions">
    <a class="button button-secondary" href="/assets/{{ asset.id }}/history/export.xlsx">Excel exportieren</a>
    <a class="button" href="/assets/{{ asset.id }}">Zurück zum Asset</a>
  </div>
</div>
<p class="table-hint">Jede geänderte Feldbezeichnung wird mit altem und neuem Wert gespeichert.</p>
<div class="table-scroll">
<table class="data-table">
  <thead><tr><th>Zeitpunkt</th><th>Quelle</th><th>Benutzer</th><th>Feld</th><th>Alter Wert</th><th>Neuer Wert</th></tr></thead>
  <tbody>
  {% for entry in entries %}
    {% for label, change in entry.changes.items() %}
    <tr><td>{{ entry.changed_at }}</td><td>{{ entry.source }}</td><td>{{ entry.changed_by or '' }}</td><td>{{ label }}</td><td class="multiline">{{ change.old }}</td><td class="multiline">{{ change.new }}</td></tr>
    {% endfor %}
  {% else %}<tr><td colspan="6" class="empty-state">Noch keine Änderungen protokolliert.</td></tr>{% endfor %}
  </tbody>
</table>
</div>
{% endblock %}
