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.
data/CHANGELOG CHANGED
@@ -1,5 +1,15 @@
1
+ v0.3.6
2
+ Netzke-core v0.2.9 compatibility
3
+ Cleaner handling of custom renderers in GridPanel.
4
+ New FormPanel-based PropertyEditor replaces PropertyGrid.
5
+ Xcheckbox and check-column introduced.
6
+ TODO file added.
7
+ Bug fix: in TableEditor, the grid now responses on events also after being reconfigured.
8
+ Bug fix: a couple of IE-related bugs.
9
+ Significant code clean-up.
10
+
1
11
  v0.3.5
2
- netzke-core v0.2.8 compatibility
12
+ Netzke-core v0.2.8 compatibility
3
13
 
4
14
  v0.3.4
5
15
  Quick tips added to the "tools"
data/Manifest CHANGED
@@ -1,5 +1,4 @@
1
1
  CHANGELOG
2
- css/basepack.css
3
2
  generators/netzke_basepack/netzke_basepack_generator.rb
4
3
  generators/netzke_basepack/USAGE
5
4
  generators/netzke_form_panel/netzke_form_panel_generator.rb
@@ -15,30 +14,33 @@ lib/netzke/accordion_panel.rb
15
14
  lib/netzke/ar_ext.rb
16
15
  lib/netzke/basic_app.rb
17
16
  lib/netzke/border_layout_panel.rb
17
+ lib/netzke/configuration_tool.rb
18
18
  lib/netzke/container.rb
19
19
  lib/netzke/db_fields.rb
20
20
  lib/netzke/fields_configurator.rb
21
21
  lib/netzke/form_panel.rb
22
22
  lib/netzke/form_panel_extras/interface.rb
23
+ lib/netzke/form_panel_extras/javascripts/xcheckbox.js
23
24
  lib/netzke/form_panel_extras/javascripts/xdatetime.js
24
25
  lib/netzke/form_panel_extras/js_builder.rb
25
26
  lib/netzke/grid_panel.rb
26
27
  lib/netzke/grid_panel_extras/interface.rb
27
- lib/netzke/grid_panel_extras/javascripts/check_column.js
28
+ lib/netzke/grid_panel_extras/javascripts/check-column.js
28
29
  lib/netzke/grid_panel_extras/javascripts/filters.js
29
30
  lib/netzke/grid_panel_extras/js_builder.rb
30
31
  lib/netzke/panel.rb
31
- lib/netzke/preference_grid.rb
32
- lib/netzke/properties_tool.rb
33
- lib/netzke/property_grid.rb
32
+ lib/netzke/property_editor.rb
33
+ lib/netzke/property_editor_extras/helper_model.rb
34
34
  lib/netzke/tab_panel.rb
35
35
  lib/netzke/table_editor.rb
36
+ lib/netzke/tree_panel.rb
36
37
  lib/netzke/wrapper.rb
37
38
  lib/netzke-basepack.rb
38
39
  LICENSE
39
40
  Manifest
40
41
  Rakefile
41
42
  README.rdoc
43
+ stylesheets/basepack.css
42
44
  tasks/netzke_basepack_tasks.rake
43
45
  test/app_root/app/controllers/application.rb
44
46
  test/app_root/app/models/book.rb
@@ -82,4 +84,5 @@ test/grid_panel_test.rb
82
84
  test/netzke_basepack_test.rb
83
85
  test/schema.rb
84
86
  test/test_helper.rb
87
+ TODO
85
88
  uninstall.rb
data/README.rdoc CHANGED
@@ -84,4 +84,4 @@ TODO: this part will be covered later
84
84
  = Credentials
85
85
  Testing done with the help of http://github.com/pluginaweek/plugin_test_helper
86
86
 
87
- Copyright (c) 2008-2009 Sergei Kozlov, released under the GNU GPL license v3
87
+ Copyright (c) 2008-2009 Sergei Kozlov, released under the LGPL 3.0
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ Echoe.new("netzke-basepack") do |p|
5
5
  p.email = "sergei@writelesscode.com"
6
6
  p.summary = "Base Netzke widgets - grid, form, tree, and more"
7
7
  p.url = "http://writelesscode.com"
8
- p.runtime_dependencies = ["searchlogic >=1.6.2", "netzke-core >= 0.2.8"]
8
+ p.runtime_dependencies = ["searchlogic >=1.6.2", "netzke-core >= 0.2.9"]
9
9
  p.development_dependencies = []
10
10
  p.test_pattern = 'test/**/*_test.rb'
11
11
 
data/TODO ADDED
@@ -0,0 +1 @@
1
+ * GridPanel. Reordering of grid columns may lead to unpredictable results when data from an "outdated" table (e.g. open in another browser) gets submitted. A mechanism is needed to submit updated data along with the field names - as hash (as done is FormPanel), *not* as array.
@@ -57,19 +57,23 @@ Ext.netzke.editors = {
57
57
  };
58
58
 
59
59
  Ext.netzke.renderer = function(renderer, c, config){
60
- res = Ext.emptyFn;
61
- switch (renderer) {
60
+ res = null; // null-renderer means "no renderer"
61
+
62
+ if (renderer){
63
+ switch (renderer) {
62
64
 
63
- // custom renderers can be later added like this:
64
- case 'my_renderer':
65
- res = function(value){ return "Not implemented" };
66
- break
65
+ // more renderers can be later added like this:
66
+ case 'my_renderer':
67
+ res = function(value){ return "My renderer: " + value };
68
+ break
67
69
 
68
- // falls back to Ext.util.Format renderers
69
- default:
70
- res = Ext.util.Format[renderer]
71
- break
70
+ // falls back to Ext.util.Format renderers
71
+ default:
72
+ res = Ext.util.Format[renderer] ? Ext.util.Format[renderer] : function(value){return "Unknown renderer"}
73
+ break
74
+ }
72
75
  }
76
+
73
77
  return res
74
78
  }
75
79
 
@@ -109,4 +113,4 @@ Ext.data.RecordArrayReader = Ext.extend(Ext.data.JsonReader, {
109
113
  record.json = n;
110
114
  return record;
111
115
  }
112
- });
116
+ });
@@ -1,3 +1,5 @@
1
+ require 'netzke/ar_ext'
2
+
1
3
  class NetzkeGridPanelColumn < ActiveRecord::Base
2
4
  belongs_to :layout, :class_name => "NetzkeLayout"
3
5
 
@@ -4,11 +4,6 @@ require 'searchlogic'
4
4
 
5
5
  require 'netzke/ar_ext'
6
6
 
7
- # Default boot config
8
- Netzke::Base.config.merge!({
9
- :grid_panel => {:filters => true}
10
- }.recursive_merge(Object.const_defined?(:NETZKE_BOOT_CONFIG) ? Object.const_get(:NETZKE_BOOT_CONFIG) : {}))
11
-
12
7
  %w{ models }.each do |dir|
13
8
  path = File.join(File.dirname(__FILE__), 'app', dir)
14
9
  $LOAD_PATH << path
@@ -19,8 +14,7 @@ end
19
14
  # Make this plugin reloadable for easier development
20
15
  ActiveSupport::Dependencies.load_once_paths.delete(File.join(File.dirname(__FILE__)))
21
16
 
22
- # Include the javascript
17
+ # Include javascript & styles required by all basepack widgets.
18
+ # These files will get loaded at the initial load of the framework (along with Ext and Netzke-core).
23
19
  Netzke::Base.config[:javascripts] << "#{File.dirname(__FILE__)}/../javascripts/basepack.js"
24
-
25
- # Include CSS
26
- Netzke::Base.config[:css] << "#{File.dirname(__FILE__)}/../css/basepack.css"
20
+ Netzke::Base.config[:stylesheets] << "#{File.dirname(__FILE__)}/../stylesheets/basepack.css"
@@ -7,7 +7,7 @@ module Netzke
7
7
  # * Gets loaded along with the widget that is to be put into the active (expanded) panel (saves us a server request)
8
8
  #
9
9
  # TODO:
10
- # * Stores the last active panel in the persistent_configuration
10
+ # * Stores the last active panel in persistent_config
11
11
  #
12
12
  class AccordionPanel < Base
13
13
  #
@@ -69,6 +69,17 @@ module Netzke
69
69
  JS
70
70
  :scope => this
71
71
  }
72
+ else
73
+ res << "->" <<
74
+ {
75
+ :text => "Login",
76
+ :handler => <<-JS.l,
77
+ function(){
78
+ window.location = "/login"
79
+ }
80
+ JS
81
+ :scope => this
82
+ }
72
83
  end
73
84
  res
74
85
  end
@@ -76,20 +87,6 @@ module Netzke
76
87
  def js_extend_properties
77
88
  super.merge({
78
89
 
79
- :logout => <<-JS.l,
80
- function(){
81
- window.location = "#{config[:logout_url]}"
82
- }
83
- JS
84
-
85
- # Work around to fire "appLoaded" event only once
86
- :on_after_layout => <<-JS.l,
87
- function(){
88
- this.un('afterlayout', this.onAfterLayout, this); // avoid multiple calls
89
- this.appLoaded();
90
- }
91
- JS
92
-
93
90
  # Initialize
94
91
  :app_loaded => <<-JS.l,
95
92
  function(){
@@ -106,9 +103,51 @@ module Netzke
106
103
  var lastLoaded = this.initialConfig.widgetToLoad; // passed from the server
107
104
  if (lastLoaded) Ext.History.add(lastLoaded);
108
105
  }
106
+
107
+ if (this.initialConfig.menu) {this.addMenu(this.initialConfig.menu, this);}
109
108
  }
110
109
  JS
111
110
 
111
+ :host_menu => <<-JS.l,
112
+ function(menu, owner){
113
+ var toolbar = this.getComponent('main-toolbar');
114
+ if (!this.menus[owner.id]) this.menus[owner.id] = [];
115
+ Ext.each(menu, function(item) {
116
+ var newMenu = new Ext.Toolbar.Button(item);
117
+ var position = toolbar.items.getCount() - 2;
118
+ position = position < 0 ? 0 : position;
119
+ toolbar.insertButton(position, newMenu);
120
+ this.menus[owner.id].push(newMenu);
121
+ }, this);
122
+ }
123
+ JS
124
+
125
+ :unhost_menu => <<-JS.l,
126
+ function(owner){
127
+ var toolbar = this.getComponent('main-toolbar');
128
+ if (this.menus[owner.id]) {
129
+ Ext.each(this.menus[owner.id], function(menu){
130
+ toolbar.items.remove(menu); // remove the item from the toolbar
131
+ menu.destroy(); // ... and destroy it
132
+ });
133
+ }
134
+ }
135
+ JS
136
+
137
+ :logout => <<-JS.l,
138
+ function(){
139
+ window.location = "#{config[:logout_url]}"
140
+ }
141
+ JS
142
+
143
+ # Work around to fire "appLoaded" event only once
144
+ :on_after_layout => <<-JS.l,
145
+ function(){
146
+ this.un('afterlayout', this.onAfterLayout, this); // avoid multiple calls
147
+ this.appLoaded();
148
+ }
149
+ JS
150
+
112
151
  # Event handler for history change
113
152
  :process_history => <<-JS.l,
114
153
  function(token){
@@ -120,24 +159,19 @@ module Netzke
120
159
  }
121
160
  JS
122
161
 
123
- #
124
- # Set this function as the event handler for your menus, e.g.:
125
- #
126
- # :menu => {
127
- # :items => [{
128
- # :text => "Books",
129
- # :handler => "this.appLoadWidget".l,
130
- # :widget => 'books', # specify here the name of the widget to be loaded
131
- # :scope => this
132
- # }]
133
- # }
134
- #
135
- :app_load_widget => <<-JS.l
136
- function(menuItem){
137
- Ext.History.add(menuItem.widget)
138
- }
162
+ # Loads widget by name
163
+ :app_load_widget => <<-JS.l,
164
+ function(name){
165
+ Ext.History.add(name)
166
+ }
139
167
  JS
140
168
 
169
+ # Loads widget by action
170
+ :load_widget_by_action => <<-JS.l
171
+ function(action){
172
+ this.appLoadWidget(action.widget || action.name)
173
+ }
174
+ JS
141
175
  })
142
176
  end
143
177
  end
@@ -175,7 +209,7 @@ module Netzke
175
209
 
176
210
  # Interface implementation
177
211
  def interface_app_get_widget(params)
178
- widget = params.delete(:widget)
212
+ widget = params.delete(:widget).underscore
179
213
  persistent_config['last_loaded_widget'] = widget # store the last loaded widget in the persistent storage
180
214
  send("#{widget}__get_widget", params)
181
215
  end
@@ -28,7 +28,6 @@ module Netzke
28
28
 
29
29
  // A function to access a region widget (even if the widget gets reloaded, the function will work).
30
30
  // E.g.: getEastWidget()
31
- // I love JavaScript
32
31
  this['get'+r.capitalize()+'Widget'] = function(){
33
32
  return this.find('region', r)[0].getWidget()
34
33
  }.createDelegate(this)
@@ -86,6 +85,13 @@ module Netzke
86
85
  end
87
86
  extend ClassMethods
88
87
 
88
+ # default instance-level configuration
89
+ def initial_config
90
+ {
91
+ :persistent_config => true
92
+ }
93
+ end
94
+
89
95
  def initial_aggregatees
90
96
  config[:regions] || {}
91
97
  end
@@ -109,8 +115,8 @@ module Netzke
109
115
  end
110
116
 
111
117
  def resize_region(params)
112
- persistent_config["#{params[:region_name]}_width"] = params[:new_width].to_i if params[:new_width]
113
- persistent_config["#{params[:region_name]}_height"] = params[:new_height].to_i if params[:new_height]
118
+ persistent_config["#{params["region_name"]}_width"] = params["new_width"].to_i if params["new_width"]
119
+ persistent_config["#{params["region_name"]}_height"] = params["new_height"].to_i if params["new_height"]
114
120
  {}
115
121
  end
116
122
 
@@ -1,8 +1,8 @@
1
1
  module Netzke
2
2
  #
3
- # Include this module into any widget if you want a "Properties" tool button in the top toolbar which will triggger a modal window, which will load the Accordion widgets, which in its turn will contain all the aggregatees specified in "property_widgets" method (*must* be defined)
3
+ # Include this module into any widget if you want a "Properties" tool button in the top toolbar which will triggger a modal window, which will load the Accordion widgets, which in its turn will contain all the aggregatees specified in "configuration_widgets" method (*must* be defined)
4
4
  #
5
- module PropertiesTool
5
+ module ConfigurationTool
6
6
  def self.included(base)
7
7
  base.extend ClassMethods
8
8
 
@@ -16,21 +16,21 @@ module Netzke
16
16
  end
17
17
  end
18
18
 
19
- # if you include PropertiesTool, you must define property_widgets method which will returns an array of arrgeratees that will be included in the property window (each in its own tab or accordion pane)
20
- raise "property_widgets method undefined" unless base.instance_methods.include?("property_widgets")
19
+ # if you include ConfigurationTool, you must define configuration_widgets method which will returns an array of arrgeratees that will be included in the property window (each in its own tab or accordion pane)
20
+ raise "configuration_widgets method undefined" unless base.instance_methods.include?("configuration_widgets")
21
21
  end
22
22
 
23
23
  module ClassMethods
24
24
  def js_extend_properties_with_properties
25
25
  js_extend_properties_without_properties.merge({
26
- :show_config => <<-JS.l
26
+ :gear => <<-JS.l
27
27
  function(){
28
28
  var w = new Ext.Window({
29
29
  title:'Config',
30
30
  layout:'fit',
31
31
  modal:true,
32
- width:window.innerWidth*.9,
33
- height:window.innerHeight*.9,
32
+ width: Ext.lib.Dom.getViewWidth() *0.9,
33
+ height: Ext.lib.Dom.getViewHeight() *0.9,
34
34
  closeAction:'destroy',
35
35
  buttons:[{
36
36
  text:'Submit',
@@ -52,10 +52,10 @@ module Netzke
52
52
  if (widget.ownerCt) {
53
53
  widget.ownerCt.loadWidget(widget.initialConfig.interface.getWidget);
54
54
  } else {
55
- this.feedback('Reload current window') // we are embedded directly in HTML
55
+ this.feedback('Reload current window'); // we are embedded directly in HTML
56
56
  }
57
57
  }
58
- }, this)
58
+ }, this);
59
59
  }
60
60
  JS
61
61
  })
@@ -64,19 +64,15 @@ module Netzke
64
64
 
65
65
  def initial_aggregatees_with_properties
66
66
  res = initial_aggregatees_without_properties
67
- # Add the accordion as aggregatee, which in its turn aggregates widgets from the property_widgets method
68
- res.merge!(:properties => {:widget_class_name => 'AccordionPanel', :items => property_widgets, :ext_config => {:title => false}, :no_caching => true, :late_aggregation => true}) if config[:ext_config][:config_tool]
67
+ # Add the accordion as aggregatee, which in its turn aggregates widgets from the configuration_widgets method
68
+ res.merge!(:properties => {:widget_class_name => 'AccordionPanel', :items => configuration_widgets, :ext_config => {:title => false}, :no_caching => true, :late_aggregation => true}) if config[:ext_config][:config_tool]
69
69
  res
70
70
  end
71
71
 
72
72
  def tools_with_properties
73
73
  tools = tools_without_properties
74
74
  # Add the toolbutton
75
- tools << {
76
- :id => 'gear',
77
- :qtip => 'Configure',
78
- :on => {:click => "showConfig"}
79
- } if config[:ext_config][:config_tool]
75
+ tools << 'gear' if config[:ext_config][:config_tool]
80
76
  tools
81
77
  end
82
78
 
@@ -23,14 +23,18 @@ module Netzke
23
23
  end
24
24
 
25
25
  def actions
26
- super + [{
27
- :text => 'Restore defaults', :handler_name => 'loadDefaults', :id => 'defaults'
28
- }]
26
+ super.merge(
27
+ :defaults => {:text => 'Restore defaults'}
28
+ )
29
+ end
30
+
31
+ def bbar
32
+ super << "-" << "defaults"
29
33
  end
30
34
 
31
35
  def self.js_extend_properties
32
36
  super.merge({
33
- :load_defaults => <<-JS.l,
37
+ :defaults => <<-JS.l,
34
38
  function(){
35
39
  Ext.Msg.confirm('Confirm', 'Are you sure?', function(btn){
36
40
  if (btn == 'yes') {
@@ -1,33 +1,38 @@
1
1
  module Netzke
2
2
  class FormPanel < Base
3
- # so that some inherited methods would know our real location
4
- self.widget_file = __FILE__
5
-
6
- include_extras
3
+ # Class-level configuration with defaults
4
+ def self.config
5
+ set_default_config({
6
+ :field_manager => "NetzkeFormPanelField",
7
+ })
8
+ end
7
9
 
10
+ include Netzke::FormPanelExtras::JsBuilder
11
+ include Netzke::FormPanelExtras::Interface
12
+ include Netzke::DbFields # database field operations
13
+
14
+ # extra javascripts
15
+ js_include %w{ xcheckbox xdatetime }.map{|js| "#{File.dirname(__FILE__)}/form_panel_extras/javascripts/#{js}.js"}
16
+
8
17
  interface :submit, :load
9
18
 
10
- include Netzke::DbFields
11
-
12
19
  def self.widget_type
13
20
  :form
14
21
  end
15
22
 
16
- # default configuration
23
+ # default instance-level configuration
17
24
  def initial_config
18
25
  {
19
26
  :ext_config => {
20
27
  :config_tool => true
21
28
  },
22
- :layout_manager => "NetzkeLayout",
23
- :field_manager => "NetzkeFormPanelField",
24
29
 
25
30
  :persistent_layout => true,
26
31
  :persistent_config => true
27
32
  }
28
33
  end
29
34
 
30
- def property_widgets
35
+ def configuration_widgets
31
36
  res = []
32
37
  res << {
33
38
  :name => 'fields',
@@ -37,21 +42,29 @@ module Netzke
37
42
  :layout => NetzkeLayout.by_widget(id_name),
38
43
  :fields_for => :form
39
44
  } if config[:persistent_layout]
45
+
46
+ res << {
47
+ :name => 'general',
48
+ :widget_class_name => "PropertyEditor",
49
+ :widget_name => id_name,
50
+ :ext_config => {:title => false}
51
+ }
52
+
40
53
  res
41
54
  end
42
55
 
43
56
  def tools
44
- [{:id => 'refresh', :on => {:click => 'refreshClick'}}]
57
+ %w{ refresh }
45
58
  end
46
59
 
47
60
  def actions
48
- [{
49
- # :text => 'Previous', :handler => 'previous'
50
- # },{
51
- # :text => 'Next', :handler => 'next'
52
- # },{
53
- :text => 'Apply', :handler_name => 'submit', :disabled => !@permissions[:update] && !@permissions[:create], :id => 'apply'
54
- }]
61
+ {
62
+ :apply => {:text => 'Apply'}
63
+ }
64
+ end
65
+
66
+ def bbar
67
+ persistent_config[:bottom_bar] ||= config[:bbar] == false ? nil : config[:bbar] || %w{ apply }
55
68
  end
56
69
 
57
70
  # get fields from layout manager
@@ -78,23 +91,17 @@ module Netzke
78
91
 
79
92
  protected
80
93
 
81
- def layout_manager_class
82
- config[:layout_manager].constantize
83
- rescue NameError
84
- nil
85
- end
86
-
87
94
  def field_manager_class
88
- config[:field_manager].constantize
95
+ self.class.config[:field_manager].constantize
89
96
  rescue NameError
90
97
  nil
91
98
  end
92
99
 
93
- def available_permissions
94
- %w(read update create delete)
95
- end
100
+ # def available_permissions
101
+ # %w{ read update }
102
+ # end
96
103
 
97
- include PropertiesTool # it will load aggregation with name :properties into a modal window
104
+ include ConfigurationTool # it will load aggregation with name :properties into a modal window
98
105
 
99
106
  end
100
107
  end