netzke-basepack-zh 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +1 -0
- data/.travis.yml +11 -0
- data/CHANGELOG.rdoc +445 -0
- data/LICENSE +1 -0
- data/README.md +94 -0
- data/Rakefile +44 -0
- data/TODO.rdoc +8 -0
- data/config/ci/before-travis.sh +28 -0
- data/init.rb +1 -0
- data/install.rb +1 -0
- data/javascripts/basepack.js +139 -0
- data/javascripts/xdatetime.js +196 -0
- data/lib/generators/netzke/basepack_generator.rb +10 -0
- data/lib/generators/netzke/templates/assets/ts-checkbox.gif +0 -0
- data/lib/generators/netzke/templates/create_netzke_field_lists.rb +18 -0
- data/lib/netzke-basepack.rb +26 -0
- data/lib/netzke/active_record.rb +20 -0
- data/lib/netzke/active_record/attributes.rb +256 -0
- data/lib/netzke/active_record/combobox_options.rb +16 -0
- data/lib/netzke/active_record/relation_extensions.rb +37 -0
- data/lib/netzke/basepack.rb +45 -0
- data/lib/netzke/basepack/accordion_panel.rb +39 -0
- data/lib/netzke/basepack/action_column.rb +68 -0
- data/lib/netzke/basepack/action_column/javascripts/action_column.js +61 -0
- data/lib/netzke/basepack/auth_app.rb +159 -0
- data/lib/netzke/basepack/basic_app.rb +7 -0
- data/lib/netzke/basepack/border_layout_panel.rb +53 -0
- data/lib/netzke/basepack/border_layout_panel/javascripts/border_layout_panel.js +40 -0
- data/lib/netzke/basepack/data_accessor.rb +53 -0
- data/lib/netzke/basepack/data_adapters/abstract_adapter.rb +164 -0
- data/lib/netzke/basepack/data_adapters/active_record_adapter.rb +279 -0
- data/lib/netzke/basepack/data_adapters/data_mapper_adapter.rb +264 -0
- data/lib/netzke/basepack/data_adapters/sequel_adapter.rb +260 -0
- data/lib/netzke/basepack/form_panel.rb +144 -0
- data/lib/netzke/basepack/form_panel/fields.rb +208 -0
- data/lib/netzke/basepack/form_panel/javascripts/comma_list_cbg.js +51 -0
- data/lib/netzke/basepack/form_panel/javascripts/form_panel.js +225 -0
- data/lib/netzke/basepack/form_panel/javascripts/misc.js +4 -0
- data/lib/netzke/basepack/form_panel/javascripts/n_radio_group.js +43 -0
- data/lib/netzke/basepack/form_panel/javascripts/readonly_mode.js +35 -0
- data/lib/netzke/basepack/form_panel/services.rb +142 -0
- data/lib/netzke/basepack/form_panel/stylesheets/readonly_mode.css +14 -0
- data/lib/netzke/basepack/grid_panel.rb +440 -0
- data/lib/netzke/basepack/grid_panel/columns.rb +394 -0
- data/lib/netzke/basepack/grid_panel/javascripts/advanced_search.js +27 -0
- data/lib/netzke/basepack/grid_panel/javascripts/check_column_fix.js +6 -0
- data/lib/netzke/basepack/grid_panel/javascripts/edit_in_form.js +51 -0
- data/lib/netzke/basepack/grid_panel/javascripts/event_handling.js +179 -0
- data/lib/netzke/basepack/grid_panel/javascripts/grid_panel.js +438 -0
- data/lib/netzke/basepack/grid_panel/javascripts/misc.js +4 -0
- data/lib/netzke/basepack/grid_panel/javascripts/rows-dd.js +281 -0
- data/lib/netzke/basepack/grid_panel/record_form_window.rb +41 -0
- data/lib/netzke/basepack/grid_panel/services.rb +235 -0
- data/lib/netzke/basepack/paging_form_panel.rb +72 -0
- data/lib/netzke/basepack/paging_form_panel/javascripts/paging_form_panel.js +76 -0
- data/lib/netzke/basepack/panel.rb +11 -0
- data/lib/netzke/basepack/query_builder.rb +107 -0
- data/lib/netzke/basepack/query_builder/javascripts/query_builder.js +153 -0
- data/lib/netzke/basepack/search_panel.rb +79 -0
- data/lib/netzke/basepack/search_panel/javascripts/condition_field.js +160 -0
- data/lib/netzke/basepack/search_panel/javascripts/search_panel.js +65 -0
- data/lib/netzke/basepack/search_window.rb +66 -0
- data/lib/netzke/basepack/simple_app.rb +104 -0
- data/lib/netzke/basepack/simple_app/javascripts/simple_app.js +64 -0
- data/lib/netzke/basepack/simple_app/javascripts/statusbar_ext.js +8 -0
- data/lib/netzke/basepack/tab_panel.rb +21 -0
- data/lib/netzke/basepack/tab_panel/javascripts/tab_panel.js +11 -0
- data/lib/netzke/basepack/version.rb +11 -0
- data/lib/netzke/basepack/window.rb +29 -0
- data/lib/netzke/basepack/window/javascripts/window.js +20 -0
- data/lib/netzke/basepack/wrap_lazy_loaded.rb +28 -0
- data/lib/netzke/basepack/wrapper.rb +28 -0
- data/lib/netzke/data_mapper.rb +18 -0
- data/lib/netzke/data_mapper/attributes.rb +273 -0
- data/lib/netzke/data_mapper/combobox_options.rb +11 -0
- data/lib/netzke/data_mapper/relation_extensions.rb +38 -0
- data/lib/netzke/sequel.rb +18 -0
- data/lib/netzke/sequel/attributes.rb +274 -0
- data/lib/netzke/sequel/combobox_options.rb +10 -0
- data/lib/netzke/sequel/relation_extensions.rb +40 -0
- data/lib/tasks/netzke_basepack_tasks.rake +4 -0
- data/locales/de.yml +79 -0
- data/locales/en.yml +79 -0
- data/netzke-basepack.gemspec +306 -0
- data/stylesheets/basepack.css +72 -0
- data/stylesheets/datetimefield.css +54 -0
- data/test/basepack_test_app/.gitignore +6 -0
- data/test/basepack_test_app/.rvmrc +1 -0
- data/test/basepack_test_app/Gemfile +59 -0
- data/test/basepack_test_app/Gemfile.lock +196 -0
- data/test/basepack_test_app/Guardfile +46 -0
- data/test/basepack_test_app/README +1 -0
- data/test/basepack_test_app/Rakefile +7 -0
- data/test/basepack_test_app/app/components/author_form.rb +32 -0
- data/test/basepack_test_app/app/components/author_grid.rb +3 -0
- data/test/basepack_test_app/app/components/book_form.rb +38 -0
- data/test/basepack_test_app/app/components/book_form_with_custom_fields.rb +21 -0
- data/test/basepack_test_app/app/components/book_form_with_defaults.rb +8 -0
- data/test/basepack_test_app/app/components/book_form_with_nested_attributes.rb +18 -0
- data/test/basepack_test_app/app/components/book_grid.rb +12 -0
- data/test/basepack_test_app/app/components/book_grid_filtering.rb +10 -0
- data/test/basepack_test_app/app/components/book_grid_loader.rb +24 -0
- data/test/basepack_test_app/app/components/book_grid_with_column_actions.rb +15 -0
- data/test/basepack_test_app/app/components/book_grid_with_custom_columns.rb +27 -0
- data/test/basepack_test_app/app/components/book_grid_with_default_values.rb +9 -0
- data/test/basepack_test_app/app/components/book_grid_with_extra_feedback.rb +8 -0
- data/test/basepack_test_app/app/components/book_grid_with_extra_filters.rb +14 -0
- data/test/basepack_test_app/app/components/book_grid_with_nested_attributes.rb +13 -0
- data/test/basepack_test_app/app/components/book_grid_with_overridden_columns.rb +15 -0
- data/test/basepack_test_app/app/components/book_grid_with_paging.rb +10 -0
- data/test/basepack_test_app/app/components/book_grid_with_persistence.rb +8 -0
- data/test/basepack_test_app/app/components/book_grid_with_scoped_authors.rb +8 -0
- data/test/basepack_test_app/app/components/book_grid_with_virtual_attributes.rb +21 -0
- data/test/basepack_test_app/app/components/book_paging_form_panel.rb +22 -0
- data/test/basepack_test_app/app/components/book_query_builder.rb +8 -0
- data/test/basepack_test_app/app/components/book_search_panel.rb +5 -0
- data/test/basepack_test_app/app/components/book_search_panel/javascripts/i18n_de.js +6 -0
- data/test/basepack_test_app/app/components/book_with_custom_primary_key_grid.rb +10 -0
- data/test/basepack_test_app/app/components/books_bound_to_author.rb +10 -0
- data/test/basepack_test_app/app/components/double_book_grid.rb +18 -0
- data/test/basepack_test_app/app/components/extras/book_presentation.rb +27 -0
- data/test/basepack_test_app/app/components/form_without_model.rb +21 -0
- data/test/basepack_test_app/app/components/generic_user_form.rb +12 -0
- data/test/basepack_test_app/app/components/lockable_book_form.rb +17 -0
- data/test/basepack_test_app/app/components/lockable_user_form.rb +7 -0
- data/test/basepack_test_app/app/components/paging_form_with_search.rb +40 -0
- data/test/basepack_test_app/app/components/simple_accordion.rb +11 -0
- data/test/basepack_test_app/app/components/simple_panel.rb +17 -0
- data/test/basepack_test_app/app/components/simple_tab_panel.rb +11 -0
- data/test/basepack_test_app/app/components/simple_window.rb +10 -0
- data/test/basepack_test_app/app/components/simple_wrapper.rb +7 -0
- data/test/basepack_test_app/app/components/some_accordion_panel.rb +22 -0
- data/test/basepack_test_app/app/components/some_auth_app.rb +32 -0
- data/test/basepack_test_app/app/components/some_border_layout.rb +28 -0
- data/test/basepack_test_app/app/components/some_simple_app.rb +35 -0
- data/test/basepack_test_app/app/components/some_tab_panel.rb +20 -0
- data/test/basepack_test_app/app/components/user_form.rb +25 -0
- data/test/basepack_test_app/app/components/user_form_with_default_fields.rb +8 -0
- data/test/basepack_test_app/app/components/user_grid.rb +8 -0
- data/test/basepack_test_app/app/components/user_grid_with_customized_form_fields.rb +18 -0
- data/test/basepack_test_app/app/components/window_component_loader.rb +27 -0
- data/test/basepack_test_app/app/controllers/application_controller.rb +9 -0
- data/test/basepack_test_app/app/controllers/components_controller.rb +10 -0
- data/test/basepack_test_app/app/controllers/welcome_controller.rb +9 -0
- data/test/basepack_test_app/app/helpers/application_helper.rb +8 -0
- data/test/basepack_test_app/app/helpers/embedded_components_helper.rb +2 -0
- data/test/basepack_test_app/app/models/address.rb +29 -0
- data/test/basepack_test_app/app/models/author.rb +38 -0
- data/test/basepack_test_app/app/models/book.rb +49 -0
- data/test/basepack_test_app/app/models/book_with_custom_primary_key.rb +26 -0
- data/test/basepack_test_app/app/models/role.rb +24 -0
- data/test/basepack_test_app/app/models/user.rb +29 -0
- data/test/basepack_test_app/app/presenters/forms/generic_user.rb +6 -0
- data/test/basepack_test_app/app/views/components/loadable_window.html.erb +9 -0
- data/test/basepack_test_app/app/views/components/simple_panel.html.erb +1 -0
- data/test/basepack_test_app/app/views/layouts/application.html.erb +12 -0
- data/test/basepack_test_app/app/views/layouts/components.html.erb +13 -0
- data/test/basepack_test_app/app/views/layouts/nested.html.erb +5 -0
- data/test/basepack_test_app/app/views/welcome/index.html.erb +10 -0
- data/test/basepack_test_app/config.ru +4 -0
- data/test/basepack_test_app/config/application.rb +57 -0
- data/test/basepack_test_app/config/boot.rb +13 -0
- data/test/basepack_test_app/config/cucumber.yml +8 -0
- data/test/basepack_test_app/config/database.yml.sample +41 -0
- data/test/basepack_test_app/config/database.yml.travis +15 -0
- data/test/basepack_test_app/config/environment.rb +6 -0
- data/test/basepack_test_app/config/environments/development.rb +22 -0
- data/test/basepack_test_app/config/environments/production.rb +49 -0
- data/test/basepack_test_app/config/environments/test.rb +35 -0
- data/test/basepack_test_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/basepack_test_app/config/initializers/data_mapper_logging.rb +3 -0
- data/test/basepack_test_app/config/initializers/inflections.rb +10 -0
- data/test/basepack_test_app/config/initializers/mime_types.rb +5 -0
- data/test/basepack_test_app/config/initializers/netzke.rb +9 -0
- data/test/basepack_test_app/config/initializers/secret_token.rb +7 -0
- data/test/basepack_test_app/config/initializers/sequel.rb +26 -0
- data/test/basepack_test_app/config/initializers/session_store.rb +8 -0
- data/test/basepack_test_app/config/locales/de.yml +35 -0
- data/test/basepack_test_app/config/locales/es.yml +96 -0
- data/test/basepack_test_app/config/routes.rb +68 -0
- data/test/basepack_test_app/db/development_structure.sql +88 -0
- data/test/basepack_test_app/db/migrate/20100914104207_create_users.rb +15 -0
- data/test/basepack_test_app/db/migrate/20100914104236_create_roles.rb +13 -0
- data/test/basepack_test_app/db/migrate/20101026185816_create_authors.rb +14 -0
- data/test/basepack_test_app/db/migrate/20101026190021_create_books.rb +19 -0
- data/test/basepack_test_app/db/migrate/20110101143818_create_addresses.rb +17 -0
- data/test/basepack_test_app/db/migrate/20110213213050_create_netzke_component_states.rb +20 -0
- data/test/basepack_test_app/db/migrate/20110701070052_create_book_with_custom_primary_keys.rb +15 -0
- data/test/basepack_test_app/db/migrate/20110901114016_add_last_read_at_to_books.rb +9 -0
- data/test/basepack_test_app/db/migrate/20110909071740_add_published_on_to_books.rb +5 -0
- data/test/basepack_test_app/db/schema.rb +81 -0
- data/test/basepack_test_app/db/seeds.rb +44 -0
- data/test/basepack_test_app/features/accordion_panel.feature +12 -0
- data/test/basepack_test_app/features/components_in_view.feature +11 -0
- data/test/basepack_test_app/features/form_panel.feature +142 -0
- data/test/basepack_test_app/features/grid_panel.feature +277 -0
- data/test/basepack_test_app/features/grid_panel_filters.feature +73 -0
- data/test/basepack_test_app/features/grid_panel_with_custom_primary_key.feature +15 -0
- data/test/basepack_test_app/features/grid_sorting.feature +47 -0
- data/test/basepack_test_app/features/i18n.feature +18 -0
- data/test/basepack_test_app/features/nested_attributes.feature +26 -0
- data/test/basepack_test_app/features/paging_form_panel.feature +43 -0
- data/test/basepack_test_app/features/search_in_grid.feature +49 -0
- data/test/basepack_test_app/features/simple_app.feature +15 -0
- data/test/basepack_test_app/features/simple_panel.feature +11 -0
- data/test/basepack_test_app/features/step_definitions/accordion_steps.rb +5 -0
- data/test/basepack_test_app/features/step_definitions/ext_steps.rb +16 -0
- data/test/basepack_test_app/features/step_definitions/form_panel_steps.rb +46 -0
- data/test/basepack_test_app/features/step_definitions/generic_steps.rb +44 -0
- data/test/basepack_test_app/features/step_definitions/grid_panel_steps.rb +186 -0
- data/test/basepack_test_app/features/step_definitions/pickle_steps.rb +100 -0
- data/test/basepack_test_app/features/step_definitions/web_steps.rb +219 -0
- data/test/basepack_test_app/features/support/env.rb +81 -0
- data/test/basepack_test_app/features/support/paths.rb +65 -0
- data/test/basepack_test_app/features/support/pickle.rb +24 -0
- data/test/basepack_test_app/features/support/selectors.rb +39 -0
- data/test/basepack_test_app/features/tab_panel.feature +12 -0
- data/test/basepack_test_app/features/validations_in_grid.feature +13 -0
- data/test/basepack_test_app/features/virtual_attributes.feature +16 -0
- data/test/basepack_test_app/features/window.feature +11 -0
- data/test/basepack_test_app/lib/tasks/.gitkeep +0 -0
- data/test/basepack_test_app/lib/tasks/cucumber.rake +71 -0
- data/test/basepack_test_app/lib/tasks/travis.rake +7 -0
- data/test/basepack_test_app/public/404.html +26 -0
- data/test/basepack_test_app/public/422.html +26 -0
- data/test/basepack_test_app/public/500.html +26 -0
- data/test/basepack_test_app/public/favicon.ico +0 -0
- data/test/basepack_test_app/public/images/header-deco.gif +0 -0
- data/test/basepack_test_app/public/images/rails.png +0 -0
- data/test/basepack_test_app/public/javascripts/application.js +2 -0
- data/test/basepack_test_app/public/javascripts/controls.js +965 -0
- data/test/basepack_test_app/public/javascripts/dragdrop.js +974 -0
- data/test/basepack_test_app/public/javascripts/effects.js +1123 -0
- data/test/basepack_test_app/public/javascripts/prototype.js +6001 -0
- data/test/basepack_test_app/public/javascripts/rails.js +175 -0
- data/test/basepack_test_app/public/robots.txt +5 -0
- data/test/basepack_test_app/public/stylesheets/.gitkeep +0 -0
- data/test/basepack_test_app/script/cucumber +10 -0
- data/test/basepack_test_app/script/rails +6 -0
- data/test/basepack_test_app/spec/components/form_panel_spec.rb +53 -0
- data/test/basepack_test_app/spec/components/grid_panel_spec.rb +10 -0
- data/test/basepack_test_app/spec/data_adapter/adapter_spec.rb +68 -0
- data/test/basepack_test_app/spec/data_adapter/attributes_spec.rb +56 -0
- data/test/basepack_test_app/spec/data_adapter/relation_extensions_spec.rb +125 -0
- data/test/basepack_test_app/spec/factories.rb +28 -0
- data/test/basepack_test_app/spec/spec_helper.rb +39 -0
- data/test/basepack_test_app/test/performance/browsing_test.rb +9 -0
- data/test/basepack_test_app/test/test_helper.rb +13 -0
- data/test/basepack_test_app/vendor/plugins/.gitkeep +0 -0
- data/test/console_with_fixtures.rb +4 -0
- data/test/fixtures/books.yml +11 -0
- data/test/fixtures/categories.yml +7 -0
- data/test/fixtures/cities.yml +21 -0
- data/test/fixtures/continents.yml +7 -0
- data/test/fixtures/countries.yml +9 -0
- data/test/fixtures/genres.yml +9 -0
- data/test/fixtures/roles.yml +8 -0
- data/test/fixtures/users.yml +11 -0
- data/test/schema.rb +10 -0
- data/test/test_helper.rb +21 -0
- data/test/unit/accordion_panel_test.rb +20 -0
- data/test/unit/active_record_basepack_test.rb +54 -0
- data/test/unit/fields_configuration_test.rb +18 -0
- data/test/unit/grid_panel_test.rb +52 -0
- data/test/unit/netzke_basepack_test.rb +4 -0
- data/test/unit/tab_panel_test.rb +21 -0
- data/uninstall.rb +1 -0
- metadata +332 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
module Netzke
|
2
|
+
module Basepack
|
3
|
+
module ActionColumn
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do |base|
|
7
|
+
|
8
|
+
# Returns registered actions
|
9
|
+
class_attribute :registered_column_actions
|
10
|
+
self.registered_column_actions = []
|
11
|
+
|
12
|
+
js_include :action_column
|
13
|
+
end
|
14
|
+
|
15
|
+
module ClassMethods
|
16
|
+
# Register an action
|
17
|
+
def register_column_action(name)
|
18
|
+
self.registered_column_actions |= [name]
|
19
|
+
end
|
20
|
+
|
21
|
+
# Use this method to define column actions in your component, e.g.:
|
22
|
+
#
|
23
|
+
# column_action :edit, :icon => "/images/icons/edit.png"
|
24
|
+
#
|
25
|
+
# TODO: List all options.
|
26
|
+
# TODO: think how it'll be possible to override individual column_actions (if need to bother at all)
|
27
|
+
def column_action(name, params = {})
|
28
|
+
params[:name] = name
|
29
|
+
params[:column] ||= "actions"
|
30
|
+
params[:icon] ||= "/extjs/examples/shared/icons/fam/cog.png"
|
31
|
+
params[:tooltip] = params[:tooltip].presence || name.to_s.humanize
|
32
|
+
params[:handler] ||= "on_#{name}"
|
33
|
+
register_column_action(name);
|
34
|
+
define_method "#{name}_column_action" do |record=nil| # TODO: this won't work in Ruby 1.8.7
|
35
|
+
params[:row_config] && record ? params.merge(params[:row_config].call(record, self)) : params
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def initial_columns(with_excluded = false)
|
41
|
+
orig_columns = super
|
42
|
+
|
43
|
+
action_column_names = column_actions.map{ |action| action[:column] }.uniq
|
44
|
+
action_columns = orig_columns.select{ |c| action_column_names.include? c[:name] }
|
45
|
+
|
46
|
+
# Append the column if none found AND no explicit column configuration was provided
|
47
|
+
if action_columns.empty? && !config[:columns]
|
48
|
+
action_columns = [{:name => "actions"}.merge(config[:override_columns].try(:fetch, :actions, nil) || {})]
|
49
|
+
orig_columns += action_columns
|
50
|
+
end
|
51
|
+
|
52
|
+
action_columns.each do |c|
|
53
|
+
c[:xtype] = :netzkeactioncolumn
|
54
|
+
c[:getter] = lambda do |r|
|
55
|
+
self.class.registered_column_actions.select{ |action_name| self.send("#{action_name}_column_action")[:column] == c[:name] }.map{ |action_name| self.send("#{action_name}_column_action", r) }.to_nifty_json
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
orig_columns
|
60
|
+
end
|
61
|
+
|
62
|
+
def column_actions
|
63
|
+
self.class.registered_column_actions.map{ |action_name| self.send("#{action_name}_column_action")}
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
Ext.define('Ext.grid.column.NetzkeAction', {
|
2
|
+
extend: 'Ext.grid.column.Action',
|
3
|
+
alias: ['widget.netzkeactioncolumn'],
|
4
|
+
|
5
|
+
constructor: function(config) {
|
6
|
+
var me = this,
|
7
|
+
cfg = Ext.apply({}, config),
|
8
|
+
i,
|
9
|
+
item;
|
10
|
+
|
11
|
+
me.callParent([cfg]);
|
12
|
+
|
13
|
+
me.renderer = function(actions, meta) {
|
14
|
+
// previous renderer
|
15
|
+
var v = Ext.isFunction(cfg.renderer) ? cfg.renderer.apply(this, arguments)||'' : '',
|
16
|
+
actions = Ext.decode(actions),
|
17
|
+
l = actions.length,
|
18
|
+
action;
|
19
|
+
|
20
|
+
meta.tdCls += ' ' + Ext.baseCSSPrefix + 'action-col-cell';
|
21
|
+
|
22
|
+
for (i = 0; i < l; i++) {
|
23
|
+
action = actions[i];
|
24
|
+
if (!action.hidden) {
|
25
|
+
v += '<img alt="' + (action.altText || me.altText) + '" src="' + (action.icon || Ext.BLANK_IMAGE_URL) +
|
26
|
+
'" class="' + Ext.baseCSSPrefix + 'action-col-icon ' + Ext.baseCSSPrefix + 'action-col-' + String(i) + ' ' + (action.iconCls || '') +
|
27
|
+
' ' + (Ext.isFunction(action.getClass) ? action.getClass.apply(action.scope||me.scope||me, arguments) : (me.iconCls || '')) + '"' +
|
28
|
+
((action.tooltip) ? ' data-qtip="' + action.tooltip + '"' : '') +
|
29
|
+
' data-name="' + action.name + '"' +
|
30
|
+
((action.handler) ? ' data-handler="' + action.handler + '"' : '') + ' />';
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
return v;
|
35
|
+
};
|
36
|
+
},
|
37
|
+
|
38
|
+
processEvent : function(type, view, cell, recordIndex, cellIndex, e){
|
39
|
+
var me = this,
|
40
|
+
target = e.getTarget(),
|
41
|
+
match = target.className.match("x-action-col-icon"),
|
42
|
+
fn, grid, record;
|
43
|
+
if (match) {
|
44
|
+
if (type == 'click') {
|
45
|
+
grid = me.ownerCt.ownerCt;
|
46
|
+
fn = (target.getAttribute("data-handler") || "").camelize(true);
|
47
|
+
fn = Ext.isFunction(grid[fn]) ? grid[fn] : undefined;
|
48
|
+
// if (fn) fn.call(grid, view, recordIndex, cellIndex, target, e);
|
49
|
+
if (fn) {
|
50
|
+
record = grid.getStore().getAt(recordIndex);
|
51
|
+
fn.call(grid, record, target, e);
|
52
|
+
} else {
|
53
|
+
Netzke.warning("Undefined handler for column action '" + target.getAttribute("data-name") + "'");
|
54
|
+
}
|
55
|
+
} else if (type == 'mousedown') {
|
56
|
+
return false;
|
57
|
+
}
|
58
|
+
}
|
59
|
+
return me.callParent(arguments);
|
60
|
+
}
|
61
|
+
});
|
@@ -0,0 +1,159 @@
|
|
1
|
+
module Netzke
|
2
|
+
module Basepack
|
3
|
+
# Extension to SimpleApp that brings in support for authentication and masquerading
|
4
|
+
# ** NOTE: it's WIP **
|
5
|
+
class AuthApp < SimpleApp
|
6
|
+
|
7
|
+
def default_config
|
8
|
+
super.tap do |c|
|
9
|
+
c[:login_url] = "/login"
|
10
|
+
c[:logout_url] = "/logout"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# class_config_option :login_url, "/login"
|
15
|
+
# # self.login_url = "/login"
|
16
|
+
#
|
17
|
+
# class_attribute :logout_url
|
18
|
+
# self.logout_url = "/logout"
|
19
|
+
|
20
|
+
js_method :on_login, <<-JS
|
21
|
+
function(){
|
22
|
+
window.location = this.loginUrl;
|
23
|
+
}
|
24
|
+
JS
|
25
|
+
|
26
|
+
js_method :on_logout, <<-JS
|
27
|
+
function(){
|
28
|
+
window.location = this.logoutUrl;
|
29
|
+
}
|
30
|
+
JS
|
31
|
+
|
32
|
+
js_method :on_toggle_config_mode, <<-JS
|
33
|
+
function(params){
|
34
|
+
this.toggleConfigMode();
|
35
|
+
}
|
36
|
+
JS
|
37
|
+
# WIP: todo - rewrite Ext.lib calls below
|
38
|
+
js_method :show_masquerade_selector, <<-JS
|
39
|
+
function(){
|
40
|
+
var w = new Ext.Window({
|
41
|
+
title: 'Masquerade as',
|
42
|
+
modal: true,
|
43
|
+
width: Ext.lib.Dom.getViewWidth() * 0.6,
|
44
|
+
height: Ext.lib.Dom.getViewHeight() * 0.6,
|
45
|
+
layout: 'fit',
|
46
|
+
closeAction :'destroy',
|
47
|
+
buttons: [{
|
48
|
+
text: 'Select',
|
49
|
+
handler : function(){
|
50
|
+
if (role = w.getNetzkeComponent().masquerade.role) {
|
51
|
+
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){
|
52
|
+
if (btn === 'yes') {
|
53
|
+
w.close();
|
54
|
+
}
|
55
|
+
});
|
56
|
+
} else {
|
57
|
+
w.close();
|
58
|
+
}
|
59
|
+
},
|
60
|
+
scope:this
|
61
|
+
},{
|
62
|
+
text:'As World',
|
63
|
+
handler:function(){
|
64
|
+
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){
|
65
|
+
if (btn === "yes") {
|
66
|
+
this.masquerade = {world:true};
|
67
|
+
w.close();
|
68
|
+
}
|
69
|
+
}, this);
|
70
|
+
},
|
71
|
+
scope:this
|
72
|
+
},{
|
73
|
+
text:'No masquerading',
|
74
|
+
handler:function(){
|
75
|
+
this.masquerade = {};
|
76
|
+
w.close();
|
77
|
+
},
|
78
|
+
scope:this
|
79
|
+
},{
|
80
|
+
text:'Cancel',
|
81
|
+
handler:function(){
|
82
|
+
w.hide();
|
83
|
+
},
|
84
|
+
scope:this
|
85
|
+
}],
|
86
|
+
listeners : {close: {fn: function(){
|
87
|
+
this.masqueradeAs(this.masquerade || w.getNetzkeComponent().masquerade || {});
|
88
|
+
}, scope: this}}
|
89
|
+
});
|
90
|
+
|
91
|
+
w.show(null, function(){
|
92
|
+
this.loadNetzkeComponent({id:"masqueradeSelector", container:w.id})
|
93
|
+
}, this);
|
94
|
+
|
95
|
+
}
|
96
|
+
JS
|
97
|
+
|
98
|
+
# Set the Logout button if Netzke::Core.current_user is set
|
99
|
+
def menu
|
100
|
+
[].tap do |menu|
|
101
|
+
user = Netzke::Core.current_user
|
102
|
+
if !user.nil?
|
103
|
+
user_name = user.respond_to?(:name) ? user.name : user.email # try to display user's name, fallback to email
|
104
|
+
menu << "->" <<
|
105
|
+
{
|
106
|
+
:text => user_name,
|
107
|
+
:menu => user_menu
|
108
|
+
}
|
109
|
+
else
|
110
|
+
menu << "->" << :login.action
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def user_menu
|
116
|
+
[:logout.action]
|
117
|
+
end
|
118
|
+
|
119
|
+
def initialize(*args)
|
120
|
+
super
|
121
|
+
|
122
|
+
if session[:netzke_just_logged_in] || session[:netzke_just_logged_out]
|
123
|
+
session[:config_mode] = false
|
124
|
+
session[:masq_world] = session[:masq_user] = session[:masq_roles] = nil
|
125
|
+
end
|
126
|
+
|
127
|
+
strong_children_config.deep_merge!(:mode => :config) if session[:config_mode]
|
128
|
+
end
|
129
|
+
|
130
|
+
action :masquerade_selector, :text => "Masquerade as ...", :handler => :show_masquerade_selector
|
131
|
+
|
132
|
+
action :toggle_config_mode do
|
133
|
+
{:text => "#{session[:config_mode] ? "Leave" : "Enter"} config mode"}
|
134
|
+
end
|
135
|
+
|
136
|
+
action :login, :icon => :door_in
|
137
|
+
|
138
|
+
action :logout, :icon => :door_out
|
139
|
+
|
140
|
+
#
|
141
|
+
# Interface section
|
142
|
+
#
|
143
|
+
endpoint :toggle_config_mode do |params|
|
144
|
+
session = Netzke::Base.session
|
145
|
+
session[:config_mode] = !session[:config_mode]
|
146
|
+
{:js => "window.location.reload();"}
|
147
|
+
end
|
148
|
+
|
149
|
+
endpoint :masquerade_as do |params|
|
150
|
+
session = Netzke::Base.session
|
151
|
+
session[:masq_world] = params[:world] == "true"
|
152
|
+
session[:masq_role] = params[:role].try(:to_i)
|
153
|
+
session[:masq_user] = params[:user].try(:to_i)
|
154
|
+
{:js => "window.location.reload();"}
|
155
|
+
end
|
156
|
+
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Netzke
|
2
|
+
module Basepack
|
3
|
+
# Panel with border layout.
|
4
|
+
#
|
5
|
+
# == Features
|
6
|
+
# * When persistence enabled, remembers the sizes and collapsed/expanded states of its regions.
|
7
|
+
#
|
8
|
+
# == Example configuration:
|
9
|
+
#
|
10
|
+
# :items => [
|
11
|
+
# {:title => "Item One", :class_name => "Basepack::Panel", :region => :center},
|
12
|
+
# {:title => "Item Two", :class_name => "Basepack::Panel", :region => :west, :width => 300, :split => true}
|
13
|
+
# ]
|
14
|
+
class BorderLayoutPanel < Netzke::Base
|
15
|
+
js_mixin :border_layout_panel
|
16
|
+
|
17
|
+
def items
|
18
|
+
@border_layout_items ||= begin
|
19
|
+
updated_items = super
|
20
|
+
|
21
|
+
if config[:persistence]
|
22
|
+
updated_items.each do |item|
|
23
|
+
region = item[:region] || components[item[:netzke_component]][:region]
|
24
|
+
item.merge!({
|
25
|
+
:width => state[:"#{region}_region_width"],
|
26
|
+
:height => state[:"#{region}_region_height"],
|
27
|
+
:collapsed => state[:"#{region}_region_collapsed"]
|
28
|
+
})
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
updated_items
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
endpoint :region_resized do |params|
|
37
|
+
size_state_hash = {}
|
38
|
+
size_state_hash[:"#{params[:region]}_region_width"] = params[:width].to_i if params[:width]
|
39
|
+
size_state_hash[:"#{params[:region]}_region_height"] = params[:height].to_i if params[:height]
|
40
|
+
update_state(size_state_hash)
|
41
|
+
end
|
42
|
+
|
43
|
+
endpoint :region_collapsed do |params|
|
44
|
+
update_state(:"#{params[:region]}_region_collapsed" => true)
|
45
|
+
end
|
46
|
+
|
47
|
+
endpoint :region_expanded do |params|
|
48
|
+
update_state(:"#{params[:region]}_region_collapsed" => false)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
{
|
2
|
+
layout: 'border',
|
3
|
+
|
4
|
+
initComponent: function(){
|
5
|
+
this.callParent();
|
6
|
+
|
7
|
+
// First time on "afterlayout", set resize events
|
8
|
+
if (this.persistence) {this.on('afterlayout', this.setRegionEvents, this, {single: true});}
|
9
|
+
},
|
10
|
+
|
11
|
+
setRegionEvents: function(){
|
12
|
+
this.items.each(function(item, index, length){
|
13
|
+
if (!item.oldSize) item.oldSize = item.getSize(); // remember initial size
|
14
|
+
|
15
|
+
item.on('resize', function(panel, w, h){
|
16
|
+
if (panel.region !== 'center' && w && h) {
|
17
|
+
var params = {region:panel.region};
|
18
|
+
|
19
|
+
if (panel.oldSize.width != w) {
|
20
|
+
params.width = w;
|
21
|
+
} else {
|
22
|
+
params.height = h;
|
23
|
+
}
|
24
|
+
|
25
|
+
panel.oldSize = panel.getSize();
|
26
|
+
this.regionResized(params);
|
27
|
+
}
|
28
|
+
}, this);
|
29
|
+
|
30
|
+
item.on('collapse', function(panel){
|
31
|
+
this.regionCollapsed({region: panel.region});
|
32
|
+
}, this);
|
33
|
+
|
34
|
+
item.on('expand', function(panel){
|
35
|
+
this.regionExpanded({region: panel.region});
|
36
|
+
}, this);
|
37
|
+
|
38
|
+
}, this);
|
39
|
+
}
|
40
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Netzke
|
2
|
+
module Basepack
|
3
|
+
# This module is included into such data-driven components as GridPanel, FormPanel, PagingFormPanel, etc.
|
4
|
+
module DataAccessor
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
# Returns options for comboboxes in grids/forms
|
9
|
+
def combobox_options_for_column(column, method_options = {})
|
10
|
+
data_adapter.combobox_options_for_column column, method_options
|
11
|
+
end
|
12
|
+
|
13
|
+
# Normalize array of attributes
|
14
|
+
# [:col1, "col2", {:name => :col3}] =>
|
15
|
+
# [{:name => "col1"}, {:name => "col2"}, {:name => "col3"}]
|
16
|
+
def normalize_attrs(attrs)
|
17
|
+
attrs.map{ |a| normalize_attr(a) }
|
18
|
+
end
|
19
|
+
|
20
|
+
# Normalize an attribute, e.g.:
|
21
|
+
# :first_name =>
|
22
|
+
# {:name => "first_name"}
|
23
|
+
def normalize_attr(a)
|
24
|
+
a.is_a?(Symbol) || a.is_a?(String) ? {:name => a.to_s} : a.merge(:name => a[:name].to_s)
|
25
|
+
end
|
26
|
+
|
27
|
+
def association_attr?(name)
|
28
|
+
!!name.to_s.index("__")
|
29
|
+
end
|
30
|
+
|
31
|
+
# Model class
|
32
|
+
def data_class
|
33
|
+
@data_class ||= config[:model].is_a?(String) ? config[:model].constantize : config[:model]
|
34
|
+
end
|
35
|
+
|
36
|
+
# Data adapter responsible for all DB-related operations
|
37
|
+
def data_adapter
|
38
|
+
@data_adapter ||= Netzke::Basepack::DataAdapters::AbstractAdapter.adapter_class(data_class).new(data_class)
|
39
|
+
end
|
40
|
+
|
41
|
+
# whether a column is bound to the primary_key
|
42
|
+
def primary_key_attr?(a)
|
43
|
+
data_class && a[:name].to_s == data_class.primary_key.to_s
|
44
|
+
end
|
45
|
+
|
46
|
+
# Mark an attribute as "virtual" by default, when it doesn't reflect a model column, or a model column of an association
|
47
|
+
def set_default_virtual(c)
|
48
|
+
c[:virtual] = data_adapter.column_virtual?(c) if c[:virtual].nil?
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|