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

{% set logged_in = true if c.userobj else false %}
{% set res = c.resource %}

{% block breadcrumb_edit_selected %}{% endblock %}

{% block content_action %}
  {% link_for _('All views'), controller='package', action='resource_views', id=pkg.name, resource_id=res.id, class_='btn', icon='arrow-left' %}
  {% if res %}
    {% set url = h.url_for(controller='package', action='resource_read', id=pkg.name, resource_id=res.id) ~ '?view_id=' ~ resource_view.id %}
    <a href="{{ url }}" class="btn"><i class="icon-eye-open"></i> {{ _('View view') }}</a>
  {% endif %}
{% endblock %}

{% block content_primary_nav %}{% endblock %}

{% block primary_content_inner %}
  {% block form %}{% endblock %}
{% endblock %}

{% block main_content %}
  {% if h.resource_view_full_page(resource_view) %}
    {{ self.flash() }}
    {{ self.toolbar() }}
    <div class="wrapper no-nav">
      {{ self.primary_content() }}
    </div>
  {% else %}
    {{ super() }}
  {% endif %}

  {% if to_preview and h.resource_view_display_preview(resource_view) %}
    <div class="wrapper no-nav">
      <section class="module module-narrow module-shallow">
        <h2 class="module-heading">
          <i class="icon-picture"></i> {{ _('View preview') }}
        </h2>
        <div class="module-content">
          {% snippet 'package/snippets/resource_view.html', resource_view=resource_view, resource=resource, package=package, to_preview=True %}
        </div>
      </section>
    </div>
  {% endif %}
{% endblock %}

{% block secondary %}
  {% if not h.resource_view_full_page(resource_view) %}
    {{ super() }}
  {% endif %}
{% endblock %}

{% block secondary_content %}
  {% snippet 'package/snippets/view_help.html' %}
{% endblock %}
