Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes #83

  • Loading branch information...
commit 6579f002eb0d69e5aaddb199e323fce85873c008 1 parent 1c2e307
@bogdan authored
View
8 lib/datagrid/renderer.rb
@@ -29,14 +29,14 @@ def format_value(grid, column, asset)
def form_for(grid, options = {})
options[:method] ||= :get
options[:html] ||= {}
- options[:html][:class] ||= "datagrid-form #{html_class(grid)}"
+ options[:html][:class] ||= "datagrid-form #{@template.dom_class(grid)}"
@template.render :partial => "datagrid/form", :locals => {:grid => grid, :options => options}
end
def table(grid, *args)
options = args.extract_options!
options[:html] ||= {}
- options[:html][:class] ||= "datagrid #{html_class(grid)}"
+ options[:html][:class] ||= "datagrid #{@template.dom_class(grid)}"
if options[:cycle]
::Datagrid::Utils.warn_once("datagrid_table cycle option is deprecated. Use css to style odd/even rows instead.")
end
@@ -68,10 +68,6 @@ def order_for(grid, column)
@template.render :partial => "datagrid/order_for", :locals => { :grid => grid, :column => column }
end
- def html_class(grid)
- grid.class.to_s.underscore.demodulize
- end
-
def _safe(string)
string.respond_to?(:html_safe) ? string.html_safe : string
end
View
25 spec/datagrid/helper_spec.rb
@@ -50,6 +50,17 @@
"table.datagrid.simple_report" => 1
)
end
+ it "should have namespaced grid class as html class on table" do
+ module ::Ns23
+ class TestGrid
+ include Datagrid
+ scope { Entry }
+ end
+ end
+ subject.datagrid_table(::Ns23::TestGrid.new).should match_css_pattern(
+ "table.datagrid.ns23_test_grid" => 1
+ )
+ end
it "should return data table html" do
datagrid_table = subject.datagrid_table(grid)
@@ -317,7 +328,7 @@ class OrderedGrid
end
end
describe ".datagrid_form_for" do
- it "should render ordering layout" do
+ it "should render form and filter inputs" do
class FormForGrid
include Datagrid
scope { Entry }
@@ -332,8 +343,20 @@ class FormForGrid
"form input[name=commit][value=Search]" => 1
)
end
+ it "should support html classes for grid class with namespace" do
+ module ::Ns22
+ class TestGrid
+ include Datagrid
+ scope { Entry }
+ end
+ end
+ subject.datagrid_form_for(::Ns22::TestGrid.new, :url => "grid").should match_css_pattern(
+ "form.datagrid-form.ns22_test_grid" => 1,
+ )
+ end
end
+
describe ".datagrid_row" do
let(:grid) do
test_report do
View
3  spec/support/simple_report.rb
@@ -9,6 +9,9 @@ def test_report_class(&block)
Class.new.tap do |klass|
klass.class_eval do
include Datagrid
+ def self.name
+ "TestGrid"
+ end
end
if block
klass.class_eval(&block)
Please sign in to comment.
Something went wrong with that request. Please try again.