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
@@ -1,11 +1,11 @@
|
|
1
|
-
|
2
|
-
Static part of GridPanel's JavaScript class.
|
3
|
-
*/
|
4
|
-
Netzke.pre.GridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
|
1
|
+
{
|
5
2
|
trackMouseOver: true,
|
6
3
|
loadMask: true,
|
7
4
|
autoScroll: true,
|
8
5
|
|
6
|
+
componentLoadMask: {msg: "Loading..."},
|
7
|
+
deleteMaskMsg: "Deleting...",
|
8
|
+
|
9
9
|
initComponent: function(){
|
10
10
|
this.plugins = []; // checkbox colums is a special case, being a plugin
|
11
11
|
|
@@ -144,6 +144,7 @@ Netzke.pre.GridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
|
|
144
144
|
|
145
145
|
// Data store
|
146
146
|
this.store = new Ext.data.Store({
|
147
|
+
pruneModifiedRecords: true,
|
147
148
|
proxy: this.proxy = httpProxy,
|
148
149
|
reader: new Ext.data.ArrayReader({root: "data", totalProperty: "total", successProperty: "success", id:0}, this.Row),
|
149
150
|
remoteSort: true,
|
@@ -167,7 +168,7 @@ Netzke.pre.GridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
|
|
167
168
|
|
168
169
|
// Now let Ext.grid.EditorGridPanel do the rest
|
169
170
|
// Original initComponent
|
170
|
-
Netzke.
|
171
|
+
Netzke.classes.Basepack.GridPanel.superclass.initComponent.call(this);
|
171
172
|
|
172
173
|
// Hidden change event
|
173
174
|
if (this.persistentConfig) {this.getColumnModel().on('hiddenchange', this.onColumnHiddenChange, this);}
|
@@ -183,6 +184,22 @@ Netzke.pre.GridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
|
|
183
184
|
this.on('rowcontextmenu', this.onRowContextMenu, this);
|
184
185
|
}
|
185
186
|
|
187
|
+
// Disabling/enabling editInForm button according to current selection
|
188
|
+
if (this.enableEditInForm) {
|
189
|
+
this.getSelectionModel().on('selectionchange', function(selModel){
|
190
|
+
var disabled;
|
191
|
+
if (!selModel.hasSelection()) {
|
192
|
+
disabled = true;
|
193
|
+
} else {
|
194
|
+
// Disable "edit in form" button if new record is present in selection
|
195
|
+
disabled = !selModel.each(function(r){
|
196
|
+
if (r.isNew) { return false; }
|
197
|
+
});
|
198
|
+
};
|
199
|
+
this.actions.editInForm.setDisabled(disabled);
|
200
|
+
}, this);
|
201
|
+
}
|
202
|
+
|
186
203
|
// Load data AFTER the toolbar is bound to the store, which will provide for correct page number
|
187
204
|
if (this.loadInlineData) {
|
188
205
|
this.getStore().loadData(this.inlineData);
|
@@ -253,7 +270,7 @@ Netzke.pre.GridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
|
|
253
270
|
},
|
254
271
|
|
255
272
|
onDel: function() {
|
256
|
-
Ext.Msg.confirm(
|
273
|
+
Ext.Msg.confirm(this.i18n.confirm, this.i18n.areYouSure, function(btn){
|
257
274
|
if (btn == 'yes') {
|
258
275
|
var records = [];
|
259
276
|
this.getSelectionModel().each(function(r){
|
@@ -266,8 +283,12 @@ Netzke.pre.GridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
|
|
266
283
|
}, this);
|
267
284
|
|
268
285
|
if (records.length > 0){
|
286
|
+
if (!this.deleteMask) this.deleteMask = new Ext.LoadMask(this.bwrap, {msg: this.deleteMaskMsg});
|
287
|
+
this.deleteMask.show();
|
269
288
|
// call API
|
270
|
-
this.deleteData({records: Ext.encode(records)})
|
289
|
+
this.deleteData({records: Ext.encode(records)}, function(){
|
290
|
+
this.deleteMask.hide();
|
291
|
+
}, this);
|
271
292
|
}
|
272
293
|
}
|
273
294
|
}, this);
|
@@ -361,11 +382,11 @@ Netzke.pre.GridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
|
|
361
382
|
},
|
362
383
|
|
363
384
|
onAfterRowMove: function(dt, oldIndex, newIndex, records){
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
385
|
+
var ids = [];
|
386
|
+
// collect records ids
|
387
|
+
Ext.each(records, function(r){ids.push(r.id)});
|
388
|
+
// call GridPanel's API
|
389
|
+
this.moveRows({ids:Ext.encode(ids), new_index: newIndex});
|
369
390
|
},
|
370
391
|
|
371
392
|
// Other methods
|
@@ -425,12 +446,10 @@ Netzke.pre.GridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
|
|
425
446
|
updateRecords: function(records, mod){
|
426
447
|
if (!mod) {mod = false;}
|
427
448
|
var modRecordsInGrid = [].concat(this.store.getModifiedRecords()); // there must be a better way to clone an array...
|
428
|
-
|
429
449
|
// replace arrays of data in the args object with Ext.data.Record objects
|
430
450
|
for (var k in records){
|
431
|
-
records[k] = this.store.reader.readRecords([records[k]]).records[0];
|
451
|
+
records[k] = this.store.reader.readRecords({data:[records[k]]}).records[0];
|
432
452
|
}
|
433
|
-
|
434
453
|
// for each new record write the data returned by the server, and commit the record
|
435
454
|
Ext.each(modRecordsInGrid, function(recordInGrid){
|
436
455
|
if (mod ^ recordInGrid.isNew) {
|
@@ -521,7 +540,6 @@ Netzke.pre.GridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
|
|
521
540
|
}
|
522
541
|
},
|
523
542
|
|
524
|
-
|
525
543
|
onEdit: function(){
|
526
544
|
var row = this.getSelectionModel().getSelected();
|
527
545
|
if (row){
|
@@ -540,4 +558,4 @@ Netzke.pre.GridPanel = Ext.extend(Ext.grid.EditorGridPanel, {
|
|
540
558
|
// }
|
541
559
|
// END_OF_JAVASCRIPT
|
542
560
|
|
543
|
-
}
|
561
|
+
}
|
@@ -38,9 +38,9 @@ module Netzke
|
|
38
38
|
record_ids = ActiveSupport::JSON.decode(params[:records])
|
39
39
|
data_class.destroy(record_ids)
|
40
40
|
on_data_changed
|
41
|
-
{:feedback =>
|
41
|
+
{:feedback => I18n.t('netzke.basepack.grid_panel.deleted_n_records', :n => record_ids.size), :load_store_data => get_data}
|
42
42
|
else
|
43
|
-
{:feedback =>
|
43
|
+
{:feedback => I18n.t('netzke.basepack.grid_panel.cannot_delete')}
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -77,7 +77,7 @@ module Netzke
|
|
77
77
|
query = params[:query]
|
78
78
|
|
79
79
|
column = columns.detect{ |c| c[:name] == params[:column] }
|
80
|
-
scope = column.to_options[:scope]
|
80
|
+
scope = column.to_options[:scope] || column.to_options[:editor].try(:fetch, :scope)
|
81
81
|
query = params[:query]
|
82
82
|
|
83
83
|
{:data => combobox_options_for_column(column, :query => query, :scope => scope, :record_id => params[:id])}
|
@@ -192,8 +192,8 @@ module Netzke
|
|
192
192
|
# if a sorting scope is set, call the scope with the given direction
|
193
193
|
column = columns.detect { |c| c[:name] == params[:sort] }
|
194
194
|
if column.has_key?(:sorting_scope)
|
195
|
-
|
196
|
-
|
195
|
+
relation = relation.send(column[:sorting_scope].to_sym, dir.to_sym)
|
196
|
+
else
|
197
197
|
relation = if method.nil?
|
198
198
|
relation.order(assoc.to_sym.send(dir))
|
199
199
|
else
|
@@ -249,7 +249,6 @@ module Netzke
|
|
249
249
|
# <tt>:operation</tt>: :update or :create
|
250
250
|
def process_data(data, operation)
|
251
251
|
success = true
|
252
|
-
# mod_record_ids = []
|
253
252
|
mod_records = {}
|
254
253
|
if !config[:"prohibit_#{operation}"]
|
255
254
|
modified_records = 0
|
@@ -261,17 +260,21 @@ module Netzke
|
|
261
260
|
# merge with strong default attirbutes
|
262
261
|
record_hash.merge!(config[:strong_default_attrs]) if config[:strong_default_attrs]
|
263
262
|
|
264
|
-
# process all attirubutes for this record
|
265
263
|
record_hash.each_pair do |k,v|
|
266
|
-
|
267
|
-
record.send("#{k}=",v)
|
268
|
-
rescue ArgumentError => exc
|
269
|
-
flash :error => exc.message
|
270
|
-
success = false
|
271
|
-
break
|
272
|
-
end
|
264
|
+
record.set_value_for_attribute(columns_hash[k.to_sym].nil? ? {:name => k} : columns_hash[k.to_sym], v)
|
273
265
|
end
|
274
266
|
|
267
|
+
# process all attirubutes for this record
|
268
|
+
#record_hash.each_pair do |k,v|
|
269
|
+
#begin
|
270
|
+
#record.send("#{k}=",v)
|
271
|
+
#rescue ArgumentError => exc
|
272
|
+
#flash :error => exc.message
|
273
|
+
#success = false
|
274
|
+
#break
|
275
|
+
#end
|
276
|
+
#end
|
277
|
+
|
275
278
|
# try to save
|
276
279
|
# modified_records += 1 if success && record.save
|
277
280
|
mod_records[id] = record.to_array(columns) if success && record.save
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module Netzke
|
2
|
+
module Basepack
|
3
|
+
# A FormPanel with paging toolbar. Allows browsing and editing records one-by-one.
|
4
|
+
#
|
5
|
+
# == Configuration
|
6
|
+
# Besides +Netzke::Basepack::FormPanel+ config options, accepts:
|
7
|
+
# * +scope+ - specifies how the data should be filtered.
|
8
|
+
# When it's a symbol, it's used as a scope name.
|
9
|
+
# When it's a string, it's a SQL statement (passed directly to +ActiveRecord::Relation#where+).
|
10
|
+
# When it's a hash, it's a conditions hash (passed directly to +ActiveRecord::Relation#where+).
|
11
|
+
# When it's an array, it's expanded into an SQL statement with arguments (passed directly to +ActiveRecord::Relation#where+), e.g.:
|
12
|
+
#
|
13
|
+
# :scope => ["id > ?", 100])
|
14
|
+
#
|
15
|
+
# When it's a Proc, it's passed the model class, and is expected to return an ActiveRecord::Relation, e.g.:
|
16
|
+
#
|
17
|
+
# :scope => { |rel| rel.where(:id.gt => 100).order(:created_at) }
|
18
|
+
class PagingFormPanel < FormPanel
|
19
|
+
|
20
|
+
# override
|
21
|
+
def record
|
22
|
+
@record ||= get_relation.first
|
23
|
+
end
|
24
|
+
|
25
|
+
# Pass total records amount and the first record to the JS constructor
|
26
|
+
def js_config
|
27
|
+
super.merge({
|
28
|
+
:total_records => total_records,
|
29
|
+
:record => record.to_hash(fields)
|
30
|
+
})
|
31
|
+
end
|
32
|
+
|
33
|
+
endpoint :get_data do |params|
|
34
|
+
record = get_relation.offset(params[:start].to_i).limit(1).first
|
35
|
+
record_hash = record && record.to_hash(fields).each_pair.inject({}){ |r,(k,v)| r.merge(k.l => v) }
|
36
|
+
{:records => record_hash && [record_hash] || [], :total => total_records}
|
37
|
+
end
|
38
|
+
|
39
|
+
js_method :init_component, <<-JS
|
40
|
+
function(){
|
41
|
+
|
42
|
+
// Extract field names from items recursively. We have to do it before calling superclass.initComponent,
|
43
|
+
// because we need to build the store for PagingToolbar that cannot be created after superclass.initComponent
|
44
|
+
// Otherwise, the things would be simpler, because this.getForm().items would already has all the fields in one place for us
|
45
|
+
this.fieldNames = [];
|
46
|
+
this.extractFields(this.items);
|
47
|
+
var fieldNames = this.fieldNames;
|
48
|
+
|
49
|
+
var store = new Ext.data.JsonStore({
|
50
|
+
url: this.endpointUrl('get_data'),
|
51
|
+
root: 'records',
|
52
|
+
fields: fieldNames,
|
53
|
+
data: {records: [this.record], total: this.totalRecords}
|
54
|
+
});
|
55
|
+
|
56
|
+
store.on('beforeload', function(){
|
57
|
+
if (!this.loadMaskCmp) this.loadMaskCmp = new Ext.LoadMask(this.bwrap, this.applyMask);
|
58
|
+
this.loadMaskCmp.show();
|
59
|
+
}, this);
|
60
|
+
|
61
|
+
store.on('load', function(st, r){
|
62
|
+
this.setFormValues(r[0].data);
|
63
|
+
if (this.loadMaskCmp) this.loadMaskCmp.hide();
|
64
|
+
}, this);
|
65
|
+
|
66
|
+
this.bbar = new Ext.PagingToolbar({
|
67
|
+
beforePageText: "Record",
|
68
|
+
store: store,
|
69
|
+
pageSize: 1,
|
70
|
+
items: ["-"].concat(this.bbar || [])
|
71
|
+
});
|
72
|
+
|
73
|
+
Netzke.classes.Basepack.PagingFormPanel.superclass.initComponent.call(this);
|
74
|
+
}
|
75
|
+
JS
|
76
|
+
|
77
|
+
protected
|
78
|
+
|
79
|
+
# Returns ActiveRecord::Relation for the data
|
80
|
+
def get_relation
|
81
|
+
relation = data_class.scoped
|
82
|
+
relation = relation.extend_with(config[:scope]) if config[:scope]
|
83
|
+
relation
|
84
|
+
end
|
85
|
+
|
86
|
+
def total_records
|
87
|
+
@total_records ||= get_relation.count
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Netzke
|
2
|
+
module Basepack
|
3
|
+
# Basis for a Ext.Viewport-based one-page application
|
4
|
+
#
|
5
|
+
# Features:
|
6
|
+
# * dynamic loading of components
|
7
|
+
# * browser history support (press the "Back"-button to go to the previously loaded component)
|
8
|
+
# * AJAX activity indicator
|
9
|
+
class SimpleApp < Base
|
10
|
+
|
11
|
+
js_base_class "Ext.Viewport"
|
12
|
+
|
13
|
+
js_property :layout, :border
|
14
|
+
|
15
|
+
js_include Netzke::Core.ext_location.join("examples", "ux/statusbar/StatusBar.js"), :statusbar_ext
|
16
|
+
|
17
|
+
js_mixin :main
|
18
|
+
|
19
|
+
def configuration
|
20
|
+
super.merge(
|
21
|
+
:items => [main_panel_config, menu_bar_config, status_bar_config]
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def menu
|
26
|
+
[]
|
27
|
+
end
|
28
|
+
|
29
|
+
def main_panel_config(overrides = {})
|
30
|
+
{
|
31
|
+
:id => 'main-panel',
|
32
|
+
:region => 'center',
|
33
|
+
:layout => 'fit'
|
34
|
+
}.merge(overrides)
|
35
|
+
end
|
36
|
+
|
37
|
+
def status_bar_config(overrides = {})
|
38
|
+
{
|
39
|
+
:id => 'main-statusbar',
|
40
|
+
:xtype => 'statusbar',
|
41
|
+
:region => 'south',
|
42
|
+
:height => 22,
|
43
|
+
:statusAlign => 'right',
|
44
|
+
:busyText => 'Busy...',
|
45
|
+
:default_text => "Ready",
|
46
|
+
:default_icon_cls => ""
|
47
|
+
}.merge(overrides)
|
48
|
+
end
|
49
|
+
|
50
|
+
def menu_bar_config(overrides = {})
|
51
|
+
{
|
52
|
+
:id => 'main-toolbar',
|
53
|
+
:xtype => 'toolbar',
|
54
|
+
:region => 'north',
|
55
|
+
:height => 28,
|
56
|
+
:items => menu
|
57
|
+
}.merge(overrides)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Html required for Ext.History to work
|
61
|
+
def js_component_html
|
62
|
+
super << %Q{
|
63
|
+
<form id="history-form" class="x-hidden">
|
64
|
+
<input type="hidden" id="x-history-field" />
|
65
|
+
<iframe id="x-history-frame"></iframe>
|
66
|
+
</form>
|
67
|
+
}
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
{
|
2
|
+
initComponent: function(){
|
3
|
+
Netzke.classes.Basepack.SimpleApp.superclass.initComponent.call(this);
|
4
|
+
|
5
|
+
Ext.History.on('change', this.processHistory, this);
|
6
|
+
|
7
|
+
// Setting the "busy" indicator for Ajax requests
|
8
|
+
Ext.Ajax.on('beforerequest', function(){this.findById('main-statusbar').showBusy()}, this);
|
9
|
+
Ext.Ajax.on('requestcomplete', function(){this.findById('main-statusbar').hideBusy()}, this);
|
10
|
+
Ext.Ajax.on('requestexception', function(){this.findById('main-statusbar').hideBusy()}, this);
|
11
|
+
|
12
|
+
// Initialize history
|
13
|
+
Ext.History.init();
|
14
|
+
},
|
15
|
+
|
16
|
+
afterRender: function(){
|
17
|
+
Netzke.classes.Basepack.SimpleApp.superclass.afterRender.call(this);
|
18
|
+
|
19
|
+
// If we are given a token, load the corresponding component, otherwise load the last loaded component
|
20
|
+
var currentToken = Ext.History.getToken();
|
21
|
+
if (currentToken != "") {
|
22
|
+
this.processHistory(currentToken);
|
23
|
+
} else {
|
24
|
+
var lastLoaded = this.initialConfig.componentToLoad; // passed from the server
|
25
|
+
if (lastLoaded) Ext.History.add(lastLoaded);
|
26
|
+
}
|
27
|
+
},
|
28
|
+
|
29
|
+
processHistory: function(token){
|
30
|
+
if (token){
|
31
|
+
this.loadComponent({name:token, container:'main-panel'});
|
32
|
+
} else {
|
33
|
+
Ext.getCmp('main-panel').removeChild();
|
34
|
+
}
|
35
|
+
},
|
36
|
+
|
37
|
+
instantiateComponent: function(config){
|
38
|
+
this.findById('main-panel').instantiateChild(config);
|
39
|
+
},
|
40
|
+
|
41
|
+
appLoadComponent: function(name){
|
42
|
+
Ext.History.add(name);
|
43
|
+
},
|
44
|
+
|
45
|
+
loadComponentByAction: function(action){
|
46
|
+
var componentName = action.component || action.name;
|
47
|
+
if (componentName) this.appLoadComponent(componentName);
|
48
|
+
},
|
49
|
+
|
50
|
+
onToggleConfigMode: function(params){
|
51
|
+
this.toggleConfigMode();
|
52
|
+
}
|
53
|
+
}
|
File without changes
|
@@ -16,17 +16,7 @@ module Netzke
|
|
16
16
|
|
17
17
|
js_base_class "Ext.TabPanel"
|
18
18
|
|
19
|
-
|
20
|
-
function(params){
|
21
|
-
#{js_full_class_name}.superclass.initComponent.call(this);
|
22
|
-
this.on('tabchange', function(self, i){
|
23
|
-
if (i && i.wrappedComponent && !i.items.first()) {
|
24
|
-
this.loadComponent({name: i.wrappedComponent, container: i.id});
|
25
|
-
}
|
26
|
-
}, this);
|
27
|
-
}
|
28
|
-
JS
|
29
|
-
|
19
|
+
js_mixin :main
|
30
20
|
end
|
31
21
|
end
|
32
|
-
end
|
22
|
+
end
|