Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/views/rails_admin/main/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
%th.last.shrink
%tbody
- @objects.each do |object|
%tr{class: "#{@abstract_model.param_key}_row"}
%tr{class: "#{@abstract_model.param_key}_row #{@model_config.list.with(object: object).row_css_class}"}
%td
= check_box_tag "bulk_ids[]", object.id, false
- if @other_left_link ||= other_left && index_path(params.except('set').merge(params[:set].to_i != 1 ? {set: (params[:set].to_i - 1)} : {}))
Expand Down
4 changes: 4 additions & 0 deletions lib/rails_admin/config/sections/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class List < RailsAdmin::Config::Sections::Base
register_instance_option :scopes do
[]
end

register_instance_option :row_css_class do
''
end
end
end
end
Expand Down
23 changes: 23 additions & 0 deletions spec/integration/basic/list/rails_admin_basic_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -564,4 +564,27 @@
end
end
end

describe 'Row CSS class' do
before do
RailsAdmin.config do |config|
config.model Team do
list do
row_css_class { 'my_class' }
end
end
end
@teams = [
FactoryGirl.create(:team, color: 'red'),
FactoryGirl.create(:team, color: 'red'),
FactoryGirl.create(:team, color: 'white'),
FactoryGirl.create(:team, color: 'black'),
]
end

it 'appends the CSS class to the model row class' do
visit index_path(model_name: 'team')
expect(page).to have_css('tr.team_row.my_class')
end
end
end