{% extends 'base.html' %}
{% block content %}
<div class="toolbar">
  <div>
    <h1>{{ t('duplicates.preview_title') }}</h1>
    <p class="muted">{{ t('duplicates.preview_help').format(id=assets[0].id) }}</p>
  </div>
</div>

<div class="panel">
  <h2>{{ t('duplicates.result') }}</h2>
  <table class="data-table">
    <thead><tr><th>{{ t('common.field') }}</th><th>{{ t('duplicates.result') }}</th><th>{{ t('duplicates.source') }}</th></tr></thead>
    <tbody>
    {% for item in preview %}
      <tr><td>{{ item.label }}</td><td class="multiline">{{ item.value }}</td><td>Asset {{ item.source_asset_id }}</td></tr>
    {% endfor %}
    </tbody>
  </table>
</div>

<div class="panel">
  <h2>{{ t('common.order') }}</h2>
  <ol>
  {% for asset in assets %}
    <li><strong>Asset {{ asset.id }}</strong> – {{ asset.name }}{% if loop.first %} ({{ t('duplicates.survives') }}){% else %} ({{ t('duplicates.will_delete') }}){% endif %}</li>
  {% endfor %}
  </ol>
</div>

<form method="post" action="/assets/merge/apply" onsubmit="return confirm({{ t('duplicates.confirm_apply')|tojson }});">
  {% for asset in assets %}<input type="hidden" name="asset_ids" value="{{ asset.id }}">{% endfor %}
  <div class="form-actions">
    <button type="button" class="button button-secondary" onclick="history.back()">{{ t('duplicates.change_order') }}</button>
    <button type="submit" class="button button-danger">{{ t('duplicates.merge_save') }}</button>
  </div>
</form>
{% endblock %}
