netzke-basepack 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +27 -2
- data/TODO.rdoc +1 -5
- data/app/models/netzke_persistent_array_auto_model.rb +0 -1
- data/features/components_in_view.feature +11 -0
- data/features/form_panel.feature +49 -0
- data/features/grid_panel.feature +32 -1
- data/features/i18n.feature +18 -0
- data/features/nested_attributes.feature +23 -0
- data/features/search_in_grid.feature +9 -9
- data/features/simple_app.feature +10 -0
- data/features/step_definitions/grid_panel_steps.rb +23 -0
- data/features/support/paths.rb +6 -0
- data/features/support/pickle.rb +0 -1
- data/features/virtual_attributes.feature +20 -0
- data/javascripts/basepack.js +166 -243
- data/lib/netzke-basepack.rb +3 -3
- data/lib/netzke/active_record.rb +6 -7
- data/lib/netzke/active_record/attributes.rb +214 -143
- data/lib/netzke/active_record/combobox_options.rb +12 -10
- data/lib/netzke/basepack.rb +6 -3
- data/lib/netzke/basepack/accordion_panel.rb +4 -2
- data/lib/netzke/basepack/auth_app.rb +152 -0
- data/lib/netzke/basepack/basic_app.rb +2 -262
- data/lib/netzke/basepack/form_panel.rb +35 -27
- data/lib/netzke/basepack/form_panel/fields.rb +35 -17
- data/lib/netzke/basepack/form_panel/javascripts/comma_list_cbg.js +59 -0
- data/lib/netzke/basepack/form_panel/javascripts/display_mode.js +62 -0
- data/lib/netzke/basepack/form_panel/javascripts/main.js +138 -0
- data/lib/netzke/basepack/form_panel/javascripts/n_radio_group.js +25 -0
- data/lib/netzke/basepack/form_panel/services.rb +12 -9
- data/lib/netzke/basepack/grid_panel.rb +87 -53
- data/lib/netzke/basepack/grid_panel/columns.rb +60 -15
- data/lib/netzke/basepack/grid_panel/javascripts/advanced_search.js +2 -64
- data/lib/netzke/basepack/grid_panel/javascripts/edit_in_form.js +2 -2
- data/lib/netzke/basepack/grid_panel/javascripts/{pre.js → main.js} +35 -17
- data/lib/netzke/basepack/grid_panel/javascripts/misc.js +4 -0
- data/lib/netzke/basepack/grid_panel/services.rb +17 -14
- data/lib/netzke/basepack/paging_form_panel.rb +92 -0
- data/lib/netzke/basepack/simple_app.rb +71 -0
- data/lib/netzke/basepack/simple_app/javascripts/main.js +53 -0
- data/lib/netzke/basepack/{basic_app → simple_app/javascripts}/statusbar_ext.js +0 -0
- data/lib/netzke/basepack/tab_panel.rb +2 -12
- data/lib/netzke/basepack/tab_panel/javascripts/main.js +11 -0
- data/lib/netzke/basepack/version.rb +2 -2
- data/lib/netzke/basepack/window.rb +6 -7
- data/lib/netzke/basepack/wrap_lazy_loaded.rb +3 -1
- data/lib/netzke/data_accessor.rb +25 -14
- data/lib/netzke/ext.rb +1 -1
- data/locales/en.yml +22 -0
- data/netzke-basepack.gemspec +66 -12
- data/spec/active_record/attributes_spec.rb +31 -2
- data/spec/factories.rb +16 -1
- data/test/rails_app/Gemfile +2 -2
- data/test/rails_app/Gemfile.lock +76 -77
- data/test/rails_app/app/components/author_grid.rb +7 -0
- data/test/rails_app/app/components/book_form.rb +24 -0
- data/test/rails_app/app/components/book_grid.rb +6 -1
- data/test/rails_app/app/components/book_grid_with_default_values.rb +11 -0
- data/test/rails_app/app/components/book_grid_with_nested_attributes.rb +13 -0
- data/test/rails_app/app/components/book_grid_with_virtual_attributes.rb +22 -0
- data/test/rails_app/app/components/book_paging_form_panel.rb +20 -0
- data/test/rails_app/app/components/book_presentation.rb +18 -0
- data/test/rails_app/app/components/books_bound_to_author.rb +10 -0
- data/test/rails_app/app/components/form_without_model.rb +19 -0
- data/test/rails_app/app/components/lockable_book_form.rb +17 -0
- data/test/rails_app/app/components/lockable_user_form.rb +7 -0
- data/test/rails_app/app/components/simple_window.rb +10 -0
- data/test/rails_app/app/components/some_accordion_panel.rb +22 -0
- data/test/rails_app/app/components/{simple_basic_app.rb → some_auth_app.rb} +3 -3
- data/test/rails_app/app/components/some_border_layout.rb +10 -7
- data/test/rails_app/app/components/some_simple_app.rb +34 -0
- data/test/rails_app/app/components/some_tab_panel.rb +16 -11
- data/test/rails_app/app/components/user_form.rb +11 -4
- data/test/rails_app/app/components/user_grid.rb +7 -1
- data/test/rails_app/app/components/window_component_loader.rb +1 -0
- data/test/rails_app/app/controllers/application_controller.rb +6 -0
- data/test/rails_app/app/controllers/components_controller.rb +3 -3
- data/test/rails_app/app/controllers/welcome_controller.rb +2 -2
- data/test/rails_app/app/helpers/embedded_components_helper.rb +2 -0
- data/test/rails_app/app/models/address.rb +3 -0
- data/test/rails_app/app/models/author.rb +2 -0
- data/test/rails_app/app/models/book.rb +1 -0
- data/test/rails_app/app/models/user.rb +1 -2
- data/test/rails_app/app/views/components/simple_panel.html.erb +1 -0
- data/test/rails_app/app/views/layouts/nested.html.erb +5 -0
- data/test/rails_app/config/application.rb +1 -1
- data/test/rails_app/config/initializers/netzke.rb +0 -4
- data/test/rails_app/config/locales/es.yml +16 -0
- data/test/rails_app/config/routes.rb +4 -1
- data/test/rails_app/db/development_structure.sql +33 -4
- data/test/rails_app/db/migrate/20101026190021_create_books.rb +2 -0
- data/test/rails_app/db/migrate/20110101143818_create_addresses.rb +17 -0
- data/test/rails_app/db/schema.rb +33 -1
- data/test/rails_app/spec/controllers/embedded_components_controller_spec.rb +12 -0
- data/test/rails_app/spec/helpers/embedded_components_helper_spec.rb +15 -0
- data/test/rails_app/spec/models/address_spec.rb +5 -0
- data/test/rails_app/spec/views/embedded_components/index.html.erb_spec.rb +5 -0
- metadata +67 -13
- data/features/basic_app.feature +0 -12
- data/lib/netzke/active_record/association_attributes.rb +0 -102
- data/lib/netzke/basepack/form_panel/javascripts/pre.js +0 -76
- data/lib/netzke/basepack/form_panel/javascripts/xcheckbox.js +0 -82
- data/lib/netzke/basepack/grid_panel/javascript.rb +0 -69
- data/locale/en.yml +0 -16
@@ -18,14 +18,16 @@ module Netzke
|
|
18
18
|
include WrapLazyLoaded
|
19
19
|
|
20
20
|
js_property :layout, 'accordion'
|
21
|
+
js_property :component_load_mask, {:msg => null} # due to a probable bug in Ext's Accordion Layout (mask message is mis-layed-out), disabling mask message
|
21
22
|
|
22
23
|
js_method :init_component, <<-JS
|
23
24
|
function(params){
|
24
25
|
#{js_full_class_name}.superclass.initComponent.call(this);
|
25
26
|
this.items.each(function(item){
|
26
27
|
item.on('expand', function(i){
|
27
|
-
if (i && i.wrappedComponent && !i.items.first()) {
|
28
|
-
|
28
|
+
if (i && i.wrappedComponent && !i.items.first() && !i.beingLoaded) {
|
29
|
+
i.beingLoaded = true; // prevent more than one request per panel in case of fast clicking
|
30
|
+
this.loadComponent({name: i.wrappedComponent, container: i.id}, function(){i.beingLoaded = false});
|
29
31
|
}
|
30
32
|
}, this);
|
31
33
|
}, this);
|
@@ -0,0 +1,152 @@
|
|
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
|
+
class_attribute :login_url
|
8
|
+
self.login_url = "/login"
|
9
|
+
|
10
|
+
class_attribute :logout_url
|
11
|
+
self.logout_url = "/logout"
|
12
|
+
|
13
|
+
js_method :on_login, <<-JS
|
14
|
+
function(){
|
15
|
+
window.location = "#{login_url}"
|
16
|
+
}
|
17
|
+
JS
|
18
|
+
|
19
|
+
js_method :on_logout, <<-JS
|
20
|
+
function(){
|
21
|
+
window.location = "#{logout_url}"
|
22
|
+
}
|
23
|
+
JS
|
24
|
+
|
25
|
+
js_method :on_toggle_config_mode, <<-JS
|
26
|
+
function(params){
|
27
|
+
this.toggleConfigMode();
|
28
|
+
}
|
29
|
+
JS
|
30
|
+
|
31
|
+
js_method :show_masquerade_selector, <<-JS
|
32
|
+
function(){
|
33
|
+
var w = new Ext.Window({
|
34
|
+
title: 'Masquerade as',
|
35
|
+
modal: true,
|
36
|
+
width: Ext.lib.Dom.getViewWidth() * 0.6,
|
37
|
+
height: Ext.lib.Dom.getViewHeight() * 0.6,
|
38
|
+
layout: 'fit',
|
39
|
+
closeAction :'destroy',
|
40
|
+
buttons: [{
|
41
|
+
text: 'Select',
|
42
|
+
handler : function(){
|
43
|
+
if (role = w.getNetzkeComponent().masquerade.role) {
|
44
|
+
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){
|
45
|
+
if (btn === 'yes') {
|
46
|
+
w.close();
|
47
|
+
}
|
48
|
+
});
|
49
|
+
} else {
|
50
|
+
w.close();
|
51
|
+
}
|
52
|
+
},
|
53
|
+
scope:this
|
54
|
+
},{
|
55
|
+
text:'As World',
|
56
|
+
handler:function(){
|
57
|
+
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){
|
58
|
+
if (btn === "yes") {
|
59
|
+
this.masquerade = {world:true};
|
60
|
+
w.close();
|
61
|
+
}
|
62
|
+
}, this);
|
63
|
+
},
|
64
|
+
scope:this
|
65
|
+
},{
|
66
|
+
text:'No masquerading',
|
67
|
+
handler:function(){
|
68
|
+
this.masquerade = {};
|
69
|
+
w.close();
|
70
|
+
},
|
71
|
+
scope:this
|
72
|
+
},{
|
73
|
+
text:'Cancel',
|
74
|
+
handler:function(){
|
75
|
+
w.hide();
|
76
|
+
},
|
77
|
+
scope:this
|
78
|
+
}],
|
79
|
+
listeners : {close: {fn: function(){
|
80
|
+
this.masqueradeAs(this.masquerade || w.getNetzkeComponent().masquerade || {});
|
81
|
+
}, scope: this}}
|
82
|
+
});
|
83
|
+
|
84
|
+
w.show(null, function(){
|
85
|
+
this.loadComponent({id:"masqueradeSelector", container:w.id})
|
86
|
+
}, this);
|
87
|
+
|
88
|
+
}
|
89
|
+
JS
|
90
|
+
|
91
|
+
# Set the Logout button if Netzke::Base.user is set
|
92
|
+
def menu
|
93
|
+
res = []
|
94
|
+
user = User.find_by_id(session[:netzke_user_id])
|
95
|
+
if !user.nil?
|
96
|
+
user_name = user.respond_to?(:name) ? user.name : user.login # try to display user's name, fallback to login
|
97
|
+
res << "->" <<
|
98
|
+
{
|
99
|
+
:text => "#{user_name}",
|
100
|
+
:menu => user_menu
|
101
|
+
}
|
102
|
+
else
|
103
|
+
res << "->" << :login.action
|
104
|
+
end
|
105
|
+
res
|
106
|
+
end
|
107
|
+
|
108
|
+
def user_menu
|
109
|
+
[:logout.action]
|
110
|
+
end
|
111
|
+
|
112
|
+
def initialize(*args)
|
113
|
+
super
|
114
|
+
|
115
|
+
if session[:netzke_just_logged_in] || session[:netzke_just_logged_out]
|
116
|
+
session[:config_mode] = false
|
117
|
+
session[:masq_world] = session[:masq_user] = session[:masq_roles] = nil
|
118
|
+
end
|
119
|
+
|
120
|
+
strong_children_config.deep_merge!(:mode => :config) if session[:config_mode]
|
121
|
+
end
|
122
|
+
|
123
|
+
action :masquerade_selector, :text => "Masquerade as ...", :handler => :show_masquerade_selector
|
124
|
+
|
125
|
+
action :toggle_config_mode do
|
126
|
+
{:text => "#{session[:config_mode] ? "Leave" : "Enter"} config mode"}
|
127
|
+
end
|
128
|
+
|
129
|
+
action :login, :icon => :door_in
|
130
|
+
|
131
|
+
action :logout, :icon => :door_out
|
132
|
+
|
133
|
+
#
|
134
|
+
# Interface section
|
135
|
+
#
|
136
|
+
endpoint :toggle_config_mode do |params|
|
137
|
+
session = Netzke::Base.session
|
138
|
+
session[:config_mode] = !session[:config_mode]
|
139
|
+
{:js => "window.location.reload();"}
|
140
|
+
end
|
141
|
+
|
142
|
+
endpoint :masquerade_as do |params|
|
143
|
+
session = Netzke::Base.session
|
144
|
+
session[:masq_world] = params[:world] == "true"
|
145
|
+
session[:masq_role] = params[:role].try(:to_i)
|
146
|
+
session[:masq_user] = params[:user].try(:to_i)
|
147
|
+
{:js => "window.location.reload();"}
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
@@ -1,267 +1,7 @@
|
|
1
1
|
module Netzke
|
2
2
|
module Basepack
|
3
|
-
#
|
4
|
-
|
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
|
-
|
3
|
+
# For backward compatibility only. Use AuthApp instead.
|
4
|
+
class BasicApp < AuthApp
|
265
5
|
end
|
266
6
|
end
|
267
7
|
end
|
@@ -1,19 +1,25 @@
|
|
1
1
|
require "netzke/basepack/form_panel/fields"
|
2
2
|
require "netzke/basepack/form_panel/services"
|
3
|
+
require "netzke/data_accessor"
|
3
4
|
# require "netzke/plugins/configuration_tool"
|
4
|
-
# require "netzke/data_accessor"
|
5
5
|
|
6
6
|
module Netzke
|
7
7
|
module Basepack
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# Represents Ext.form.FormPanel
|
8
|
+
# Ext.form.FormPanel-based component with different goodies
|
11
9
|
#
|
12
10
|
# == Configuration
|
13
|
-
#
|
14
|
-
# *
|
15
|
-
# *
|
11
|
+
# Besides all the standard +Ext.form.FormPanel+ config options, accepts:
|
12
|
+
# * +model+ - name of the ActiveRecord model that provides data to this GridPanel.
|
13
|
+
# * +record+ - record to be displayd in the form. Takes precedence over +:record_id+
|
14
|
+
# * +record_id+ - id of the record to be displayd in the form. Also see +:record+
|
15
|
+
# * +mode+ - render mode, accepted options:
|
16
|
+
# * +lockable+ - makes the form panel load initially in "display mode", then lets "unlock" it, change the values, and "lock" it again, while updating the values on the server
|
17
|
+
# * +updateMask+ - +Ext.LoadMask+ config options for the mask shown while the form is submitting its values
|
18
|
+
#
|
19
|
+
# === Layout configuration
|
20
|
+
# The layout of the form is configured by supplying the +item+ config option, same way it would be configured in Ext (thus allowing for complex form layouts). FormPanel will expand fields by looking at their names (unless +no_binding+ set to +true+ is specified for a specific field).
|
16
21
|
class FormPanel < Netzke::Base
|
22
|
+
|
17
23
|
# Class-level configuration
|
18
24
|
class_attribute :config_tool_available
|
19
25
|
self.config_tool_available = true
|
@@ -23,32 +29,36 @@ module Netzke
|
|
23
29
|
|
24
30
|
include self::Services
|
25
31
|
include self::Fields
|
26
|
-
|
27
32
|
include Netzke::DataAccessor
|
28
33
|
|
29
|
-
js_base_class "
|
34
|
+
js_base_class "Ext.form.FormPanel"
|
35
|
+
|
36
|
+
def bbar(config)
|
37
|
+
config[:mode] == :lockable ? nil : [:apply.action]
|
38
|
+
end
|
30
39
|
|
31
|
-
|
40
|
+
action :apply, :text => I18n.t('netzke.basepack.form_panel.apply', :default => "Apply"), :icon => :tick
|
41
|
+
action :edit, :text => I18n.t('netzke.basepack.form_panel.edit', :default => "Edit"), :icon => :pencil
|
42
|
+
action :cancel, :text => I18n.t('netzke.basepack.form_panel.cancel', :default => "Cancel"), :icon => :cancel
|
32
43
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
# end
|
44
|
+
def configuration
|
45
|
+
sup = super
|
46
|
+
|
47
|
+
sup.merge(
|
48
|
+
:bbar => sup[:bbar] || bbar(sup),
|
49
|
+
:locked => sup[:locked].nil? ? (sup[:mode] == :lockable) : sup[:locked]
|
50
|
+
)
|
51
|
+
end
|
42
52
|
|
43
53
|
# Extra javascripts
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
54
|
+
js_mixin :main
|
55
|
+
js_include :comma_list_cbg
|
56
|
+
js_include :n_radio_group, :display_mode
|
57
|
+
# Netzke::Base.config[:ext_location] + "/examples/ux/fileuploadfield/FileUploadField.js",
|
58
|
+
# "#{File.dirname(__FILE__)}/form_panel/javascripts/netzkefileupload.js"
|
48
59
|
|
49
60
|
def js_config
|
50
61
|
super.merge(
|
51
|
-
# :fields => fields,
|
52
62
|
:pri => data_class && data_class.primary_key
|
53
63
|
)
|
54
64
|
end
|
@@ -78,8 +88,6 @@ module Netzke
|
|
78
88
|
res
|
79
89
|
end
|
80
90
|
|
81
|
-
action :apply, :text => 'Apply', :icon => :tick
|
82
|
-
|
83
91
|
def self.property_fields
|
84
92
|
res = [
|
85
93
|
# {:name => "ext_config__title", :attr_type => :string},
|
@@ -99,4 +107,4 @@ module Netzke
|
|
99
107
|
# include ::Netzke::Plugins::ConfigurationTool if config_tool_available # it will load ConfigurationPanel into a modal window
|
100
108
|
end
|
101
109
|
end
|
102
|
-
end
|
110
|
+
end
|