netzke-basepack 0.6.5 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/CHANGELOG.rdoc +7 -4
  2. data/README.md +63 -0
  3. data/Rakefile +4 -4
  4. data/javascripts/basepack.js +113 -133
  5. data/lib/netzke-basepack.rb +9 -2
  6. data/lib/netzke/basepack.rb +9 -6
  7. data/lib/netzke/basepack/accordion_panel.rb +1 -1
  8. data/lib/netzke/basepack/auth_app.rb +28 -21
  9. data/lib/netzke/basepack/border_layout_panel.rb +9 -57
  10. data/lib/netzke/basepack/border_layout_panel/javascripts/border_layout_panel.js +40 -0
  11. data/lib/netzke/basepack/data_accessor.rb +3 -5
  12. data/lib/netzke/basepack/form_panel.rb +55 -52
  13. data/lib/netzke/basepack/form_panel/fields.rb +4 -2
  14. data/lib/netzke/basepack/form_panel/javascripts/comma_list_cbg.js +13 -28
  15. data/lib/netzke/basepack/form_panel/javascripts/form_panel.js +61 -34
  16. data/lib/netzke/basepack/form_panel/javascripts/n_radio_group.js +4 -3
  17. data/lib/netzke/basepack/form_panel/javascripts/readonly_mode.js +10 -10
  18. data/lib/netzke/basepack/form_panel/services.rb +1 -1
  19. data/lib/netzke/basepack/grid_panel.rb +23 -17
  20. data/lib/netzke/basepack/grid_panel/columns.rb +116 -71
  21. data/lib/netzke/basepack/grid_panel/javascripts/advanced_search.js +5 -7
  22. data/lib/netzke/basepack/grid_panel/javascripts/check_column_fix.js +6 -0
  23. data/lib/netzke/basepack/grid_panel/javascripts/edit_in_form.js +18 -15
  24. data/lib/netzke/basepack/grid_panel/javascripts/event_handling.js +178 -0
  25. data/lib/netzke/basepack/grid_panel/javascripts/grid_panel.js +230 -454
  26. data/lib/netzke/basepack/grid_panel/javascripts/rows-dd.js +1 -0
  27. data/lib/netzke/basepack/grid_panel/record_form_window.rb +8 -8
  28. data/lib/netzke/basepack/grid_panel/services.rb +12 -15
  29. data/lib/netzke/basepack/paging_form_panel.rb +1 -82
  30. data/lib/netzke/basepack/paging_form_panel/javascripts/paging_form_panel.js +76 -0
  31. data/lib/netzke/basepack/query_builder.rb +4 -4
  32. data/lib/netzke/basepack/query_builder/javascripts/query_builder.js +7 -4
  33. data/lib/netzke/basepack/search_panel.rb +1 -1
  34. data/lib/netzke/basepack/search_panel/javascripts/condition_field.js +27 -20
  35. data/lib/netzke/basepack/search_panel/javascripts/search_panel.js +4 -4
  36. data/lib/netzke/basepack/search_window.rb +4 -4
  37. data/lib/netzke/basepack/simple_app.rb +36 -8
  38. data/lib/netzke/basepack/simple_app/javascripts/simple_app.js +27 -16
  39. data/lib/netzke/basepack/tab_panel/javascripts/tab_panel.js +1 -1
  40. data/lib/netzke/basepack/version.rb +2 -2
  41. data/lib/netzke/basepack/window.rb +2 -45
  42. data/lib/netzke/basepack/window/javascripts/window.js +18 -0
  43. data/lib/netzke/basepack/wrap_lazy_loaded.rb +1 -1
  44. data/locales/de.yml +79 -0
  45. data/locales/en.yml +0 -10
  46. data/netzke-basepack.gemspec +32 -19
  47. data/stylesheets/basepack.css +16 -16
  48. data/test/rails_app/.gitignore +1 -0
  49. data/test/rails_app/Gemfile +9 -5
  50. data/test/rails_app/Gemfile.lock +51 -49
  51. data/test/rails_app/app/components/author_form.rb +32 -0
  52. data/test/rails_app/app/components/book_form.rb +6 -4
  53. data/test/rails_app/app/components/book_grid.rb +4 -3
  54. data/test/rails_app/app/components/book_grid_loader.rb +2 -2
  55. data/test/rails_app/app/components/book_grid_with_custom_columns.rb +11 -5
  56. data/test/rails_app/app/components/book_grid_with_default_values.rb +1 -1
  57. data/test/rails_app/app/components/book_grid_with_extra_feedback.rb +11 -0
  58. data/test/rails_app/app/components/book_grid_with_extra_filters.rb +14 -0
  59. data/test/rails_app/app/components/book_grid_with_paging.rb +10 -0
  60. data/test/rails_app/app/components/book_grid_with_persistence.rb +6 -0
  61. data/test/rails_app/app/components/book_paging_form_panel.rb +3 -3
  62. data/test/rails_app/app/components/book_with_custom_primary_key_grid.rb +10 -0
  63. data/test/rails_app/app/components/form_without_model.rb +5 -4
  64. data/test/rails_app/app/components/paging_form_with_search.rb +3 -2
  65. data/test/rails_app/app/components/some_auth_app.rb +3 -3
  66. data/test/rails_app/app/components/some_border_layout.rb +2 -2
  67. data/test/rails_app/app/components/some_simple_app.rb +6 -5
  68. data/test/rails_app/app/components/window_component_loader.rb +11 -2
  69. data/test/rails_app/app/controllers/components_controller.rb +1 -1
  70. data/test/rails_app/app/models/book_with_custom_primary_key.rb +4 -0
  71. data/test/rails_app/config/initializers/netzke.rb +6 -0
  72. data/test/rails_app/config/locales/es.yml +0 -10
  73. data/test/rails_app/db/migrate/20110701070052_create_book_with_custom_primary_keys.rb +15 -0
  74. data/test/rails_app/db/schema.rb +12 -2
  75. data/test/rails_app/db/seeds.rb +21 -1
  76. data/test/rails_app/features/form_panel.feature +17 -17
  77. data/test/rails_app/features/grid_panel.feature +20 -4
  78. data/test/rails_app/features/grid_panel_with_custom_primary_key.feature +15 -0
  79. data/test/rails_app/features/paging_form_panel.feature +14 -0
  80. data/test/rails_app/features/search_in_grid.feature +2 -1
  81. data/test/rails_app/features/simple_app.feature +5 -0
  82. data/test/rails_app/features/step_definitions/accordion_steps.rb +1 -5
  83. data/test/rails_app/features/step_definitions/ext_steps.rb +16 -0
  84. data/test/rails_app/features/step_definitions/form_panel_steps.rb +10 -12
  85. data/test/rails_app/features/step_definitions/generic_steps.rb +12 -4
  86. data/test/rails_app/features/step_definitions/grid_panel_steps.rb +47 -32
  87. data/test/rails_app/features/tab_panel.feature +2 -2
  88. data/test/rails_app/spec/factories.rb +4 -0
  89. metadata +26 -13
  90. data/README.rdoc +0 -67
  91. data/from_05_to_06.rdoc +0 -2
  92. data/javascripts/feedback_ghost.js +0 -34
  93. data/test/rails_app/public/netzke/basepack/ts-checkbox.gif +0 -0
data/CHANGELOG.rdoc CHANGED
@@ -1,12 +1,15 @@
1
- = v0.6.5 - 2011-08-16
2
- * changes
3
- * Replaced tri-state checkbox with combobox in the multi-edit form and search form
1
+ = 0.7.0 - 2011-08-09
2
+ * Core 0.7.0 and Ext 4 compatibility
3
+ * API changes
4
+ * [JS] Removed the helper BorderLayoutPanel#get<Region>Component method altogether. Use Ext 4 Container#child instead
5
+
6
+ = v0.6.5 - to be released
4
7
  * enhancements
5
8
  * When columns states are saved in the persistent storage, adding/removing columns (e.g. in the code) will reset the saved states
6
9
  * Moved features and specs to test/rails_app
7
10
  * bug fix
8
11
  * FormPanel with multiple association fields wouldn't submit data correctly
9
- * Fixed an old bug where tri-checkbox set to 'unchecked' had no effect in multi-edit
12
+ * GridPanel's forms take over the +text+ configuration option for columns as +fieldLabel+ for default fields
10
13
 
11
14
  = v0.6.4 - 2011-02-26
12
15
  * API changes
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # Netzke Basepack
2
+
3
+ A pack of pre-built [Netzke](http://netzke.org) components - such as grid, form, tab panel, etc.
4
+
5
+ ## Requirements
6
+
7
+ * Ruby 1.9.2 (1.8.7 may work, too)
8
+ * Rails >= 3.0.0
9
+ * Ext JS >= 4.0.0
10
+
11
+ ## Installation
12
+
13
+ In your Gemfile:
14
+
15
+ gem 'netzke-basepack'
16
+
17
+ For the "edge" stuff, tell bundler to get the gem straight from GitHub:
18
+
19
+ gem 'netzke-basepack', :git => "git://github.com/skozlov/netzke-basepack.git"
20
+
21
+ ## Usage
22
+
23
+ Embed a basepack component into a view as any other Netzke component, e.g.:
24
+
25
+ <%= netzke :books, :class_name => 'Netzke::Basepack::GridPanel', :model => 'Book' %>
26
+
27
+ For more examples, see http://demo.netzke.com, and look into test/rails_app.
28
+
29
+ ## Testing and playing with Netzke Basepack
30
+
31
+ Netzke Basepack is bundled with Cucumber and RSpec tests. If you would like to contribute to the project, you may want to learn how to [run the tests](https://github.com/skozlov/netzke-core/wiki/Automated-testing).
32
+
33
+ Besides, the bundled test application is a convenient [playground](https://github.com/skozlov/netzke-core/wiki/Playground) for those who search to experiment with the framework.
34
+
35
+ After setting up the test application, you can access the test components (from test/rails_app/app/components) like this:
36
+
37
+ http://localhost:3000/components/<name_of_the_test_component_class>
38
+
39
+ e.g.:
40
+
41
+ http://localhost:3000/components/UserGrid
42
+
43
+ ## Icons support
44
+ Netzke Basepack can make use of FamFamFam Silk icon set (http://www.famfamfam.com/archive/silk-icons-thats-your-lot/). To enable this, download the icons and put the "icons" folder into your app's public/images folder. Then restart your application.
45
+
46
+ ## Ext 3 support
47
+ Versions 0.6.x are for you if you're using Ext 3 (*hardly maintained*)
48
+
49
+ ## Rails 2 support
50
+ With Rails 2 (and Ext 3 only), use versions 0.5.x (*not maintained*)
51
+
52
+ ## More info
53
+ Official project site: http://netzke.org
54
+
55
+ Twitter:
56
+
57
+ * latest news about Netzke: http://twitter.com/netzke
58
+ * author's rambling about osx, productivity and what not: http://twitter.com/nomadcoder
59
+
60
+ Many (if a bit outdated) tutorials: http://blog.writelesscode.com
61
+
62
+ ---
63
+ Copyright (c) 2008-2011 NomadCoder, released under the MIT license
data/Rakefile CHANGED
@@ -9,10 +9,10 @@ begin
9
9
  gemspec.email = "sergei@playcode.nl"
10
10
  gemspec.homepage = "http://netzke.org"
11
11
  gemspec.authors = ["Sergei Kozlov"]
12
- gemspec.add_dependency("netzke-core", "~>0.6.7")
13
- gemspec.add_dependency("meta_where", ">=0.9.3")
14
- gemspec.add_dependency("will_paginate", "~>3.0.pre2")
15
- gemspec.add_dependency("acts_as_list")
12
+ gemspec.add_dependency("netzke-core", "~>0.7.0")
13
+ gemspec.add_dependency("meta_where", "~>1.0.0")
14
+ gemspec.add_dependency("will_paginate", "~>3.0.0")
15
+ gemspec.add_dependency("acts_as_list", "~>0.1.4")
16
16
  gemspec.post_install_message = <<-MESSAGE
17
17
 
18
18
  ========================================================================
@@ -5,164 +5,144 @@ Ext.ns("Ext.ux.grid");
5
5
  Ext.apply(Ext.History, new Ext.util.Observable());
6
6
 
7
7
  // A convenient passfield
8
- Ext.netzke.PassField = Ext.extend(Ext.form.TextField, {
9
- inputType: 'password'
10
- });
11
- Ext.reg('passfield', Ext.netzke.PassField);
12
-
13
- Ext.override(Ext.ux.form.DateTimeField, {
14
- format: "Y-m-d",
15
- timeFormat: "g:i:s",
16
- picker: {
17
- minIncremenet: 15
18
- }
19
- });
8
+ // Ext.netzke.PassField = Ext.extend(Ext.form.TextField, {
9
+ // inputType: 'password'
10
+ // });
11
+ // Ext.reg('passfield', Ext.netzke.PassField);
12
+
13
+ // Ext.override(Ext.ux.form.DateTimeField, {
14
+ // format: "Y-m-d",
15
+ // timeFormat: "g:i:s",
16
+ // picker: {
17
+ // minIncremenet: 15
18
+ // }
19
+ // });
20
20
 
21
21
  // ComboBox that gets options from the server (used in both grids and panels)
22
- Ext.netzke.ComboBox = Ext.extend(Ext.form.ComboBox, {
22
+ Ext.define('Ext.netzke.ComboBox', {
23
+ extend : 'Ext.form.field.ComboBox',
24
+ alias : 'widget.netzkeremotecombo',
23
25
  valueField : 'field1',
24
26
  displayField : 'field2',
25
27
  triggerAction : 'all',
26
- typeAhead : true,
28
+ // WIP: Breaking - should not be 'true' if combobox is not editable
29
+ // typeAhead : true,
27
30
 
28
31
  initComponent : function(){
29
- var row = Ext.data.Record.create(['field1', 'field2']); // defaults for local ComboBox; makes testing easier
32
+ var modelName = this.parentId + "_" + this.name;
33
+
34
+ Ext.define(modelName, {
35
+ extend: 'Ext.data.Model',
36
+ fields: ['field1', 'field2']
37
+ });
38
+
30
39
  var store = new Ext.data.Store({
31
- proxy : new Ext.data.DirectProxy({directFn: Netzke.providers[this.parentId].getComboboxOptions}),
32
- reader : new Ext.data.ArrayReader({root:'data', id:0}, row)
40
+ model: modelName,
41
+ proxy: {
42
+ type: 'direct',
43
+ directFn: Netzke.providers[this.parentId].getComboboxOptions,
44
+ reader: {
45
+ type: 'array',
46
+ root: 'data'
47
+ }
48
+ }
33
49
  });
34
- store.proxy.on('beforeload', function (self, params) {
35
- params.column = this.name;
50
+
51
+ // TODO: find a cleaner way to pass this.name to the server
52
+ store.on('beforeload', function(self, params) {
53
+ params.params.column = this.name;
36
54
  },this);
37
55
 
56
+ // If inline data was passed (TODO: is this actually working?)
38
57
  if (this.store) store.loadData({data: this.store});
39
58
 
40
59
  this.store = store;
41
60
 
42
- Ext.netzke.ComboBox.superclass.initComponent.apply(this, arguments);
43
-
44
- var parent = Ext.getCmp(this.parentId);
45
- // Is parent a grid?
46
- if (parent.getSelectionModel) {
47
- this.on('beforequery',function(qe) {
48
- delete qe.combo.lastQuery;
49
- },this);
50
- }
51
-
52
- // A not-so-clean approach to submit the current record id
53
- store.on('beforeload',function(store, options){
54
- if (parent.getSelectionModel) {
55
- var selected = parent.getSelectionModel().getSelected();
56
- if (selected) options.params.id = selected.id;
57
- } else {
58
- // TODO: also for the FormPanel
59
- }
60
- }, this);
61
+ this.callParent();
62
+ },
63
+
64
+ collapse: function(){
65
+ // HACK: do not hide dropdown menu while loading items
66
+ if( !this.store.loading ) this.callParent();
61
67
  }
62
68
  });
63
69
 
64
- Ext.reg('netzkeremotecombo', Ext.netzke.ComboBox);
65
-
66
70
  Ext.util.Format.mask = function(v){
67
71
  return "********";
68
72
  };
69
73
 
70
- Ext.netzke.JsonField = Ext.extend(Ext.form.TextField, {
71
- validator: function(value) {
72
- try{
73
- var d = Ext.decode(value);
74
- return true;
75
- } catch(e) {
76
- return "Invalid JSON"
77
- }
78
- }
74
+ // Ext.netzke.JsonField = Ext.extend(Ext.form.TextField, {
75
+ // validator: function(value) {
76
+ // try{
77
+ // var d = Ext.decode(value);
78
+ // return true;
79
+ // } catch(e) {
80
+ // return "Invalid JSON"
81
+ // }
82
+ // }
83
+ //
84
+ // ,setValue: function(value) {
85
+ // this.setRawValue(Ext.encode(value));
86
+ // }
87
+ //
88
+ // });
89
+ //
90
+ // Ext.reg('jsonfield', Ext.netzke.JsonField);
91
+ //
92
+ // WIP: todo - rewrite Ext.lib calls below
93
+ // Ext.grid.HeaderDropZone.prototype.onNodeDrop = function(n, dd, e, data){
94
+ // var h = data.header;
95
+ // if(h != n){
96
+ // var cm = this.grid.colModel;
97
+ // var x = Ext.lib.Event.getPageX(e);
98
+ // var r = Ext.lib.Dom.getRegion(n.firstChild);
99
+ // var pt = (r.right - x) <= ((r.right-r.left)/2) ? "after" : "before";
100
+ // var oldIndex = this.view.getCellIndex(h);
101
+ // var newIndex = this.view.getCellIndex(n);
102
+ // if(pt == "after"){
103
+ // newIndex++;
104
+ // }
105
+ // if(oldIndex < newIndex){
106
+ // newIndex--;
107
+ // }
108
+ // cm.moveColumn(oldIndex, newIndex);
109
+ // return true;
110
+ // }
111
+ // return false;
112
+ // };
113
+ //
114
+ //
115
+ // Ext.ns('Ext.ux.form');
116
+
117
+ Ext.define('Ext.ux.form.TriCheckbox', {
118
+ extend: 'Ext.form.field.ComboBox',
119
+ alias: 'widget.tricheckbox',
120
+ store: [[true, "Yes"], [false, "No"]],
121
+ forceSelection: true
122
+ });
79
123
 
80
- ,setValue: function(value) {
81
- this.setRawValue(Ext.encode(value));
124
+ // Enabling checkbox submission when unchecked
125
+ // TODO: it would be nice to standardize return values
126
+ // because currently checkboxes return "on", if checked,
127
+ // and boolean 'false' otherwise. It's not nice
128
+ // MAV
129
+ // TODO: maybe we should simply initialize 'uncheckedValue' somewhere else,
130
+ // instead
131
+ Ext.override( Ext.form.field.Checkbox, {
132
+ getSubmitValue: function() {
133
+ return this.callOverridden() || false; // 'off';
82
134
  }
83
-
84
135
  });
85
136
 
86
- Ext.reg('jsonfield', Ext.netzke.JsonField);
87
-
88
- Ext.grid.HeaderDropZone.prototype.onNodeDrop = function(n, dd, e, data){
89
- var h = data.header;
90
- if(h != n){
91
- var cm = this.grid.colModel;
92
- var x = Ext.lib.Event.getPageX(e);
93
- var r = Ext.lib.Dom.getRegion(n.firstChild);
94
- var pt = (r.right - x) <= ((r.right-r.left)/2) ? "after" : "before";
95
- var oldIndex = this.view.getCellIndex(h);
96
- var newIndex = this.view.getCellIndex(n);
97
- if(pt == "after"){
98
- newIndex++;
99
- }
100
- if(oldIndex < newIndex){
101
- newIndex--;
102
- }
103
- cm.moveColumn(oldIndex, newIndex);
104
- return true;
105
- }
106
- return false;
107
- };
108
-
137
+ /* We were missing the 'load' event on proxy, implementing it ourselves */
138
+ Ext.override(Ext.data.proxy.Server, {
139
+ constructor: function() {
140
+ this.addEvents('load');
141
+ this.callOverridden([arguments]);
142
+ },
109
143
 
110
- Ext.ns('Ext.ux.form');
111
- Ext.ux.form.TriCheckbox = Ext.extend(Ext.form.ComboBox, {
112
- store: [[true, "true"], [false, "false"]],
113
- forceSelection: true,
114
- triggerAction: 'all'
144
+ processResponse: function(success, operation, request, response, callback, scope){
145
+ this.callOverridden(arguments);
146
+ this.fireEvent('load', this, response, operation);
147
+ }
115
148
  });
116
- Ext.reg('tricheckbox', Ext.ux.form.TriCheckbox);
117
-
118
-
119
- // Enabling checkbox submission when unchecked
120
- (function() {
121
- origCheckboxRender = Ext.form.Checkbox.prototype.onRender;
122
- origCheckboxSetValue = Ext.form.Checkbox.prototype.setValue;
123
-
124
- Ext.override(Ext.form.Checkbox, {
125
- onRender: function() {
126
- // call the original onRender() function
127
- origCheckboxRender.apply(this, arguments);
128
-
129
- if (this.getXType() === 'radio') return;
130
-
131
- // Handle initial case based on this.checked
132
- if (this.checked == false) {
133
- this.noValEl = Ext.DomHelper.insertAfter(this.el, {
134
- tag: 'input',
135
- type: 'hidden',
136
- value: false,
137
- name: this.getName()
138
- }, true);
139
- }
140
- else {
141
- this.noValEl = null;
142
- }
143
- },
144
- setValue: function() {
145
- // call original setValue() function
146
- origCheckboxSetValue.apply(this, arguments);
147
-
148
- if (this.getXType() === 'radio') return;
149
-
150
- if (this.checked) {
151
- if (this.noValEl != null) {
152
- // Remove the extra hidden element
153
- this.noValEl.remove();
154
- this.noValEl = null;
155
- }
156
- }
157
- else {
158
- // Add our hidden element for (unchecked) value
159
- if (this.noValEl == null) this.noValEl = Ext.DomHelper.insertAfter(this.el, {
160
- tag: 'input',
161
- type: 'hidden',
162
- value: false,
163
- name: this.getName()
164
- }, true);
165
- }
166
- }
167
- });
168
- })();
@@ -10,10 +10,17 @@ require 'netzke/basepack'
10
10
  module Netzke
11
11
  module Basepack
12
12
  class Engine < Rails::Engine
13
+
14
+ I18n.load_path << File.dirname(__FILE__) + '/../locales/en.yml'
15
+ I18n.load_path << File.dirname(__FILE__) + '/../locales/de.yml'
16
+
17
+ config.after_initialize do
18
+ Netzke::Core.external_ext_css << "#{Netzke::Core.ext_uri}/examples/ux/grid/css/RangeMenu"
19
+ Netzke::Core.external_ext_css << "#{Netzke::Core.ext_uri}/examples/ux/grid/css/GridFilters"
20
+ Netzke::Core.external_ext_css << "#{Netzke::Core.ext_uri}/examples/ux/css/CheckHeader"
21
+ end
13
22
  end
14
23
  end
15
24
  end
16
25
 
17
- I18n.load_path << File.dirname(__FILE__) + '/../locales/en.yml'
18
-
19
26
  Netzke::Basepack.init
@@ -1,5 +1,12 @@
1
1
  require 'netzke/basepack/version'
2
- require 'netzke/active_record'
2
+
3
+ if defined? ActiveRecord
4
+ require 'netzke/active_record'
5
+ require 'meta_where'
6
+ end
7
+
8
+ # will_paginate supports more than just ActiveRecord
9
+ require 'will_paginate'
3
10
 
4
11
  module Netzke
5
12
  module Basepack
@@ -11,15 +18,11 @@ module Netzke
11
18
 
12
19
  # Called from netzke-basepack.rb
13
20
  def init
14
- Netzke::Core.ext_javascripts << "#{File.dirname(__FILE__)}/../../javascripts/feedback_ghost.js"
15
- Netzke::Core.ext_javascripts << "#{File.dirname(__FILE__)}/../../javascripts/datetimefield.js"
21
+ # Netzke::Core.ext_javascripts << "#{File.dirname(__FILE__)}/../../javascripts/datetimefield.js"
16
22
  Netzke::Core.ext_javascripts << "#{File.dirname(__FILE__)}/../../javascripts/basepack.js"
17
23
 
18
24
  Netzke::Core.ext_stylesheets << "#{File.dirname(__FILE__)}/../../stylesheets/datetimefield.css"
19
25
  Netzke::Core.ext_stylesheets << "#{File.dirname(__FILE__)}/../../stylesheets/basepack.css"
20
-
21
- Netzke::Core.external_ext_css << "/extjs/examples/ux/gridfilters/css/RangeMenu"
22
- Netzke::Core.external_ext_css << "/extjs/examples/ux/gridfilters/css/GridFilters"
23
26
  end
24
27
 
25
28
  # Use it to confirure Basepack in the initializers, e.g.:
@@ -27,7 +27,7 @@ module Netzke
27
27
  item.on('expand', function(i){
28
28
  if (i && i.wrappedComponent && !i.items.first() && !i.beingLoaded) {
29
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});
30
+ this.loadNetzkeComponent({name: i.wrappedComponent, container: i.id}, function(){i.beingLoaded = false});
31
31
  }
32
32
  }, this);
33
33
  }, this);
@@ -4,21 +4,28 @@ module Netzke
4
4
  # ** NOTE: it's WIP **
5
5
  class AuthApp < SimpleApp
6
6
 
7
- class_attribute :login_url
8
- self.login_url = "/login"
7
+ def default_config
8
+ super.tap do |c|
9
+ c[:login_url] = "/login"
10
+ c[:logout_url] = "/logout"
11
+ end
12
+ end
9
13
 
10
- class_attribute :logout_url
11
- self.logout_url = "/logout"
14
+ # class_config_option :login_url, "/login"
15
+ # # self.login_url = "/login"
16
+ #
17
+ # class_attribute :logout_url
18
+ # self.logout_url = "/logout"
12
19
 
13
20
  js_method :on_login, <<-JS
14
21
  function(){
15
- window.location = "#{login_url}"
22
+ window.location = this.loginUrl;
16
23
  }
17
24
  JS
18
25
 
19
26
  js_method :on_logout, <<-JS
20
27
  function(){
21
- window.location = "#{logout_url}"
28
+ window.location = this.logoutUrl;
22
29
  }
23
30
  JS
24
31
 
@@ -27,7 +34,7 @@ module Netzke
27
34
  this.toggleConfigMode();
28
35
  }
29
36
  JS
30
-
37
+ # WIP: todo - rewrite Ext.lib calls below
31
38
  js_method :show_masquerade_selector, <<-JS
32
39
  function(){
33
40
  var w = new Ext.Window({
@@ -82,27 +89,27 @@ module Netzke
82
89
  });
83
90
 
84
91
  w.show(null, function(){
85
- this.loadComponent({id:"masqueradeSelector", container:w.id})
92
+ this.loadNetzkeComponent({id:"masqueradeSelector", container:w.id})
86
93
  }, this);
87
94
 
88
95
  }
89
96
  JS
90
97
 
91
- # Set the Logout button if Netzke::Base.user is set
98
+ # Set the Logout button if Netzke::Core.current_user is set
92
99
  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
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
104
112
  end
105
- res
106
113
  end
107
114
 
108
115
  def user_menu