skozlov-netzke-basepack 0.5.0 → 0.5.1
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/.gitignore +1 -0
- data/CHANGELOG.rdoc +178 -0
- data/Rakefile +26 -16
- data/TODO.rdoc +1 -0
- data/VERSION +1 -1
- data/javascripts/basepack.js +1 -56
- data/lib/netzke/active_record/data_accessor.rb +13 -1
- data/lib/netzke/basic_app.rb +18 -22
- data/lib/netzke/configuration_panel.rb +1 -1
- data/lib/netzke/data_accessor.rb +1 -1
- data/lib/netzke/form_panel_api.rb +4 -4
- data/lib/netzke/grid_panel.rb +3 -5
- data/lib/netzke/grid_panel_api.rb +2 -2
- data/lib/netzke/grid_panel_js.rb +1 -1
- data/lib/netzke/masquerade_selector.rb +53 -0
- data/lib/netzke/plugins/configuration_tool.rb +1 -1
- data/lib/netzke/property_editor_extras/helper_model.rb +1 -1
- data/lib/netzke/tab_panel.rb +31 -21
- data/netzke-basepack.gemspec +10 -5
- data/test/app_root/db/migrate/20081222035855_create_netzke_preferences.rb +1 -1
- metadata +16 -4
data/.gitignore
CHANGED
data/CHANGELOG.rdoc
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
v0.5.1 - 2009-09-11
|
2
|
+
Fix: crash when FormPanel has no data_class_name specified.
|
3
|
+
New: DataAccessor widgets (Form/GridPanel) now let the underlying model know which widget (i.e. which instance) accesses its data. Can be useful in virtual attributes for generating widget-specific HTML.
|
4
|
+
Fix: DataAccessor widgets (Form/GridPanel) now don't crash when calculating default columns/fields for the underlying model that has polymorphic columns.
|
5
|
+
Fix: TabPanel was sending redundant "tabchange" event to server when initially instantiated.
|
6
|
+
Fix: column filters were making GridPanel crash when the column editor was set to "textarea".
|
7
|
+
Fix: dongling comma and "delete" object properties caused problems in IE and Safari.
|
8
|
+
Fix: a stand-alone TabPanel would not render the active item.
|
9
|
+
New: BasicApp: masquerading as "World". In this mode all the "touched" persistent preferences will be overwritten for all roles and users.
|
10
|
+
Impr: configuration panel's header now shows the underlying model's name for convenience.
|
11
|
+
Fix: MasqueradeSelector widget added.
|
12
|
+
|
13
|
+
v0.5.0
|
14
|
+
2009-09-06
|
15
|
+
Major refactoring and code reorganization.
|
16
|
+
Compatibility with netzke-core v0.4.0.
|
17
|
+
New: GridPanel now supports adding/editing records in a form and extended configurable search.
|
18
|
+
New: GridPanel now can be loaded along with initial data (saves a request to the server).
|
19
|
+
New: context menu in GridPanel
|
20
|
+
New: "scopes" configuration option added to GridPanel to specify the searchlogic-compatible scope for the data.
|
21
|
+
New: "strong_default_attrs" config option added to GridPanel to specify the attributes that will be assigned to each record that is created or modified by the grid.
|
22
|
+
Usability: GridPanel's actions now get enabled/disabled according to the current selection.
|
23
|
+
Configuration panel for grids and forms now works more consistently.
|
24
|
+
New: some smart defaults for column/fields in Grid/FormPanel.
|
25
|
+
New: BasicApp supports masquerading and application-wide AJAX activity indicator.
|
26
|
+
|
27
|
+
v0.4.2
|
28
|
+
2009-05-07
|
29
|
+
Fix: afterlayout event bind removed completely because of some tricky inconsistent behavior of Ext. BasicApp initializing code put directly into js_after_constructor.
|
30
|
+
|
31
|
+
v0.4.1
|
32
|
+
2009-05-07
|
33
|
+
Fix: afterlayout call moved to js_after_constructor in BasicApp
|
34
|
+
Fix: cleaner persistent_config handling
|
35
|
+
New: default's configuration enabled for FormPanel on class-level
|
36
|
+
Fix: differently configured forms on the same page were showing the same columns
|
37
|
+
Fix: TableEditor was showing config-tool by default (must be hidden)
|
38
|
+
|
39
|
+
v0.4.0
|
40
|
+
2009-05-07
|
41
|
+
Refactor: got rid of NetzkeFormPanelField and NetzkeGridPanelColumn classes along with their tables. The layout is now stored in netzke_preferences.
|
42
|
+
New: dynamic hiding of columns from column menu in GridPanel.
|
43
|
+
New: FormPanel now supports combo boxes.
|
44
|
+
Fix: config[:bbar] set to 'false' now works in grids with pagination
|
45
|
+
New: you can specify :preloaded => true in a tab config in TabPanel to preload the widget in that tab along with the TabPanel itself
|
46
|
+
New: hideBusy added to Ext.StatusBar
|
47
|
+
Fix: assigning association (a Boss to a Clerk) by virtual column (like boss__name) works now
|
48
|
+
Fix: an old bug that made GridPanel misbehave after reordering the columns
|
49
|
+
|
50
|
+
v0.3.10
|
51
|
+
BasicApp-based widgets can now introduce arbitrary layout, following the convention of defining "main-panel" and "main-toolbar" panels with layout 'fit'.
|
52
|
+
|
53
|
+
v0.3.9.1
|
54
|
+
Bug fix: (regression) appLoaded() in BasicApp gets executed again
|
55
|
+
|
56
|
+
v0.3.9
|
57
|
+
AccordionPanel tests added
|
58
|
+
TabPanel works now
|
59
|
+
AccordionPanel replaced with more intuitive TabPanel in the configuration window
|
60
|
+
Code clean-up by using "single" option to call appLoaded() on "afterlayout"
|
61
|
+
Table editor bug fix
|
62
|
+
|
63
|
+
v0.3.8
|
64
|
+
Fixing Ext's EditableItem render problem.
|
65
|
+
Filters by default enabled again in GridPanel.
|
66
|
+
GridPanel enhancement: base_params get sent along with post_data.
|
67
|
+
|
68
|
+
v0.3.7
|
69
|
+
Netzke-core version sync.
|
70
|
+
Rails 2.3.2 compatibility.
|
71
|
+
|
72
|
+
v0.3.6
|
73
|
+
Netzke-core v0.2.9 compatibility.
|
74
|
+
Cleaner handling of custom renderers in GridPanel.
|
75
|
+
New FormPanel-based PropertyEditor replaces PropertyGrid.
|
76
|
+
Xcheckbox and check-column introduced.
|
77
|
+
TODO file added.
|
78
|
+
Bug fix: in TableEditor, the grid now responses on events also after being reconfigured.
|
79
|
+
Bug fix: a couple of IE-related bugs.
|
80
|
+
Significant code clean-up.
|
81
|
+
|
82
|
+
v0.3.5
|
83
|
+
Netzke-core v0.2.8 compatibility.
|
84
|
+
|
85
|
+
v0.3.4
|
86
|
+
Quick tips added to the "tools".
|
87
|
+
Regression: the "General" configuration panel for GridPanel works again.
|
88
|
+
GridPanel: rows_per_page configuration is now read from General config panel.
|
89
|
+
|
90
|
+
v0.3.3.1
|
91
|
+
Obviously using "new" as a property name in JavaScript isn't liked by Safari. Fixed.
|
92
|
+
|
93
|
+
v0.3.3
|
94
|
+
Bug fix: application not loading the widget specified in the URL (Ext.History-related).
|
95
|
+
Some code refactoring and readability improvements.
|
96
|
+
Ext.componentCache renamed into Ext.netzke.cache.
|
97
|
+
New widget: TableEditor (a compound widget containing a grid and a form for editing table data).
|
98
|
+
BorderLayoutPanel: a function getRegionWidget(region) added to access a widget in the specified region.
|
99
|
+
Bug fix: BasicApp: FeedbackGhost now gets instantiated before BasicApp.
|
100
|
+
Clearer handling of requests to non-existing aggregatees.
|
101
|
+
Bug fix: now Ext 2.2.1 compatible.
|
102
|
+
Column operations are now handled properly when :persistent_layout is set to false.
|
103
|
+
Grid/Form fields configuration is extended with "ext_config" field which stores (in JSON-format) all the extra configuration, which gives extra flexibility to individual column/field configuration.
|
104
|
+
:persistent_layout set to false now makes a widget ignore what's in the DB.
|
105
|
+
Bug fix: AccordionPanel doesn't crash when no active item is specified.
|
106
|
+
Bug fix: redundant flash messages for GridPanel.
|
107
|
+
FeedbackGhost won't be showing anything if given an empty array.
|
108
|
+
Cleaner handling of validations in GridPanel.
|
109
|
+
FormPanel ready for the demo.
|
110
|
+
|
111
|
+
v0.3.2
|
112
|
+
Minor code restructuring.
|
113
|
+
Working on FormPanel cont'd.
|
114
|
+
|
115
|
+
v0.3.1
|
116
|
+
Added the "conditions" configuration option to GridPanel to limit the search
|
117
|
+
Basic column editor for grids has been replaced with FieldsConfigurator, which can do a bit more
|
118
|
+
Added Checkbox column/form-field type for boolean fields
|
119
|
+
"renderer" configuration option added for grid columns - any Ext.util.Format renderer can be specified there (thanks to Josh Holt for the initial idea)
|
120
|
+
|
121
|
+
v0.3.0
|
122
|
+
Added BasicApp widget - the base for a Ext.Viewport based ("application") widget with support for dynamic widget loading, browser history, authentification, and more. See the demo an http://netzke-demo.writelesscode.com
|
123
|
+
|
124
|
+
v0.2.2
|
125
|
+
Meta: updated netzke-core version (dependency)
|
126
|
+
|
127
|
+
v0.2.1
|
128
|
+
Regression: BorderLayoutPanel now restores the region sizes from the database
|
129
|
+
|
130
|
+
v0.2.0.1
|
131
|
+
Meta: updated netzke-core version (dependency)
|
132
|
+
|
133
|
+
v0.2.0
|
134
|
+
Some re-factoring and redesign along with netzke-core
|
135
|
+
Panel widget added
|
136
|
+
BorderLayoutPanel added
|
137
|
+
AccordionPanel added
|
138
|
+
Bug fix: column operations configuration misbehaving
|
139
|
+
Renamed Grid into GridPanel
|
140
|
+
Bug fix: exception was thrown at a column operation when no layout_manager was present
|
141
|
+
Reworked permission handling in GridPanel.
|
142
|
+
|
143
|
+
v0.1.4.1
|
144
|
+
Meta: updated netzke-core version (dependency)
|
145
|
+
|
146
|
+
v0.1.4
|
147
|
+
Grid#get_columns provides default columns even if none of layout_manager_class & column_manager_class are available
|
148
|
+
|
149
|
+
v0.1.3.1
|
150
|
+
Meta: updated netzke-core version (dependency)
|
151
|
+
|
152
|
+
v0.1.3
|
153
|
+
Path to javascript for grid filters corrected
|
154
|
+
Bug with creating new records in the grid fixed
|
155
|
+
Optimized away redundant sql queries when calling Grid#get_columns (sort of memoization)
|
156
|
+
README updated
|
157
|
+
|
158
|
+
v0.1.2.1
|
159
|
+
Meta: trying to succeed publishing on RubyForge
|
160
|
+
|
161
|
+
v0.1.2
|
162
|
+
Updated README with an example of stand-alone widget usage
|
163
|
+
Meta: updated netzke-core version (dependency)
|
164
|
+
|
165
|
+
v0.1.1.2
|
166
|
+
Meta: updated netzke-core version (dependency)
|
167
|
+
|
168
|
+
v0.1.1.1
|
169
|
+
Meta: github gem naming convention
|
170
|
+
|
171
|
+
v0.1.1
|
172
|
+
Cleaner exception handling while loading data to grid
|
173
|
+
Column resize & move functionality enabled by default
|
174
|
+
Column filters added
|
175
|
+
|
176
|
+
v0.1.0.1 Meta work: replacing underscore with dash in the name
|
177
|
+
|
178
|
+
v0.1.0 Initial release
|
data/Rakefile
CHANGED
@@ -1,18 +1,3 @@
|
|
1
|
-
# require 'echoe'
|
2
|
-
#
|
3
|
-
# Echoe.new("netzke-basepack") do |p|
|
4
|
-
# p.author = "Sergei Kozlov"
|
5
|
-
# p.email = "sergei@playcode.nl"
|
6
|
-
# p.summary = "Prebuilt Netzke widgets for your RIA"
|
7
|
-
# p.url = "http://playcode.nl"
|
8
|
-
# p.runtime_dependencies = ["binarylogic-searchlogic >= 2.0.0", "skozlov-netzke-core >= 0.4.0"]
|
9
|
-
# p.development_dependencies = []
|
10
|
-
# p.test_pattern = 'test/**/*_test.rb'
|
11
|
-
#
|
12
|
-
# # fixing the problem with lib/*-* files being removed while doing manifest
|
13
|
-
# p.clean_pattern = ["pkg", "doc", 'build/*', '**/coverage', '**/*.o', '**/*.so', '**/*.a', '**/*.log', "{ext,lib}/*.{bundle,so,obj,pdb,lib,def,exp}", "ext/Makefile", "{ext,lib}/**/*.{bundle,so,obj,pdb,lib,def,exp}", "ext/**/Makefile", "pkg", "*.gem", ".config"]
|
14
|
-
# end
|
15
|
-
|
16
1
|
begin
|
17
2
|
require 'jeweler'
|
18
3
|
Jeweler::Tasks.new do |gemspec|
|
@@ -23,8 +8,33 @@ begin
|
|
23
8
|
gemspec.homepage = "http://github.com/skozlov/netzke-basepack"
|
24
9
|
gemspec.rubyforge_project = "netzke-basepack"
|
25
10
|
gemspec.authors = ["Sergei Kozlov"]
|
26
|
-
gemspec.add_dependency "
|
11
|
+
gemspec.add_dependency "netzke-core"
|
12
|
+
gemspec.add_dependency "searchlogic"
|
13
|
+
end
|
14
|
+
Jeweler::RubyforgeTasks.new do |rubyforge|
|
15
|
+
rubyforge.doc_task = "rdoc"
|
27
16
|
end
|
28
17
|
rescue LoadError
|
29
18
|
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
30
19
|
end
|
20
|
+
|
21
|
+
require 'rake/rdoctask'
|
22
|
+
Rake::RDocTask.new do |rdoc|
|
23
|
+
if File.exist?('VERSION')
|
24
|
+
version = File.read('VERSION')
|
25
|
+
else
|
26
|
+
version = ""
|
27
|
+
end
|
28
|
+
|
29
|
+
rdoc.rdoc_dir = 'rdoc'
|
30
|
+
rdoc.title = "netzke-basepack #{version}"
|
31
|
+
rdoc.rdoc_files.include('README*')
|
32
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'rake/testtask'
|
36
|
+
Rake::TestTask.new(:test) do |test|
|
37
|
+
test.libs << 'lib' << 'test'
|
38
|
+
test.pattern = 'test/**/*_test.rb'
|
39
|
+
test.verbose = true
|
40
|
+
end
|
data/TODO.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.1
|
data/javascripts/basepack.js
CHANGED
@@ -89,6 +89,7 @@ Ext.util.Format.mask = function(v){
|
|
89
89
|
Ext.netzke.filterMap = {
|
90
90
|
numberfield:'Numeric',
|
91
91
|
textfield:'String',
|
92
|
+
textarea:'String',
|
92
93
|
xdatetime:'String',
|
93
94
|
checkbox:'Boolean',
|
94
95
|
combobox:'String',
|
@@ -150,62 +151,6 @@ Ext.netzke.JsonField = Ext.extend(Ext.form.TextField, {
|
|
150
151
|
|
151
152
|
Ext.reg('jsonfield', Ext.netzke.JsonField);
|
152
153
|
|
153
|
-
Ext.ns('Ext.netzke.form');
|
154
|
-
|
155
|
-
Ext.netzke.form.FileWithType = Ext.extend(Ext.form.Field, {
|
156
|
-
defaultAutoCreate:{tag:'input', type:'hidden'},
|
157
|
-
|
158
|
-
initComponent: function(){
|
159
|
-
Ext.netzke.form.FileWithType.superclass.initComponent.call(this);
|
160
|
-
|
161
|
-
// this.ft = new Ext.form.ComboBox({
|
162
|
-
// });
|
163
|
-
this.ft = new Ext.form.TextField({
|
164
|
-
name: this.name + "_filetype"
|
165
|
-
});
|
166
|
-
this.ft.ownerCt = this;
|
167
|
-
|
168
|
-
this.f = new Ext.form.TextField({
|
169
|
-
inputType:'file',
|
170
|
-
name: this.name + "_file"
|
171
|
-
});
|
172
|
-
this.f.ownerCt = this;
|
173
|
-
},
|
174
|
-
|
175
|
-
onRender: function(ct, position){
|
176
|
-
if(this.isRendered) {
|
177
|
-
return;
|
178
|
-
}
|
179
|
-
|
180
|
-
// render underlying hidden field
|
181
|
-
Ext.netzke.form.FileWithType.superclass.onRender.call(this, ct, position);
|
182
|
-
|
183
|
-
var t; // table
|
184
|
-
|
185
|
-
t = Ext.DomHelper.append(ct, {tag:'table',style:'border-collapse:collapse',children:[
|
186
|
-
{tag:'tr',children:[
|
187
|
-
{tag:'td', style:'padding:4px', cls:'ux-filewithtype-type'},
|
188
|
-
{tag:'td', style:'padding:4px', cls:'ux-filewithtype-file'}
|
189
|
-
]}
|
190
|
-
]}, true);
|
191
|
-
|
192
|
-
this.ft.render(t.child('td.ux-filewithtype-type'));
|
193
|
-
this.f.render(t.child('td.ux-filewithtype-file'));
|
194
|
-
|
195
|
-
this.el.dom.removeAttribute("name");
|
196
|
-
|
197
|
-
//
|
198
|
-
// this.tableEl = t;
|
199
|
-
|
200
|
-
// we're rendered flag
|
201
|
-
this.isRendered = true;
|
202
|
-
|
203
|
-
// this.updateHidden();
|
204
|
-
}
|
205
|
-
});
|
206
|
-
|
207
|
-
Ext.reg('filewithtype', Ext.netzke.form.FileWithType);
|
208
|
-
|
209
154
|
/**
|
210
155
|
* @class Ext.ux.form.DateTime
|
211
156
|
* @extends Ext.form.Field
|
@@ -2,8 +2,20 @@ module Netzke::ActiveRecord
|
|
2
2
|
# Provides extensions to those ActiveRecord-based models that provide data to the "data accessor" widgets,
|
3
3
|
# like GridPanel, FormPanel, etc
|
4
4
|
module DataAccessor
|
5
|
+
|
6
|
+
# Allow specify the netzke widget that requires this data. Virtual attributes may be using it to produce
|
7
|
+
# widget-dependent result.
|
8
|
+
def netzke_widget=(widget)
|
9
|
+
@netzke_widget = widget
|
10
|
+
end
|
11
|
+
|
12
|
+
def netzke_widget
|
13
|
+
@netzke_widget
|
14
|
+
end
|
15
|
+
|
5
16
|
# Transforms a record to array of values according to the passed columns.
|
6
|
-
def to_array(columns)
|
17
|
+
def to_array(columns, widget = nil)
|
18
|
+
self.netzke_widget = widget
|
7
19
|
res = []
|
8
20
|
for c in columns
|
9
21
|
nc = c.is_a?(Symbol) ? {:name => c} : c
|
data/lib/netzke/basic_app.rb
CHANGED
@@ -32,6 +32,8 @@ module Netzke
|
|
32
32
|
elsif session[:masq_role]
|
33
33
|
role = Role.find(session[:masq_role])
|
34
34
|
masq = %Q{role "#{role.name}"}
|
35
|
+
elsif session[:masq_world]
|
36
|
+
masq = %Q{World}
|
35
37
|
end
|
36
38
|
|
37
39
|
[{
|
@@ -153,7 +155,7 @@ module Netzke
|
|
153
155
|
END_OF_JAVASCRIPT
|
154
156
|
|
155
157
|
# Masquerade selector window
|
156
|
-
:show_masquerade_selector => <<-END_OF_JAVASCRIPT.l
|
158
|
+
:show_masquerade_selector => <<-END_OF_JAVASCRIPT.l
|
157
159
|
function(){
|
158
160
|
var w = new Ext.Window({
|
159
161
|
title: 'Masquerade as',
|
@@ -177,7 +179,18 @@ module Netzke
|
|
177
179
|
},
|
178
180
|
scope:this
|
179
181
|
},{
|
180
|
-
text:'
|
182
|
+
text:'As World',
|
183
|
+
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){
|
185
|
+
if (btn === "yes") {
|
186
|
+
this.masquerade = {world:true};
|
187
|
+
w.close();
|
188
|
+
}
|
189
|
+
}, this);
|
190
|
+
},
|
191
|
+
scope:this
|
192
|
+
},{
|
193
|
+
text:'No masquerading',
|
181
194
|
handler:function(){
|
182
195
|
this.masquerade = {};
|
183
196
|
w.close();
|
@@ -191,7 +204,7 @@ module Netzke
|
|
191
204
|
scope:this
|
192
205
|
}],
|
193
206
|
listeners : {close: {fn: function(){
|
194
|
-
this.
|
207
|
+
this.masqueradeAs(this.masquerade || w.getWidget().masquerade || {});
|
195
208
|
}, scope: this}}
|
196
209
|
});
|
197
210
|
|
@@ -201,24 +214,6 @@ module Netzke
|
|
201
214
|
|
202
215
|
}
|
203
216
|
END_OF_JAVASCRIPT
|
204
|
-
|
205
|
-
# Masquerade as...
|
206
|
-
:masq_as => <<-END_OF_JAVASCRIPT.l
|
207
|
-
function(masqConfig){
|
208
|
-
params = {};
|
209
|
-
|
210
|
-
if (masqConfig.user) {
|
211
|
-
params.user = masqConfig.user
|
212
|
-
}
|
213
|
-
|
214
|
-
if (masqConfig.role) {
|
215
|
-
params.role = masqConfig.role
|
216
|
-
}
|
217
|
-
|
218
|
-
this.masqueradeAs(params);
|
219
|
-
|
220
|
-
}
|
221
|
-
END_OF_JAVASCRIPT
|
222
217
|
}
|
223
218
|
end
|
224
219
|
end
|
@@ -260,7 +255,7 @@ module Netzke
|
|
260
255
|
|
261
256
|
if session[:netzke_just_logged_in] || session[:netzke_just_logged_out]
|
262
257
|
session[:config_mode] = false
|
263
|
-
session[:masq_user] = session[:masq_roles] = nil
|
258
|
+
session[:masq_world] = session[:masq_user] = session[:masq_roles] = nil
|
264
259
|
end
|
265
260
|
|
266
261
|
strong_children_config.deep_merge!({:ext_config => {:mode => :config}}) if session[:config_mode]
|
@@ -316,6 +311,7 @@ module Netzke
|
|
316
311
|
api :masquerade_as
|
317
312
|
def masquerade_as(params)
|
318
313
|
session = Netzke::Base.session
|
314
|
+
session[:masq_world] = params[:world]
|
319
315
|
session[:masq_role] = params[:role]
|
320
316
|
session[:masq_user] = params[:user]
|
321
317
|
{:js => "window.location.reload()"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Netzke
|
2
|
-
# TabPanel-based widget that wraps-up "
|
2
|
+
# TabPanel-based widget that wraps-up "configuration widgets" that each widget can define
|
3
3
|
# (along) with including the Plugins::ConfigurationTool tool.
|
4
4
|
class ConfigurationPanel < TabPanel
|
5
5
|
api :commit
|
data/lib/netzke/data_accessor.rb
CHANGED
@@ -24,7 +24,7 @@ module Netzke
|
|
24
24
|
def predefined_columns
|
25
25
|
helper_module = "Netzke::Helpers::#{short_widget_class_name}#{data_class.name}".constantize rescue nil
|
26
26
|
|
27
|
-
data_class_columns = data_class.column_names.map(&:to_sym)
|
27
|
+
data_class_columns = data_class && data_class.column_names.map(&:to_sym) || []
|
28
28
|
|
29
29
|
if helper_module
|
30
30
|
exposed_attributes = helper_module.respond_to?(:exposed_attributes) ? normalize_array_of_columns(helper_module.exposed_attributes) : nil
|
@@ -26,7 +26,7 @@ module Netzke
|
|
26
26
|
end
|
27
27
|
|
28
28
|
if success && @record.save
|
29
|
-
{:set_form_values =>
|
29
|
+
{:set_form_values => array_of_values}
|
30
30
|
else
|
31
31
|
# flash eventual errors
|
32
32
|
@record.errors.each_full do |msg|
|
@@ -48,8 +48,8 @@ module Netzke
|
|
48
48
|
# end
|
49
49
|
|
50
50
|
def load(params)
|
51
|
-
record = data_class && data_class.find_by_id(params[:id])
|
52
|
-
{:set_form_values =>
|
51
|
+
@record = data_class && data_class.find_by_id(params[:id])
|
52
|
+
{:set_form_values => array_of_values}
|
53
53
|
end
|
54
54
|
|
55
55
|
# API that returns options for a combobox
|
@@ -67,7 +67,7 @@ module Netzke
|
|
67
67
|
|
68
68
|
# Returns array of form values according to the configured columns
|
69
69
|
def array_of_values
|
70
|
-
@record && @record.to_array(columns)
|
70
|
+
@record && @record.to_array(columns, self)
|
71
71
|
end
|
72
72
|
|
73
73
|
end
|
data/lib/netzke/grid_panel.rb
CHANGED
@@ -385,7 +385,7 @@ module Netzke
|
|
385
385
|
# detect ActiveRecord column type (if the column is "real") or fall back to :virtual
|
386
386
|
type = (data_class.columns_hash[c[:name].to_s] && data_class.columns_hash[c[:name].to_s].type) || :virtual
|
387
387
|
|
388
|
-
# detect :assoc__method
|
388
|
+
# detect :assoc__method columns
|
389
389
|
if c[:name].to_s.index('__')
|
390
390
|
assoc_name, method = c[:name].to_s.split('__').map(&:to_sym)
|
391
391
|
if assoc = data_class.reflect_on_association(assoc_name)
|
@@ -399,7 +399,8 @@ module Netzke
|
|
399
399
|
end
|
400
400
|
|
401
401
|
# detect association column (e.g. :category_id)
|
402
|
-
|
402
|
+
assoc = data_class.reflect_on_all_associations.detect{|a| a.primary_key_name.to_sym == c[:name]}
|
403
|
+
if assoc && !assoc.options[:polymorphic]
|
403
404
|
c[:editor] ||= :combobox
|
404
405
|
assoc_method = %w{name title label id}.detect{|m| (assoc.klass.instance_methods + assoc.klass.column_names).include?(m) } || assoc.klass.primary_key
|
405
406
|
c[:name] = "#{assoc.name}__#{assoc_method}".to_sym
|
@@ -410,13 +411,10 @@ module Netzke
|
|
410
411
|
|
411
412
|
# default editor, dependent on column type
|
412
413
|
c[:editor] ||= TYPE_EDITOR_MAP[type] unless TYPE_EDITOR_MAP[type].nil?
|
413
|
-
|
414
414
|
# narrow column for checkbox
|
415
415
|
c[:width] ||= 50 if c[:editor] == :checkbox
|
416
|
-
|
417
416
|
# wider column for xdatetime
|
418
417
|
c[:width] ||= 120 if c[:editor] == :xdatetime
|
419
|
-
|
420
418
|
# hide ID column
|
421
419
|
c[:hidden] = true if c[:name] == data_class.primary_key.to_sym && c[:hidden].nil?
|
422
420
|
|
@@ -21,7 +21,7 @@ module Netzke
|
|
21
21
|
def get_data(params = {})
|
22
22
|
if !ext_config[:prohibit_read]
|
23
23
|
records = get_records(params)
|
24
|
-
{:data => records.map{|r| r.to_array(normalized_columns)}, :total => ext_config[:enable_pagination] && records.total_entries}
|
24
|
+
{:data => records.map{|r| r.to_array(normalized_columns, self)}, :total => ext_config[:enable_pagination] && records.total_entries}
|
25
25
|
else
|
26
26
|
flash :error => "You don't have permissions to read data"
|
27
27
|
{:feedback => @flash}
|
@@ -149,7 +149,7 @@ module Netzke
|
|
149
149
|
|
150
150
|
# try to save
|
151
151
|
# modified_records += 1 if success && record.save
|
152
|
-
mod_records[id] = record.to_array(columns) if success && record.save
|
152
|
+
mod_records[id] = record.to_array(columns, self) if success && record.save
|
153
153
|
# mod_record_ids << id if success && record.save
|
154
154
|
|
155
155
|
# flash eventual errors
|
data/lib/netzke/grid_panel_js.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
module Netzke
|
2
|
+
class MasqueradeSelector < TabPanel
|
3
|
+
|
4
|
+
def items
|
5
|
+
@items ||= [{
|
6
|
+
:name => "roles",
|
7
|
+
:active => true,
|
8
|
+
:widget_class_name => "GridPanel",
|
9
|
+
:data_class_name => 'Role',
|
10
|
+
:columns => [:id, :name],
|
11
|
+
:ext_config => {
|
12
|
+
:header => false,
|
13
|
+
:bbar => ['search']
|
14
|
+
}
|
15
|
+
},{
|
16
|
+
:name => "users",
|
17
|
+
:preloaded => true,
|
18
|
+
:widget_class_name => "GridPanel",
|
19
|
+
:data_class_name => 'User',
|
20
|
+
:ext_config => {
|
21
|
+
:header => false,
|
22
|
+
:rows_per_page => 10,
|
23
|
+
:bbar => ['search']
|
24
|
+
},
|
25
|
+
:columns => [:id, :login]
|
26
|
+
}]
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.js_extend_properties
|
30
|
+
{
|
31
|
+
:after_constructor => <<-END_OF_JAVASCRIPT.l,
|
32
|
+
function(){
|
33
|
+
this.items.each(function(tab){
|
34
|
+
tab.on('add', function(ct, cmp){
|
35
|
+
cmp.on('rowclick', this.rowclickHandler, this);
|
36
|
+
}, this);
|
37
|
+
}, this);
|
38
|
+
}
|
39
|
+
END_OF_JAVASCRIPT
|
40
|
+
|
41
|
+
:rowclick_handler => <<-END_OF_JAVASCRIPT.l
|
42
|
+
function(grid, rowIndex, e){
|
43
|
+
var mode = grid.id.split("__").pop();
|
44
|
+
var normMode = mode === 'users' ? 'user' : 'role';
|
45
|
+
this.masquerade = {};
|
46
|
+
this.masquerade[normMode] = grid.store.getAt(rowIndex).get('id');
|
47
|
+
}
|
48
|
+
END_OF_JAVASCRIPT
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
data/lib/netzke/tab_panel.rb
CHANGED
@@ -22,11 +22,28 @@ module Netzke
|
|
22
22
|
:id_delimiter => "___", # the default was "__", which conflicts with Netzke's double underscore notation
|
23
23
|
:defaults => {:layout => 'fit'}, # all tabs will be Ext.Panel-s with layout 'fit' ("fit-panels")
|
24
24
|
|
25
|
-
:
|
26
|
-
function(){
|
27
|
-
Ext.netzke.cache.#{short_widget_class_name}.superclass.
|
25
|
+
:render => <<-END_OF_JAVASCRIPT.l,
|
26
|
+
function(el){
|
27
|
+
Ext.netzke.cache.#{short_widget_class_name}.superclass.render.call(this, el);
|
28
28
|
|
29
|
-
this
|
29
|
+
// We do this all in +render+ because only at this moment the activeTab is actually activated
|
30
|
+
var activeTab = this.getActiveTab();
|
31
|
+
this.loadWidgetInto(activeTab);
|
32
|
+
this.on('tabchange', this.onTabChange, this);
|
33
|
+
}
|
34
|
+
END_OF_JAVASCRIPT
|
35
|
+
|
36
|
+
:load_widget_into => <<-END_OF_JAVASCRIPT.l,
|
37
|
+
function(fitPanel){
|
38
|
+
var preloadedItemConfig = this[fitPanel.widget.camelize(true)+"Config"];
|
39
|
+
if (preloadedItemConfig){
|
40
|
+
// preloaded widget only needs to be instantiated, as its class and configuration have already been loaded
|
41
|
+
fitPanel.add(new Ext.netzke.cache[preloadedItemConfig.widgetClassName](preloadedItemConfig));
|
42
|
+
fitPanel.doLayout();
|
43
|
+
} else {
|
44
|
+
// load the widget from the server
|
45
|
+
this.loadAggregatee({id:fitPanel.widget, container:fitPanel.id});
|
46
|
+
}
|
30
47
|
}
|
31
48
|
END_OF_JAVASCRIPT
|
32
49
|
|
@@ -58,27 +75,20 @@ module Netzke
|
|
58
75
|
}
|
59
76
|
END_OF_JAVASCRIPT
|
60
77
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
if (!
|
65
|
-
|
66
|
-
// preloaded widget only needs to be instantiated, as its class and configuration have already been loaded
|
67
|
-
panel.add(new Ext.netzke.cache[preloadedItemConfig.widgetClassName](preloadedItemConfig));
|
68
|
-
panel.doLayout(); // always needed after adding a component
|
69
|
-
} else {
|
70
|
-
// load the widget from the server
|
71
|
-
this.loadAggregatee({id:panel.widget, container:panel.id});
|
72
|
-
}
|
78
|
+
:on_tab_change => <<-END_OF_JAVASCRIPT.l
|
79
|
+
function(self, tab) {
|
80
|
+
// load widget into the panel if it wasn't loaded yet
|
81
|
+
if (!tab.getWidget()) {
|
82
|
+
this.loadWidgetInto(tab);
|
73
83
|
}
|
74
84
|
|
75
|
-
// inform the server about active tab
|
76
|
-
this.apiActivateTab({tab:
|
85
|
+
// inform the server about active tab change
|
86
|
+
this.apiActivateTab({tab:tab.widget});
|
77
87
|
|
78
88
|
// call "update" on the widget
|
79
|
-
if (
|
80
|
-
|
81
|
-
var widget =
|
89
|
+
if (tab.outdated) {
|
90
|
+
tab.outdated = false;
|
91
|
+
var widget = tab.getWidget();
|
82
92
|
if (widget && widget.update) {widget.update.call(widget)};
|
83
93
|
}
|
84
94
|
}
|
data/netzke-basepack.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{netzke-basepack}
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Sergei Kozlov"]
|
12
|
-
s.date = %q{2009-09-
|
12
|
+
s.date = %q{2009-09-11}
|
13
13
|
s.description = %q{Pre-built Netzke widgets for your RIA}
|
14
14
|
s.email = %q{sergei@playcode.nl}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.files = [
|
20
20
|
".autotest",
|
21
21
|
".gitignore",
|
22
|
+
"CHANGELOG.rdoc",
|
22
23
|
"LICENSE",
|
23
24
|
"README.rdoc",
|
24
25
|
"Rakefile",
|
@@ -50,6 +51,7 @@ Gem::Specification.new do |s|
|
|
50
51
|
"lib/netzke/grid_panel_extras/javascripts/filters.js",
|
51
52
|
"lib/netzke/grid_panel_extras/javascripts/rows-dd.js",
|
52
53
|
"lib/netzke/grid_panel_js.rb",
|
54
|
+
"lib/netzke/masquerade_selector.rb",
|
53
55
|
"lib/netzke/panel.rb",
|
54
56
|
"lib/netzke/plugins/configuration_tool.rb",
|
55
57
|
"lib/netzke/property_editor.rb",
|
@@ -155,11 +157,14 @@ Gem::Specification.new do |s|
|
|
155
157
|
s.specification_version = 3
|
156
158
|
|
157
159
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
158
|
-
s.add_runtime_dependency(%q<
|
160
|
+
s.add_runtime_dependency(%q<netzke-core>, [">= 0"])
|
161
|
+
s.add_runtime_dependency(%q<searchlogic>, [">= 0"])
|
159
162
|
else
|
160
|
-
s.add_dependency(%q<
|
163
|
+
s.add_dependency(%q<netzke-core>, [">= 0"])
|
164
|
+
s.add_dependency(%q<searchlogic>, [">= 0"])
|
161
165
|
end
|
162
166
|
else
|
163
|
-
s.add_dependency(%q<
|
167
|
+
s.add_dependency(%q<netzke-core>, [">= 0"])
|
168
|
+
s.add_dependency(%q<searchlogic>, [">= 0"])
|
164
169
|
end
|
165
170
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skozlov-netzke-basepack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergei Kozlov
|
@@ -9,18 +9,28 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-11 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: netzke-core
|
17
17
|
type: :runtime
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: searchlogic
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
24
34
|
version:
|
25
35
|
description: Pre-built Netzke widgets for your RIA
|
26
36
|
email: sergei@playcode.nl
|
@@ -34,6 +44,7 @@ extra_rdoc_files:
|
|
34
44
|
files:
|
35
45
|
- .autotest
|
36
46
|
- .gitignore
|
47
|
+
- CHANGELOG.rdoc
|
37
48
|
- LICENSE
|
38
49
|
- README.rdoc
|
39
50
|
- Rakefile
|
@@ -65,6 +76,7 @@ files:
|
|
65
76
|
- lib/netzke/grid_panel_extras/javascripts/filters.js
|
66
77
|
- lib/netzke/grid_panel_extras/javascripts/rows-dd.js
|
67
78
|
- lib/netzke/grid_panel_js.rb
|
79
|
+
- lib/netzke/masquerade_selector.rb
|
68
80
|
- lib/netzke/panel.rb
|
69
81
|
- lib/netzke/plugins/configuration_tool.rb
|
70
82
|
- lib/netzke/property_editor.rb
|