{% extends "quite_admin/base.html" %} {% from "quite_admin/_filter_controls.html" import add_filter_button, condition_chips with context %} {% macro change_value(text, present, truncated, kind) %} {% if not present %}{{ t('Not present') }} {% elif text is none %}NULL {% elif text == '' %}{{ t('Empty string') }} {% elif kind == 'boolean' %}{{ t('True' if text == 'true' else 'False') }} {% else %}
{{ text }}
{% endif %} {% if truncated %}{{ t('Value truncated') }}{% endif %} {% endmacro %} {% macro action_label(event) %}{% if event.action.startswith('action:') %}{{ history_actions.get(event.action, t('Custom action') ~ ': ' ~ event.action[7:]) }}{% else %}{{ t(history_actions.get(event.action, event.action)) }}{% endif %}{% endmacro %} {% macro record_reference(item) %}{% if item.record_label %}{% if item.record_url %}#{{ item.record_label }} ↗{% else %}#{{ item.record_label }}{% endif %}{% endif %}{% endmacro %} {% macro event_changes(item, expanded=false) %} {% set event = item.event %} {% if item.changes %}
{{ t('Changed fields: {count}', count=item.changes|length) }}{{ item.changes|map(attribute='label')|join(', ') }}
{{ t('Field') }}{{ t('Before') }}{{ t('After') }}
{% for change in item.changes %}
{{ change.label }}{% if change.label != change.name %}{{ change.name }}{% endif %}
{{ t('Before') }}{{ change_value(change.before, change.before_present, change.before_truncated, change.kind) }}
{{ t('After') }}{{ change_value(change.after, change.after_present, change.after_truncated, change.kind) }}
{% endfor %}
{% if item.omitted %}

{{ t('Additional changes omitted: {count}', count=item.omitted) }}

{% endif %}
{% elif item.write %}

{% if event.outcome == 'failure' %}{{ t('Changes were not saved.') }}{% elif event.details is none %}{{ t('Field details were not recorded for this event.') }}{% else %}{{ t('No visible field changes.') }}{% endif %}

{% endif %} {% endmacro %} {% from "quite_admin/_ui.html" import empty_state with context %} {% block content %}

{{ t('Activity journal') }}

{{ t('Activity history') }}

{{ t('Who changed what, with field values before and after.') }}

{{ t('Time (UTC)') }}
{{ t('Filters') }}
{% for subject, label in history_users %}{% endfor %}
{{ add_filter_button(true) }} {% if active_filters %}
{{ condition_chips(active_filters, history_clear_url) }}
{% endif %} {% include 'quite_admin/_history_period.html' %}
{{ t('{count} on this page', count=events|length) }}
{% if history_view == 'table' %}
{% for group in activity_groups %}{% for item in group.events %}{% set event = item.event %} {% endfor %}{% else %}{% endfor %}
{{ t('Time (UTC)') }}{{ t('User') }}{{ t('Collection') }}{{ t('Action') }}{{ t('Result') }}{{ t('Field changes') }}
{{ event.display_name or event.subject }}{% if event.display_name and event.display_name != event.subject %}{{ event.subject }}{% endif %}{{ history_resources[event.collection].label if event.collection else t('Authentication') }}{{ action_label(event) }}
{{ record_reference(item) }}
{{ t('Success' if event.outcome == 'success' else 'Failure') }} {{ event.status_code }}{{ event_changes(item) }}
{% call empty_state('No activity found', 'Choose another user or collection, or clear the filters.', 'empty-state') %}{% if history_filters.action == 'changes' and history_level != 'changes' %}{{ t('Show all activity') }}{% endif %}{% endcall %}
{% else %}
{% for group in activity_groups %}

{{ group.label }}

    {% for item in group.events %}{% set event = item.event %}
  1. {{ action_label(event) }}

    {{ history_resources[event.collection].label if event.collection else t('Authentication') }}{{ record_reference(item) }}
    {{ t('Success' if event.outcome == 'success' else 'Failure') }}{% if event.outcome == 'failure' %} · {{ event.status_code }}{% endif %}
    {{ event_changes(item, item.open) }}
  2. {% endfor %}
{% else %}{% call empty_state('No activity found', 'Choose another user or collection, or clear the filters.', 'history-empty', icon='↻') %}{% if history_filters.action == 'changes' and history_level != 'changes' %}{{ t('Show all activity') }}{% endif %}{% endcall %}{% endfor %}
{% endif %}
{% endblock %}