lib/admino/table/presenter.rb in admino-0.0.1 vs lib/admino/table/presenter.rb in admino-0.0.2
- old
+ new
@@ -4,10 +4,11 @@
module Admino
module Table
class Presenter < Showcase::Presenter
attr_reader :collection_klass
+ attr_reader :query
def self.tag_helper(name, tag, options = {})
default_options_method = :"#{name}_html_options"
define_method :"#{name}_tag" do |*args, &block|
@@ -26,20 +27,25 @@
tag_helper :thead, :thead
tag_helper :thead_tr, :tr
tag_helper :tbody, :tbody
tag_helper :tbody_tr, :tr, params: %w(resource index)
- def initialize(collection, klass, context)
- @collection_klass = klass
+ def initialize(*args)
+ context = args.pop
+ collection = args.shift
+
+ @collection_klass = args.shift
+ @query = args.shift
+
super(collection, context)
end
def to_html(options = {}, &block)
table_tag(options) do
thead_tag do
thead_tr_tag do
- row = head_row(collection_klass, view_context)
+ row = head_row(collection_klass, query, view_context)
h.capture(row, nil, &block) if block_given?
row.to_html
end
end <<
tbody_tag do
@@ -62,11 +68,11 @@
def collection
@collection ||= present_collection(object)
end
- def head_row(collection_klass, view_context)
- HeadRow.new(collection_klass, view_context)
+ def head_row(collection_klass, query, view_context)
+ HeadRow.new(collection_klass, query, view_context)
end
def resource_row(resource, view_context)
ResourceRow.new(resource, view_context)
end