netzke-basepack 0.3.5 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,43 +0,0 @@
1
- module Netzke
2
- # GUI for Preference class
3
- class PreferenceGrid < PropertyGrid
4
- def initialize(*args)
5
- super
6
- config[:default_properties] ||= []
7
- NetzkePreference.widget_name = config[:host_widget_name]
8
-
9
- # Create default properties
10
- config[:default_properties].each do |p|
11
- NetzkePreference[p[:name]] = p[:value] if NetzkePreference[p[:name]].nil?
12
- end
13
- end
14
-
15
- def load_source(params = {})
16
- # config[:data_class_name] = 'NetzkePreference'
17
- config[:conditions] ||= {}
18
-
19
- data_class = NetzkePreference
20
- records = data_class.find(:all, :conditions => {:widget_name => config[:host_widget_name]})
21
-
22
- NetzkePreference.widget_name = config[:host_widget_name]
23
-
24
- source = {}
25
- records.each do |r|
26
- source.merge!(r.name => NetzkePreference[r.name])
27
- end
28
-
29
- {:source => source}
30
- end
31
-
32
- def submit_source(params = {})
33
- data = JSON.parse(params[:data])
34
- NetzkePreference.widget_name = config[:host_widget_name]
35
- data.each_pair do |k,v|
36
- NetzkePreference[k.underscore] = v
37
- end
38
-
39
- {:success => true, :flash => @flash}
40
- end
41
-
42
- end
43
- end
@@ -1,60 +0,0 @@
1
- module Netzke
2
- #
3
- # Ext.grid.PropertyGrid
4
- #
5
- class PropertyGrid < Base
6
- interface :load_source, :submit_source
7
-
8
- def initialize(*args)
9
- super
10
- @config = {:ext_config => {}}.merge(@config)
11
- end
12
-
13
- def self.js_base_class
14
- "Ext.grid.PropertyGrid"
15
- end
16
-
17
- def actions
18
- [{
19
- :text => 'Apply', :handler_name => 'submit', :id => 'apply'
20
- }]
21
- end
22
-
23
- def self.js_default_config
24
- super.merge({
25
- :bbar => "config.actions".l
26
- })
27
- end
28
-
29
- def self.js_extend_properties
30
- {
31
- :submit => <<-JS.l,
32
- function() {
33
- Ext.Ajax.request({
34
- url:this.initialConfig.interface.submitSource,
35
- params:{data:Ext.encode(this.getSource())},
36
- scope:this
37
- })
38
- }
39
- JS
40
- :on_widget_load => <<-JS.l,
41
- function(){
42
- this.loadSource()
43
- }
44
- JS
45
- :load_source => <<-JS.l,
46
- function(){Ext.Ajax.request({
47
- url:this.initialConfig.interface.loadSource,
48
- success:function(r){
49
- var m = Ext.decode(r.responseText);
50
- this.setSource(m.source);
51
- // this.feedback(m.flash);
52
- },
53
- scope:this
54
- })}
55
- JS
56
- }
57
- end
58
-
59
- end
60
- end