Improve user interface showing a change log entry
Don't use <label> tags for things that are not labels, add a proper <title> for the page, add a back link, remove an unnecessary `inline-block` style for a header, localize dates and field names, ... The interface could be further improve: proper diffs for long texts, better separation between fields, ...
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
module AuditsHelper
|
||||
def truncate_audit_value(resource, field, value)
|
||||
truncate(audit_value(resource, field, value), length: 50)
|
||||
end
|
||||
|
||||
def audit_value(resource, field, value)
|
||||
if value.is_a?(Array)
|
||||
truncate(value.join(","), length: 50)
|
||||
value.join(",")
|
||||
elsif resource.type_for_attribute(field.to_s).type == :boolean
|
||||
resource.class.human_attribute_name("#{field}_#{value}")
|
||||
else
|
||||
truncate(value.to_s, length: 50)
|
||||
value.to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
<h2 class="inline-block"><%= t("admin.audits.title") %></h2>
|
||||
<% provide(:title) do %>
|
||||
<%= t("admin.audits.title") %>
|
||||
<% end %>
|
||||
<%= back_link_to polymorphic_path([:admin, *resource_hierarchy_for(@audit.associated || @audit.auditable)]) %>
|
||||
|
||||
<label><strong><%= t("admin.audits.id") %></strong></label>
|
||||
<p><%= @audit.id %></p>
|
||||
<h2><%= t("admin.audits.title") %></h2>
|
||||
|
||||
<p><strong><%= t("admin.audits.edited_at") %></strong> <%= l @audit.created_at.to_date %></p>
|
||||
<p><strong><%= t("admin.audits.edited_by") %></strong> <%= @audit.user&.name %></p>
|
||||
|
||||
<h3><%= t("admin.audits.changes") %></h3>
|
||||
|
||||
<% @audit.audited_changes.each do |field, (old_value, new_value)| %>
|
||||
<label><strong><%= t("admin.audits.field") %></strong></label>
|
||||
<p><%= field %></p>
|
||||
<label><strong><%= t("admin.audits.old_value") %></strong></label>
|
||||
<p><%= old_value %></p>
|
||||
<label><strong><%= t("admin.audits.new_value") %></strong></label>
|
||||
<p><%= new_value %></p>
|
||||
<strong><%= t("admin.audits.field") %></strong>
|
||||
<p><%= sanitize(@audit.auditable.class.human_attribute_name(field)) %></p>
|
||||
<strong><%= t("admin.audits.old_value") %></strong>
|
||||
<p><%= wysiwyg(audit_value(@audit.auditable, field, old_value)) %></p>
|
||||
<strong><%= t("admin.audits.new_value") %></strong>
|
||||
<p><%= wysiwyg(audit_value(@audit.auditable, field, new_value)) %></p>
|
||||
<% end %>
|
||||
|
||||
<label><strong><%= t("admin.audits.edited_at") %></strong></label>
|
||||
<p><%= @audit.created_at.to_date %></p>
|
||||
<strong><%= t("admin.audits.edited_by") %></strong>
|
||||
<label><strong><%= t("admin.audits.edited_by") %></strong></label>
|
||||
<p><%= @audit.user&.name %></p>
|
||||
|
||||
@@ -1583,6 +1583,7 @@ en:
|
||||
submit_card: Save card
|
||||
audits:
|
||||
title: "Change Log"
|
||||
changes: "List of changes"
|
||||
id: "ID"
|
||||
field: "Field"
|
||||
new_value: "New Value"
|
||||
|
||||
@@ -1582,6 +1582,7 @@ es:
|
||||
submit_card: Guardar tarjeta
|
||||
audits:
|
||||
title: "Historial"
|
||||
changes: "Lista de cambios"
|
||||
id: "ID"
|
||||
field: "Campo"
|
||||
new_value: "Valor nuevo"
|
||||
|
||||
Reference in New Issue
Block a user