<% provide :title do %><%= t('proposals.index.title') %><% end %>
<% content_for :header_addon do %>
  <%= render "shared/search_form",
             search_path: proposals_path(page: 1),
             i18n_namespace: "proposals.index.search_form" %>
<% end %>

<main>
  <div class="wrap row">
    <div id="proposals" class="proposals-list small-12 medium-9 column">

      <div class="small-12 search-results">
        <% if @search_terms || @advanced_search_terms %>
          <h2>
            <%= page_entries_info @proposals %>
            <% if !@advanced_search_terms %>
              <%= t("proposals.index.search_results", count: @proposals.size, search_term: @search_terms) %>
            <% end %>
          </h2>
        <% elsif @tag_filter %>
          <h2>
            <%= page_entries_info @proposals %>
            <%= t("proposals.index.filter_topic", count: @proposals.size, topic: @tag_filter) %>
          </h2>
        <% elsif params[:retired].present? %>
          <h2><%= t("proposals.index.retired_proposals") %>
        <% end %>
      </div>

      <% if has_banners %>
        <%= render "shared/banner" %>
      <% end %>
      
      <% if @featured_proposals.present? %>
        <div id="featured-proposals" class="row featured-proposals">
          <div class="small-12 column">
            <h2>
              <%= t("proposals.index.featured_proposals") %>
            </h2>
          </div>
          <% @featured_proposals.each do |featured_proposal| %>
            <%= render "featured_proposal", proposal: featured_proposal %>
          <% end %>
        </div>
      <% end %>

      <%= render("shared/advanced_search", search_path: proposals_path(page: 1)) unless params[:retired].present? %>

      <%= render 'shared/order_links', i18n_namespace: "proposals.index" %>

      <div class="show-for-small-only">
        <%= link_to t("proposals.index.start_proposal"), new_proposal_path, class: 'button expanded' %>
      </div>

      <%= render partial: 'proposals/proposal', collection: @proposals %>
      <%= paginate @proposals %>
    </div>

    <div class="small-12 medium-3 column">
      <aside class="margin-bottom">
        <%= link_to t("proposals.index.start_proposal"), new_proposal_path, class: 'button expanded' %>
        <% if params[:retired].blank? %>
            <%= render "shared/tag_cloud", taggable: 'proposal' %>
            <%= render 'categories' %>
            <%= render 'geozones' %>
            <%= render 'popular' %>
          <% end %>
          <%= render 'retired' %>
      </aside>
    </div>

  </div>
</main>
