Class: Netzke::TreePanel

Inherits:
Base
  • Object
show all
Defined in:
lib/netzke/tree_panel.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.js_base_classObject



4
5
6
# File 'lib/netzke/tree_panel.rb', line 4

def self.js_base_class
  "Ext.tree.TreePanel"
end

.js_common_config_for_constructorObject



8
9
10
11
12
13
# File 'lib/netzke/tree_panel.rb', line 8

def self.js_common_config_for_constructor
  super.merge({
    :root => {:text => '/', :id => 'source'},
    :loader => {:data_url => "config.api.getChildren".l}
  })
end

.js_extend_propertiesObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/netzke/tree_panel.rb', line 15

def self.js_extend_properties
  {
    :refresh_handler => <<-END_OF_JAVASCRIPT.l,

    :add_handler => <<-END_OF_JAVASCRIPT.l,

    :edit_handler => <<-END_OF_JAVASCRIPT.l,

    :delete_handler => <<-END_OF_JAVASCRIPT.l
      function(e){
        console.info(e);
      
      }
    END_OF_JAVASCRIPT
  }
end

Instance Method Details

#actionsObject



45
46
47
48
49
50
# File 'lib/netzke/tree_panel.rb', line 45

def actions
  { :add    => {:text => 'Add'},
    :edit   => {:text => 'Edit'},
    :del => {:text => 'Delete', :disabled => true}
  }
end

#bbarObject



52
53
54
# File 'lib/netzke/tree_panel.rb', line 52

def bbar
  persistent_config[:bbar] ||= config[:bbar] == false ? nil : config[:bbar] || %w{ add edit delete }
end

#get_children(params) ⇒ Object



68
69
70
71
72
# File 'lib/netzke/tree_panel.rb', line 68

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


64
65
66
# File 'lib/netzke/tree_panel.rb', line 64

def menu
  persistent_config[:menu] ||= config[:menu] == false ? nil : config[:menu] # || [{:text => 'Button', :menu => ['edit', {:text => 'Submenu', :menu => ['delete']}]}]
end

#tbarObject



60
61
62
# File 'lib/netzke/tree_panel.rb', line 60

def tbar
  persistent_config[:tbar] ||= config[:tbar] == false ? nil : config[:tbar]
end

#toolsObject



56
57
58
# File 'lib/netzke/tree_panel.rb', line 56

def tools
  persistent_config[:tools] ||= config[:tools] == false ? nil : config[:tools] #|| %w{ gear refresh }
end