Module: Netzke::Basepack::ActionColumn

Extended by:
ActiveSupport::Concern
Defined in:
lib/netzke/basepack/action_column.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#column_actionsObject



62
63
64
# File 'lib/netzke/basepack/action_column.rb', line 62

def column_actions
  self.class.registered_column_actions.map{ |action_name| self.send("#{action_name}_column_action")}
end

#initial_columns(with_excluded = false) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/netzke/basepack/action_column.rb', line 40

def initial_columns(with_excluded = false)
  orig_columns = super

  action_column_names = column_actions.map{ |action| action[:column] }.uniq
  action_columns = orig_columns.select{ |c| action_column_names.include? c[:name] }

  # Append the column if none found AND no explicit column configuration was provided
  if action_columns.empty? && !config[:columns]
    action_columns = [{:name => "actions"}.merge(config[:override_columns].try(:fetch, :actions, nil) || {})]
    orig_columns += action_columns
  end

  action_columns.each do |c|
    c[:xtype] = :netzkeactioncolumn
    c[:getter] = lambda do |r|
      self.class.registered_column_actions.select{ |action_name| self.send("#{action_name}_column_action")[:column] == c[:name] }.map{ |action_name| self.send("#{action_name}_column_action", r) }.to_nifty_json
    end
  end

  orig_columns
end