netzke-basepack 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/Manifest +1 -0
- data/Rakefile +1 -1
- data/lib/netzke/basic_app.rb +184 -0
- data/lib/netzke/grid_panel_interface.rb +1 -2
- data/netzke-basepack.gemspec +7 -7
- metadata +5 -3
data/CHANGELOG
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
v0.3.0
|
2
|
+
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
|
3
|
+
|
1
4
|
v0.2.2
|
2
5
|
Meta: updated netzke-core version (dependency)
|
3
6
|
|
data/Manifest
CHANGED
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
|
+
p.runtime_dependencies = ["searchlogic >=1.6.2", "netzke-core >= 0.2.3"]
|
9
9
|
p.development_dependencies = []
|
10
10
|
p.test_pattern = 'test/**/*_test.rb'
|
11
11
|
|
@@ -0,0 +1,184 @@
|
|
1
|
+
module Netzke
|
2
|
+
#
|
3
|
+
# Basis for a Ext.Viewport-based application
|
4
|
+
#
|
5
|
+
# Features:
|
6
|
+
# * dynamic loading of widgets
|
7
|
+
# * restoring of the last loaded widget
|
8
|
+
# * authentification support
|
9
|
+
# * browser history support (press the "Back"-button to go to the previously loaded widget)
|
10
|
+
# * FeedbackGhost-powered feedback
|
11
|
+
# * aggregation of widget's own menus (TODO: coming soon)
|
12
|
+
#
|
13
|
+
class BasicApp < Base
|
14
|
+
interface :app_get_widget # to dynamically load the widgets that are defined in initial_late_aggregatees
|
15
|
+
|
16
|
+
module ClassMethods
|
17
|
+
|
18
|
+
def js_base_class
|
19
|
+
"Ext.Viewport"
|
20
|
+
end
|
21
|
+
|
22
|
+
# Global BasicApp configuration
|
23
|
+
def config
|
24
|
+
set_default_config({
|
25
|
+
:logout_url => "/logout" # logout url assumed by default
|
26
|
+
})
|
27
|
+
end
|
28
|
+
|
29
|
+
# The layout
|
30
|
+
def js_default_config
|
31
|
+
super.merge({
|
32
|
+
:layout => 'border',
|
33
|
+
:items => [{
|
34
|
+
:id => 'main-panel',
|
35
|
+
:region => 'center',
|
36
|
+
:layout => 'fit'
|
37
|
+
},{
|
38
|
+
:id => 'main-toolbar',
|
39
|
+
:xtype => 'toolbar',
|
40
|
+
:region => 'north',
|
41
|
+
:height => 25,
|
42
|
+
:items => js_initial_menus
|
43
|
+
}]
|
44
|
+
})
|
45
|
+
end
|
46
|
+
|
47
|
+
# Set the event to do some things after the application is completely visible (e.g. to load the initial widget)
|
48
|
+
def js_listeners
|
49
|
+
{:afterlayout => {:fn => "this.onAfterLayout".l, :scope => this}}
|
50
|
+
end
|
51
|
+
|
52
|
+
# Set the Logout button if Netzke::Base.user is set
|
53
|
+
def js_initial_menus
|
54
|
+
res = []
|
55
|
+
user = Netzke::Base.user
|
56
|
+
if !user.nil?
|
57
|
+
user_name = user.respond_to?(:name) ? user.name : user.login # try to display user's name, fallback to login
|
58
|
+
res << "->" <<
|
59
|
+
{
|
60
|
+
:text => "Logout #{user_name}",
|
61
|
+
:handler => <<-JS.l,
|
62
|
+
function(){
|
63
|
+
Ext.MessageBox.confirm('Confirm', 'Are you sure you want to logout?', function(btn){
|
64
|
+
if( btn == "yes" ) {
|
65
|
+
this.logout();
|
66
|
+
}
|
67
|
+
}.createDelegate(this));
|
68
|
+
}
|
69
|
+
JS
|
70
|
+
:scope => this
|
71
|
+
}
|
72
|
+
end
|
73
|
+
res
|
74
|
+
end
|
75
|
+
|
76
|
+
def js_extend_properties
|
77
|
+
super.merge({
|
78
|
+
|
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
|
+
# Initialize
|
94
|
+
:app_loaded => <<-JS.l,
|
95
|
+
function(){
|
96
|
+
// Initialize menus (upcoming support for dynamically loaded menus)
|
97
|
+
this.menus = {};
|
98
|
+
|
99
|
+
// Initialize history
|
100
|
+
Ext.History.init();
|
101
|
+
Ext.History.on('change', this.processHistory, this);
|
102
|
+
|
103
|
+
// If we are given a token, load the corresponding widget, otherwise load the last loaded widget
|
104
|
+
var currentToken = Ext.History.getToken();
|
105
|
+
if (currentToken != "") {
|
106
|
+
this.processHistory(currentToken)
|
107
|
+
} else {
|
108
|
+
var lastLoaded = this.initialConfig.widgetToLoad; // passed from the server
|
109
|
+
if (lastLoaded) Ext.History.add(lastLoaded);
|
110
|
+
}
|
111
|
+
}
|
112
|
+
JS
|
113
|
+
|
114
|
+
# Event handler for history change
|
115
|
+
:process_history => <<-JS.l,
|
116
|
+
function(token){
|
117
|
+
if (token){
|
118
|
+
Ext.getCmp('main-panel').loadWidget(this.initialConfig.interface.appGetWidget, {widget:token})
|
119
|
+
} else {
|
120
|
+
Ext.getCmp('main-panel').loadWidget(null)
|
121
|
+
}
|
122
|
+
}
|
123
|
+
JS
|
124
|
+
|
125
|
+
#
|
126
|
+
# Set this function as the event handler for your menus, e.g.:
|
127
|
+
#
|
128
|
+
# :menu => {
|
129
|
+
# :items => [{
|
130
|
+
# :text => "Books",
|
131
|
+
# :handler => "this.appLoadWidget".l,
|
132
|
+
# :widget => 'books', # specify here the name of the widget to be loaded
|
133
|
+
# :scope => this
|
134
|
+
# }]
|
135
|
+
# }
|
136
|
+
#
|
137
|
+
:app_load_widget => <<-JS.l
|
138
|
+
function(menuItem){
|
139
|
+
Ext.History.add(menuItem.widget)
|
140
|
+
}
|
141
|
+
JS
|
142
|
+
|
143
|
+
})
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
extend ClassMethods
|
148
|
+
|
149
|
+
# Pass the last loaded widget from the persistent storage (DB) to the browser
|
150
|
+
def js_config
|
151
|
+
super.merge({:widget_to_load => persistent_config['last_loaded_widget']})
|
152
|
+
end
|
153
|
+
|
154
|
+
# Html required for Ext.History to work
|
155
|
+
def js_widget_html
|
156
|
+
super << %Q{
|
157
|
+
<form id="history-form" class="x-hidden">
|
158
|
+
<input type="hidden" id="x-history-field" />
|
159
|
+
<iframe id="x-history-frame"></iframe>
|
160
|
+
</form>
|
161
|
+
}
|
162
|
+
end
|
163
|
+
|
164
|
+
# We rely on the FeedbackGhost (to not need to implement our own feedback management)
|
165
|
+
def initial_aggregatees
|
166
|
+
{:feedback_ghost => {:widget_class_name => "FeedbackGhost"}}
|
167
|
+
end
|
168
|
+
|
169
|
+
# Besides instantiating ourselves, also instantiate the FeedbackGhost
|
170
|
+
def js_widget_instance
|
171
|
+
super << %Q{
|
172
|
+
new Ext.componentCache['FeedbackGhost']({id:'feedback_ghost'})
|
173
|
+
}
|
174
|
+
end
|
175
|
+
|
176
|
+
# Interface implementation
|
177
|
+
def interface_app_get_widget(params)
|
178
|
+
widget = params.delete(:widget)
|
179
|
+
persistent_config['last_loaded_widget'] = widget # store the last loaded widget in the persistent storage
|
180
|
+
send("#{widget}__get_widget", params)
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
184
|
+
end
|
@@ -73,7 +73,6 @@ module Netzke::GridPanelInterface
|
|
73
73
|
exception = nil
|
74
74
|
|
75
75
|
# process all attirubutes for the same record (OPTIMIZE: we can use update_attributes separately for regular attributes to speed things up)
|
76
|
-
logger.debug { "!!! record_hash: #{record_hash.inspect}" }
|
77
76
|
record_hash.each_pair do |k,v|
|
78
77
|
begin
|
79
78
|
record.send("#{k}=",v)
|
@@ -92,7 +91,7 @@ module Netzke::GridPanelInterface
|
|
92
91
|
flash :error => msg
|
93
92
|
end
|
94
93
|
|
95
|
-
flash :notice => "#{operation.to_s.capitalize}d #{modified_records}
|
94
|
+
flash :notice => "#{operation.to_s.capitalize}d #{modified_records} record(s)"
|
96
95
|
end
|
97
96
|
else
|
98
97
|
flash :error => "You don't have permissions to #{operation} data"
|
data/netzke-basepack.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{netzke-basepack}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.3.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Sergei Kozlov"]
|
9
|
-
s.date = %q{2009-01-
|
9
|
+
s.date = %q{2009-01-25}
|
10
10
|
s.description = %q{Base Netzke widgets - grid, form, tree, and more}
|
11
11
|
s.email = %q{sergei@writelesscode.com}
|
12
|
-
s.extra_rdoc_files = ["CHANGELOG", "lib/app/models/netzke_form_panel_field.rb", "lib/app/models/netzke_grid_panel_column.rb", "lib/netzke/accordion_panel.rb", "lib/netzke/ar_ext.rb", "lib/netzke/border_layout_panel.rb", "lib/netzke/column.rb", "lib/netzke/container.rb", "lib/netzke/form_panel.rb", "lib/netzke/grid_panel.rb", "lib/netzke/grid_panel_interface.rb", "lib/netzke/grid_panel_js_builder.rb", "lib/netzke/panel.rb", "lib/netzke/preference_grid.rb", "lib/netzke/properties_tool.rb", "lib/netzke/property_grid.rb", "lib/netzke/wrapper.rb", "lib/netzke-basepack.rb", "LICENSE", "README.rdoc", "tasks/netzke_basepack_tasks.rake"]
|
13
|
-
s.files = ["CHANGELOG", "css/basepack.css", "generators/netzke_basepack/netzke_basepack_generator.rb", "generators/netzke_basepack/USAGE", "generators/netzke_form_panel/netzke_form_panel_generator.rb", "generators/netzke_form_panel/templates/create_netzke_form_panel_fields.rb", "generators/netzke_grid_panel/netzke_grid_panel_generator.rb", "generators/netzke_grid_panel/templates/create_netzke_grid_panel_columns.rb", "init.rb", "install.rb", "javascripts/basepack.js", "javascripts/filters.js", "lib/app/models/netzke_form_panel_field.rb", "lib/app/models/netzke_grid_panel_column.rb", "lib/netzke/accordion_panel.rb", "lib/netzke/ar_ext.rb", "lib/netzke/border_layout_panel.rb", "lib/netzke/column.rb", "lib/netzke/container.rb", "lib/netzke/form_panel.rb", "lib/netzke/grid_panel.rb", "lib/netzke/grid_panel_interface.rb", "lib/netzke/grid_panel_js_builder.rb", "lib/netzke/panel.rb", "lib/netzke/preference_grid.rb", "lib/netzke/properties_tool.rb", "lib/netzke/property_grid.rb", "lib/netzke/wrapper.rb", "lib/netzke-basepack.rb", "LICENSE", "Manifest", "Rakefile", "README.rdoc", "tasks/netzke_basepack_tasks.rake", "test/app_root/app/controllers/application.rb", "test/app_root/app/models/book.rb", "test/app_root/app/models/category.rb", "test/app_root/app/models/city.rb", "test/app_root/app/models/continent.rb", "test/app_root/app/models/country.rb", "test/app_root/app/models/genre.rb", "test/app_root/config/boot.rb", "test/app_root/config/database.yml", "test/app_root/config/environment.rb", "test/app_root/config/environments/in_memory.rb", "test/app_root/config/environments/mysql.rb", "test/app_root/config/environments/postgresql.rb", "test/app_root/config/environments/sqlite.rb", "test/app_root/config/environments/sqlite3.rb", "test/app_root/config/routes.rb", "test/app_root/db/migrate/20081222033343_create_books.rb", "test/app_root/db/migrate/20081222033440_create_genres.rb", "test/app_root/db/migrate/20081222035855_create_netzke_preferences.rb", "test/app_root/db/migrate/20081223024935_create_categories.rb", "test/app_root/db/migrate/20081223025635_create_countries.rb", "test/app_root/db/migrate/20081223025653_create_continents.rb", "test/app_root/db/migrate/20081223025732_create_cities.rb", "test/app_root/db/migrate/20090102223630_create_netzke_layouts.rb", "test/app_root/db/migrate/20090102223811_create_netzke_grid_panel_columns.rb", "test/app_root/script/console", "test/app_root/vendor/plugins/acts_as_list/init.rb", "test/app_root/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb", "test/app_root/vendor/plugins/acts_as_list/README", "test/ar_ext_test.rb", "test/border_layout_panel_test.rb", "test/column_test.rb", "test/console_with_fixtures.rb", "test/fixtures/books.yml", "test/fixtures/categories.yml", "test/fixtures/cities.yml", "test/fixtures/continents.yml", "test/fixtures/countries.yml", "test/fixtures/genres.yml", "test/grid_panel_test.rb", "test/netzke_basepack_test.rb", "test/schema.rb", "test/test_helper.rb", "uninstall.rb", "netzke-basepack.gemspec"]
|
12
|
+
s.extra_rdoc_files = ["CHANGELOG", "lib/app/models/netzke_form_panel_field.rb", "lib/app/models/netzke_grid_panel_column.rb", "lib/netzke/accordion_panel.rb", "lib/netzke/ar_ext.rb", "lib/netzke/basic_app.rb", "lib/netzke/border_layout_panel.rb", "lib/netzke/column.rb", "lib/netzke/container.rb", "lib/netzke/form_panel.rb", "lib/netzke/grid_panel.rb", "lib/netzke/grid_panel_interface.rb", "lib/netzke/grid_panel_js_builder.rb", "lib/netzke/panel.rb", "lib/netzke/preference_grid.rb", "lib/netzke/properties_tool.rb", "lib/netzke/property_grid.rb", "lib/netzke/wrapper.rb", "lib/netzke-basepack.rb", "LICENSE", "README.rdoc", "tasks/netzke_basepack_tasks.rake"]
|
13
|
+
s.files = ["CHANGELOG", "css/basepack.css", "generators/netzke_basepack/netzke_basepack_generator.rb", "generators/netzke_basepack/USAGE", "generators/netzke_form_panel/netzke_form_panel_generator.rb", "generators/netzke_form_panel/templates/create_netzke_form_panel_fields.rb", "generators/netzke_grid_panel/netzke_grid_panel_generator.rb", "generators/netzke_grid_panel/templates/create_netzke_grid_panel_columns.rb", "init.rb", "install.rb", "javascripts/basepack.js", "javascripts/filters.js", "lib/app/models/netzke_form_panel_field.rb", "lib/app/models/netzke_grid_panel_column.rb", "lib/netzke/accordion_panel.rb", "lib/netzke/ar_ext.rb", "lib/netzke/basic_app.rb", "lib/netzke/border_layout_panel.rb", "lib/netzke/column.rb", "lib/netzke/container.rb", "lib/netzke/form_panel.rb", "lib/netzke/grid_panel.rb", "lib/netzke/grid_panel_interface.rb", "lib/netzke/grid_panel_js_builder.rb", "lib/netzke/panel.rb", "lib/netzke/preference_grid.rb", "lib/netzke/properties_tool.rb", "lib/netzke/property_grid.rb", "lib/netzke/wrapper.rb", "lib/netzke-basepack.rb", "LICENSE", "Manifest", "Rakefile", "README.rdoc", "tasks/netzke_basepack_tasks.rake", "test/app_root/app/controllers/application.rb", "test/app_root/app/models/book.rb", "test/app_root/app/models/category.rb", "test/app_root/app/models/city.rb", "test/app_root/app/models/continent.rb", "test/app_root/app/models/country.rb", "test/app_root/app/models/genre.rb", "test/app_root/config/boot.rb", "test/app_root/config/database.yml", "test/app_root/config/environment.rb", "test/app_root/config/environments/in_memory.rb", "test/app_root/config/environments/mysql.rb", "test/app_root/config/environments/postgresql.rb", "test/app_root/config/environments/sqlite.rb", "test/app_root/config/environments/sqlite3.rb", "test/app_root/config/routes.rb", "test/app_root/db/migrate/20081222033343_create_books.rb", "test/app_root/db/migrate/20081222033440_create_genres.rb", "test/app_root/db/migrate/20081222035855_create_netzke_preferences.rb", "test/app_root/db/migrate/20081223024935_create_categories.rb", "test/app_root/db/migrate/20081223025635_create_countries.rb", "test/app_root/db/migrate/20081223025653_create_continents.rb", "test/app_root/db/migrate/20081223025732_create_cities.rb", "test/app_root/db/migrate/20090102223630_create_netzke_layouts.rb", "test/app_root/db/migrate/20090102223811_create_netzke_grid_panel_columns.rb", "test/app_root/script/console", "test/app_root/vendor/plugins/acts_as_list/init.rb", "test/app_root/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb", "test/app_root/vendor/plugins/acts_as_list/README", "test/ar_ext_test.rb", "test/border_layout_panel_test.rb", "test/column_test.rb", "test/console_with_fixtures.rb", "test/fixtures/books.yml", "test/fixtures/categories.yml", "test/fixtures/cities.yml", "test/fixtures/continents.yml", "test/fixtures/countries.yml", "test/fixtures/genres.yml", "test/grid_panel_test.rb", "test/netzke_basepack_test.rb", "test/schema.rb", "test/test_helper.rb", "uninstall.rb", "netzke-basepack.gemspec"]
|
14
14
|
s.has_rdoc = true
|
15
15
|
s.homepage = %q{http://writelesscode.com}
|
16
16
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Netzke-basepack", "--main", "README.rdoc"]
|
@@ -26,13 +26,13 @@ Gem::Specification.new do |s|
|
|
26
26
|
|
27
27
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
28
|
s.add_runtime_dependency(%q<searchlogic>, [">= 1.6.2"])
|
29
|
-
s.add_runtime_dependency(%q<netzke-core>, [">= 0", "= 0.2.
|
29
|
+
s.add_runtime_dependency(%q<netzke-core>, [">= 0", "= 0.2.3"])
|
30
30
|
else
|
31
31
|
s.add_dependency(%q<searchlogic>, [">= 1.6.2"])
|
32
|
-
s.add_dependency(%q<netzke-core>, [">= 0", "= 0.2.
|
32
|
+
s.add_dependency(%q<netzke-core>, [">= 0", "= 0.2.3"])
|
33
33
|
end
|
34
34
|
else
|
35
35
|
s.add_dependency(%q<searchlogic>, [">= 1.6.2"])
|
36
|
-
s.add_dependency(%q<netzke-core>, [">= 0", "= 0.2.
|
36
|
+
s.add_dependency(%q<netzke-core>, [">= 0", "= 0.2.3"])
|
37
37
|
end
|
38
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netzke-basepack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergei Kozlov
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-01-
|
12
|
+
date: 2009-01-25 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: "0"
|
34
34
|
- - "="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 0.2.
|
36
|
+
version: 0.2.3
|
37
37
|
version:
|
38
38
|
description: Base Netzke widgets - grid, form, tree, and more
|
39
39
|
email: sergei@writelesscode.com
|
@@ -47,6 +47,7 @@ extra_rdoc_files:
|
|
47
47
|
- lib/app/models/netzke_grid_panel_column.rb
|
48
48
|
- lib/netzke/accordion_panel.rb
|
49
49
|
- lib/netzke/ar_ext.rb
|
50
|
+
- lib/netzke/basic_app.rb
|
50
51
|
- lib/netzke/border_layout_panel.rb
|
51
52
|
- lib/netzke/column.rb
|
52
53
|
- lib/netzke/container.rb
|
@@ -80,6 +81,7 @@ files:
|
|
80
81
|
- lib/app/models/netzke_grid_panel_column.rb
|
81
82
|
- lib/netzke/accordion_panel.rb
|
82
83
|
- lib/netzke/ar_ext.rb
|
84
|
+
- lib/netzke/basic_app.rb
|
83
85
|
- lib/netzke/border_layout_panel.rb
|
84
86
|
- lib/netzke/column.rb
|
85
87
|
- lib/netzke/container.rb
|