netzke-basepack 0.12.9 → 1.0.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/CHANGELOG.md +75 -44
  2. data/Gemfile +4 -2
  3. data/LICENSE +2 -6
  4. data/README.md +22 -24
  5. data/javascripts/basepack.js +0 -8
  6. data/javascripts/{columns.js → grid/columns.js} +59 -71
  7. data/javascripts/grid/event_handlers.js +218 -0
  8. data/javascripts/netzkeremotecombo.js +5 -13
  9. data/javascripts/tristate.js +62 -0
  10. data/javascripts/xdatetime.js +8 -37
  11. data/lib/netzke-basepack.rb +3 -2
  12. data/lib/netzke/basepack.rb +1 -1
  13. data/lib/netzke/basepack/action_column.rb +6 -23
  14. data/lib/netzke/basepack/active_record.rb +0 -6
  15. data/lib/netzke/basepack/attr_config.rb +20 -11
  16. data/lib/netzke/basepack/attribute_config.rb +10 -0
  17. data/lib/netzke/basepack/attributes.rb +196 -0
  18. data/lib/netzke/basepack/column_config.rb +47 -39
  19. data/lib/netzke/basepack/columns.rb +127 -97
  20. data/lib/netzke/basepack/data_accessor.rb +7 -48
  21. data/lib/netzke/basepack/data_adapters/abstract_adapter.rb +15 -17
  22. data/lib/netzke/basepack/data_adapters/active_record_adapter.rb +111 -90
  23. data/lib/netzke/basepack/dynamic_tab_panel.rb +3 -5
  24. data/lib/netzke/basepack/dynamic_tab_panel/{javascripts → client}/dynamic_tab_panel.js +6 -5
  25. data/lib/netzke/basepack/field_config.rb +30 -19
  26. data/lib/netzke/basepack/fields.rb +22 -12
  27. data/lib/netzke/basepack/grid_live_search.rb +1 -4
  28. data/lib/netzke/basepack/grid_live_search/{javascripts → client}/grid_live_search.js +9 -7
  29. data/lib/netzke/basepack/item_persistence.rb +3 -3
  30. data/lib/netzke/basepack/item_persistence/events_plugin.rb +8 -10
  31. data/lib/netzke/basepack/paging_form.rb +7 -11
  32. data/lib/netzke/basepack/paging_form/{javascripts → client}/paging_form.js +4 -4
  33. data/lib/netzke/basepack/query_builder.rb +12 -10
  34. data/lib/netzke/basepack/query_builder/{javascripts → client}/query_builder.js +14 -12
  35. data/lib/netzke/basepack/record_form_window.rb +8 -8
  36. data/lib/netzke/basepack/search_panel.rb +4 -6
  37. data/lib/netzke/basepack/search_panel/{javascripts → client}/condition_field.js +13 -16
  38. data/lib/netzke/basepack/search_panel/{javascripts → client}/search_panel.js +7 -7
  39. data/lib/netzke/basepack/search_window.rb +6 -6
  40. data/lib/netzke/basepack/simple_app/{javascripts → client}/statusbar_ext.js +0 -0
  41. data/lib/netzke/basepack/version.rb +1 -1
  42. data/lib/netzke/form/base.rb +166 -0
  43. data/lib/netzke/{basepack/form/javascripts/form.js → form/base/client/base.js} +77 -38
  44. data/lib/netzke/form/base/client/readonly_mode.css +4 -0
  45. data/lib/netzke/{basepack/form/javascripts → form/base/client}/readonly_mode.js +5 -5
  46. data/lib/netzke/form/endpoints.rb +33 -0
  47. data/lib/netzke/form/services.rb +74 -0
  48. data/lib/netzke/grid/actions.rb +52 -0
  49. data/lib/netzke/grid/base.rb +289 -0
  50. data/lib/netzke/{basepack/grid/javascripts → grid/base/client}/advanced_search.js +5 -1
  51. data/lib/netzke/{basepack/grid/javascripts/grid.js → grid/base/client/base.js} +61 -53
  52. data/lib/netzke/{basepack/grid/javascripts → grid/base/client}/extensions.js +19 -13
  53. data/lib/netzke/{basepack/grid/javascripts → grid/base/client}/remember_selection.js +0 -1
  54. data/lib/netzke/grid/client.rb +8 -0
  55. data/lib/netzke/grid/components.rb +55 -0
  56. data/lib/netzke/grid/configuration.rb +72 -0
  57. data/lib/netzke/grid/endpoints.rb +99 -0
  58. data/lib/netzke/grid/permissions.rb +18 -0
  59. data/lib/netzke/grid/services.rb +141 -0
  60. data/lib/netzke/tree/base.rb +173 -0
  61. data/lib/netzke/{basepack/tree/javascripts/tree.js → tree/base/client/base.js} +55 -26
  62. data/lib/netzke/{basepack/tree/javascripts → tree/base/client}/extensions.js +7 -7
  63. data/lib/netzke/tree/endpoints.rb +34 -0
  64. data/lib/netzke/{basepack/viewport.rb → viewport/base.rb} +3 -3
  65. data/lib/netzke/{basepack/window.rb → window/base.rb} +7 -8
  66. data/lib/netzke/window/base/client/base.js +26 -0
  67. data/locales/de.yml +49 -33
  68. data/locales/en.yml +32 -39
  69. data/locales/es.yml +39 -25
  70. data/locales/nl.yml +39 -25
  71. data/locales/ru.yml +38 -25
  72. data/locales/uk.yml +40 -26
  73. data/stylesheets/basepack.css +10 -0
  74. metadata +48 -45
  75. data/javascripts/mixins/grid_event_handlers.js +0 -139
  76. data/lib/netzke/basepack/accordion.rb +0 -45
  77. data/lib/netzke/basepack/active_record/relation_extensions.rb +0 -27
  78. data/lib/netzke/basepack/form.rb +0 -131
  79. data/lib/netzke/basepack/form/endpoints.rb +0 -35
  80. data/lib/netzke/basepack/form/services.rb +0 -74
  81. data/lib/netzke/basepack/form/stylesheets/readonly_mode.css +0 -14
  82. data/lib/netzke/basepack/grid.rb +0 -570
  83. data/lib/netzke/basepack/grid/endpoints.rb +0 -111
  84. data/lib/netzke/basepack/grid/javascripts/edit_in_form.js +0 -51
  85. data/lib/netzke/basepack/grid/services.rb +0 -148
  86. data/lib/netzke/basepack/tab_panel.rb +0 -22
  87. data/lib/netzke/basepack/tab_panel/javascripts/tab_panel.js +0 -11
  88. data/lib/netzke/basepack/tree.rb +0 -269
  89. data/lib/netzke/basepack/window/javascripts/window.js +0 -26
  90. data/lib/netzke/basepack/wrap_lazy_loaded.rb +0 -29
data/CHANGELOG.md CHANGED
@@ -1,44 +1,75 @@
1
- # 0.12.9 - 2015-12-06
2
- * Grid: warn the user at an attempt to change the page when there are unapplied changes;
3
- disable the warning by setting `disable_dirty_page_warning` to `true`.
4
- * Implement `scope` option for `Tree`
5
-
6
- # 0.12.8 - 2015-09-11
7
- * Fix regression in Tree that would (again) prevent snake_cased columns from being displayed
8
-
9
- # 0.12.7 - 2015-08-09
10
- * Fix the strong_default_attrs option support
11
- * Support column action's isDisabled option
12
- * Store tree nodes expand/collapse state
13
-
14
- # 0.12.6 - 2015-07-11
15
- * Regression: show cell editor on adding/editing a record in grid
16
- * Fix occasional autoload-related problems
17
-
18
- # 0.12.5 - 2015-07-07
19
- * Fix potential problems caused by changing window.id on deleting grid records
20
-
21
- # 0.12.4 - 2015-06-22
22
- * Remove (broken) `load_inline_data` option
23
-
24
- # 0.12.3 - 2015-06-16
25
- * Fix bug preventing primary key column from being overridden in a specific case
26
- * Fix grid freeze when `prohibit_read` is set to true
27
-
28
- # 0.12.2 - 2015-06-06
29
- * Fix exception when nesting a grid with action column
30
- * Fix Tree for Ruby 1.9.3
31
-
32
- # 0.12.1 - 2015-05-31
33
- * New component: Tree
34
- * Fix filtering by association when associtaion method is integer
35
- * Fix decimal and float columns in extended search form
36
- * Fix showing 0-value in association shown by integer
37
- * Fix extended panel browser exceptions
38
- * Fix showing null values as 0 in int columns
39
-
40
- # 0.12.0 - 2015-03-18
41
- * ExtJS 5
42
- * New component: DynamicTabPanel
43
-
44
- Please check [0-11](https://github.com/netzke/netzke-basepack/blob/0-11/CHANGELOG.md) for previous changes.
1
+ ### Components changed/renamed
2
+
3
+ * Base classes of main componens have been renamed from `Netzke::Basepack::{Grid|Form|Tree|Window|Viewport}` to `Netzke::{Grid|Form|Tree|Window|Viewport}::Base`.
4
+
5
+ * `Netzke::Basepack::TapPanel` and `Netzke::Basepack::Accordion` have been removed. The only purpose for them was dynamic loading of child components, which didn't prove that useful.
6
+
7
+ ### Form, Grid, Tree
8
+
9
+ #### Breaking changes
10
+
11
+ * `strong_default_attrs` config option has been renamed to `strong_values`.
12
+
13
+ * `attr_type` config option for columns/fields has been renamed to `type`.
14
+
15
+ * The new `attribute` DSL method and the accompanying `attribute_overrides` config option allow reconfiguring the way specific model attributes are presented by both the grid and the form. The `column` DSL method has been left for configuring what's specific for a column. For details, see [Netzke::Basepack::Attributes](http://www.rubydoc.info/github/netzke/netzke-basepack/Netzke/Basepack/Attributes).
16
+
17
+ ### Form
18
+
19
+ #### Breaking changes
20
+
21
+ * The `netzkeSubmit` and `netzkeLoad` endpoints have been renamed to `submit` and `load` respectively; keep this in mind if you override them in your app.
22
+
23
+ ### Grid
24
+
25
+ #### Breaking changes
26
+
27
+ * Column/field label for association no longer includes association method name by default. For example, for
28
+ `author__name` attribute it'll now be "Author", not "Author name".
29
+
30
+ * `preconfigure_record_window` has been renamed to `configure_form_window`
31
+
32
+ * The `default_fields_for_forms` method has been renamed to `default_form_items`.
33
+
34
+ * The `data_store` config option has been renamed to `store_config`.
35
+
36
+ * Permissions configuration got consolidated into single `permissions` config option. See [Netzke::Grid::Base](http://www.rubydoc.info/github/netzke/netzke-basepack/Netzke/Grid/Base)
37
+
38
+ * The `del` action has been renamed to `delete`.
39
+
40
+ * Columns configuration (by using the `Grid.column` DSL method, or the `columns` configuration option) no longer has effect on corresponding form fields. Use the new `attribute` DSL method or the `attribute_overrides` config option (see above) to set the common configuration option for both column and form field.
41
+
42
+ * Virtual columns declared with the `column` DSL method are no longer automatically appended to the end of the column
43
+ list; use the `columns` config option or override the `Grid#columns` method to explicitely list them.
44
+
45
+ * The endpoints dropped their prefix `server`; additionally, `serverDelete` has become `destroy`; keep this in mind if you override endpoints in your app.
46
+
47
+ * All scope-related configs (including those of the columns) now only accept a Proc object.
48
+
49
+ * Class-level configuration is gone (its sole purpose was to allow reducing the amount of generated JS code - not worth it).
50
+
51
+ * `enable_edit_in_form`, `enable_edit_inline`, `enable_pagination` options are gone.
52
+
53
+ * `enable_extended_search` option is gone.
54
+
55
+ #### Non-breaking changes
56
+
57
+ * By default, Grid now uses form to add/edit records. Set `edit_inline` to true to use inline editing when possible (implicitly sets `paging` to `true`).
58
+
59
+ * By default, Grid now handles large number of records by using a buffered store (allows for "infinite scrolling"). Set `paging` to `true` if you want pagination instead.
60
+
61
+ * The toolbar was reduced to 'add', 'edit', 'delete', and 'search' buttons by default. Additionally, the 'apply' button is added when `edit_inline` is set to `true`.
62
+
63
+ * Buttons previously disabled due to permissions are now not added to the bottom bar alltogether.
64
+
65
+ #### Added
66
+
67
+ * Override new `configure_form` method to specify extra configuration to the forms
68
+
69
+ * Warn the user at an attempt to change the page when there are unapplied changes; disable the warning by setting `disable_dirty_page_warning` to `true`.
70
+
71
+ #### Bugfixes
72
+
73
+ * Multiediting of reconds now works properly with boolean fields (a tristate selector was implemented).
74
+
75
+ Please check [0-12](https://github.com/netzke/netzke-basepack/blob/0-12/CHANGELOG.md) for previous changes.
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ gem 'yard'
8
8
  gem 'rake'
9
9
 
10
10
  gem 'awesome_nested_set'
11
+ gem 'carrierwave'
11
12
 
12
13
  group :test do
13
14
  gem 'rspec'
@@ -22,6 +23,7 @@ group :development, :test do
22
23
  gem 'web-console', '~> 2.0'
23
24
  # gem 'spring' # troubles...
24
25
  gem 'pry-rails'
25
- gem 'netzke-core', github: 'netzke/netzke-core', branch: '0-12'
26
- gem 'netzke-testing', github: 'netzke/netzke-testing', branch: '0-12'
26
+ gem 'netzke-core', github: 'netzke/netzke-core', branch: 'master'
27
+ gem 'netzke-testing', github: 'netzke/netzke-testing', branch: 'master'
28
+ gem 'faker'
27
29
  end
data/LICENSE CHANGED
@@ -1,7 +1,3 @@
1
- Copyright (c) 2013 Max Gorin
1
+ Copyright (c) 2009-2015 Good Bit Labs Limited
2
2
 
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3
+ GPLv3 License: http://www.gnu.org/licenses/gpl-3.0.en.html
data/README.md CHANGED
@@ -1,37 +1,37 @@
1
- # Netzke Basepack [![Build Status](https://travis-ci.org/netzke/netzke-basepack.png?branch=master)](https://travis-ci.org/netzke/netzke-basepack) [![Code Climate](https://codeclimate.com/github/netzke/netzke-basepack.png)](https://codeclimate.com/github/netzke/netzke-basepack)
1
+ # Netzke Basepack [![Build Status](https://travis-ci.org/netzke/netzke-basepack.svg?branch=master)](https://travis-ci.org/netzke/netzke-basepack) [![Code Climate](https://codeclimate.com/github/netzke/netzke-basepack/badges/gpa.svg)](https://codeclimate.com/github/netzke/netzke-basepack)
2
2
 
3
3
  [RDocs](http://rdoc.info/github/netzke/netzke-basepack)
4
4
 
5
5
  A pack of pre-built [Netzke](http://netzke.org) components that can be used as building blocks for your webapps.
6
6
 
7
7
  *Notes on versioning:*
8
- * [![Gem Version](https://badge.fury.io/rb/netzke-basepack.png)](http://badge.fury.io/rb/netzke-basepack) is the latest *released* version
9
- * for the version under development (master), check [version.rb](https://github.com/netzke/netzke-core/blob/master/lib/netzke/core/version.rb)
10
- * for other versions, check corresponding [branches](https://github.com/netzke/netzke-core/branches)
8
+
9
+ * The latest *released* version is: [![Gem Version](https://badge.fury.io/rb/netzke-basepack.svg)](https://badge.fury.io/rb/netzke-basepack)
10
+ * The version under development (master): [version.rb](https://github.com/netzke/netzke-core/blob/master/lib/netzke/core/version.rb)
11
+ * For other versions check corresponding [branches](https://github.com/netzke/netzke-core/branches)
11
12
 
12
13
  ## Included components
13
14
 
14
15
  Basepack includes the following components:
15
16
 
16
- * [Grid](http://rdoc.info/github/netzke/netzke-basepack/Netzke/Basepack/Grid) - a grid panel with a thick bag of features
17
- * [Tree](http://rdoc.info/github/netzke/netzke-basepack/Netzke/Basepack/Tree) - a tree panel with features similar to the Grid
18
- * [Form](http://rdoc.info/github/netzke/netzke-basepack/Netzke/Basepack/Form) - a form panel with automatic binding of fields
19
- * [TabPanel](http://rdoc.info/github/netzke/netzke-basepack/Netzke/Basepack/TabPanel) - a tab panel with support for lazy loading of nested components
20
- * [Accordion](http://rdoc.info/github/netzke/netzke-basepack/Netzke/Basepack/Accordion) - an accordion panel with support for lazy loading of nested components
21
- * [Window](http://rdoc.info/github/netzke/netzke-basepack/Netzke/Basepack/Window) - a window which stores its size, position, and maximized state
17
+ * [Grid](http://rdoc.info/github/netzke/netzke-basepack/Netzke/Grid/Base) - a grid panel with a thick bag of features
18
+ * [Tree](http://rdoc.info/github/netzke/netzke-basepack/Netzke/Tree/Base) - a tree panel with features similar to the Grid
19
+ * [Form](http://rdoc.info/github/netzke/netzke-basepack/Netzke/Form/Base) - a form panel with automatic binding of fields
20
+ * [Window](http://rdoc.info/github/netzke/netzke-basepack/Netzke/Window/Base) - a window which stores its size, position, and maximized state
21
+ * [Viewport](http://rdoc.info/github/netzke/netzke-basepack/Netzke/Viewport/Base) - a full-window component usually used as one-page application base
22
22
 
23
23
  Besides, Basepack implements:
24
24
 
25
25
  * persistence of region sizes and collapsed states of an arbitrary component that uses
26
- [border layout](http://docs.sencha.com/ext-js/4-1/#!/api/Ext.layout.container.Border) (see [ItemPersistence](http://rdoc.info/github/netzke/netzke-basepack/Netzke/Basepack/ItemPersistence))
26
+ Ext's border layout (see [ItemPersistence](http://rdoc.info/github/netzke/netzke-basepack/Netzke/Basepack/ItemPersistence))
27
27
  * [GridLiveSearch](http://rdoc.info/github/netzke/netzke-basepack/Netzke/Basepack/GridLiveSearch) - a plugin that allows
28
28
  enhancing any grid with live search functionality
29
29
 
30
30
  ## Requirements
31
31
 
32
- * Ruby > 1.9.3
32
+ * Ruby >= 1.9.3
33
33
  * Rails ~> 4.2.0
34
- * Ext JS = 5.1.0
34
+ * Ext JS = 5.1.1
35
35
 
36
36
  ## Installation
37
37
 
@@ -48,11 +48,12 @@ For the "edge" stuff, instruct bundler to get the gem straight from GitHub:
48
48
  Embed a basepack component into a view as any other Netzke component, e.g.:
49
49
 
50
50
  ```erb
51
- <%= netzke :books, class_name: 'Netzke::Basepack::Grid', model: 'Book' %>
51
+ <%= netzke :books, class_name: 'Netzke::Grid::Base', model: 'Book' %>
52
52
  ```
53
53
 
54
- For more examples, see http://netzke-demo.herokuapp.com ([source code](https://github.com/netzke/netzke-demo)), and look
55
- into `spec/rails_app`.
54
+ This will give you a grid with all the many features, configured to use your `Book` model.
55
+
56
+ For detailed examples with code see http://demo.netzke.org
56
57
 
57
58
  ## Running tests
58
59
 
@@ -66,13 +67,13 @@ good source of concise, focused examples. After starting the application, access
66
67
 
67
68
  http://localhost:3000/netzke/components/{name of the component's class}
68
69
 
69
- For example [http://localhost:3000/netzke/components/BookGrid](http://localhost:3000/netzke/components/BookGrid)
70
+ For example [http://localhost:3000/netzke/components/Grid::Books](http://localhost:3000/netzke/components/Grid::Books)
70
71
 
71
72
  To run all the tests (from the gem's root):
72
73
 
73
74
  $ rake
74
75
 
75
- *Sourcing Ext JS files from Sencha CDN is broken in Basepack at the moment*.
76
+ *Sourcing Ext JS files from Sencha CDN is not possible with Basepack at the moment*.
76
77
 
77
78
  ## Using ORM other than ActiveRecord
78
79
 
@@ -94,15 +95,12 @@ application.
94
95
 
95
96
  Help developing Netzke by submitting a pull request when you think others can benefit from it.
96
97
 
97
- If you feel particularily generous, you can donate a couple of bucks weekly at [Gratipay](https://www.gittip.com/mxgrn/).
98
+ If you feel particularily generous, you can donate a couple of bucks weekly at [Gratipay](https://gratipay.com/~mxgrn/).
98
99
 
99
100
  ## Useful links
100
101
  * [Project website](http://netzke.org)
101
- * [Live-demo](http://netzke-demo.herokuapp.com)
102
+ * [Live demo](http://demo.netzke.org)
102
103
  * [Twitter](http://twitter.com/netzke) - latest news about the framework
103
104
 
104
105
  ---
105
- Copyright (c) 2008-2015 [Max Gorin](https://twitter.com/mxgrn), released under the MIT license (see LICENSE).
106
-
107
- **Note** that Ext JS is licensed [differently](http://www.sencha.com/products/extjs/license/), and you may need to
108
- purchase a commercial license in order to use it in your projects.
106
+ Copyright (c) 2009-2015 [Good Bit Labs](http://goodbitlabs.com/), released under the GPLv3 license
@@ -26,14 +26,6 @@ Ext.override(Ext.view.BoundList, {
26
26
  },
27
27
  });
28
28
 
29
- Netzke.isModelDefined = function(name) {
30
- return !!(Netzke.models || {})[name];
31
- };
32
-
33
- Netzke.modelName = function(name){
34
- return "Netzke.models." + name;
35
- };
36
-
37
29
  // Fix 2-digit precision in the numeric filter
38
30
  Ext.define('Ext.grid.filters.filter.Number', {
39
31
  override: 'Ext.grid.filters.filter.Number',
@@ -1,84 +1,73 @@
1
1
  /* Shared column-related functionality, used in Tree and Grid */
2
- Ext.define("Netzke.mixins.Basepack.Columns", {
3
- netzkeBuildModel: function(modelClass) {
4
- if (!Netzke.isModelDefined(this.id)) {
5
- Ext.define(Netzke.modelName(this.id), {
6
- extend: modelClass,
7
- idProperty: this.pri, // Primary key
8
- fields: this.fields
9
- });
10
- }
11
- delete this.pri;
12
- },
13
-
2
+ Ext.define("Netzke.Grid.Columns", {
14
3
  netzkeProcessColumns: function() {
15
4
  this.fields = [];
16
5
 
17
6
  // Run through columns and set up different configuration for each
18
- Ext.each(this.columns.items, function(c, i){
19
-
7
+ Ext.each(this.columns.items, function(c){
20
8
  this.netzkeNormalizeRenderer(c);
9
+ this.fields.push(this.netzkeExtractFieldConfig(c));
21
10
 
22
- // Build the field configuration for this column
23
- var fieldConfig = {name: c.name, defaultValue: c.defaultValue, allowNull: true};
11
+ // We will not use meta columns as actual columns (not even hidden) - only to create the records
12
+ if (!c.meta) {
13
+ this.netzkeExtendColumnConfig(c);
14
+ }
15
+ }, this);
24
16
 
25
- if (c.name !== 'meta') fieldConfig.type = this.netzkeFieldTypeForAttrType(c.attrType); // field type (grid editors need this to function well)
17
+ // Now reorder columns as specified in this.columnsOrder
18
+ this.orderColumns();
19
+ },
26
20
 
27
- if (c.attrType == 'datetime') {
28
- fieldConfig.dateFormat = 'Y-m-d H:i:s'; // set the format in which we receive datetime from the server (so that the model can parse it)
21
+ netzkeExtractFieldConfig: function(c){
22
+ // Build the field configuration for this column
23
+ var fieldConfig = {name: c.name, defaultValue: c.defaultValue, allowNull: true};
29
24
 
30
- // While for 'date' columns the renderer is set up automatically (through using column's xtype), there's no appropriate xtype for our custom datetime column.
31
- // Thus, we need to set the renderer manually.
32
- // NOTE: for Ext there's no distinction b/w date and datetime; date fields can include time.
33
- if (!c.renderer) {
34
- // format in which the data will be rendered; if c.format is nil, Ext.Date.defaultFormat extended with time will be used
35
- c.renderer = Ext.util.Format.dateRenderer(c.format || Ext.Date.defaultFormat + " H:i:s");
36
- }
37
- };
25
+ if (!c.meta) fieldConfig.type = this.netzkeFieldTypeForAttrType(c.type); // field type (grid editors need this to function well)
38
26
 
39
- if (c.attrType == 'date') {
40
- // If no dateFormat given for date attrType, Timezone translation can subtract zone offset from 00:00:00 causing previous day.
41
- fieldConfig.dateFormat = 'Y-m-d';
42
- };
27
+ if (c.type == 'datetime') {
28
+ fieldConfig.dateFormat = 'Y-m-d H:i:s'; // set the format in which we receive datetime from the server (so that the model can parse it)
29
+ };
43
30
 
44
- // because checkcolumn doesn't care about editor (not) being set, we need to explicitely set readOnly here
45
- if (c.xtype == 'checkcolumn' && !c.editor) {
46
- c.readOnly = true;
47
- }
31
+ if (c.type == 'date') {
32
+ // If no dateFormat given for date type, Timezone translation can subtract zone offset from 00:00:00 causing previous day.
33
+ fieldConfig.dateFormat = 'Y-m-d';
34
+ };
48
35
 
49
- this.fields.push(fieldConfig);
36
+ return fieldConfig;
37
+ },
50
38
 
51
- // We will not use meta columns as actual columns (not even hidden) - only to create the records
52
- if (c.meta) {
53
- this.metaColumn = c;
54
- return;
55
- }
39
+ netzkeExtendColumnConfig: function(c){
40
+ // Set rendeder for association columns (the one displaying associations by the specified method instead of id)
41
+ if (c.assoc) {
42
+ // Editor for association column
43
+ if (c.editor) c.editor = Ext.apply({ name: c.name, netzkeParent: this }, c.editor);
56
44
 
57
- // Set rendeder for association columns (the one displaying associations by the specified method instead of id)
58
- if (c.assoc) {
59
- // Editor for association column
60
- if (c.editor) c.editor = Ext.apply({ name: c.name }, c.editor);
45
+ // Renderer for association column
46
+ this.netzkeNormalizeAssociationRenderer(c);
47
+ }
61
48
 
62
- // Renderer for association column
63
- this.netzkeNormalizeAssociationRenderer(c);
64
- }
49
+ // extend editor with editorConfig passed from the server
50
+ if (c.editor) {
51
+ Ext.apply(c.editor, (c.editorConfig || {}), {selectOnFocus: true});
52
+ }
65
53
 
66
- if (c.editor) {
67
- Ext.applyIf(c.editor, {selectOnFocus: true, netzkeParent: this});
68
- }
54
+ // Setting the default filter type
55
+ if (c.filterable != false && !c.filter) {
56
+ c.filter = {type: this.netzkeFilterTypeForAttrType(c.type)};
57
+ }
69
58
 
70
- // Setting the default filter type
71
- if (c.filterable != false && !c.filter) {
72
- c.filter = {type: this.netzkeFilterTypeForAttrType(c.attrType)};
59
+ if (c.type == 'datetime') {
60
+ // While for 'date' columns the renderer is set up automatically (through using column's xtype), there's no appropriate xtype for our custom datetime column.
61
+ // Thus, we need to set the renderer manually.
62
+ // NOTE: for Ext there's no distinction b/w date and datetime; date fields can include time.
63
+ if (!c.renderer) {
64
+ // format in which the data will be rendered; if c.format is nil, Ext.Date.defaultFormat extended with time will be used
65
+ c.renderer = Ext.util.Format.dateRenderer(c.format || Ext.Date.defaultFormat + " H:i:s");
73
66
  }
67
+ };
74
68
 
75
- // setting dataIndex
76
- c.dataIndex = c.name;
77
-
78
- }, this);
79
-
80
- // Now reorder columns as specified in this.columnsOrder
81
- this.orderColumns();
69
+ // setting dataIndex
70
+ c.dataIndex = c.name;
82
71
  },
83
72
 
84
73
  // Build column model config with columns in the correct order; columns out of order go to the end.
@@ -101,7 +90,7 @@ Ext.define("Netzke.mixins.Basepack.Columns", {
101
90
  // We don't need original columns any longer
102
91
  delete this.columns.items;
103
92
 
104
- // ... instead, define own column model
93
+ // ... instead, use own column model
105
94
  this.columns.items = colModelConfig;
106
95
  },
107
96
 
@@ -150,7 +139,7 @@ Ext.define("Netzke.mixins.Basepack.Columns", {
150
139
  */
151
140
  netzkeNormalizeAssociationRenderer: function(c) {
152
141
  var passedRenderer = c.renderer, // renderer we got from netzkeNormalizeRenderer
153
- metaData, assocValue;
142
+ assocValue;
154
143
  c.scope = this;
155
144
  c.renderer = function(value, a, r, ri, ci, store, view){
156
145
  var column = view.headerCt.items.getAt(ci),
@@ -160,8 +149,7 @@ Ext.define("Netzke.mixins.Basepack.Columns", {
160
149
 
161
150
  if (recordFromStore) {
162
151
  renderedValue = recordFromStore.get('text');
163
- } else if (metaData = r.get('meta')) {
164
- assocValue = metaData.associationValues[c.name];
152
+ } else if ((assocValue = (r.get('association_values') || {})[c.name]) !== undefined) {
165
153
  renderedValue = (assocValue == undefined) ? c.emptyText : assocValue;
166
154
  } else {
167
155
  renderedValue = value;
@@ -177,19 +165,19 @@ Ext.define("Netzke.mixins.Basepack.Columns", {
177
165
  cols.push({name: c.name, width: c.width, hidden: c.hidden});
178
166
  });
179
167
 
180
- this.serverSaveColumns(cols);
168
+ this.server.saveColumns(cols);
181
169
  },
182
170
 
183
171
  // Tries editing the first editable (i.e. not hidden, not read-only) sell
184
172
  netzkeTryStartEditing: function(r){
185
173
  var column = Ext.Array.findBy(this.columns, function(c){
186
- return !(c.hidden || c.readOnly || c.attrType == 'boolean')
174
+ return !(c.hidden || c.readOnly || c.type == 'boolean')
187
175
  });
188
176
 
189
177
  if (column) {this.getPlugin('celleditor').startEdit(r, column);}
190
178
  },
191
179
 
192
- netzkeFilterTypeForAttrType: function(attrType){
180
+ netzkeFilterTypeForAttrType: function(type){
193
181
  var map = {
194
182
  integer : 'number',
195
183
  decimal : 'number',
@@ -200,10 +188,10 @@ Ext.define("Netzke.mixins.Basepack.Columns", {
200
188
  text : 'string',
201
189
  'boolean' : 'boolean'
202
190
  };
203
- return map[attrType] || 'string';
191
+ return map[type] || 'string';
204
192
  },
205
193
 
206
- netzkeFieldTypeForAttrType: function(attrType){
194
+ netzkeFieldTypeForAttrType: function(type){
207
195
  var map = {
208
196
  integer : 'int',
209
197
  decimal : 'float',
@@ -214,6 +202,6 @@ Ext.define("Netzke.mixins.Basepack.Columns", {
214
202
  text : 'string',
215
203
  'boolean' : 'boolean'
216
204
  };
217
- return map[attrType] || 'string';
205
+ return map[type] || 'string';
218
206
  }
219
207
  });