From 8a4922b3e755d561a51634fa0c861dabd7ed4344 Mon Sep 17 00:00:00 2001 From: "Mr. Outis" Date: Tue, 5 Apr 2016 19:03:11 -0500 Subject: [PATCH] Add instance option to add a CSS class for rows As Rails Admin uses Bootstrap, I wanted to use the tables contextual classes in my lists. This is an approach to add classes per list declared in RailsAdmin::Config. --- app/views/rails_admin/main/index.html.haml | 2 +- lib/rails_admin/config/sections/list.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/rails_admin/main/index.html.haml b/app/views/rails_admin/main/index.html.haml index 0756f0166f..441dfd1f5b 100644 --- a/app/views/rails_admin/main/index.html.haml +++ b/app/views/rails_admin/main/index.html.haml @@ -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)} : {})) diff --git a/lib/rails_admin/config/sections/list.rb b/lib/rails_admin/config/sections/list.rb index dbad27cd75..fd2a20a7a7 100644 --- a/lib/rails_admin/config/sections/list.rb +++ b/lib/rails_admin/config/sections/list.rb @@ -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