Module: Netzke::Basepack::ActionColumn::ClassMethods

Defined in:
lib/netzke/basepack/action_column.rb

Instance Method Summary collapse

Instance Method Details

#column_action(name, params = {}) ⇒ Object

Use this method to define column actions in your component, e.g.:

column_action :edit, :icon => "/images/icons/edit.png"

TODO: List all options. TODO: think how it’ll be possible to override individual column_actions (if need to bother at all)



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/netzke/basepack/action_column.rb', line 27

def column_action(name, params = {})
  params[:name] = name
  params[:column] ||= "actions"
  params[:icon] ||= "/extjs/examples/shared/icons/fam/cog.png"
  params[:tooltip] = params[:tooltip].presence || name.to_s.humanize
  params[:handler] ||= "on_#{name}"
  register_column_action(name);
  define_method "#{name}_column_action" do |record=nil| # TODO: this won't work in Ruby 1.8.7
    params[:row_config] && record ? params.merge(params[:row_config].call(record, self)) : params
  end
end

#register_column_action(name) ⇒ Object

Register an action



17
18
19
# File 'lib/netzke/basepack/action_column.rb', line 17

def register_column_action(name)
  self.registered_column_actions |= [name]
end