{% extends "package/edit_base.html" %}

{% set has_reorder = c.pkg_dict and c.pkg_dict.resources and c.pkg_dict.resources|length > 0 %}

{% block subtitle %}{{ _('Resources') }} - {{ h.dataset_display_name(pkg) }}{% endblock %}

{% block page_primary_action %}
  {% link_for _('Add new resource'), controller='package', action='new_resource', id=c.pkg_dict.name, class_='btn btn-primary', icon='plus' %}
{% endblock %}

{% block primary_content_inner %}
  {% if pkg.resources %}
    <ul class="resource-list"{% if has_reorder %} data-module="resource-reorder" data-module-id="{{ pkg.id }}"{% endif %}>
      {% set can_edit = h.check_access('package_update', {'id':pkg.id }) %}
      {% for resource in pkg.resources %}
        {% snippet 'package/snippets/resource_item.html', pkg=pkg, res=resource, url_is_edit=true, can_edit=can_edit %}
      {% endfor %}
    </ul>
  {% else %}
    {% trans url=h.url_for(controller='package', action='new_resource', id=pkg.name) %}
      <p class="empty">This dataset has no data, <a href="{{ url }}">why not add some?</a></p>
    {% endtrans %}
  {% endif %}
{% endblock %}

{% block scripts %}
  {{ super() }}
  {% if has_reorder %}
    {% resource 'vendor/reorder' %}
  {% endif %}
{% endblock %}
