{% import 'macros/form.html' as form %}
{% extends "package/resource_edit_base.html" %}

{% block subtitle %}{{ _('View') }} - {{ h.resource_display_name(res) }}{% endblock %}

{% block page_primary_action %}
  <div class="btn-group">
    <a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#">
      <i class="icon-plus-sign-alt"></i>
      {{ _('New view') }}
      <span class="caret"></span>
    </a>
    <ul class="dropdown-menu">
      {% for option in h.get_allowed_view_types(c.resource, c.pkg_dict)  %}
        {% set url = h.url_for(controller='package', action='edit_view', id=c.pkg_dict.name, resource_id=c.resource.id, view_type=option[0]) %}
        <li><a href="{{ url }}"><i class="icon-{{ option[2] }}"></i> {{ option[1] }}</a></li>
      {% endfor %}
    </ul>
  </div>
  {% resource 'vendor/reorder' %}
{% endblock %}

{% block primary_content_inner %}
  <hr>
  {% if c.views %}
    {% snippet "package/snippets/resource_views_list.html", views=c.views, pkg=pkg, is_edit=true, extra_attributes='data-module = resource-view-reorder data-module-id=' + c.resource.id, extra_class='nav-stacked' %}
  {% else %}
    <p class="empty">{{ _('This resource has no views') }}</p>
  {% endif %}
{% endblock %}
