{% from 'macros/dataset-part.html' import dataset_part_collapsible, add_parts %}
{% if dataset %}
<div id="dataset-{{dataset.slug}}-parts-upload-container"></div>
<div id="dataset-{{dataset.slug}}-parts" class="dataset-parts dataset-parts-table collapsible-table">
  {% else %}
<div id="dataset-parts" class="dataset-parts dataset-parts-table collapsible-table{% if review %} review{% endif %}">
{% endif %}
{% if parts | length == 0 %}
  <span>No dataset parts</span>
{% else %}
    {% if pages %}
    {% with swap_target="#dataset-parts" %}
    {% include 'includes/pagination-buttons.html' %}
    {% endwith %}
    {% endif %}
    <div class="table-head">
      <span class="marker"></span>
      <span class="col-slug">
          slug
      </span>
      <span class="col-created">
          created
      </span>
      {% if review %}<span></span><span></span>
      {% else %}
      <div class="upload-batch-button">
        <form id="dataset-parts-{{ dataset.slug }}-batch-upload-form"
              class="color-strip primary"
              hx-get="/datasets/{{ dataset.slug }}/upload/start"
              hx-target="#dataset-{{dataset.slug}}-parts-upload-container"
              hx-ext="form-json"
        >
          <button class="angled-button button upload-button" type="submit">Upload</button>
        </form>
      </div>
      {% endif %}
    </div>
  {% for part in parts if part.visible_to(current_account) %}
  {{ dataset_part_collapsible(part, dataset, current_account, config, review) }}
  {% endfor %}
  {% if pages %}
  {% with swap_target="#dataset-parts" %}
  {% include 'includes/pagination-buttons.html' %}
  {% endwith %}
  {% endif %}
{% endif %}
</div>
{% if current_account and not review %}
{{ add_parts(dataset) }}
{% endif %}