netzke-basepack 0.5.2 → 0.5.3

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.
@@ -42,7 +42,7 @@ class NetzkeAutoColumn < ActiveRecord::Base
42
42
  end
43
43
 
44
44
  # populate the table with data
45
- NetzkeAutoColumn.create @@widget.normalized_columns.map(&:deebeefy_values)
45
+ NetzkeAutoColumn.create @@widget.normalized_columns.map(&:deebeefy_values) rescue ActiveRecord::UnknownAttributeError
46
46
 
47
47
  end
48
48
 
@@ -24,6 +24,19 @@ module Netzke
24
24
  })
25
25
  end
26
26
 
27
+ def include_js
28
+ res = []
29
+ ext_examples = Netzke::Base.config[:ext_location] + "/examples/"
30
+ res << ext_examples + "ux/StatusBar.js"
31
+ res << "#{File.dirname(__FILE__)}/basic_app_extras/statusbar_ext.js"
32
+ end
33
+
34
+ # def include_css
35
+ # res = []
36
+ # res << Netzke::Base.config[:ext_location] + "/examples/ux/css/StatusBar.css"
37
+ # res
38
+ # end
39
+
27
40
  def js_panels
28
41
  # In status bar we want to show what we are masquerading as
29
42
  if session[:masq_user]
@@ -50,6 +63,7 @@ module Netzke
50
63
  :id => 'main-statusbar',
51
64
  :xtype => 'statusbar',
52
65
  :region => 'south',
66
+ :height => 22,
53
67
  :statusAlign => 'right',
54
68
  :busyText => 'Busy...',
55
69
  :default_text => masq.nil? ? "Ready #{"(config mode)" if session[:config_mode]}" : "Masquerading as #{masq}",
@@ -181,7 +195,7 @@ module Netzke
181
195
  },{
182
196
  text:'As World',
183
197
  handler:function(){
184
- Ext.Msg.confirm("Masquerading as World", "Caution! All settings that you will modify will be ovewritten for all roles and all users. Are you sure you know what you're doing?", function(btn){
198
+ Ext.Msg.confirm("Masquerading as World", "Caution! All settings that you will modify will be overwritten for all roles and all users. Are you sure you know what you're doing?", function(btn){
185
199
  if (btn === "yes") {
186
200
  this.masquerade = {world:true};
187
201
  w.close();
@@ -197,7 +211,7 @@ module Netzke
197
211
  },
198
212
  scope:this
199
213
  },{
200
- text:'Cansel',
214
+ text:'Cancel',
201
215
  handler:function(){
202
216
  w.hide();
203
217
  },
@@ -0,0 +1,8 @@
1
+ Ext.override(Ext.ux.StatusBar, {
2
+ hideBusy : function(){
3
+ return this.setStatus({
4
+ text: this.defaultText,
5
+ iconCls: this.defaultIconCls
6
+ });
7
+ }
8
+ });
@@ -64,7 +64,7 @@ module Netzke
64
64
  Ext.netzke.cache.BorderLayoutPanel.superclass.initComponent.call(this);
65
65
 
66
66
  // First time on "afterlayout", set resize events
67
- this.on('afterlayout', this.setResizeEvents, this, {single: true});
67
+ if (this.persistentConfig) {this.on('afterlayout', this.setResizeEvents, this, {single: true});}
68
68
  }
69
69
  END_OF_JAVASCRIPT
70
70
 
data/lib/netzke/ext.rb CHANGED
@@ -2,5 +2,6 @@ module Netzke
2
2
  # Ext-related module. Some constants provide meta-information about the Ext.library.
3
3
  module Ext
4
4
  FORM_FIELD_XTYPES = %w{ textfield numberfield textarea combobox checkbox xdatetime }
5
+ COLUMN_XTYPES = %w{ gridcolumn booleancolumn numbercolumn datecolumn }
5
6
  end
6
7
  end
@@ -31,10 +31,8 @@ module Netzke
31
31
  )
32
32
  end
33
33
 
34
- def independent_config
35
- res = super
36
- res[:ext_config][:bbar] = %w{ edit apply - defaults }
37
- res
34
+ def default_bbar
35
+ %w{ edit apply - defaults }
38
36
  end
39
37
 
40
38
  def predefined_columns
@@ -44,7 +42,7 @@ module Netzke
44
42
  def self.js_extend_properties
45
43
  {
46
44
  # Disable the 'gear' tool for now
47
- :gear => <<-END_OF_JAVASCRIPT.l,
45
+ :on_gear => <<-END_OF_JAVASCRIPT.l,
48
46
  function(){
49
47
  this.feedback("You can't configure configurator (yet)");
50
48
  }
@@ -22,15 +22,24 @@ module Netzke
22
22
  :config_tool_available => true,
23
23
 
24
24
  :default_config => {
25
+ :persistent_config => true,
25
26
  :ext_config => {
26
- :bbar => %w{ apply },
27
- :tools => %w{ }
27
+ :tools => []
28
28
  },
29
- :persistent_config => false
30
29
  }
31
30
  })
32
31
  end
33
32
 
33
+ def initial_config
34
+ res = super
35
+ res[:ext_config][:bbar] = default_bbar if res[:ext_config][:bbar].nil?
36
+ res
37
+ end
38
+
39
+ def default_bbar
40
+ %w{ apply }
41
+ end
42
+
34
43
  # Extra javascripts
35
44
  def self.include_js
36
45
  [
@@ -107,16 +116,11 @@ module Netzke
107
116
  def self.property_fields
108
117
  res = [
109
118
  {:name => :ext_config__title, :type => :string},
110
- {:name => :ext_config__header, :type => :boolean, :default => true}
111
- # {:name => :ext_config__bbar, :type => :json},
112
- # {:name => :ext_config__prohibit_create, :type => :boolean},
113
- # {:name => :ext_config__prohibit_update, :type => :boolean},
114
- # {:name => :ext_config__prohibit_delete, :type => :boolean},
115
- # {:name => :ext_config__prohibit_read, :type => :boolean}
119
+ {:name => :ext_config__header, :type => :boolean, :default => true},
120
+ {:name => :ext_config__bbar, :type => :json}
116
121
  ]
117
122
 
118
123
  res
119
-
120
124
  end
121
125
 
122
126
  # Normalized columns
@@ -126,7 +130,7 @@ module Netzke
126
130
 
127
131
 
128
132
  def get_columns
129
- if config[:persistent_config]
133
+ if persistent_config_enabled?
130
134
  persistent_config['layout__columns'] ||= default_columns
131
135
  res = normalize_array_of_columns(persistent_config['layout__columns'])
132
136
  else
@@ -15,7 +15,6 @@ module Netzke
15
15
  :auto_scroll => true,
16
16
  :label_width => 150,
17
17
  :default_type => 'textfield',
18
- # :label_align => 'top',
19
18
 
20
19
  :init_component => <<-END_OF_JAVASCRIPT.l,
21
20
  function(){
@@ -87,12 +86,6 @@ module Netzke
87
86
  :load_record => <<-END_OF_JAVASCRIPT.l,
88
87
  function(id, neighbour){
89
88
  this.load({id:id});
90
- // var proxy = new Ext.data.HttpProxy({url:this.initialConfig.api.load});
91
- // proxy.load({id:id, neighbour:neighbour}, this.reader, function(data){
92
- // if (data){
93
- // this.form.loadRecord(data.records[0])
94
- // }
95
- // }, this)
96
89
  }
97
90
  END_OF_JAVASCRIPT
98
91
 
@@ -110,7 +103,7 @@ module Netzke
110
103
  # }
111
104
  # END_OF_JAVASCRIPT
112
105
 
113
- :apply => <<-END_OF_JAVASCRIPT.l
106
+ :on_apply => <<-END_OF_JAVASCRIPT.l
114
107
  function() {
115
108
  if (this.fireEvent('apply', this)) {
116
109
  var values = this.form.getValues();
@@ -38,9 +38,9 @@ module Netzke
38
38
  # The following config options are available:
39
39
  # * <tt>:data_class_name</tt> - name of the ActiveRecord model that provides data to this GridPanel.
40
40
  # * <tt>:strong_default_attrs</tt> - a hash of attributes to be merged atop of every created/updated record.
41
- # * <tt>:scopes</tt> - an array of searchlogic-compatible scopes to filter grid data like this:
41
+ # * <tt>:scopes</tt> - an array of named scopes to filter grid data, e.g.:
42
42
  #
43
- # ["user_id_not", 100]
43
+ # [["user_id_not", 100], ["name_like", "Peter"]]
44
44
  #
45
45
  # In the <tt>:ext_config</tt> hash (see Netzke::Base) the following GridPanel specific options are available:
46
46
  #
@@ -79,7 +79,7 @@ module Netzke
79
79
  :config_tool_available => true,
80
80
  :edit_in_form_available => true,
81
81
  :extended_search_available => true,
82
- :rows_reordering_available => false,
82
+ :rows_reordering_available => true,
83
83
 
84
84
  :default_config => {
85
85
  :ext_config => {
@@ -88,18 +88,15 @@ module Netzke
88
88
  :enable_column_filters => true,
89
89
  :load_inline_data => true,
90
90
  :enable_context_menu => true,
91
-
91
+ :enable_rows_reordering => false, # column drag n drop
92
92
  :enable_pagination => true,
93
93
  :rows_per_page => 25,
94
+ :tools => %w{ refresh },
94
95
 
95
- :mode => :normal, # when set to :config, :configuration button is enabled
96
-
97
- :enable_rows_reordering => false, # drag n drop
98
-
99
- :tools => %w{ refresh }
96
+ :mode => :normal # when set to :config, :configuration button is enabled
100
97
  },
98
+ :persistent_config => true
101
99
 
102
- :persistent_config => false
103
100
  }
104
101
  })
105
102
  end
@@ -109,22 +106,26 @@ module Netzke
109
106
  res = []
110
107
 
111
108
  # Checkcolumn
112
- res << "#{File.dirname(__FILE__)}/grid_panel_extras/javascripts/check-column.js"
109
+ ext_examples = Netzke::Base.config[:ext_location] + "/examples/"
110
+ res << ext_examples + "ux/CheckColumn.js"
111
+ # res << "#{File.dirname(__FILE__)}/grid_panel_extras/javascripts/check-column.js"
112
+
113
113
 
114
114
  # Filters
115
- if config[:column_filters_available]
116
- ext_examples = Netzke::Base.config[:ext_location] + "/examples/"
117
- res << ext_examples + "grid-filtering/menu/EditableItem.js"
118
- res << ext_examples + "grid-filtering/menu/RangeMenu.js"
119
- res << ext_examples + "grid-filtering/grid/GridFilters.js"
120
-
121
- %w{Boolean Date List Numeric String}.unshift("").each do |f|
122
- res << ext_examples + "grid-filtering/grid/filter/#{f}Filter.js"
123
- end
124
-
125
- res << "#{File.dirname(__FILE__)}/grid_panel_extras/javascripts/filters.js"
126
-
127
- end
115
+ # Not compatible with Ext 3.0
116
+ # if config[:column_filters_available]
117
+ # ext_examples = Netzke::Base.config[:ext_location] + "/examples/"
118
+ # res << ext_examples + "grid-filtering/menu/EditableItem.js"
119
+ # res << ext_examples + "grid-filtering/menu/RangeMenu.js"
120
+ # res << ext_examples + "grid-filtering/grid/GridFilters.js"
121
+ #
122
+ # %w{Boolean Date List Numeric String}.unshift("").each do |f|
123
+ # res << ext_examples + "grid-filtering/grid/filter/#{f}Filter.js"
124
+ # end
125
+ #
126
+ # res << "#{File.dirname(__FILE__)}/grid_panel_extras/javascripts/filters.js"
127
+ #
128
+ # end
128
129
 
129
130
  # DD
130
131
  if config[:rows_reordering_available]
@@ -160,11 +161,17 @@ module Netzke
160
161
  {:name => :value},
161
162
  {:name => :header},
162
163
  {:name => :hidden, :type => :boolean, :editor => :checkbox},
163
- {:name => :read_only, :type => :boolean, :editor => :checkbox, :header => "R"},
164
+ {:name => :editable, :type => :boolean, :editor => :checkbox, :header => "Editable", :default => true},
164
165
  {:name => :editor, :type => :string, :editor => {:xtype => :combobox, :options => Netzke::Ext::FORM_FIELD_XTYPES}},
165
166
  {:name => :renderer, :type => :string},
167
+
168
+ # maybe later
169
+ # {:name => :xtype, :type => :string, :editor => {:xtype => :combobox, :options => Netzke::Ext::COLUMN_XTYPES}},
170
+
166
171
  # {:name => :renderer, :type => :string, :editor => {:xtype => :jsonfield}},
167
- {:name => :with_filters, :type => :boolean, :editor => :checkbox, :default => true, :header => "Filters"},
172
+
173
+ # Filters not supported in Ext 3.0
174
+ # {:name => :with_filters, :type => :boolean, :editor => :checkbox, :default => true, :header => "Filters"},
168
175
 
169
176
  # some rarely used configurations, hidden
170
177
  {:name => :width, :type => :integer, :editor => :numberfield, :hidden => true},
@@ -181,7 +188,7 @@ module Netzke
181
188
  {:name => :ext_config__context_menu, :type => :json},
182
189
  {:name => :ext_config__enable_pagination, :type => :boolean, :default => true},
183
190
  {:name => :ext_config__rows_per_page, :type => :integer},
184
- # {:name => :ext_config__bbar, :type => :json},
191
+ {:name => :ext_config__bbar, :type => :json},
185
192
  {:name => :ext_config__prohibit_create, :type => :boolean},
186
193
  {:name => :ext_config__prohibit_update, :type => :boolean},
187
194
  {:name => :ext_config__prohibit_delete, :type => :boolean},
@@ -195,25 +202,25 @@ module Netzke
195
202
 
196
203
  end
197
204
 
198
- def independent_config
205
+ def initial_config
199
206
  res = super
200
207
 
201
- # Bottom bar
202
- if res[:ext_config][:bbar].nil?
203
- res[:ext_config][:bbar] = %w{ add edit apply del }
204
- res[:ext_config][:bbar] << "-" << "add_in_form" << "edit_in_form" if res[:ext_config][:enable_edit_in_form]
205
- res[:ext_config][:bbar] << "-" << "search" if res[:ext_config][:enable_extended_search]
206
- end
207
-
208
- # Context menu
209
- res[:ext_config][:context_menu] ||= default_context_menu(res)
208
+ res[:ext_config][:bbar] = default_bbar if res[:ext_config][:bbar].nil?
209
+ res[:ext_config][:context_menu] ||= default_context_menu
210
210
 
211
211
  res
212
212
  end
213
213
 
214
- def default_context_menu(indep_config)
214
+ def default_bbar
215
+ res = %w{ add edit apply del }
216
+ res << "-" << "add_in_form" << "edit_in_form" if self.class.config[:edit_in_form_available]
217
+ res << "-" << "search" if self.class.config[:extended_search_available]
218
+ res
219
+ end
220
+
221
+ def default_context_menu
215
222
  res = %w{ edit del }
216
- res << "-" << "edit_in_form" if indep_config[:ext_config][:enable_edit_in_form]
223
+ res << "-" << "edit_in_form" if self.class.config[:edit_in_form_available]
217
224
  res
218
225
  end
219
226
 
@@ -238,23 +245,15 @@ module Netzke
238
245
  def actions
239
246
  # Defaults
240
247
  res = {
241
- :add => {:text => 'Add', :disabled => ext_config[:prohibit_create]},
242
- :edit => {:text => 'Edit', :disabled => true},
243
- :del => {:text => 'Delete', :disabled => true},
244
- :apply => {:text => 'Apply', :disabled => ext_config[:prohibit_update] && ext_config[:prohibit_create]}
248
+ :add => {:text => 'Add', :disabled => ext_config[:prohibit_create]},
249
+ :edit => {:text => 'Edit', :disabled => true},
250
+ :del => {:text => 'Delete', :disabled => true},
251
+ :apply => {:text => 'Apply', :disabled => ext_config[:prohibit_update] && ext_config[:prohibit_create]},
252
+ :add_in_form => {:text => 'Add in form', :disabled => !ext_config[:enable_edit_in_form]},
253
+ :edit_in_form => {:text => 'Edit in form', :disabled => true},
254
+ :search => {:text => 'Search', :disabled => !ext_config[:enable_extended_search]}
245
255
  }
246
256
 
247
- # Edit in form
248
- res.merge!({
249
- :add_in_form => {:text => 'Add in form'},
250
- :edit_in_form => {:text => 'Edit in form', :disabled => true}
251
- }) if ext_config[:enable_edit_in_form]
252
-
253
- # Extended search
254
- res.merge!({
255
- :search => {:text => 'Search'}
256
- }) if ext_config[:enable_extended_search]
257
-
258
257
  res
259
258
  end
260
259
 
@@ -265,8 +264,8 @@ module Netzke
265
264
  res.merge!({
266
265
  :edit_form => {
267
266
  :widget_class_name => "FormPanel",
268
- :persistent_config => true,
269
267
  :data_class_name => config[:data_class_name],
268
+ :persistent_config => config[:persistent_config],
270
269
  :ext_config => {
271
270
  :bbar => false,
272
271
  :header => false,
@@ -276,8 +275,8 @@ module Netzke
276
275
 
277
276
  :multi_edit_form => {
278
277
  :widget_class_name => "FormPanel",
279
- :persistent_config => true,
280
278
  :data_class_name => config[:data_class_name],
279
+ :persistent_config => config[:persistent_config],
281
280
  :ext_config => {
282
281
  :bbar => false,
283
282
  :header => false,
@@ -287,8 +286,8 @@ module Netzke
287
286
 
288
287
  :new_record_form => {
289
288
  :widget_class_name => "FormPanel",
290
- :persistent_config => true,
291
289
  :data_class_name => config[:data_class_name],
290
+ :persistent_config => config[:persistent_config],
292
291
  :ext_config => {
293
292
  :bbar => false,
294
293
  :header => false,
@@ -303,7 +302,7 @@ module Netzke
303
302
  :search_panel => {
304
303
  :widget_class_name => "SearchPanel",
305
304
  :search_class_name => config[:data_class_name],
306
- :persistent_config => true,
305
+ :persistent_config => config[:persistent_config],
307
306
  :ext_config => {
308
307
  :header => false,
309
308
  :bbar => false,
@@ -328,7 +327,7 @@ module Netzke
328
327
  end
329
328
 
330
329
  def get_columns
331
- if config[:persistent_config]
330
+ if persistent_config_enabled?
332
331
  persistent_config['layout__columns'] ||= default_columns
333
332
  res = normalize_array_of_columns(persistent_config['layout__columns'])
334
333
  else
@@ -421,11 +420,12 @@ module Netzke
421
420
  # Some default limitations for virtual columns
422
421
  if type == :virtual
423
422
  # disable filters
424
- c[:with_filters].nil? && c[:with_filters] = false
423
+ # c[:with_filters].nil? && c[:with_filters] = false
425
424
  # disable sorting
426
425
  c[:sortable].nil? && c[:sortable] = false
427
426
  # read-only
428
- c[:read_only].nil? && c[:read_only] = true
427
+ # c[:read_only].nil? && c[:read_only] = true
428
+ c[:editable].nil? && c[:editable] = false
429
429
  end
430
430
 
431
431
  # denormalize column (save space)
@@ -32,7 +32,7 @@ module Netzke
32
32
  if !ext_config[:prohibit_delete]
33
33
  record_ids = ActiveSupport::JSON.decode(params[:records])
34
34
  klass = config[:data_class_name].constantize
35
- klass.delete(record_ids)
35
+ klass.destroy(record_ids)
36
36
  {:feedback => "Deleted #{record_ids.size} record(s)", :load_store_data => get_data}
37
37
  else
38
38
  {:feedback => "You don't have permissions to delete data"}
@@ -96,7 +96,7 @@ module Netzke
96
96
  scope_name, *args = s
97
97
  search.send(scope_name, *args)
98
98
  else
99
- search.send(s)
99
+ search.send(s, true)
100
100
  end
101
101
  end
102
102