Fix edit button in backend show page.

This commit is contained in:
邱博亞 2024-07-21 15:25:17 +08:00
parent d202a8ad0a
commit 0a3fc812c4
1 changed files with 23 additions and 25 deletions

View File

@ -27,32 +27,35 @@
</tr>
</thead>
<tbody>
<% can_edit = can_edit_or_delete?(@entries.first.u_table) if !(@entries.first.nil?) %>
<% can_edit = can_edit_or_delete?(@table) %>
<% @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? %>
<% ce = entry.column_entries.where(:table_column_id => column.id).first rescue nil %>
<td>
<% 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>
<% 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) %>
<% 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 %>
<% else %>
&nbsp;
<% end %>
<% if index == 0 && can_edit %>
<div class="quick-edit">
@ -63,11 +66,6 @@
</div>
<% end %>
</td>
<% else %>
<td>
&nbsp;
</td>
<% end %>
<% end %>
</tr>
<% end %>