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
@@ -0,0 +1,69 @@
|
|
1
|
+
module Netzke
|
2
|
+
module Basepack
|
3
|
+
class GridPanel < Netzke::Base
|
4
|
+
# (Dynamic) JavaScript for GridPanel
|
5
|
+
module Javascript
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
js_base_class "Netzke.pre.GridPanel"
|
10
|
+
js_method :init_component, js_init_component
|
11
|
+
end
|
12
|
+
|
13
|
+
module InstanceMethods
|
14
|
+
# The result of this method (a hash) is converted to a JSON object and passed as the configuration parameter
|
15
|
+
# to the constructor of our JavaScript class. Override it when you want to pass any extra configuration
|
16
|
+
# to the JavaScript side.
|
17
|
+
def js_config
|
18
|
+
super.merge({
|
19
|
+
:bbar => config.has_key?(:bbar) ? config[:bbar] : default_bbar,
|
20
|
+
:context_menu => config.has_key?(:context_menu) ? config[:context_menu] : default_context_menu,
|
21
|
+
:columns => columns, # columns
|
22
|
+
:model => config[:model], # the model name
|
23
|
+
:inline_data => (get_data if config[:load_inline_data]), # inline data (loaded along with the grid panel)
|
24
|
+
:pri => data_class.primary_key # table primary key name
|
25
|
+
})
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
module ClassMethods
|
30
|
+
private
|
31
|
+
|
32
|
+
# Ext.Component#initComponent, built up from pices (dependent on class-level configuration)
|
33
|
+
def js_init_component
|
34
|
+
# Optional "edit in form"-related events
|
35
|
+
edit_in_form_events = <<-END_OF_JAVASCRIPT if edit_in_form_available
|
36
|
+
if (this.enableEditInForm) {
|
37
|
+
this.getSelectionModel().on('selectionchange', function(selModel){
|
38
|
+
var disabled;
|
39
|
+
if (!selModel.hasSelection()) {
|
40
|
+
disabled = true;
|
41
|
+
} else {
|
42
|
+
// Disable "edit in form" button if new record is present in selection
|
43
|
+
disabled = !selModel.each(function(r){
|
44
|
+
if (r.isNew) { return false; }
|
45
|
+
});
|
46
|
+
};
|
47
|
+
this.actions.editInForm.setDisabled(disabled);
|
48
|
+
}, this);
|
49
|
+
}
|
50
|
+
END_OF_JAVASCRIPT
|
51
|
+
|
52
|
+
# Result
|
53
|
+
<<-END_OF_JAVASCRIPT
|
54
|
+
function(){
|
55
|
+
// Original initComponent
|
56
|
+
#{js_full_class_name}.superclass.initComponent.call(this);
|
57
|
+
#{edit_in_form_events}
|
58
|
+
}
|
59
|
+
|
60
|
+
END_OF_JAVASCRIPT
|
61
|
+
end
|
62
|
+
|
63
|
+
# end private
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
Ext.override(Netzke.pre.GridPanel, {
|
2
|
+
onSearch: function(el){
|
3
|
+
el.toggle(el.toggled); // do not toggle immediately
|
4
|
+
|
5
|
+
this.loadComponent({name: 'search_form', callback: function(win){
|
6
|
+
var currentConditionsString = this.getStore().baseParams.extra_conditions;
|
7
|
+
if (currentConditionsString) {
|
8
|
+
win.items.first().getForm().setValues(Ext.decode(currentConditionsString));
|
9
|
+
}
|
10
|
+
|
11
|
+
win.items.first().on('apply', function(){
|
12
|
+
win.onSearch();
|
13
|
+
return false; // do not propagate the 'apply' event
|
14
|
+
}, this);
|
15
|
+
|
16
|
+
win.on('close', function(){
|
17
|
+
if (win.closeRes == 'OK'){
|
18
|
+
var searchConditions = win.conditions;
|
19
|
+
var filtered = false;
|
20
|
+
// check if there's any search condition set
|
21
|
+
for (var k in searchConditions) {
|
22
|
+
if (searchConditions[k].length > 0) {
|
23
|
+
filtered = true;
|
24
|
+
break;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
el.toggle(filtered); // toggle based on the state
|
28
|
+
this.getStore().baseParams.extra_conditions = Ext.encode(win.conditions);
|
29
|
+
this.getStore().load();
|
30
|
+
}
|
31
|
+
}, this);
|
32
|
+
}, scope: this});
|
33
|
+
|
34
|
+
// delete this.searchWindow;
|
35
|
+
// this.searchWindow = new Ext.Window({
|
36
|
+
// title:'Advanced search',
|
37
|
+
// layout:'fit',
|
38
|
+
// modal: true,
|
39
|
+
// width: 400,
|
40
|
+
// height: Ext.lib.Dom.getViewHeight() *0.9,
|
41
|
+
// closeAction:'close',
|
42
|
+
// buttons:[{
|
43
|
+
// text: 'OK',
|
44
|
+
// handler: function(){
|
45
|
+
// this.ownerCt.ownerCt.closePositively();
|
46
|
+
// }
|
47
|
+
// },{
|
48
|
+
// text:'Cancel',
|
49
|
+
// handler:function(){
|
50
|
+
// this.ownerCt.ownerCt.closeNegatively();
|
51
|
+
// }
|
52
|
+
// }],
|
53
|
+
// closePositively : function(){
|
54
|
+
// this.conditions = this.getNetzkeComponent().getForm().getValues();
|
55
|
+
// this.closeRes = 'OK';
|
56
|
+
// this.close();
|
57
|
+
// },
|
58
|
+
// closeNegatively: function(){
|
59
|
+
// this.closeRes = 'cancel';
|
60
|
+
// this.close();
|
61
|
+
// }
|
62
|
+
// });
|
63
|
+
//
|
64
|
+
// this.searchWindow.on('close', function(){
|
65
|
+
// if (this.searchWindow.closeRes == 'OK'){
|
66
|
+
// var searchConditions = this.searchWindow.conditions;
|
67
|
+
// var filtered = false;
|
68
|
+
// // check if there's any search condition set
|
69
|
+
// for (var k in searchConditions) {
|
70
|
+
// if (searchConditions[k].length > 0) {
|
71
|
+
// filtered = true;
|
72
|
+
// break;
|
73
|
+
// }
|
74
|
+
// }
|
75
|
+
// this.actions.search.setText(filtered ? "Search *" : "Search");
|
76
|
+
// this.getStore().baseParams = {extra_conditions: Ext.encode(this.searchWindow.conditions)};
|
77
|
+
// this.getStore().load();
|
78
|
+
// }
|
79
|
+
// }, this);
|
80
|
+
//
|
81
|
+
// this.searchWindow.on('add', function(container, searchPanel){
|
82
|
+
// searchPanel.on('apply', function(component){
|
83
|
+
// this.searchWindow.closePositively();
|
84
|
+
// return false; // stop the event
|
85
|
+
// }, this);
|
86
|
+
// }, this);
|
87
|
+
//
|
88
|
+
// this.searchWindow.show(null, function(){
|
89
|
+
// this.searchWindow.closeRes = 'cancel';
|
90
|
+
// if (!this.searchWindow.getNetzkeComponent()){
|
91
|
+
// this.loadComponent({id:"searchPanel", container:this.searchWindow.id});
|
92
|
+
// }
|
93
|
+
// }, this);
|
94
|
+
//
|
95
|
+
}
|
96
|
+
});
|
@@ -3,7 +3,7 @@ Ext.override(Netzke.pre.GridPanel, {
|
|
3
3
|
var selModel = this.getSelectionModel();
|
4
4
|
if (selModel.getCount() > 1) {
|
5
5
|
var recordId = selModel.getSelected().id;
|
6
|
-
this.
|
6
|
+
this.loadComponent({name: "multi_edit_form",
|
7
7
|
params: {record_id: recordId},
|
8
8
|
callback: function(w){
|
9
9
|
var form = w.items.first();
|
@@ -12,7 +12,8 @@ Ext.override(Netzke.pre.GridPanel, {
|
|
12
12
|
selModel.each(function(r){
|
13
13
|
ids.push(r.id);
|
14
14
|
});
|
15
|
-
form.baseParams = {
|
15
|
+
if (!form.baseParams) form.baseParams = {};
|
16
|
+
form.baseParams.ids = Ext.encode(ids);
|
16
17
|
}, this);
|
17
18
|
|
18
19
|
w.on('close', function(){
|
@@ -23,7 +24,7 @@ Ext.override(Netzke.pre.GridPanel, {
|
|
23
24
|
}, scope: this});
|
24
25
|
} else {
|
25
26
|
var recordId = selModel.getSelected().id;
|
26
|
-
this.
|
27
|
+
this.loadComponent({name: "edit_form",
|
27
28
|
params: {record_id: recordId},
|
28
29
|
callback: function(form){
|
29
30
|
form.on('close', function(){
|
@@ -36,7 +37,7 @@ Ext.override(Netzke.pre.GridPanel, {
|
|
36
37
|
},
|
37
38
|
|
38
39
|
onAddInForm: function(){
|
39
|
-
this.
|
40
|
+
this.loadComponent({name: "add_form", callback: function(form){
|
40
41
|
form.on('close', function(){
|
41
42
|
if (form.closeRes === "ok") {
|
42
43
|
this.store.reload();
|
@@ -7,29 +7,12 @@ Netzke.pre.GridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
|
|
7
7
|
autoScroll: true,
|
8
8
|
|
9
9
|
initComponent: function(){
|
10
|
-
if (!this.clmns) {this.feedback('No columns defined for grid '+this.id);}
|
11
|
-
|
12
|
-
/* Process columns - all in sake of creating the column model */
|
13
|
-
// Normalize columns passed in the config
|
14
|
-
var normClmns = [];
|
15
|
-
Ext.each(this.clmns, function(c){
|
16
|
-
// normalize columns
|
17
|
-
if (typeof c == 'string') {
|
18
|
-
normClmns.push({name:c});
|
19
|
-
} else {
|
20
|
-
normClmns.push(c);
|
21
|
-
}
|
22
|
-
});
|
23
|
-
|
24
|
-
delete this.clmns; // we don't need them anymore
|
25
|
-
|
26
|
-
var cmConfig = []; // column model config - we'll use it later to create the ColumnModel
|
27
10
|
this.plugins = []; // checkbox colums is a special case, being a plugin
|
28
11
|
|
29
12
|
var filters = [];
|
30
13
|
|
31
14
|
// Run through columns and set up different configuration for each
|
32
|
-
Ext.each(
|
15
|
+
Ext.each(this.columns, function(c, i){
|
33
16
|
// We will not use meta columns as actual columns (not even hidden) - only to create the records
|
34
17
|
if (c.meta) return;
|
35
18
|
|
@@ -44,11 +27,11 @@ Netzke.pre.GridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
|
|
44
27
|
|
45
28
|
// normalize editor
|
46
29
|
if (c.editor) {
|
47
|
-
c.editor =
|
30
|
+
c.editor = Ext.isObject(c.editor) ? c.editor : {xtype:c.editor};
|
48
31
|
} else {
|
49
32
|
c.editor = {xtype: this.attrTypeEditorMap[c.attrType] || 'textfield'}
|
50
33
|
}
|
51
|
-
|
34
|
+
|
52
35
|
// if comboboxOptions are provided, we render a combobox instead of textfield
|
53
36
|
if (c.comboboxOptions && c.editor.xtype === "textfield") {
|
54
37
|
c.editor = {xtype: "combobox", options: c.comboboxOptions.split('\\n')}
|
@@ -63,17 +46,17 @@ Netzke.pre.GridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
|
|
63
46
|
// Special case of checkbox column
|
64
47
|
var plugin = new Ext.ux.grid.CheckColumn(c);
|
65
48
|
this.plugins.push(plugin);
|
66
|
-
|
49
|
+
this.columns[i] = plugin;
|
67
50
|
} else {
|
68
51
|
// a "normal" column, not a plugin
|
69
52
|
if (!c.readOnly && !this.prohibitUpdate) {
|
70
53
|
// c.editor contains complete config of the editor
|
71
54
|
var xtype = c.editor.xtype;
|
72
|
-
c.editor = Ext.
|
55
|
+
c.editor = Ext.apply({
|
73
56
|
parentId: this.id,
|
74
57
|
name: c.name,
|
75
58
|
selectOnFocus:true
|
76
|
-
}, c.editor)
|
59
|
+
}, c.editor);
|
77
60
|
} else {
|
78
61
|
c.editor = null;
|
79
62
|
}
|
@@ -99,17 +82,11 @@ Netzke.pre.GridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
|
|
99
82
|
// }
|
100
83
|
//
|
101
84
|
// add to the list
|
102
|
-
cmConfig.push(c);
|
85
|
+
// cmConfig.push(c);
|
103
86
|
}
|
104
87
|
|
105
88
|
}, this);
|
106
89
|
|
107
|
-
// Finally, create the ColumnModel based on processed columns
|
108
|
-
this.cm = new Ext.grid.ColumnModel(cmConfig);
|
109
|
-
|
110
|
-
// Hidden change event
|
111
|
-
if (this.persistentConfig) {this.cm.on('hiddenchange', this.onColumnHiddenChange, this);}
|
112
|
-
|
113
90
|
/* ... and done with columns */
|
114
91
|
|
115
92
|
// Filters
|
@@ -119,7 +96,7 @@ Netzke.pre.GridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
|
|
119
96
|
|
120
97
|
// Create Ext.data.Record constructor specific for our particular column configuration
|
121
98
|
this.recordConfig = [];
|
122
|
-
Ext.each(
|
99
|
+
Ext.each(this.columns, function(column){this.recordConfig.push({name:column.name, defaultValue:column.defaultValue});}, this);
|
123
100
|
this.Row = Ext.data.Record.create(this.recordConfig);
|
124
101
|
|
125
102
|
// Drag'n'Drop
|
@@ -134,7 +111,7 @@ Netzke.pre.GridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
|
|
134
111
|
// because we don't want the app-wide Ext.Ajax to be used,
|
135
112
|
// as we are going to subscribe to its events
|
136
113
|
var connection = new Ext.data.Connection({
|
137
|
-
url: this.
|
114
|
+
url: this.endpointUrl("get_data"),
|
138
115
|
extraParams: {
|
139
116
|
authenticity_token : Netzke.authenticityToken
|
140
117
|
},
|
@@ -186,12 +163,15 @@ Netzke.pre.GridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
|
|
186
163
|
}) : this.bbar;
|
187
164
|
|
188
165
|
// Selection model
|
189
|
-
this.sm = new Ext.grid.RowSelectionModel();
|
166
|
+
if (!this.sm) this.sm = new Ext.grid.RowSelectionModel();
|
190
167
|
|
191
168
|
// Now let Ext.grid.EditorGridPanel do the rest
|
192
169
|
// Original initComponent
|
193
170
|
Netzke.pre.GridPanel.superclass.initComponent.call(this);
|
194
|
-
|
171
|
+
|
172
|
+
// Hidden change event
|
173
|
+
if (this.persistentConfig) {this.getColumnModel().on('hiddenchange', this.onColumnHiddenChange, this);}
|
174
|
+
|
195
175
|
// Inform the server part about column operations
|
196
176
|
if (this.persistentConfig) {
|
197
177
|
this.on('columnresize', this.onColumnResize, this);
|
@@ -199,7 +179,7 @@ Netzke.pre.GridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
|
|
199
179
|
}
|
200
180
|
|
201
181
|
// Context menu
|
202
|
-
if (this.
|
182
|
+
if (this.contextMenu) {
|
203
183
|
this.on('rowcontextmenu', this.onRowContextMenu, this);
|
204
184
|
}
|
205
185
|
|
@@ -222,8 +202,8 @@ Netzke.pre.GridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
|
|
222
202
|
// Process selectionchange event
|
223
203
|
this.getSelectionModel().on('selectionchange', function(selModel){
|
224
204
|
// enable/disable actions
|
225
|
-
this.actions.del.setDisabled(!selModel.hasSelection() || this.prohibitDelete);
|
226
|
-
this.actions.edit.setDisabled(selModel.getCount() != 1 || this.prohibitUpdate);
|
205
|
+
if (this.actions.del) this.actions.del.setDisabled(!selModel.hasSelection() || this.prohibitDelete);
|
206
|
+
if (this.actions.edit) this.actions.edit.setDisabled(selModel.getCount() != 1 || this.prohibitUpdate);
|
227
207
|
}, this);
|
228
208
|
|
229
209
|
// Drag n Drop event
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Netzke
|
2
|
+
module Basepack
|
3
|
+
class GridPanel < Netzke::Base
|
4
|
+
class MultiEditForm < FormPanel
|
5
|
+
|
6
|
+
# Replace checkbox for boolean fields with tristate checkbox
|
7
|
+
def attr_type_to_xtype_map
|
8
|
+
super.merge({
|
9
|
+
:boolean => :tricheckbox
|
10
|
+
})
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Netzke
|
2
|
+
module Basepack
|
3
|
+
class GridPanel < Netzke::Base
|
4
|
+
class RecordFormWindow < Window
|
5
|
+
js_properties :button_align => "right"
|
6
|
+
|
7
|
+
config :modal => true,
|
8
|
+
:width => "50%",
|
9
|
+
:auto_height => true,
|
10
|
+
:fbar => [:ok.action, :cancel.action]
|
11
|
+
|
12
|
+
action :ok, :text => 'OK'
|
13
|
+
action :cancel
|
14
|
+
|
15
|
+
js_method :init_component, <<-JS
|
16
|
+
function(params){
|
17
|
+
#{js_full_class_name}.superclass.initComponent.call(this);
|
18
|
+
this.getNetzkeComponent().on("submitsuccess", function(){this.closeRes = "ok"; this.close();}, this);
|
19
|
+
}
|
20
|
+
JS
|
21
|
+
|
22
|
+
js_method :on_ok, <<-JS
|
23
|
+
function(params){
|
24
|
+
this.getNetzkeComponent().onApply();
|
25
|
+
}
|
26
|
+
JS
|
27
|
+
|
28
|
+
js_method :on_cancel, <<-JS
|
29
|
+
function(params){
|
30
|
+
this.close();
|
31
|
+
}
|
32
|
+
JS
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Netzke
|
2
|
+
module Basepack
|
3
|
+
class GridPanel < Netzke::Base
|
4
|
+
class SearchWindow < Netzke::Basepack::Window
|
5
|
+
|
6
|
+
action :search
|
7
|
+
action :cancel
|
8
|
+
action :clear, :icon => :application_form
|
9
|
+
|
10
|
+
js_properties :title => "Advanced Search",
|
11
|
+
:width => "50%",
|
12
|
+
:auto_height => true,
|
13
|
+
:buttons => [:search.action, :cancel.action],
|
14
|
+
:tbar => [:clear.action]
|
15
|
+
|
16
|
+
config :items => [js_component(:search_panel)]
|
17
|
+
|
18
|
+
component :search_panel do
|
19
|
+
{
|
20
|
+
:class_name => "Basepack::SearchPanel",
|
21
|
+
:model => config[:model],
|
22
|
+
:items => config[:fields]
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
js_method :on_clear, <<-JS
|
27
|
+
function(){
|
28
|
+
this.items.first().getForm().reset();
|
29
|
+
}
|
30
|
+
JS
|
31
|
+
|
32
|
+
js_method :on_search, <<-JS
|
33
|
+
function(){
|
34
|
+
this.conditions = this.items.first().getForm().getValues();
|
35
|
+
|
36
|
+
// do not send values of empty values
|
37
|
+
for (var cond in this.conditions) {
|
38
|
+
if (this.conditions[cond] == "") delete this.conditions[cond];
|
39
|
+
}
|
40
|
+
|
41
|
+
this.closeRes = 'OK';
|
42
|
+
this.close();
|
43
|
+
}
|
44
|
+
JS
|
45
|
+
|
46
|
+
js_method :on_cancel, <<-JS
|
47
|
+
function(){
|
48
|
+
this.closeRes = 'cancel';
|
49
|
+
this.close();
|
50
|
+
}
|
51
|
+
JS
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|