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

99 lines
3.8 KiB
Plaintext
Raw Normal View History

2015-11-13 13:10:00 +00:00
<% 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">
2015-11-13 13:10:00 +00:00
<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 %>
2015-11-13 13:10:00 +00:00
</form>
2015-11-13 13:10:00 +00:00
<div id="data-table" class="ut-table">
<table class="table main-list">
<thead>
<tr class="sort-header">
<% @table_fields.each do |field| %>
<%
sort = field.to_s.include?('.') ? field.to_s.split('.')[1] : field.to_s
active = params[:sort].eql? sort
order = active ? (["asc", "desc"]-[params[:order]]).first : "asc"
arrow = (order.eql? "desc") ? "<b class='icons-arrow-up-3'></b>" : "<b class='icons-arrow-down-4'></b>"
klass = field.eql?(:title) ? "span5" : "span2"
th_data = "<a href='?sort=#{sort}&order=#{order}'>#{field} #{active ? arrow : ""}</a>"
%>
<th class='<%= klass %> <%= active ? "active" : "" %>'><%= th_data.html_safe %></th>
2015-11-13 13:10:00 +00:00
<% end %>
</tr>
</thead>
<tbody>
2024-07-21 07:25:17 +00:00
<% can_edit = can_edit_or_delete?(@table) %>
2015-11-13 13:10:00 +00:00
<% @entries.each do |entry| %>
<tr>
<% @columns.each_with_index do |column, index| %>
2024-07-21 07:25:17 +00:00
<% ce = entry.column_entries.where(:table_column_id => column.id).first rescue nil %>
2015-11-13 13:10:00 +00:00
<td>
2024-07-21 07:25:17 +00:00
<% if !ce.nil? %>
<% case ce.type %>
<% when "text" %>
<%= ce.text %>
<% when "integer" %>
<%= ce.number %>
<% 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) %>
2015-11-13 13:10:00 +00:00
<% end %>
2024-07-21 07:26:48 +00:00
<% when "file" %>
<% locale = I18n.locale.to_s %>
<ol>
<% ce.column_entry_files.desc(:sort_number).each do |entry_file| %>
<% next unless entry_file.choose_lang_display(locale) %>
<li><%= link_to entry_file.get_file_title, entry_file.file.url, target: "_blank" %></li>
<% end %>
</ol>
2015-11-13 13:10:00 +00:00
<% end %>
2024-07-21 07:25:17 +00:00
<% else %>
&nbsp;
2015-11-13 13:10:00 +00:00
<% end %>
2019-03-08 13:47:03 +00:00
<% if index == 0 && can_edit %>
2015-11-13 13:10:00 +00:00
<div class="quick-edit">
<ul class="nav nav-pills">
2024-08-11 02:16:31 +00:00
<li><a href="<%= admin_universal_table_edit_entry_path(:universal_table_id=> entry.to_param, :page => params[:page]) %>"><%= 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>
2015-11-13 13:10:00 +00:00
</ul>
</div>
<% end %>
</td>
<% 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>