netzke-basepack 0.5.13 → 0.5.14
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +15 -0
- data/Rakefile +2 -2
- data/TODO.rdoc +3 -3
- data/lib/netzke/active_record/attributes.rb +15 -1
- data/lib/netzke/active_record/data_accessor.rb +6 -2
- data/lib/netzke/data_accessor.rb +7 -3
- data/lib/netzke/form_panel.rb +3 -3
- data/lib/netzke/form_panel/form_panel_fields.rb +2 -2
- data/lib/netzke/grid_panel.rb +12 -21
- data/lib/netzke/grid_panel/grid_panel_columns.rb +11 -23
- data/lib/netzke/grid_panel/grid_panel_js.rb +2 -0
- data/lib/netzke/grid_panel/javascripts/grid_panel_pre.js +1 -0
- data/lib/netzke/search_panel.rb +2 -2
- metadata +8 -27
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
= v0.5.14 - 2010-09-08
|
2
|
+
* bug fix
|
3
|
+
* fields configurator wouldn't open in some cases
|
4
|
+
* icons location was hardcoded in search panel (credits to @pschyska)
|
5
|
+
* quick fix for datetimes not being displayed in the preferred timezone
|
6
|
+
* ext_config options :enable_edit_in_form and :enable_advanced_search now do have effect
|
7
|
+
* PropertyEditor fixed for Grid/FormPanel
|
8
|
+
* Grid/FormPanel again obeys persistent_config option when loading columns/fields
|
9
|
+
|
10
|
+
* enhancements
|
11
|
+
* numberfield is default in grids also for columns of type float
|
12
|
+
* more narrow exception rescuing in GridPanel code
|
13
|
+
* combobox options can now be searched ("type ahead") also in virtual columns (not efficient though, use at own risk!)
|
14
|
+
* overriding an already existing attribute with `netzke_attribute` now also has effect on association attributes, such as boss__name
|
15
|
+
|
1
16
|
= v0.5.13 - 2010-08-11
|
2
17
|
* regression
|
3
18
|
* combobox options configuration again has effect
|
data/Rakefile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
begin
|
2
2
|
require 'jeweler'
|
3
3
|
Jeweler::Tasks.new do |gemspec|
|
4
|
-
gemspec.version = "0.5.
|
4
|
+
gemspec.version = "0.5.14"
|
5
5
|
gemspec.name = "netzke-basepack"
|
6
6
|
gemspec.summary = "Pre-built Rails + ExtJS widgets for your RIA"
|
7
7
|
gemspec.description = "A set of full-featured extendible Netzke widgets (such as FormPanel, GridPanel, Window, BorderLayoutPanel, etc) which can be used as building block for your RIA"
|
@@ -9,7 +9,7 @@ begin
|
|
9
9
|
gemspec.homepage = "http://github.com/skozlov/netzke-basepack"
|
10
10
|
gemspec.rubyforge_project = "netzke-basepack"
|
11
11
|
gemspec.authors = ["Sergei Kozlov"]
|
12
|
-
gemspec.add_dependency("netzke-core", ">=0.5.
|
12
|
+
gemspec.add_dependency("netzke-core", ">=0.5.5")
|
13
13
|
gemspec.add_dependency("searchlogic", ">=2.0.0")
|
14
14
|
gemspec.add_dependency("will_paginate", ">=2.0.0")
|
15
15
|
gemspec.add_dependency("acts_as_list", ">=0.1.2")
|
data/TODO.rdoc
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
== Priority
|
2
|
-
*
|
2
|
+
* Solve the confusion about columns being stored in the persistent config
|
3
3
|
* On grid refresh, reset the dirty fields, so that the "Apply" button doesn't do anything
|
4
4
|
* GridPanel's read_only vs editable (doesn't work now) options
|
5
|
-
* Solve the confusion about columns being stored in the persistent config
|
6
5
|
* Inclusion of css in a stand-alone widget
|
7
|
-
*
|
6
|
+
* Find a way to print the grid nicely (along with the column and rows that don't fit on the screen)
|
7
|
+
* Auto-include the ID column into GridPanel by default
|
8
8
|
|
9
9
|
== Foolproof
|
10
10
|
* Should not be possible delete the "ID" field from grids/forms
|
@@ -69,16 +69,30 @@ module Netzke::ActiveRecord::Attributes
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
+
# Returns netzke attributes in the order of columns in the table, followed by extra declared attributes
|
73
|
+
# Detects one-to-many association columns and replaces the name of the column with association column name (Netzke style), e.g.:
|
74
|
+
#
|
75
|
+
# role_id => role__name
|
72
76
|
def netzke_attrs_in_natural_order
|
73
77
|
(
|
74
78
|
declared_attrs = netzke_declared_attributes
|
75
79
|
column_names.map do |name|
|
76
80
|
c = {:name => name, :attr_type => columns_hash[name].type}
|
81
|
+
|
82
|
+
# If it's named as foreign key of some association, then it's an association column
|
83
|
+
assoc = reflect_on_all_associations.detect{|a| a.primary_key_name == c[:name]}
|
84
|
+
|
85
|
+
if assoc && !assoc.options[:polymorphic]
|
86
|
+
assoc_method = %w{name title label id}.detect{|m| (assoc.klass.instance_methods + assoc.klass.column_names).include?(m) } || assoc.klass.primary_key
|
87
|
+
c[:name] = "#{assoc.name}__#{assoc_method}"
|
88
|
+
c[:attr_type] = assoc.klass.columns_hash[assoc_method].type
|
89
|
+
end
|
90
|
+
|
77
91
|
# auto set up the default value from the column settings
|
78
92
|
c.merge!(:default_value => columns_hash[name].default) if columns_hash[name].default
|
79
93
|
|
80
94
|
# if there's a declared attr with the same name, simply merge it with what's taken from the model's columns
|
81
|
-
if declared = declared_attrs.detect{ |va| va[:name] == name }
|
95
|
+
if declared = declared_attrs.detect{ |va| va[:name] == c[:name] }
|
82
96
|
c.merge!(declared)
|
83
97
|
declared_attrs.delete(declared)
|
84
98
|
end
|
@@ -8,8 +8,12 @@ module Netzke::ActiveRecord
|
|
8
8
|
res = []
|
9
9
|
for c in columns
|
10
10
|
begin
|
11
|
-
|
12
|
-
|
11
|
+
next if c[:included] == false
|
12
|
+
v = send(c[:name])
|
13
|
+
# a work-around for to_json not taking the current timezone into account when serializing ActiveSupport::TimeWithZone
|
14
|
+
v = v.to_datetime.to_s(:db) if v.is_a?(ActiveSupport::TimeWithZone)
|
15
|
+
res << v
|
16
|
+
rescue NoMethodError
|
13
17
|
# So that we don't crash at a badly configured column
|
14
18
|
res << "UNDEF"
|
15
19
|
end
|
data/lib/netzke/data_accessor.rb
CHANGED
@@ -36,10 +36,14 @@ module Netzke
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
|
-
|
39
|
+
if assoc.klass.column_names.include?(assoc_method)
|
40
|
+
# apply query
|
41
|
+
search.send("#{assoc_method}_like", "#{method_options[:query]}%") if method_options[:query]
|
42
|
+
search.all.map{ |r| [r.send(assoc_method)] }
|
43
|
+
else
|
44
|
+
search.all.map{ |r| r.send(assoc_method) }.select{ |value| value =~ /^#{method_options[:query]}/ }.map{ |v| [v] }
|
45
|
+
end
|
41
46
|
|
42
|
-
search.all.map{ |r| [r.send(assoc_method)] }
|
43
47
|
else
|
44
48
|
# Options for a non-association attribute
|
45
49
|
data_class.options_for(column[:name], method_options[:query]).map{|s| [s]}
|
data/lib/netzke/form_panel.rb
CHANGED
@@ -125,9 +125,9 @@ module Netzke
|
|
125
125
|
|
126
126
|
def self.property_fields
|
127
127
|
res = [
|
128
|
-
{:name => "ext_config__title", :
|
129
|
-
{:name => "ext_config__header", :
|
130
|
-
# {:name => "ext_config__bbar", :
|
128
|
+
{:name => "ext_config__title", :attr_type => :string},
|
129
|
+
{:name => "ext_config__header", :attr_type => :boolean, :default => true},
|
130
|
+
# {:name => "ext_config__bbar", :attr_type => :json}
|
131
131
|
]
|
132
132
|
|
133
133
|
res
|
@@ -91,7 +91,7 @@ module Netzke
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def load_model_level_attrs
|
94
|
-
NetzkeModelAttrList.read_list(data_class.name) if data_class
|
94
|
+
NetzkeModelAttrList.read_list(data_class.name) if persistent_config_enabled? && data_class
|
95
95
|
end
|
96
96
|
|
97
97
|
def set_default_field_label(c)
|
@@ -133,7 +133,7 @@ module Netzke
|
|
133
133
|
|
134
134
|
# Receives 2 arrays of columns. Merges the missing config from the +source+ into +dest+, matching columns by name
|
135
135
|
def reverse_merge_equally_named_fields(dest, source)
|
136
|
-
dest.each{ |dc| dc.reverse_merge!(source.detect{ |sc| sc[:name] == dc[:name] }) }
|
136
|
+
dest.each{ |dc| dc.reverse_merge!(source.detect{ |sc| sc[:name] == dc[:name] } || {}) }
|
137
137
|
end
|
138
138
|
|
139
139
|
|
data/lib/netzke/grid_panel.rb
CHANGED
@@ -206,37 +206,28 @@ module Netzke
|
|
206
206
|
# Fields to be displayed in the "General" tab of the configuration panel
|
207
207
|
def self.property_fields
|
208
208
|
[
|
209
|
-
{:name => :ext_config__title, :
|
210
|
-
{:name => :ext_config__header, :
|
211
|
-
{:name => :ext_config__enable_context_menu, :
|
212
|
-
{:name => :ext_config__enable_pagination, :
|
213
|
-
{:name => :ext_config__rows_per_page, :
|
214
|
-
{:name => :ext_config__prohibit_create, :
|
215
|
-
{:name => :ext_config__prohibit_update, :
|
216
|
-
{:name => :ext_config__prohibit_delete, :
|
217
|
-
{:name => :ext_config__prohibit_read, :
|
209
|
+
{:name => :ext_config__title, :attr_type => :string},
|
210
|
+
{:name => :ext_config__header, :attr_type => :boolean, :default => true},
|
211
|
+
{:name => :ext_config__enable_context_menu, :attr_type => :boolean, :default => true},
|
212
|
+
{:name => :ext_config__enable_pagination, :attr_type => :boolean, :default => true},
|
213
|
+
{:name => :ext_config__rows_per_page, :attr_type => :integer},
|
214
|
+
{:name => :ext_config__prohibit_create, :attr_type => :boolean},
|
215
|
+
{:name => :ext_config__prohibit_update, :attr_type => :boolean},
|
216
|
+
{:name => :ext_config__prohibit_delete, :attr_type => :boolean},
|
217
|
+
{:name => :ext_config__prohibit_read, :attr_type => :boolean}
|
218
218
|
]
|
219
219
|
end
|
220
220
|
|
221
|
-
def default_config
|
222
|
-
res = super
|
223
|
-
|
224
|
-
res[:ext_config][:bbar] = default_bbar
|
225
|
-
res[:ext_config][:context_menu] = default_context_menu
|
226
|
-
|
227
|
-
res
|
228
|
-
end
|
229
|
-
|
230
221
|
def default_bbar
|
231
222
|
res = %w{ add edit apply del }
|
232
|
-
res << "-" << "add_in_form" << "edit_in_form" if
|
233
|
-
res << "-" << "search" if
|
223
|
+
res << "-" << "add_in_form" << "edit_in_form" if ext_config[:enable_edit_in_form]
|
224
|
+
res << "-" << "search" if ext_config[:enable_extended_search]
|
234
225
|
res
|
235
226
|
end
|
236
227
|
|
237
228
|
def default_context_menu
|
238
229
|
res = %w{ edit del }
|
239
|
-
res << "-" << "edit_in_form" if
|
230
|
+
res << "-" << "edit_in_form" if ext_config[:enable_edit_in_form]
|
240
231
|
res
|
241
232
|
end
|
242
233
|
|
@@ -112,7 +112,7 @@ module Netzke
|
|
112
112
|
|
113
113
|
# Stores modified columns in persistent storage
|
114
114
|
def save_columns!
|
115
|
-
NetzkeFieldList.update_list_for_current_authority(global_id, columns(false), original_data_class.name)
|
115
|
+
NetzkeFieldList.update_list_for_current_authority(global_id, columns(false), original_data_class.name) if persistent_config_enabled?
|
116
116
|
end
|
117
117
|
|
118
118
|
def load_columns
|
@@ -120,7 +120,7 @@ module Netzke
|
|
120
120
|
end
|
121
121
|
|
122
122
|
def load_model_level_attrs
|
123
|
-
NetzkeModelAttrList.read_list(data_class.name)
|
123
|
+
NetzkeModelAttrList.read_list(data_class.name) if persistent_config_enabled?
|
124
124
|
end
|
125
125
|
|
126
126
|
# whether a column is bound to the primary_key
|
@@ -181,31 +181,19 @@ module Netzke
|
|
181
181
|
end
|
182
182
|
|
183
183
|
# Detects an association column and sets up the proper editor.
|
184
|
-
# If a column is a foreign key (e.g. "category_id"), also renames the column into "normalized" association column, e.g.:
|
185
|
-
# category__name
|
186
|
-
# If association doesn't respond to methods "name", "title" or "label", falls back to "id", e.g.:
|
187
|
-
# category__id
|
188
184
|
def detect_association(c)
|
189
|
-
#
|
190
|
-
|
191
|
-
|
192
|
-
if assoc && !assoc.options[:polymorphic]
|
193
|
-
assoc_method = %w{name title label id}.detect{|m| (assoc.klass.instance_methods + assoc.klass.column_names).include?(m) } || assoc.klass.primary_key
|
194
|
-
c[:name] = "#{assoc.name}__#{assoc_method}"
|
195
|
-
end
|
196
|
-
|
197
|
-
# named with an double-underscore notation? surely an association column then
|
198
|
-
if !assoc && c[:name].index('__')
|
185
|
+
# double-underscore notation? surely an association column
|
186
|
+
if c[:name].index('__')
|
199
187
|
assoc_name, assoc_method = c[:name].split('__')
|
200
188
|
assoc = data_class.reflect_on_association(assoc_name.to_sym)
|
201
|
-
end
|
202
189
|
|
203
|
-
|
204
|
-
|
205
|
-
|
190
|
+
if assoc && assoc_method
|
191
|
+
assoc_column = assoc.klass.columns_hash[assoc_method]
|
192
|
+
assoc_method_type = assoc_column.try(:type)
|
206
193
|
|
207
|
-
|
208
|
-
|
194
|
+
# if association column is boolean, display a checkbox (or alike), otherwise - a combobox (or alike)
|
195
|
+
c[:editor] ||= assoc_method_type == :boolean ? editor_for_attr_type(:boolean) : editor_for_association
|
196
|
+
end
|
209
197
|
end
|
210
198
|
end
|
211
199
|
|
@@ -233,7 +221,7 @@ module Netzke
|
|
233
221
|
|
234
222
|
# Receives 2 arrays of columns. Merges the missing config from the +source+ into +dest+, matching columns by name
|
235
223
|
def reverse_merge_equally_named_columns(dest, source)
|
236
|
-
dest.each{ |dc| dc.reverse_merge!(source.detect{ |sc| sc[:name] == dc[:name] }) }
|
224
|
+
dest.each{ |dc| dc.reverse_merge!(source.detect{ |sc| sc[:name] == dc[:name] } || {}) }
|
237
225
|
end
|
238
226
|
|
239
227
|
def self.included(receiver)
|
@@ -8,6 +8,8 @@ module Netzke
|
|
8
8
|
# to the JavaScript side.
|
9
9
|
def js_config
|
10
10
|
super.merge(
|
11
|
+
:bbar => ext_config.has_key?(:bbar) ? ext_config[:bbar] : default_bbar,
|
12
|
+
:context_menu => ext_config.has_key?(:context_menu) ? ext_config[:context_menu] : default_context_menu,
|
11
13
|
:clmns => columns, # columns
|
12
14
|
:model => config[:model], # the model name
|
13
15
|
:inline_data => (get_data if ext_config[:load_inline_data]), # inline data (loaded along with the grid panel)
|
data/lib/netzke/search_panel.rb
CHANGED
@@ -34,8 +34,8 @@ module Netzke
|
|
34
34
|
|
35
35
|
def actions
|
36
36
|
super.merge(
|
37
|
-
:save => {:text => "Save", :icon => "
|
38
|
-
:del => {:text => "Delete", :icon => "
|
37
|
+
:save => {:text => "Save", :icon => Netzke::Base.config[:with_icons] && (Netzke::Base.config[:icons_uri] + "disk.png")},
|
38
|
+
:del => {:text => "Delete", :icon => Netzke::Base.config[:with_icons] && (Netzke::Base.config[:icons_uri] + "delete.png")}
|
39
39
|
)
|
40
40
|
end
|
41
41
|
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netzke-basepack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 17
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
8
|
+
- 14
|
9
|
+
version: 0.5.14
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Sergei Kozlov
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-08
|
17
|
+
date: 2010-09-08 00:00:00 +02:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -26,12 +25,11 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
28
|
segments:
|
31
29
|
- 0
|
32
30
|
- 5
|
33
|
-
-
|
34
|
-
version: 0.5.
|
31
|
+
- 5
|
32
|
+
version: 0.5.5
|
35
33
|
type: :runtime
|
36
34
|
version_requirements: *id001
|
37
35
|
- !ruby/object:Gem::Dependency
|
@@ -42,7 +40,6 @@ dependencies:
|
|
42
40
|
requirements:
|
43
41
|
- - ">="
|
44
42
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 15
|
46
43
|
segments:
|
47
44
|
- 2
|
48
45
|
- 0
|
@@ -58,7 +55,6 @@ dependencies:
|
|
58
55
|
requirements:
|
59
56
|
- - ">="
|
60
57
|
- !ruby/object:Gem::Version
|
61
|
-
hash: 15
|
62
58
|
segments:
|
63
59
|
- 2
|
64
60
|
- 0
|
@@ -74,7 +70,6 @@ dependencies:
|
|
74
70
|
requirements:
|
75
71
|
- - ">="
|
76
72
|
- !ruby/object:Gem::Version
|
77
|
-
hash: 31
|
78
73
|
segments:
|
79
74
|
- 0
|
80
75
|
- 1
|
@@ -208,21 +203,9 @@ has_rdoc: true
|
|
208
203
|
homepage: http://github.com/skozlov/netzke-basepack
|
209
204
|
licenses: []
|
210
205
|
|
211
|
-
post_install_message:
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
Thanks for installing Netzke Basepack!
|
216
|
-
|
217
|
-
Don't forget to run "./script/generate netzke_basepack" for each
|
218
|
-
Rails app that will be using this gem.
|
219
|
-
|
220
|
-
Netzke home page: http://netzke.org
|
221
|
-
Netzke Google Groups: http://groups.google.com/group/netzke
|
222
|
-
Netzke tutorials: http://blog.writelesscode.com
|
223
|
-
|
224
|
-
========================================================================
|
225
|
-
|
206
|
+
post_install_message: "\n\
|
207
|
+
========================================================================\n\n Thanks for installing Netzke Basepack!\n \n Don't forget to run \"./script/generate netzke_basepack\" for each \n Rails app that will be using this gem.\n\n Netzke home page: http://netzke.org\n Netzke Google Groups: http://groups.google.com/group/netzke\n Netzke tutorials: http://blog.writelesscode.com\n\n\
|
208
|
+
========================================================================\n\n"
|
226
209
|
rdoc_options:
|
227
210
|
- --charset=UTF-8
|
228
211
|
require_paths:
|
@@ -232,7 +215,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
232
215
|
requirements:
|
233
216
|
- - ">="
|
234
217
|
- !ruby/object:Gem::Version
|
235
|
-
hash: 3
|
236
218
|
segments:
|
237
219
|
- 0
|
238
220
|
version: "0"
|
@@ -241,7 +223,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
241
223
|
requirements:
|
242
224
|
- - ">="
|
243
225
|
- !ruby/object:Gem::Version
|
244
|
-
hash: 3
|
245
226
|
segments:
|
246
227
|
- 0
|
247
228
|
version: "0"
|