universal_table/app/views/admin/universal_tables/show.html.erb

82 lines
2.6 KiB
Plaintext

<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "universal_table/universal-table" %>
<% end %>
<form class="form-search" action="<%= admin_universal_table_path(@table) %>" method="get">
<input type="text" name="q" class="input-large search-query" placeholder="Search from text or editor columns">
<button type="submit" class="btn btn-primary">Search</button>
<% if params[:q].present? %>
<a href="<%= admin_universal_table_path(@table) %>" class="btn btn-info">Reset</a>
<% end %>
</form>
<div id="data-table" class="ut-table">
<table class="table main-list">
<thead>
<tr class="sort-header">
<% @table_fields.each do |f| %>
<%= thead(f) %>
<% end %>
</tr>
</thead>
<tbody>
<% @entries.each do |entry| %>
<tr>
<% @columns.each_with_index do |column, index| %>
<% ce = entry.column_entries.where(:table_column_id => column.id).first rescue nil %>
<% if !ce.nil? %>
<td>
<% case ce.type %>
<% when "text" %>
<%= ce.text %>
<% when "editor" %>
<%= ce.content.html_safe rescue "" %>
<% when "image" %>
<div class="image-expander">
<% if !ce.image.nil? %>
<a href="<%= ce.image.url %>" target="_blank"><img src="<%= ce.image.thumb.url %>" class="image-preview" /></a>
<% end %>
</div>
<% when "date" %>
<%= format_date(ce.date, column.date_format) %>
<% when "period" %>
<% if !ce.period_from.nil? %>
<%= format_date(ce.period_from, column.date_format) %> ~ <%= format_date(ce.period_to, column.date_format) %>
<% end %>
<% end %>
<% if index == 0 %>
<div class="quick-edit">
<ul class="nav nav-pills">
<li><a href="<%= admin_universal_table_edit_entry_path(entry) %>"><%= t(:edit) %></a></li>
<li><a href="<%= admin_universal_table_delete_entry_path(entry.id) %>" class="delete text-error" data-method="delete" data-confirm="Are you sure?"><%= t(:delete_) %></a></li>
</ul>
</div>
<% end %>
</td>
<% else %>
<td>
&nbsp;
</td>
<% end %>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
<div class="bottomnav clearfix">
<%= content_tag :div, paginate(@entries), class: "pagination pagination-centered" %>
<div class="action pull-right">
<a href="<%= admin_universal_table_new_entry_path(@table) %>" class="btn btn-primary" role="button" data-toggle="modal">Add Entry</a>
</div>
</div>