<% title "'#{@table.name}'"%>

Table: <%= @table.name %>

<%= link_to '+ ADD', table_new_path(@table), remote: true, class: 'button small' %>

<%= search_form_for @q, url: table_data_path(@table), method: :get, remote: true, html: { id: 'search_form', class: search_form_class } do |f| %>
Search
<%= f.condition_fields do |c| %> <%= render "condition_fields", f: c %> <% end %>

<%= link_to_add_fields raw("#{fa_icon 'plus'} Add Conditions"), f, :condition %>

Sort: <%= f.sort_fields do |s| %> <%= s.sort_select %> <% end %>
<%= f.submit "Search", class: 'button small' %>
<% end %> <% if @table.primary_key %> <% end %> <% @model.column_names.each do |column| %> <% end %> <% @records.each do |record| %> <%= render 'row', record: record %> <% end %> <% if @records.none? %> <% end %> <% if @records.size > 10 %> <% if @table.primary_key %> <% end %> <% @model.column_names.each do |column| %> <% end %> <% end %>
Actions <%= sort_link @q, column, controller: :tables, action: :data %>
No Records
Actions <%= sort_link @q, column, controller: :tables, action: :data %>

Total: <%= pluralize @records.total_count, 'record' %> SQL

<% if @records.total_count > 10 %>
<%= form_tag table_pagination_path, method: :get, remote: true do %> <%= select_tag :per_page, options_for_select([10, 15, 20, 50, 100, 200, 500], per_page), class: 'per_page_pagination_select' %> <% end %>
<%= paginate @records, remote: true, params: { controller: :tables, action: :data } %>
<% end %>
<%= render 'sql', sql: @sql %>