<% @page_title = t('blacklight.search_history.page_title', :application_name => application_name) %>

<div id="content" class="col-md-12">
<h2 class='page-heading'><%=t('blacklight.search_history.title')%></h2>
<%- if @searches.blank? -%>
  <h3 class='section-heading'><%=t('blacklight.search_history.no_history')%></h3>
<%- else -%>
    <p>
    <%= link_to t('blacklight.search_history.clear.action_title'), blacklight.clear_search_history_path, :method => :delete, :data => { :confirm => t('blacklight.search_history.clear.action_confirm') }, :class => 'btn btn-danger pull-right' %>
    </p>
  <h3 class='section-heading'><%#=t('blacklight.search_history.recent')%>.</h3>


    <div class="panel-group search_history">
    <%-  @searches.each_with_index do |search,index| -%>
    <%= content_tag :div, :id => "document_#{index + 1}", class: 'panel panel-default' do %>
      <div class="panel-body">
        <div class="row">
        <div class="col-sm-8 col-md-9 query"><%= link_to_previous_search(search_state.reset(search.query_params).to_hash) %></div>
        <%- if has_user_authentication_provider? -%>
              <div class="col-sm-4 col-md-3 actions">
          <%- if current_or_guest_user && search.saved? -%>
            <%= button_to t('blacklight.search_history.forget'), blacklight.forget_search_path(search.id), :class => 'btn btn-success' %>
          <%- else -%>
            <%= button_to t('blacklight.search_history.save'), blacklight.save_search_path(search.id), :method => :put, :class => 'btn btn-success' %>
          <%- end -%>
        </div>
      <%- end -%>
      </div>
    </div>
    <% end #content_tag %>
  <%- end -%>
  </div>
<%- end -%>
</div>
