{% import 'macro/table.html' as table %}
{% import 'macro/badge.html' as badge %}
{% import 'macro/form.html' as form %}

<div class="alert alert-info m-2" role="alert">This page lists the sets that may need a refresh because they have some of their newer fields containing empty values.</div>
{% if table_collection | length > 0 %}
<div class="alert alert-primary m-2" role="alert">
  <h4 class="alert-heading">Too many sets to refresh individually?</h4>
  <p class="mb-0">
    You can refresh multiple sets at once with
    <a href="{{ url_for('admin_set.refresh_bulk') }}" class="btn btn-primary">
      <i class="ri-refresh-line"></i> Bulk Refresh ({{ table_collection | length }} sets)
    </a>
  </p>
</div>
{% endif %}
<div class="table-responsive-sm">
  <table data-table="true" class="table table-striped align-middle" id="wish">
    <thead>
      <tr>
        <th data-table-no-sort-and-search="true" class="no-sort" scope="col"><i class="ri-image-line fw-normal"></i> Image</th>
        <th scope="col"><i class="ri-hashtag fw-normal"></i> Set</th>
        <th scope="col"><i class="ri-pencil-line fw-normal"></i> Name</th>
        <th scope="col"><i class="ri-shapes-line fw-normal"></i> Parts</th>
        <th data-table-number="true" scope="col"><i class="ri-error-warning-line fw-normal"></i> Empty RGB</th>
        <th data-table-number="true" scope="col"><i class="ri-error-warning-line fw-normal"></i> Empty transparent</th>
        <th data-table-number="true" scope="col"><i class="ri-error-warning-line fw-normal"></i> Empty URL</th>
        <th data-table-number="true" scope="col"><i class="ri-palette-line fw-normal"></i>BrickLink Issues</th>
        <th data-table-no-sort-and-search="true" class="no-sort" scope="col"><i class="ri-settings-4-line fw-normal"></i> Actions</th>
      </tr>
    </thead>
    <tbody>
      {% for item in table_collection %}
        <tr>
          {{ table.image(item.url_for_image(), caption=item.fields.name, alt=item.fields.set) }}
          <td>{{ item.fields.set }} {{ table.rebrickable(item) }}</td>
          <td>{{ item.fields.name }}</td>
          <td>{{ item.fields.number_of_parts }}</td>
          <td>{{ item.fields.null_rgb }}</td>
          <td>{{ item.fields.null_transparent }}</td>
          <td>{{ item.fields.null_url }}</td>
          <td>{{ item.fields.null_bricklink_color_id + item.fields.null_bricklink_color_name + item.fields.null_bricklink_part_num }}</td>
          <td><a href="{{ item.url_for_refresh() }}" class="btn btn-primary" role="button"><i class="ri-refresh-line"></i> Refresh</a></td>
        </tr>
      {% endfor %}
    </tbody>
  </table>
</div>