{% load static %}
{% load i18n %}
{% load mastodon %}
<!DOCTYPE html>
<html lang="zh" class="content-page">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ site_name }} - {{ item.display_title }} - {% trans "revision history" %}</title>
    {% include "common_libs.html" %}
    <style>
      aside details {
        margin-bottom: 1rem;
        padding: 1rem;
        border: var(--pico-muted-color) solid 1px;
      }
      aside summary {
        cursor: pointer;
        font-weight: bold;
      }
      main>div {
        margin-bottom: 4rem;
      }
    </style>
  </head>
  <body>
    {% include "_header.html" %}
    <main>
      <div class="grid__main">
        <h4>{{ item.display_title }} - {% trans "revision history" %}</h4>
        <table class="table table-striped table-bordered">
          <thead>
            <tr style="background:#eee;">
              <th>Field</th>
              <th style="width:40%;">From</th>
              <th style="width:40%;">To</th>
            </tr>
          </thead>
          <tbody>
            {% for log in item.history.all %}
              <tr>
                <td colspan="3">
                  <b title="#{{ log.id }}">
                    {% if request.user.is_staff or log.actor.preference.show_last_edit %}
                      {{ log.actor.username }}
                    {% else %}
                      <i class="fa-solid fa-user-secret"></i>
                    {% endif %}
                  </b>
                  {{ log.get_action_display }} on {{ log.timestamp }}
                </td>
              </tr>
              {% for key, value in log.changes_dict.items %}
                <tr {% cycle 'style="background:#eee;"' '' %}>
                  <td>{{ key }}</td>
                  <td>{{ value.0|default:"-" }}</td>
                  <td>{{ value.1|default:"-" }}</td>
                </tr>
              {% empty %}
                <tr>
                  <td>-</td>
                  <td></td>
                  <td></td>
                </tr>
              {% endfor %}
            {% empty %}
              <p>No history for this item has been logged yet.</p>
            {% endfor %}
          </tbody>
        </table>
      </div>
      <aside class="grid__aside">
        {% include "_sidebar_edit.html" %}
      </aside>
    </main>
    {% include "_footer.html" %}
  </body>
</html>
