Skip to content

Commit

Permalink
Add custom rendering for enums in automatic tables
Browse files Browse the repository at this point in the history
  • Loading branch information
spohlenz committed Oct 20, 2021
1 parent 2d04eed commit b6f813c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/trestle/table/automatic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ def content_columns
case attribute.type
when :association
Column.new(attribute.association_name, sort: false)
when :enum
Column.new(attribute.name, align: :center, sort: attribute.name) do |instance|
if value = instance.public_send(attribute.name)
full_attribute_name = [attribute.name.to_s.pluralize, value].join(".")
status_tag(admin.human_attribute_name(full_attribute_name, default: value.humanize))
end
end
else
Column.new(attribute.name, link: index.zero?, align: (:center if [:datetime, :boolean].include?(attribute.type)))
end
Expand Down

0 comments on commit b6f813c

Please sign in to comment.