netzke-basepack 0.5.14 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -2
- data/CHANGELOG.rdoc +15 -0
- data/README.rdoc +45 -50
- data/Rakefile +8 -8
- data/TODO.rdoc +1 -6
- data/app/components/netzke/basepack/accordion_panel.rb +37 -0
- data/app/components/netzke/basepack/basic_app.rb +267 -0
- data/{lib/netzke → app/components/netzke/basepack}/basic_app/statusbar_ext.js +0 -0
- data/app/components/netzke/basepack/border_layout_panel.rb +39 -0
- data/app/components/netzke/basepack/form_panel.rb +102 -0
- data/app/components/netzke/basepack/form_panel/fields.rb +206 -0
- data/{lib/netzke → app/components/netzke/basepack}/form_panel/javascripts/netzkefileupload.js +0 -0
- data/app/components/netzke/basepack/form_panel/javascripts/pre.js +76 -0
- data/{lib/netzke → app/components/netzke/basepack}/form_panel/javascripts/xcheckbox.js +0 -0
- data/app/components/netzke/basepack/form_panel/services.rb +99 -0
- data/app/components/netzke/basepack/grid_panel.rb +374 -0
- data/app/components/netzke/basepack/grid_panel/columns.rb +233 -0
- data/app/components/netzke/basepack/grid_panel/javascript.rb +69 -0
- data/app/components/netzke/basepack/grid_panel/javascripts/advanced_search.js +96 -0
- data/{lib/netzke → app/components/netzke/basepack}/grid_panel/javascripts/edit_in_form.js +5 -4
- data/{lib/netzke/grid_panel/javascripts/grid_panel_pre.js → app/components/netzke/basepack/grid_panel/javascripts/pre.js} +17 -37
- data/{lib/netzke → app/components/netzke/basepack}/grid_panel/javascripts/rows-dd.js +0 -0
- data/app/components/netzke/basepack/grid_panel/multi_edit_form.rb +16 -0
- data/app/components/netzke/basepack/grid_panel/record_form_window.rb +36 -0
- data/app/components/netzke/basepack/grid_panel/search_window.rb +56 -0
- data/app/components/netzke/basepack/grid_panel/services.rb +356 -0
- data/app/components/netzke/basepack/panel.rb +11 -0
- data/app/components/netzke/basepack/search_panel.rb +59 -0
- data/app/components/netzke/basepack/tab_panel.rb +32 -0
- data/app/components/netzke/basepack/window.rb +73 -0
- data/app/components/netzke/basepack/wrapper.rb +28 -0
- data/{lib/app → app}/models/netzke_field_list.rb +1 -1
- data/{lib/app → app}/models/netzke_model_attr_list.rb +0 -0
- data/{lib/app → app}/models/netzke_persistent_array_auto_model.rb +0 -0
- data/config/database.yml +35 -0
- data/features/accordion_panel.feature +15 -0
- data/features/basic_app.feature +12 -0
- data/features/form_panel.feature +40 -0
- data/features/grid_panel.feature +62 -0
- data/features/search_in_grid.feature +35 -0
- data/features/simple_panel.feature +15 -0
- data/features/step_definitions/accordion_steps.rb +9 -0
- data/features/step_definitions/generic_steps.rb +15 -0
- data/features/step_definitions/grid_panel_steps.rb +26 -0
- data/features/step_definitions/pickle_steps.rb +100 -0
- data/features/step_definitions/web_steps.rb +219 -0
- data/features/support/env.rb +66 -0
- data/features/support/paths.rb +59 -0
- data/features/support/pickle.rb +25 -0
- data/features/tab_panel.feature +15 -0
- data/features/window.feature +11 -0
- data/from_05_to_06.rdoc +2 -0
- data/javascripts/basepack.js +54 -2
- data/lib/netzke-basepack.rb +38 -25
- data/lib/netzke/active_record.rb +12 -4
- data/lib/netzke/active_record/attributes.rb +60 -5
- data/lib/netzke/active_record/combobox_options.rb +3 -2
- data/lib/netzke/active_record/relation_extensions.rb +35 -0
- data/lib/netzke/basepack.rb +27 -0
- data/lib/netzke/basepack/version.rb +11 -0
- data/lib/netzke/basepack/wrap_lazy_loaded.rb +26 -0
- data/lib/netzke/data_accessor.rb +60 -32
- data/lib/netzke/fields_configurator.rb +5 -9
- data/lib/netzke/masquerade_selector.rb +1 -1
- data/locale/en.yml +16 -0
- data/netzke-basepack.gemspec +298 -0
- data/spec/active_record/attributes_spec.rb +14 -0
- data/spec/active_record/relation_extensions_spec.rb +44 -0
- data/spec/components/form_panel_spec.rb +70 -0
- data/spec/components/grid_panel_spec.rb +10 -0
- data/spec/factories.rb +9 -0
- data/spec/spec_helper.rb +35 -0
- data/test/rails_app/.gitignore +4 -0
- data/test/rails_app/Gemfile +32 -0
- data/test/rails_app/Gemfile.lock +171 -0
- data/test/rails_app/README +256 -0
- data/test/rails_app/Rakefile +7 -0
- data/test/rails_app/app/components/generic_user_form.rb +12 -0
- data/test/rails_app/app/components/simple_accordion.rb +11 -0
- data/test/rails_app/app/components/simple_basic_app.rb +32 -0
- data/test/rails_app/app/components/simple_panel.rb +17 -0
- data/test/rails_app/app/components/simple_tab_panel.rb +11 -0
- data/test/rails_app/app/components/simple_wrapper.rb +7 -0
- data/test/rails_app/app/components/some_border_layout.rb +24 -0
- data/test/rails_app/app/components/some_search_panel.rb +34 -0
- data/test/rails_app/app/components/some_tab_panel.rb +15 -0
- data/test/rails_app/app/components/user_form.rb +21 -0
- data/test/rails_app/app/components/user_form_with_default_fields.rb +8 -0
- data/test/rails_app/app/components/user_grid.rb +4 -0
- data/test/rails_app/app/components/window_component_loader.rb +17 -0
- data/test/{app_root/app/controllers/application.rb → rails_app/app/controllers/application_controller.rb} +1 -0
- data/test/rails_app/app/controllers/components_controller.rb +6 -0
- data/test/rails_app/app/controllers/welcome_controller.rb +5 -0
- data/test/rails_app/app/helpers/application_helper.rb +2 -0
- data/test/{app_root → rails_app}/app/models/role.rb +0 -0
- data/test/rails_app/app/models/user.rb +6 -0
- data/test/rails_app/app/presenters/forms/generic_user.rb +6 -0
- data/test/rails_app/app/views/layouts/application.html.erb +13 -0
- data/test/rails_app/config.ru +4 -0
- data/test/rails_app/config/application.rb +45 -0
- data/test/rails_app/config/boot.rb +13 -0
- data/test/rails_app/config/database.yml +35 -0
- data/test/rails_app/config/environment.rb +6 -0
- data/test/rails_app/config/environments/development.rb +22 -0
- data/test/rails_app/config/environments/production.rb +49 -0
- data/test/rails_app/config/environments/test.rb +35 -0
- data/test/rails_app/config/initializers/backtrace_silencers.rb +8 -0
- data/test/rails_app/config/initializers/inflections.rb +10 -0
- data/test/rails_app/config/initializers/mime_types.rb +5 -0
- data/test/rails_app/config/initializers/netzke.rb +7 -0
- data/test/rails_app/config/initializers/secret_token.rb +7 -0
- data/test/rails_app/config/initializers/session_store.rb +8 -0
- data/test/rails_app/config/locales/es.yml +12 -0
- data/test/rails_app/config/routes.rb +65 -0
- data/test/rails_app/db/development_structure.sql +39 -0
- data/test/{app_root/db/migrate/20081222035855_create_netzke_preferences.rb → rails_app/db/migrate/20100905214933_create_netzke_preferences.rb} +2 -4
- data/test/{app_root/db/migrate/20090423222114_create_users.rb → rails_app/db/migrate/20100914104207_create_users.rb} +4 -1
- data/test/{app_root/db/migrate/20090423214303_create_roles.rb → rails_app/db/migrate/20100914104236_create_roles.rb} +2 -0
- data/test/rails_app/db/schema.rb +38 -0
- data/test/rails_app/db/seeds.rb +20 -0
- data/test/rails_app/features/support/paths.rb +47 -0
- data/test/{app_root/config/environments/in_memory.rb → rails_app/lib/tasks/.gitkeep} +0 -0
- data/test/rails_app/public/404.html +26 -0
- data/test/rails_app/public/422.html +26 -0
- data/test/rails_app/public/500.html +26 -0
- data/test/{app_root/config/environments/mysql.rb → rails_app/public/favicon.ico} +0 -0
- data/test/rails_app/public/images/header-deco.gif +0 -0
- data/test/rails_app/public/images/rails.png +0 -0
- data/test/rails_app/public/javascripts/application.js +2 -0
- data/test/rails_app/public/javascripts/controls.js +965 -0
- data/test/rails_app/public/javascripts/dragdrop.js +974 -0
- data/test/rails_app/public/javascripts/effects.js +1123 -0
- data/test/rails_app/public/javascripts/prototype.js +6001 -0
- data/test/rails_app/public/javascripts/rails.js +175 -0
- data/test/rails_app/public/robots.txt +5 -0
- data/test/{app_root/config/environments/postgresql.rb → rails_app/public/stylesheets/.gitkeep} +0 -0
- data/test/rails_app/script/rails +6 -0
- data/test/rails_app/spec/models/role_spec.rb +5 -0
- data/test/rails_app/spec/models/user_spec.rb +5 -0
- data/test/rails_app/test/performance/browsing_test.rb +9 -0
- data/test/rails_app/test/test_helper.rb +13 -0
- data/test/{app_root/config/environments/sqlite.rb → rails_app/vendor/plugins/.gitkeep} +0 -0
- data/test/unit/accordion_panel_test.rb +3 -3
- data/test/unit/active_record_basepack_test.rb +4 -4
- data/test/unit/tab_panel_test.rb +4 -4
- metadata +199 -119
- data/lib/netzke/accordion_panel.rb +0 -115
- data/lib/netzke/active_record/data_accessor.rb +0 -25
- data/lib/netzke/attributes_configurator.rb +0 -195
- data/lib/netzke/basic_app.rb +0 -368
- data/lib/netzke/border_layout_panel.rb +0 -130
- data/lib/netzke/configuration_panel.rb +0 -24
- data/lib/netzke/form_panel.rb +0 -138
- data/lib/netzke/form_panel/form_panel_api.rb +0 -81
- data/lib/netzke/form_panel/form_panel_fields.rb +0 -149
- data/lib/netzke/form_panel/form_panel_js.rb +0 -163
- data/lib/netzke/grid_panel.rb +0 -367
- data/lib/netzke/grid_panel/grid_panel_api.rb +0 -364
- data/lib/netzke/grid_panel/grid_panel_columns.rb +0 -232
- data/lib/netzke/grid_panel/grid_panel_js.rb +0 -73
- data/lib/netzke/grid_panel/javascripts/advanced_search.js +0 -65
- data/lib/netzke/grid_panel/multi_edit_form.rb +0 -14
- data/lib/netzke/grid_panel/record_form_window.rb +0 -50
- data/lib/netzke/panel.rb +0 -11
- data/lib/netzke/plugins/configuration_tool.rb +0 -121
- data/lib/netzke/property_editor.rb +0 -111
- data/lib/netzke/property_editor/helper_model.rb +0 -122
- data/lib/netzke/search_panel.rb +0 -199
- data/lib/netzke/tab_panel.rb +0 -174
- data/lib/netzke/table_editor.rb +0 -118
- data/lib/netzke/tree_panel.rb +0 -25
- data/lib/netzke/window.rb +0 -82
- data/lib/netzke/wrapper.rb +0 -42
- data/test/app_root/app/models/book.rb +0 -9
- data/test/app_root/app/models/category.rb +0 -2
- data/test/app_root/app/models/city.rb +0 -3
- data/test/app_root/app/models/continent.rb +0 -2
- data/test/app_root/app/models/country.rb +0 -3
- data/test/app_root/app/models/genre.rb +0 -3
- data/test/app_root/app/models/user.rb +0 -3
- data/test/app_root/config/boot.rb +0 -114
- data/test/app_root/config/database.yml +0 -21
- data/test/app_root/config/environment.rb +0 -14
- data/test/app_root/config/environments/sqlite3.rb +0 -0
- data/test/app_root/config/routes.rb +0 -4
- data/test/app_root/db/migrate/20081222033343_create_books.rb +0 -15
- data/test/app_root/db/migrate/20081222033440_create_genres.rb +0 -15
- data/test/app_root/db/migrate/20081223024935_create_categories.rb +0 -13
- data/test/app_root/db/migrate/20081223025635_create_countries.rb +0 -14
- data/test/app_root/db/migrate/20081223025653_create_continents.rb +0 -13
- data/test/app_root/db/migrate/20081223025732_create_cities.rb +0 -15
- data/test/app_root/db/migrate/20090102223630_create_netzke_field_lists.rb +0 -18
- data/test/app_root/script/console +0 -7
- data/test/app_root/vendor/plugins/acts_as_list/README +0 -23
- data/test/app_root/vendor/plugins/acts_as_list/init.rb +0 -3
- data/test/app_root/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb +0 -256
data/.gitignore
CHANGED
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
= v0.6.0 - 2010-10-24
|
2
|
+
* netzke-core 0.6.0 compatibility, thorough refactoring
|
3
|
+
* Much more thorough testing (cucumber and rspec)
|
4
|
+
* FormPanel/GridPanel dynamic column/field configuration has been left out (planned for a separate gem)
|
5
|
+
* different bug fixes
|
6
|
+
|
7
|
+
* enhancements
|
8
|
+
* if omitted in config, a column for the primary key is automatically added to Grid/FormPanel
|
9
|
+
|
10
|
+
* API incompatibilities
|
11
|
+
* in FormPanel, define the fields layout directly in :items, not in :fields or :columns
|
12
|
+
|
13
|
+
* new
|
14
|
+
* FormPanel allows for arbitrary layout of fields
|
15
|
+
|
1
16
|
= v0.5.14 - 2010-09-08
|
2
17
|
* bug fix
|
3
18
|
* fields configurator wouldn't open in some cases
|
data/README.rdoc
CHANGED
@@ -1,87 +1,82 @@
|
|
1
1
|
= netzke-basepack
|
2
|
-
A pack of basic Rails/ExtJS widgets as a part of the Netzke framework. Live demo/tutorials on http://blog.writelesscode.com. Introduction to the Netzke framework and the Wiki: http://github.com/skozlov/netzke
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
2. Netzke assumes that your ExtJS library is in public/extjs, which may be a symbolic link, e.g:
|
7
|
-
|
8
|
-
cd public && ln -s ~/Developer/extjs/ext-3.1.1 extjs
|
9
|
-
|
10
|
-
3. acts_as_list plugin:
|
3
|
+
A pack of pre-built Netzke components, such as grid, form, tab panel, etc.
|
4
|
+
Learn about Netzke on http://netzke.org.
|
11
5
|
|
12
|
-
|
6
|
+
== Prerequisites
|
13
7
|
|
14
|
-
|
15
|
-
|
16
|
-
gem install netzke-core
|
17
|
-
|
18
|
-
Plugin (for the "edge" stuff, recommended):
|
8
|
+
1. Rails >= 3.0, Ext JS >= 3.3.0
|
9
|
+
2. Netzke assumes that your ExtJS library is in public/extjs, which may be a symbolic link, e.g (from your app root):
|
19
10
|
|
20
|
-
|
11
|
+
ln -s ~/code/sencha/extjs/ext-3.3.0 public/extjs
|
21
12
|
|
22
13
|
= Installation
|
23
|
-
For the "edge" stuff, install as plugin (recommended):
|
24
14
|
|
25
|
-
|
15
|
+
For the latest ("edge") stuff, install as plugin:
|
26
16
|
|
27
|
-
|
17
|
+
rails plugin install git://github.com/skozlov/netzke-basepack.git
|
18
|
+
|
19
|
+
Or tell bundler to get the gem straight from github:
|
28
20
|
|
29
|
-
gem
|
21
|
+
gem 'netzke-basepack', :git => "git://github.com/skozlov/netzke-basepack.git"
|
30
22
|
|
31
23
|
== Usage
|
32
|
-
If using as gem, include it into environment.rb:
|
33
24
|
|
34
|
-
|
25
|
+
Add Netzke routes (in routes.rb):
|
26
|
+
|
27
|
+
# in routes.rb
|
28
|
+
RailsApp::Application.routes.draw do
|
29
|
+
netzke
|
30
|
+
...
|
31
|
+
end
|
35
32
|
|
36
|
-
|
33
|
+
== Embedding components into Rails' view
|
37
34
|
|
38
|
-
|
35
|
+
Before you can use Netzke components in Rails' views, you need to add the following helper into your layout template, inside the "head" tag:
|
39
36
|
|
40
|
-
|
37
|
+
<%= netzke_init %>
|
41
38
|
|
42
|
-
|
39
|
+
This will include both ExtJS-related files (JavaScript and styles), and Netzke-related files.
|
43
40
|
|
44
|
-
To
|
41
|
+
To embed a component into a view, use the +netzke+ helper, e.g.:
|
45
42
|
|
46
|
-
|
47
|
-
|
48
|
-
|
43
|
+
<%= netzke :books, :class_name => 'Basepack::GridPanel', :model => 'Book' %>
|
44
|
+
|
45
|
+
(assuming the existence of model 'Book')
|
49
46
|
|
50
|
-
|
47
|
+
For more examples, see http://demo.netzke.com, and look into test/rails_app
|
51
48
|
|
52
|
-
==
|
53
|
-
To enable Netzke widgets in Rails' views, you need to add the following helper into your layout template, inside the "head" tag:
|
49
|
+
== Running tests
|
54
50
|
|
55
|
-
|
56
|
-
|
57
|
-
This will include both ExtJS-related files (JavaScript and styles), and Netzke-related files.
|
51
|
+
Netzke-basepack is bundled with automated tests. To run them, you need to set up test/rails_app a similar way as you did with your own Rails app that is using Netzke, i.e.: 1) link Ext JS into the "public" folder, 2) link netzke-core into vendor/plugins, 3) run migrations and clone the development database structure into the test database.
|
58
52
|
|
59
|
-
|
53
|
+
After this you may run (*from the netzke-basepack folder*):
|
60
54
|
|
61
|
-
|
55
|
+
cucumber features
|
56
|
+
|
57
|
+
and
|
62
58
|
|
63
|
-
|
59
|
+
rspec spec
|
64
60
|
|
65
|
-
|
61
|
+
== Testing playground
|
66
62
|
|
67
|
-
|
63
|
+
The test/rails_app application is also a convenient playground, as it may be run as independent Rails 3 app. After starting it, access any of the lib/netzke widgets by using the following url:
|
68
64
|
|
69
|
-
|
65
|
+
http://localhost:3000/components/<name of the component class>
|
66
|
+
|
67
|
+
e.g.:
|
70
68
|
|
69
|
+
http://localhost:3000/components/UserGrid
|
70
|
+
|
71
71
|
== Icons support
|
72
|
-
Netzke-basepack
|
72
|
+
Netzke-basepack can make use of FamFamFam Silk icon set (http://www.famfamfam.com/archive/silk-icons-thats-your-lot/). To enable this, download the icons and put the "icons" folder into your app's public/images folder. Then restart your application.
|
73
73
|
|
74
74
|
== More info
|
75
|
-
|
76
|
-
|
77
|
-
Twitter: http://twitter.com/skozlov
|
78
|
-
|
79
|
-
Tutorials: http://blog.writelesscode.com
|
75
|
+
Official project site: http://netzke.org
|
80
76
|
|
81
|
-
|
77
|
+
Twitter (I try to only tweet about useful stuff): http://twitter.com/skozlov
|
82
78
|
|
83
|
-
|
84
|
-
Testing done with the help of http://github.com/pluginaweek/plugin_test_helper
|
79
|
+
Many (if a bit outdated) tutorials: http://blog.writelesscode.com
|
85
80
|
|
86
81
|
---
|
87
82
|
Copyright (c) 2008-2010 Sergei Kozlov, released under the MIT license
|
data/Rakefile
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
begin
|
2
2
|
require 'jeweler'
|
3
|
+
require './lib/netzke/basepack/version'
|
3
4
|
Jeweler::Tasks.new do |gemspec|
|
4
|
-
gemspec.version =
|
5
|
+
gemspec.version = Netzke::Basepack::Version::STRING
|
5
6
|
gemspec.name = "netzke-basepack"
|
6
|
-
gemspec.summary = "Pre-built Rails + ExtJS
|
7
|
-
gemspec.description = "A set of full-featured extendible Netzke
|
7
|
+
gemspec.summary = "Pre-built Rails + ExtJS components for your RIA"
|
8
|
+
gemspec.description = "A set of full-featured extendible Netzke components (such as FormPanel, GridPanel, Window, BorderLayoutPanel, etc) which can be used as building block for your RIA"
|
8
9
|
gemspec.email = "sergei@playcode.nl"
|
9
10
|
gemspec.homepage = "http://github.com/skozlov/netzke-basepack"
|
10
|
-
gemspec.rubyforge_project = "netzke-basepack"
|
11
11
|
gemspec.authors = ["Sergei Kozlov"]
|
12
|
-
gemspec.add_dependency("netzke-core", "
|
13
|
-
gemspec.add_dependency("
|
14
|
-
gemspec.add_dependency("will_paginate", "
|
15
|
-
gemspec.add_dependency("acts_as_list"
|
12
|
+
gemspec.add_dependency("netzke-core", "~>0.6.0")
|
13
|
+
gemspec.add_dependency("meta_where", ">=0.9.3")
|
14
|
+
gemspec.add_dependency("will_paginate", "~>3.0.pre2")
|
15
|
+
gemspec.add_dependency("acts_as_list")
|
16
16
|
gemspec.post_install_message = <<-MESSAGE
|
17
17
|
|
18
18
|
========================================================================
|
data/TODO.rdoc
CHANGED
@@ -1,20 +1,15 @@
|
|
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
|
+
* DataAccessor#to_array should not rescue exceptions, but rather check the availability of the attributes; `respond_to_with_basepack?` should be extended to also return true for association columns
|
4
5
|
* GridPanel's read_only vs editable (doesn't work now) options
|
5
|
-
* Inclusion of css in a stand-alone widget
|
6
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
7
|
|
9
8
|
== Foolproof
|
10
|
-
* Should not be possible delete the "ID" field from grids/forms
|
11
9
|
* Should not be possible to put the "ID" field on any place but first for grids (otherwise record ID is not correct)
|
12
10
|
|
13
11
|
== Optimizations
|
14
12
|
* Check persistent_config-related queries (aren't they too many?)
|
15
13
|
|
16
|
-
== Code design
|
17
|
-
* Replace <tt>initial_late_aggregatees</tt> method with a set of methods for each aggregatee, so that more logic would be possible at the moment of on-demand aggregatee loading.
|
18
|
-
|
19
14
|
== One day
|
20
15
|
* Replace xcheckbox with checkbox in FormPanel
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Netzke
|
2
|
+
module Basepack
|
3
|
+
# = AccordionPanel
|
4
|
+
#
|
5
|
+
# A panel with the 'accordion' layout. Can lazily load its nested components. For example:
|
6
|
+
#
|
7
|
+
# netzke :my_accordion, :items => [{
|
8
|
+
# :html => "I'm a simple Ext.Panel",
|
9
|
+
# :title => "Panel One"
|
10
|
+
# },{
|
11
|
+
# :class_name => "SimplePanel",
|
12
|
+
# :update_text => "Update for Panel Two",
|
13
|
+
# :title => "Panel Two",
|
14
|
+
# :lazy_loading => true
|
15
|
+
# }]
|
16
|
+
class AccordionPanel < Netzke::Base
|
17
|
+
|
18
|
+
include WrapLazyLoaded
|
19
|
+
|
20
|
+
js_property :layout, 'accordion'
|
21
|
+
|
22
|
+
js_method :init_component, <<-JS
|
23
|
+
function(params){
|
24
|
+
#{js_full_class_name}.superclass.initComponent.call(this);
|
25
|
+
this.items.each(function(item){
|
26
|
+
item.on('expand', function(i){
|
27
|
+
if (i.wrappedComponent && !i.items.first()) {
|
28
|
+
this.loadComponent({name: i.wrappedComponent, container: i.id});
|
29
|
+
}
|
30
|
+
}, this);
|
31
|
+
}, this);
|
32
|
+
}
|
33
|
+
JS
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,267 @@
|
|
1
|
+
module Netzke
|
2
|
+
module Basepack
|
3
|
+
# == BasicApp
|
4
|
+
# Basis for a Ext.Viewport-based application
|
5
|
+
#
|
6
|
+
# Features:
|
7
|
+
# * dynamic loading of components
|
8
|
+
# * browser history support (press the "Back"-button to go to the previously loaded component)
|
9
|
+
# * AJAX activity indicator
|
10
|
+
# * (TODO) authentification support
|
11
|
+
# * (TODO) masquerade support
|
12
|
+
class BasicApp < Base
|
13
|
+
|
14
|
+
js_base_class "Ext.Viewport"
|
15
|
+
|
16
|
+
js_property :layout, :border
|
17
|
+
|
18
|
+
def self.include_js
|
19
|
+
res = []
|
20
|
+
ext_examples = Netzke::Core.ext_location.join("examples")
|
21
|
+
res << ext_examples.join("ux/statusbar/StatusBar.js")
|
22
|
+
res << "#{File.dirname(__FILE__)}/basic_app/statusbar_ext.js"
|
23
|
+
end
|
24
|
+
|
25
|
+
class_attribute :logout_url
|
26
|
+
self.logout_url = "/logout"
|
27
|
+
|
28
|
+
config do
|
29
|
+
# In status bar we want to show what we are masquerading as
|
30
|
+
if session[:masq_user]
|
31
|
+
user = User.find(session[:masq_user])
|
32
|
+
masq = %Q{user "#{user.login}"}
|
33
|
+
elsif session[:masq_role]
|
34
|
+
role = Role.find(session[:masq_role])
|
35
|
+
masq = %Q{role "#{role.name}"}
|
36
|
+
elsif session[:masq_world]
|
37
|
+
masq = %Q{World}
|
38
|
+
end
|
39
|
+
|
40
|
+
{
|
41
|
+
:items => [{
|
42
|
+
:id => 'main-panel',
|
43
|
+
:region => 'center',
|
44
|
+
:layout => 'fit'
|
45
|
+
},{
|
46
|
+
:id => 'main-toolbar',
|
47
|
+
:xtype => 'toolbar',
|
48
|
+
:region => 'north',
|
49
|
+
:height => 25,
|
50
|
+
:items => menu
|
51
|
+
},{
|
52
|
+
:id => 'main-statusbar',
|
53
|
+
:xtype => 'statusbar',
|
54
|
+
:region => 'south',
|
55
|
+
:height => 22,
|
56
|
+
:statusAlign => 'right',
|
57
|
+
:busyText => 'Busy...',
|
58
|
+
:default_text => masq.nil? ? "Ready #{"(config mode)" if session[:config_mode]}" : "Masquerading as #{masq}",
|
59
|
+
:default_icon_cls => ""
|
60
|
+
}]
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
js_method :init_component, <<-JS
|
65
|
+
function(){
|
66
|
+
#{js_full_class_name}.superclass.initComponent.call(this);
|
67
|
+
|
68
|
+
// If we are given a token, load the corresponding component, otherwise load the last loaded component
|
69
|
+
var currentToken = Ext.History.getToken();
|
70
|
+
if (currentToken != "") {
|
71
|
+
this.processHistory(currentToken);
|
72
|
+
} else {
|
73
|
+
var lastLoaded = this.initialConfig.componentToLoad; // passed from the server
|
74
|
+
if (lastLoaded) Ext.History.add(lastLoaded);
|
75
|
+
}
|
76
|
+
|
77
|
+
Ext.History.on('change', this.processHistory, this);
|
78
|
+
|
79
|
+
// Setting the "busy" indicator for Ajax requests
|
80
|
+
Ext.Ajax.on('beforerequest', function(){this.findById('main-statusbar').showBusy()}, this);
|
81
|
+
Ext.Ajax.on('requestcomplete', function(){this.findById('main-statusbar').hideBusy()}, this);
|
82
|
+
Ext.Ajax.on('requestexception', function(){this.findById('main-statusbar').hideBusy()}, this);
|
83
|
+
|
84
|
+
// Initialize history
|
85
|
+
Ext.History.init();
|
86
|
+
}
|
87
|
+
JS
|
88
|
+
|
89
|
+
js_method :on_login, <<-JS
|
90
|
+
function(){
|
91
|
+
window.location = "/login"
|
92
|
+
}
|
93
|
+
JS
|
94
|
+
|
95
|
+
js_method :on_logout, <<-JS
|
96
|
+
function(){
|
97
|
+
window.location = "#{logout_url}"
|
98
|
+
}
|
99
|
+
JS
|
100
|
+
|
101
|
+
js_method :process_history, <<-JS
|
102
|
+
function(token){
|
103
|
+
if (token){
|
104
|
+
this.loadComponent({name:token, container:'main-panel'});
|
105
|
+
} else {
|
106
|
+
Ext.getCmp('main-panel').removeChild();
|
107
|
+
}
|
108
|
+
}
|
109
|
+
JS
|
110
|
+
|
111
|
+
js_method :instantiate_component, <<-JS
|
112
|
+
function(config){
|
113
|
+
this.findById('main-panel').instantiateChild(config);
|
114
|
+
}
|
115
|
+
JS
|
116
|
+
|
117
|
+
js_method :app_load_component, <<-JS
|
118
|
+
function(name){
|
119
|
+
Ext.History.add(name);
|
120
|
+
}
|
121
|
+
JS
|
122
|
+
|
123
|
+
js_method :load_component_by_action, <<-JS
|
124
|
+
function(action){
|
125
|
+
this.appLoadComponent(action.component || action.name);
|
126
|
+
}
|
127
|
+
JS
|
128
|
+
|
129
|
+
js_method :on_toggle_config_mode, <<-JS
|
130
|
+
function(params){
|
131
|
+
this.toggleConfigMode();
|
132
|
+
}
|
133
|
+
JS
|
134
|
+
|
135
|
+
js_method :show_masquerade_selector, <<-JS
|
136
|
+
function(){
|
137
|
+
var w = new Ext.Window({
|
138
|
+
title: 'Masquerade as',
|
139
|
+
modal: true,
|
140
|
+
width: Ext.lib.Dom.getViewWidth() * 0.6,
|
141
|
+
height: Ext.lib.Dom.getViewHeight() * 0.6,
|
142
|
+
layout: 'fit',
|
143
|
+
closeAction :'destroy',
|
144
|
+
buttons: [{
|
145
|
+
text: 'Select',
|
146
|
+
handler : function(){
|
147
|
+
if (role = w.getNetzkeComponent().masquerade.role) {
|
148
|
+
Ext.Msg.confirm("Masquerading as a role", "Individual preferences for all users with this role will get overwritten as you make changes. Continue?", function(btn){
|
149
|
+
if (btn === 'yes') {
|
150
|
+
w.close();
|
151
|
+
}
|
152
|
+
});
|
153
|
+
} else {
|
154
|
+
w.close();
|
155
|
+
}
|
156
|
+
},
|
157
|
+
scope:this
|
158
|
+
},{
|
159
|
+
text:'As World',
|
160
|
+
handler:function(){
|
161
|
+
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){
|
162
|
+
if (btn === "yes") {
|
163
|
+
this.masquerade = {world:true};
|
164
|
+
w.close();
|
165
|
+
}
|
166
|
+
}, this);
|
167
|
+
},
|
168
|
+
scope:this
|
169
|
+
},{
|
170
|
+
text:'No masquerading',
|
171
|
+
handler:function(){
|
172
|
+
this.masquerade = {};
|
173
|
+
w.close();
|
174
|
+
},
|
175
|
+
scope:this
|
176
|
+
},{
|
177
|
+
text:'Cancel',
|
178
|
+
handler:function(){
|
179
|
+
w.hide();
|
180
|
+
},
|
181
|
+
scope:this
|
182
|
+
}],
|
183
|
+
listeners : {close: {fn: function(){
|
184
|
+
this.masqueradeAs(this.masquerade || w.getNetzkeComponent().masquerade || {});
|
185
|
+
}, scope: this}}
|
186
|
+
});
|
187
|
+
|
188
|
+
w.show(null, function(){
|
189
|
+
this.loadComponent({id:"masqueradeSelector", container:w.id})
|
190
|
+
}, this);
|
191
|
+
|
192
|
+
}
|
193
|
+
JS
|
194
|
+
|
195
|
+
# Set the Logout button if Netzke::Base.user is set
|
196
|
+
def menu
|
197
|
+
res = []
|
198
|
+
user = User.find_by_id(session[:netzke_user_id])
|
199
|
+
if !user.nil?
|
200
|
+
user_name = user.respond_to?(:name) ? user.name : user.login # try to display user's name, fallback to login
|
201
|
+
res << "->" <<
|
202
|
+
{
|
203
|
+
:text => "#{user_name}",
|
204
|
+
:menu => user_menu
|
205
|
+
}
|
206
|
+
else
|
207
|
+
res << "->" << :login.action
|
208
|
+
end
|
209
|
+
res
|
210
|
+
end
|
211
|
+
|
212
|
+
def user_menu
|
213
|
+
[:logout.action]
|
214
|
+
end
|
215
|
+
|
216
|
+
def initialize(*args)
|
217
|
+
super
|
218
|
+
|
219
|
+
if session[:netzke_just_logged_in] || session[:netzke_just_logged_out]
|
220
|
+
session[:config_mode] = false
|
221
|
+
session[:masq_world] = session[:masq_user] = session[:masq_roles] = nil
|
222
|
+
end
|
223
|
+
|
224
|
+
strong_children_config.deep_merge!(:mode => :config) if session[:config_mode]
|
225
|
+
end
|
226
|
+
|
227
|
+
|
228
|
+
action :masquerade_selector, :text => "Masquerade as ...", :handler => :show_masquerade_selector
|
229
|
+
|
230
|
+
action :toggle_config_mode do
|
231
|
+
{:text => "#{session[:config_mode] ? "Leave" : "Enter"} config mode"}
|
232
|
+
end
|
233
|
+
|
234
|
+
action :login, :icon => :door_in
|
235
|
+
|
236
|
+
action :logout, :icon => :door_out
|
237
|
+
|
238
|
+
# Html required for Ext.History to work
|
239
|
+
def js_component_html
|
240
|
+
super << %Q{
|
241
|
+
<form id="history-form" class="x-hidden">
|
242
|
+
<input type="hidden" id="x-history-field" />
|
243
|
+
<iframe id="x-history-frame"></iframe>
|
244
|
+
</form>
|
245
|
+
}
|
246
|
+
end
|
247
|
+
|
248
|
+
#
|
249
|
+
# Interface section
|
250
|
+
#
|
251
|
+
endpoint :toggle_config_mode do |params|
|
252
|
+
session = Netzke::Base.session
|
253
|
+
session[:config_mode] = !session[:config_mode]
|
254
|
+
{:js => "window.location.reload();"}
|
255
|
+
end
|
256
|
+
|
257
|
+
endpoint :masquerade_as do |params|
|
258
|
+
session = Netzke::Base.session
|
259
|
+
session[:masq_world] = params[:world] == "true"
|
260
|
+
session[:masq_role] = params[:role].try(:to_i)
|
261
|
+
session[:masq_user] = params[:user].try(:to_i)
|
262
|
+
{:js => "window.location.reload();"}
|
263
|
+
end
|
264
|
+
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|