Module: FlexaLib::Helpers::TableHelpers

Included in:
FlexaLib::Helpers
Defined in:
lib/flexa_lib/helpers/table_helpers.rb

Instance Method Summary collapse

Instance Method Details

#flexa_table_for(collection, *args, &proc) ⇒ Object

TABLE_HELPERS



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/flexa_lib/helpers/table_helpers.rb', line 6

def flexa_table_for(collection, *args, &proc)
  options = args.extract_options!
  options[:html]={:class=>'table table-striped table-bordered table-condensed'}
  table_for collection, options do |t|
    if options[:actions].present? && options[:actions].count > 0
      t.column :title=>"",:html => { :th => { :width => ((options[:actions].count.to_i*21)).to_s }, :td=>{:class=>"btn_actions"}} do |resource|
        options[:actions].each do |action|
          if [:show,:edit,:delete].include? action
            concat(send("flexa_grid_button_#{action}_to",resource))
          elsif [:select].include? action
            concat(send("flexa_grid_button_select_to",resource,params[:fill]))
          else
            send("#{action}",resource)
          end
        end
      end
    end
    begin
      t.instance_eval(&proc)
    rescue
      concat("")
    end
  end
end