<div class="page-header">
  <% unless partial?('collection')%>
  <div class="mb1 index-actions">
  	<% if subject.can_create?(collection_name) && controller.action_methods.include?("new") %>
      <%= button t('fullstack.admin.new', :default => "New"), 
                 send("new_admin_#{resource_name}_path"),
                 :type => :primary, :icon => :plus, :icon_color => :white %>
  	<% end %>
  
    <% if subject.can_sort?(collection_name) && positionable?(current_collection.klass) %>
    <%= button t('fullstack.admin.sort', :default => "Sort"), 
                 send("admin_positionables_path", :type => resource_name)
                 %>
  
    <% end %>
  
    <%= button t('fullstack.admin.delete', :default => "Delete"), 
               'javascript:void(0)', :class => "toggle-delete",
               :icon => :trash %>
  </div>
  
  <% end %>

<h1>
<% if content_for?(:title) %>
  <%= yield(:title)  %>

<% elsif @title %>

  <%= @title %>

<% else -%>
  
  <%= t(collection_name, :scope => "fullstack.admin.resources") %>

<% end -%>
</h1>


</div>

<% if partial?('collection') %>
  <%= render :partial => "collection", 
  :locals => { 
    :collection => current_collection,
    :"#{controller_name}" => current_collection
  } 
  %>
<% else %>




<table class="table table-bordered table-striped index-table">
  <thead>
  <tr>
      <%= render :partial => 'index', :locals => {:thead => true, :tbody => false, :content =>  nil} %>
  </tr>
  </thead>
  <tbody>
    <% current_collection.each do |item| -%>
      <tr>
        <%= render :partial => 'index', :locals => {:thead => false, :tbody => true, :content =>  item} %>
      </tr>
    <% end -%>
  </tbody>
  <%= paginate current_collection, :window => 4, :outer_window => 3 %>
</table>

<% end %>

<% content_for :aside do -%>

<% if (!@skip_filter) && (partial?('filter') || title_column(current_resource_class) || has_timestamps?(current_resource_class)) %>
  	<div class="box">
      <div class="box-header">
        <%= t('fullstack.admin.filter', :default => "Filter") %>
      </div>
        
  		<%= admin_form_for @search, :url => self.send("admin_#{collection_name}_path") , :html => {:method => :get} do |f| %>
      <div class="box-content">

      <% if partial?('filter') %>
        <%= render :partial => "filter", :locals => {:f => f} %>
      <% else %>
        <%= f.inputs :class => "filter-inputs"  do %>

        <% if tc = title_column(current_resource_class) %>
            <%=  f.input :"#{tc}_contains" %>
          <% end %>

          <% if has_timestamps?(current_resource_class) %>
            <%=  f.input :created_at, :as => :daterange %>
          <% end %>
          
        <% end %>

      <% end %>
      </div>
      <div class="box-footer align-right">
        <%= f.action t('fullstack.admin.filter', :default => "Filter"), :as => :button %>
      </div>
  		<% end %>
  	</div>
  <% end %>
  
<% end -%>