Skip to content

Commit

Permalink
Add ability to exclude attributes from automatic tables
Browse files Browse the repository at this point in the history
  • Loading branch information
spohlenz committed Oct 31, 2024
1 parent bcd2286 commit bfeffe3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/trestle/table/automatic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def columns
end

def content_columns
admin.default_table_attributes.map.with_index do |attribute, index|
attributes.map.with_index do |attribute, index|
case attribute.type
when :association
Column.new(attribute.association_name, sort: false)
Expand All @@ -30,6 +30,17 @@ def content_columns
def actions_column
ActionsColumn.new
end

private
def attributes
admin.default_table_attributes.reject { |attribute|
exclude?(attribute.name)
}
end

def exclude?(field)
Array(options[:exclude]).include?(field)
end
end
end
end

0 comments on commit bfeffe3

Please sign in to comment.