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> </tr>
</thead> </thead>
<tbody> <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| %> <% @entries.each do |entry| %>
<tr> <tr>
<% @columns.each_with_index do |column, index| %> <% @columns.each_with_index do |column, index| %>
<% ce = entry.column_entries.where(:table_column_id => column.id).first rescue nil %> <% ce = entry.column_entries.where(:table_column_id => column.id).first rescue nil %>
<% if !ce.nil? %>
<td> <td>
<% case ce.type %> <% if !ce.nil? %>
<% when "text" %> <% case ce.type %>
<%= ce.text %> <% when "text" %>
<% when "integer" %> <%= ce.text %>
<%= ce.number %> <% when "integer" %>
<% when "editor" %> <%= ce.number %>
<%= ce.content.html_safe rescue "" %> <% when "editor" %>
<% when "image" %> <%= ce.content.html_safe rescue "" %>
<div class="image-expander"> <% when "image" %>
<% if !ce.image.nil? %> <div class="image-expander">
<a href="<%= ce.image.url %>" target="_blank"><img src="<%= ce.image.thumb.url %>" class="image-preview" /></a> <% 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 %>
</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 %>
<% else %>
&nbsp;
<% end %> <% end %>
<% if index == 0 && can_edit %> <% if index == 0 && can_edit %>
<div class="quick-edit"> <div class="quick-edit">
@ -63,11 +66,6 @@
</div> </div>
<% end %> <% end %>
</td> </td>
<% else %>
<td>
&nbsp;
</td>
<% end %>
<% end %> <% end %>
</tr> </tr>
<% end %> <% end %>