{% extends "page.html" %}

{% set page = c.page %}
{% set item_count = c.page.item_count %}

{% block subtitle %}{{ _('Apps & Ideas') }}{% endblock %}

{% block breadcrumb_content %}
  <li>{{ _('Apps & Ideas') }}</li>
{% endblock %}

{% block primary_content %}
  <article class="module">
    <div class="module-content">
      <h1 class="page-heading">
        {% block page_heading %}{{ _('Apps & Ideas') }}{% endblock %}
      </h1>

      {% block related_items %}
        {% if item_count %}
          {% trans first=page.first_item, last=page.last_item, item_count=item_count %}
            <p>Showing items <strong>{{ first }} - {{ last }}</strong> of <strong>{{ item_count }}</strong> related items found</p>
          {% endtrans %}
        {% elif c.filters.type %}
          {% trans item_count=item_count %}
            <p><strong>{{ item_count }}</strong> related items found</p>
          {% endtrans %}
        {% else %}
          <p class="empty">{{ _('There have been no apps submitted yet.') }}
        {% endif %}
      {% endblock %}

      {% block related_list %}
        {% if page.items %}
          {% snippet "related/snippets/related_list.html", related_items=page.items %}
        {% endif %}
      {% endblock %}
    </div>

    {% block page_pagination %}
      {{ page.pager() }}
    {% endblock %}
  </article>
{% endblock %}

{% block secondary_content %}
  <section class="module module-narrow module-shallow">
    <h2 class="module-heading">{{ _('What are applications?') }}</h2>
    <div class="module-content">
      {% trans %}
        These are applications built with the datasets as well as ideas for
        things that could be done with them.
      {% endtrans %}
    </div>
  </section>

  <section class="module module-narrow module-shallow">
    <h2 class="module-heading">{{ _('Filter Results') }}</h2>
    <form action="" method="get" class="module-content form-inline form-narrow">
      <input type='hidden' name='page' value='1'/>

      <div class="control-group">
        <label for="field-type">{{ _('Filter by type') }}</label>
        <select id="field-type" name="type">
          <option value="">{{ _('All') }}</option>
          {% for option in c.type_options %}
            <option value="{{ option.value }}"{% if c.filters.type == option.value %} selected="selected"{% endif %}>{{ option.text or option.value }}</option>
          {% endfor %}
        </select>
      </div>

      <div class="control-group">
        <label for="field-sort">{{ _('Sort by') }}</label>
        <select id="field-sort" name="sort">
          <option value="">{{ _('Default') }}</option>
          {% for option in c.sort_options %}
            <option value="{{ option.value }}"{% if c.filters.sort == option.value %} selected="selected"{% endif %}>{{ option.text or option.value }}</option>
          {% endfor %}
        </select>
      </div>

      <div class="control-group">
        <label for="field-featured" class="checkbox">
          <input type="checkbox" id="field-featured" name="featured" {% if c.filters.get('featured') == 'on' %} checked="checked"{% endif %}></input>
          {{ _('Only show featured items') }}
        </label>
      </div>

      <div class="form-actions">
        <button class="btn btn-primary">{{ _('Apply') }}</button>
      </div>
    </form>
  </section>
{% endblock %}
