<ul class="nav nav-tabs">
  <li class=active> <%%= link_to tag_icon(:list, pat(:list)), url(:<%= @orm.name_plural %>, :index) %></li>
  <li> <%%= link_to tag_icon(:plus, pat(:new)), url(:<%= @orm.name_plural  %>, :new) %></li>
</ul>
<div class=tabs-content>
  <table id=list class="table table-striped table-hover table-condensed">
    <thead>
      <tr>
        <th class="header list-menu">
          <div class=dropdown>
            <a href="#" class="list-menu-toggle dropdown-toggle" data-toggle='dropdown'>
              <%%= tag_icon :magic %> <span class=caret></span>
            </a>
            <ul class="list-menu dropdown-menu" role=menu>
              <li class=ist-menu-wrapper>
                <%%= link_to tag_icon('check-square-o', pat(:select_all)), '#', :id => 'select-all', :class => 'list-menu-link' %>
              </li>
              <li class=list-menu-wrapper.list-menu-wrapper-disabled>
                <%%= link_to tag_icon('square-o', pat(:deselect_all)), '#', :id => 'deselect-all', :class => 'list-menu-link list-menu-link-disabled' %>
              </li>
              <li class="list-menu-divider divider"></li>
              <li class=list-menu-wrapper.list-menu-wrapper-disabled>
                <%%=link_to tag_icon('trash-o', pat(:delete_selected)), '#', :id => 'delete-selected', :class => 'list-menu-link list-menu-link-disabled' %>
                <div class='list-menu-popover-delete-selected popover right'>
                  <div class=arrow></div>
                  <h3 class=popover-title><%%= pat(:delete_selected_title) %></h3>
                  <div class=popover-content>
                    <%% form_tag url(:<%= @orm.name_plural %>, :destroy_many), :method => :delete do %>
                      <%%=hidden_field_tag :<%= @orm.name_singular %>_ids, :'data-delete-many-ids' => true %>
                      <%%=submit_tag pat(:delete), :class =>'list-menu-popover-delete-selected-btn btn btn-danger btn-small' %>
                      <div class='btn btn-default btn-small cancel'><%%= pat(:cancel) %></div>
                    <%% end %>
                  </div>
                </div>
              </li>
            </ul>
          </div>
        </th>
        <% @orm.columns.each_with_index do |column, i| -%>
        <th class=header> <%%= mat(:<%= @orm.name_singular %>, :<%= column.name %>) %></th>
        <% end -%>
        <th class="header list-row-action-header"></th>
      </tr>
    </thead>

    <tbody>
      <%% @<%= @orm.name_plural %>.each do |<%= @orm.name_singular %>| %>
        <tr class=list-row>
          <td class="list-column list-selectable">
            <%%= check_box_tag '<%= @orm.name_singular %>_ids[]', :value => <%= @orm.name_singular %>.id, :class => 'list-selectable-checkbox' %>
           </td>
          <%- @orm.columns.each_with_index do |column, i| -%>
          <%- if column.name == "created_at" || column.name == "updated_at" -%>
          <td class=list-column> <%%= time_ago_in_words <%= @orm.name_singular %>.<%= column.name %> %></td>
          <%- elsif column.type == :boolean -%>
          <td class=list-column> <%%= <%= @orm.name_singular %>.<%= column.name %> ? tag_icon(:ok) : tag_icon(:remove) %> </td>
          <%- else -%>
          <td class=list-column> <%%= <%= @orm.name_singular %>.<%= column.name %> %> </td>
          <%- end -%>
          <%- end -%>
          <td class="list-column list-row-action">
            <div class='list-row-action-wrapper'>
               <%%= link_to tag_icon(:edit), :href => url(:<%= @orm.name_plural %>, :edit, :id => <%= @orm.name_singular %>.id), :rel => :tooltip, :title => "#{pat(:edit)} <%= @orm.name_singular %>", :class => 'list-row-action-wrapper-link' %>
               <%%= link_to tag_icon('trash-o'), :rel => :tooltip, :title => "#{pat(:delete)} <%= @orm.name_singular %>", :class => 'list-row-action-delete-one list-row-action-wrapper-link' %>
               <div class="popover list-row-action-popover-delete-one left">
                 <div class=arrow> </div>
                 <h3 class=popover-title><%%= pat(:delete, :model => "<%= @orm.name_singular %>") %></h3>
                 <div class=popover-content>
                   <%%- form_tag url(:<%= @orm.name_plural %>, :destroy, :id => <%= @orm.name_singular %>.id), :method => :delete do %>
                     <%%= submit_tag pat(:delete), :class =>'list-row-action-popover-delete-one-btn btn btn-danger btn-small' %>
                     <div class="btn btn-default btn-small cancel"><%%= pat(:cancel) %></div>
                   <%% end %>
                 </div>
               </div>
             </div>
          </td>
        </tr>
      <%% end %>
    </tbody>
  </table>
</div>
