{% ckan_extends %}

{% block resource_actions_inner %}
  {{ super() }}
  {% if res.datastore_active %}
    <li>{% snippet 'package/snippets/data_api_button.html', resource=res %}</li>
  {% endif %}
{% endblock %}

{% block download_resource_button %}
{% if res.datastore_active %}
    <button class="btn btn-primary dropdown-toggle" role="button" id="dropdownDownloadFormat" data-bs-toggle="dropdown" aria-expanded="false" aria-label="list of downloadable formats">
        <span class="caret"></span>
      </button>
    <ul class="dropdown-menu" aria-labelledby="dropdownDownloadFormat">
      <li>
        <a class="dropdown-item" href="{{ h.url_for('datastore.dump', resource_id=res.id, bom=True) }}"
          target="_blank" rel="noreferrer"><span>CSV</span></a>
      </li>
      <li>
        <a class="dropdown-item" href="{{ h.url_for('datastore.dump', resource_id=res.id, format='tsv', bom=True) }}"
          target="_blank" rel="noreferrer"><span>TSV</span></a>
      </li>
      <li>
          <a class="dropdown-item" href="{{ h.url_for('datastore.dump', resource_id=res.id, format='json') }}"
          target="_blank" rel="noreferrer"><span>JSON</span></a>
      </li>
      <li>
          <a class="dropdown-item" href="{{ h.url_for('datastore.dump', resource_id=res.id, format='xml') }}"
          target="_blank" rel="noreferrer"><span>XML</span></a>
      </li>
    </ul>
{% endif %}
{% endblock download_resource_button %}

{% block resource_additional_information_inner %}
  {% if res.datastore_active %}
    {% block resource_data_dictionary %}
      {% snippet 'datastore/snippets/dictionary_view.html',
        ddict=h.datastore_dictionary(res.id), res=res %}
    {% endblock %}
  {% endif %}
  {{ super() }}
{% endblock %}

{% block action_manage_inner %}
  {{ super() }}
  {% if res.datastore_active %}
    <li>{% link_for _('Data Dictionary'), named_route='datastore.dictionary', id=pkg.name, resource_id=res.id, class_='btn btn-secondary', icon='code' %}</li>
  {% endif %}
{% endblock %}

{% block scripts %}
  {{ super() }}
  {% asset "ckanext_datastore/datastore" %}
{% endblock %}
