Sha256: 3029a6e75a76d88f2e063855f4c69f857654d8113b076d4d11a3fadc439ade2a
Contents?: true
Size: 1.74 KB
Versions: 9
Compression:
Stored size: 1.74 KB
Contents
class Netzke::TreePanel < Netzke::Base interface :get_children def self.js_base_class "Ext.tree.TreePanel" end def self.js_default_config super.merge({ :root => {:text => '/', :id => 'source'}, :loader => {:data_url => "config.interface.getChildren".l} }) end def self.js_extend_properties { :on_widget_load => <<-JS.l, function(){ } JS :refresh_handler => <<-JS.l, function(){ console.info('refresh!'); } JS :add_handler => <<-JS.l, function(e){ console.info(e); } JS :edit_handler => <<-JS.l, function(e){ console.info(e); } JS :delete_handler => <<-JS.l function(e){ console.info(e); } JS } end def actions { :add => {:text => 'Add'}, :edit => {:text => 'Edit'}, :delete => {:text => 'Delete', :disabled => true} } end def bbar persistent_config[:bbar] ||= config[:bbar] == false ? nil : config[:bbar] || %w{ add edit delete } end def tools persistent_config[:tools] ||= config[:tools] == false ? nil : config[:tools] #|| %w{ gear refresh } end def tbar persistent_config[:tbar] ||= config[:tbar] == false ? nil : config[:tbar] end def menu persistent_config[:menu] ||= config[:menu] == false ? nil : config[:menu] # || [{:text => 'Button', :menu => ['edit', {:text => 'Submenu', :menu => ['delete']}]}] end def get_children(params) klass = config[:data_class_name].constantize node = params[:node] == 'source' ? klass.find_by_parent_id(nil) : klass.find(params[:node].to_i) node.children.map{|n| {:text => n.name, :id => n.id}} end end
Version data entries
9 entries across 9 versions & 1 rubygems