netzke-basepack 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/CHANGELOG.rdoc +17 -0
  2. data/README.rdoc +1 -1
  3. data/Rakefile +3 -0
  4. data/TODO.rdoc +1 -4
  5. data/features/form_panel.feature +2 -1
  6. data/features/grid_panel.feature +134 -5
  7. data/features/nested_attributes.feature +4 -1
  8. data/features/paging_form_panel.feature +41 -0
  9. data/features/search_in_grid.feature +20 -7
  10. data/features/step_definitions/form_panel_steps.rb +35 -0
  11. data/features/step_definitions/generic_steps.rb +20 -1
  12. data/features/step_definitions/grid_panel_steps.rb +63 -0
  13. data/features/support/env.rb +4 -0
  14. data/features/validations_in_grid.feature +13 -0
  15. data/features/virtual_attributes.feature +5 -9
  16. data/javascripts/basepack.js +21 -650
  17. data/javascripts/datetimefield.js +24 -0
  18. data/lib/generators/netzke/basepack_generator.rb +10 -0
  19. data/{generators/netzke_basepack/templates/public_assets → lib/generators/netzke/templates/assets}/ts-checkbox.gif +0 -0
  20. data/{generators/netzke_basepack → lib/generators/netzke}/templates/create_netzke_field_lists.rb +0 -0
  21. data/lib/netzke-basepack.rb +3 -41
  22. data/lib/netzke/active_record/attributes.rb +17 -21
  23. data/lib/netzke/basepack.rb +6 -1
  24. data/lib/netzke/basepack/data_accessor.rb +166 -0
  25. data/lib/netzke/basepack/form_panel.rb +69 -20
  26. data/lib/netzke/basepack/form_panel/fields.rb +15 -17
  27. data/lib/netzke/basepack/form_panel/javascripts/comma_list_cbg.js +7 -0
  28. data/lib/netzke/basepack/form_panel/javascripts/display_mode.js +6 -0
  29. data/lib/netzke/basepack/form_panel/javascripts/{main.js → form_panel.js} +42 -8
  30. data/lib/netzke/basepack/form_panel/javascripts/n_radio_group.js +24 -7
  31. data/lib/netzke/basepack/form_panel/javascripts/readonly_mode.js +52 -0
  32. data/lib/netzke/basepack/form_panel/services.rb +28 -2
  33. data/lib/netzke/basepack/form_panel/stylesheets/readonly_mode.css +14 -0
  34. data/lib/netzke/basepack/grid_panel.rb +151 -181
  35. data/lib/netzke/basepack/grid_panel/columns.rb +122 -84
  36. data/lib/netzke/basepack/grid_panel/javascripts/advanced_search.js +22 -27
  37. data/lib/netzke/basepack/grid_panel/javascripts/{main.js → grid_panel.js} +182 -108
  38. data/lib/netzke/basepack/grid_panel/record_form_window.rb +7 -2
  39. data/lib/netzke/basepack/grid_panel/services.rb +58 -39
  40. data/lib/netzke/basepack/paging_form_panel.rb +86 -25
  41. data/lib/netzke/basepack/query_builder.rb +105 -0
  42. data/lib/netzke/basepack/query_builder/javascripts/query_builder.js +140 -0
  43. data/lib/netzke/basepack/search_panel.rb +61 -44
  44. data/lib/netzke/basepack/search_panel/javascripts/condition_field.js +153 -0
  45. data/lib/netzke/basepack/search_panel/javascripts/search_panel.js +64 -0
  46. data/lib/netzke/basepack/search_window.rb +64 -0
  47. data/lib/netzke/basepack/simple_app.rb +1 -1
  48. data/lib/netzke/basepack/simple_app/javascripts/{main.js → simple_app.js} +0 -0
  49. data/lib/netzke/basepack/tab_panel.rb +1 -2
  50. data/lib/netzke/basepack/tab_panel/javascripts/{main.js → tab_panel.js} +0 -0
  51. data/lib/netzke/basepack/version.rb +1 -1
  52. data/locales/en.yml +71 -4
  53. data/netzke-basepack.gemspec +47 -22
  54. data/spec/active_record/attributes_spec.rb +6 -6
  55. data/spec/components/form_panel_spec.rb +2 -13
  56. data/stylesheets/datetimefield.css +54 -0
  57. data/test/rails_app/Gemfile +3 -3
  58. data/test/rails_app/Gemfile.lock +67 -57
  59. data/test/rails_app/README +1 -256
  60. data/test/rails_app/app/components/book_form.rb +1 -3
  61. data/test/rails_app/app/components/book_form_with_custom_fields.rb +20 -0
  62. data/test/rails_app/app/components/book_form_with_nested_attributes.rb +18 -0
  63. data/test/rails_app/app/components/book_grid.rb +3 -1
  64. data/test/rails_app/app/components/book_grid_loader.rb +24 -0
  65. data/test/rails_app/app/components/book_grid_with_custom_columns.rb +28 -0
  66. data/test/rails_app/app/components/book_grid_with_default_values.rb +1 -1
  67. data/test/rails_app/app/components/book_grid_with_virtual_attributes.rb +0 -1
  68. data/test/rails_app/app/components/book_paging_form_panel.rb +3 -2
  69. data/test/rails_app/app/components/book_presentation.rb +3 -3
  70. data/test/rails_app/app/components/book_query_builder.rb +8 -0
  71. data/test/rails_app/app/components/book_search_panel.rb +5 -0
  72. data/test/rails_app/app/components/book_search_panel/javascripts/i18n_de.js +6 -0
  73. data/test/rails_app/app/components/double_book_grid.rb +18 -0
  74. data/test/rails_app/app/components/form_without_model.rb +1 -1
  75. data/test/rails_app/app/components/paging_form_with_search.rb +39 -0
  76. data/test/rails_app/app/components/user_grid.rb +1 -1
  77. data/test/rails_app/app/models/author.rb +1 -0
  78. data/test/rails_app/config/application.rb +6 -1
  79. data/test/rails_app/config/database.yml +7 -5
  80. data/test/rails_app/config/environments/test.rb +1 -1
  81. data/test/rails_app/config/locales/de.yml +35 -0
  82. data/test/rails_app/config/locales/es.yml +84 -8
  83. data/test/rails_app/db/migrate/20101026190021_create_books.rb +2 -2
  84. data/test/rails_app/db/migrate/20110213213050_create_netzke_component_states.rb +20 -0
  85. data/test/rails_app/db/schema.rb +2 -18
  86. data/test/rails_app/public/netzke/basepack/ts-checkbox.gif +0 -0
  87. data/test/unit/active_record_basepack_test.rb +1 -1
  88. metadata +46 -45
  89. data/generators/netzke_basepack/netzke_basepack_generator.rb +0 -13
  90. data/lib/netzke/basepack/grid_panel/search_window.rb +0 -56
  91. data/lib/netzke/data_accessor.rb +0 -113
  92. data/lib/netzke/ext.rb +0 -7
  93. data/lib/netzke/fields_configurator.rb +0 -170
  94. data/lib/netzke/json_array_editor.rb +0 -67
  95. data/lib/netzke/masquerade_selector.rb +0 -53
  96. data/test/rails_app/app/components/some_search_panel.rb +0 -34
  97. data/test/rails_app/db/development_structure.sql +0 -93
  98. data/test/rails_app/db/migrate/20100905214933_create_netzke_preferences.rb +0 -16
@@ -14,11 +14,9 @@ class BookForm < Netzke::Basepack::FormPanel
14
14
  :exemplars,
15
15
  {:name => :in_abundance, :getter => in_abundance_getter, :xtype => :displayfield},
16
16
  {:name => :tags, :xtype => :commalistcbg, :options => %w(read cool recommend buy)},
17
- {:name => :rating, :xtype => :nradiogroup, :options => %w(Good Average Poor)}
17
+ {:name => :rating, :xtype => :nradiogroup, :options => [[1, "Good"], [2, "Average"], [3, "Poor"]]}
18
18
  ]
19
19
  )
20
20
  end
21
21
 
22
-
23
-
24
22
  end
@@ -0,0 +1,20 @@
1
+ class BookFormWithCustomFields < Netzke::Basepack::FormPanel
2
+ js_property :title, Book.model_name.human
3
+
4
+ def default_config
5
+ super.merge(
6
+ :model => "Book",
7
+ :record => Book.first,
8
+ # :mode => :lockable,
9
+ :items => [
10
+ :title,
11
+ {:name => :notes, :read_only => true},
12
+ :author__first_name,
13
+ :author__last_name,
14
+ :digitized,
15
+ :exemplars
16
+ ]
17
+ )
18
+ end
19
+
20
+ end
@@ -0,0 +1,18 @@
1
+ class BookFormWithNestedAttributes < Netzke::Basepack::FormPanel
2
+ js_property :title, Book.model_name.human
3
+
4
+ def default_config
5
+ super.merge(
6
+ :model => "Book",
7
+ :record => Book.first,
8
+ :items => [
9
+ :title,
10
+ {:name => :author__first_name, :nested_attribute => true},
11
+ {:name => :author__last_name, :nested_attribute => true},
12
+ :digitized,
13
+ :exemplars
14
+ ]
15
+ )
16
+ end
17
+
18
+ end
@@ -1,9 +1,11 @@
1
1
  class BookGrid < Netzke::Basepack::GridPanel
2
+
2
3
  js_property :title, "Books"
3
4
 
4
5
  def default_config
5
6
  super.merge(
6
- :model => "Book"
7
+ :model => "Book",
8
+ :persistence => true
7
9
  )
8
10
  end
9
11
  end
@@ -0,0 +1,24 @@
1
+ class BookGridLoader < Netzke::Base
2
+ js_property :layout, :fit
3
+
4
+ component :book_grid_one, :class_name => "Netzke::Basepack::GridPanel", :model => "Book", :lazy_loading => true
5
+ component :book_grid_two, :class_name => "Netzke::Basepack::GridPanel", :model => "Book", :lazy_loading => true
6
+
7
+ action :load_one
8
+ action :load_two
9
+
10
+ js_method :on_load_one, <<-JS
11
+ function(){
12
+ this.loadComponent({name: 'book_grid_one', container: this.id});
13
+ }
14
+ JS
15
+
16
+ js_method :on_load_two, <<-JS
17
+ function(){
18
+ this.loadComponent({name: 'book_grid_two', container: this.id});
19
+ }
20
+ JS
21
+
22
+ js_property :bbar, [:load_one.action, :load_two.action]
23
+
24
+ end
@@ -0,0 +1,28 @@
1
+ class BookGridWithCustomColumns < Netzke::Basepack::GridPanel
2
+ js_property :title, "Books"
3
+
4
+ def default_config
5
+ super.merge(
6
+ :model => "Book",
7
+ :columns => [
8
+ {:name => :author__first_name},
9
+ {:name => :author__last_name, :renderer => :uppercase},
10
+ :author__name,
11
+ :title,
12
+ :digitized,
13
+ {
14
+ :name => :rating,
15
+ :editor => {
16
+ :trigger_action => :all,
17
+ :xtype => :combo,
18
+ :store => [[1, "Good"], [2, "Average"], [3, "Poor"]]
19
+ },
20
+ :renderer => "function(v){return ['', 'Good', 'Average', 'Poor'][v];}"
21
+ },
22
+ :exemplars,
23
+ :updated_at
24
+ ]
25
+ )
26
+ end
27
+
28
+ end
@@ -4,7 +4,7 @@ class BookGridWithDefaultValues < Netzke::Basepack::GridPanel
4
4
  def default_config
5
5
  super.merge(
6
6
  :model => "Book",
7
- :columns => [{:name => 'title', :default_value => "Lolita"}, {:name => 'exemplars', :default_value => 100}, {:name => 'digitized', :default_value => true}]
7
+ :columns => [{:name => 'author__last_name', :default_value => Author.first.id}, {:name => 'title', :default_value => "Lolita"}, {:name => 'exemplars', :default_value => 100}, {:name => 'digitized', :default_value => true}]
8
8
  )
9
9
  end
10
10
 
@@ -18,5 +18,4 @@ class BookGridWithVirtualAttributes < Netzke::Basepack::GridPanel
18
18
  {:name => :in_abundance, :getter => in_abundance_getter}
19
19
  ]
20
20
  end
21
-
22
21
  end
@@ -1,8 +1,9 @@
1
1
  class BookPagingFormPanel < Netzke::Basepack::PagingFormPanel
2
2
  def default_config
3
3
  super.merge({
4
+ :title => "Digitized books",
4
5
  :model => "Book",
5
- :scope => {:digitized => true},
6
+ # :scope => {:digitized => true},
6
7
  :mode => :lockable,
7
8
  :items => [{:layout => :hbox, :label_align => :top, :border => false, :defaults => {:border => false}, :items => [{
8
9
  :flex => 2,
@@ -13,7 +14,7 @@ class BookPagingFormPanel < Netzke::Basepack::PagingFormPanel
13
14
  :flex => 1,
14
15
  :layout => :form,
15
16
  :defaults => {:anchor => "-8"},
16
- :items => [:author__name, :exemplars, :digitized]
17
+ :items => [:author__name, :exemplars, :digitized, :created_at, {:name => :updated_at, :xtype => :datetimefield}]
17
18
  }]}]
18
19
  })
19
20
  end
@@ -2,10 +2,10 @@ module BookPresentation
2
2
  # A setter that creates an author on the fly
3
3
  def author_first_name_setter
4
4
  lambda do |r,v|
5
- if (author = Author.where(:first_name => v).first).nil?
6
- r.author = Author.create(:first_name => v)
5
+ if v.is_a?(Integer)
6
+ r.author = Author.find(v)
7
7
  else
8
- r.author = author
8
+ r.author = Author.create(:first_name => v)
9
9
  end
10
10
  end
11
11
  end
@@ -0,0 +1,8 @@
1
+ class BookQueryBuilder < Netzke::Basepack::QueryBuilder
2
+ def default_config
3
+ super.tap do |s|
4
+ s[:model] = "Book"
5
+ s[:auto_scroll] = true
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ class BookSearchPanel < Netzke::Basepack::SearchPanel
2
+ def default_config
3
+ super.merge(:model => "Book", :persistence => true)
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ {
2
+ i18n: {
3
+ overwriteConfirm: "Sind sie sicher das Preset '{0}' zu überschreiben?",
4
+ overwriteConfirmTitle: "Überschreiben",
5
+ }
6
+ }
@@ -0,0 +1,18 @@
1
+ class DoubleBookGrid < Netzke::Base
2
+ js_property :layout, :border
3
+
4
+ def configuration
5
+ super.tap do |s|
6
+ s[:items] = [{
7
+ :region => :center,
8
+ :class_name => "Netzke::Basepack::GridPanel",
9
+ :model => "Book"
10
+ },{
11
+ :region => :south,
12
+ :height => 200,
13
+ :class_name => "Netzke::Basepack::GridPanel",
14
+ :model => "Book"
15
+ }]
16
+ end
17
+ end
18
+ end
@@ -13,7 +13,7 @@ class FormWithoutModel < Netzke::Basepack::FormPanel
13
13
  end
14
14
 
15
15
  def netzke_submit_endpoint(params)
16
- data = ActiveSupport::JSON.decode(params.data)
16
+ data = ActiveSupport::JSON.decode(params[:data])
17
17
  {:feedback => data.each_pair.map{ |k,v| "#{k.humanize}: #{v}" }.join("<br/>")}
18
18
  end
19
19
  end
@@ -0,0 +1,39 @@
1
+ class PagingFormWithSearch < Netzke::Basepack::BorderLayoutPanel
2
+ def default_config
3
+ super.tap do |s|
4
+ s[:model] = "Book"
5
+ s[:items] = [
6
+ :paging_form_panel.component(:region => :center),
7
+ :search_panel.component(:region => :west, :width => 600, :split => true)
8
+ ]
9
+ end
10
+ end
11
+
12
+ component :paging_form_panel do
13
+ {
14
+ :class_name => "Netzke::Basepack::PagingFormPanel",
15
+ :model => config[:model]
16
+ }
17
+ end
18
+
19
+ component :search_panel do
20
+ {
21
+ :class_name => "Netzke::Basepack::SearchPanel",
22
+ :model => config[:model],
23
+ :bbar => [:apply.action],
24
+ :query => []
25
+ }
26
+ end
27
+
28
+ js_method :init_component, <<-JS
29
+ function(){
30
+ Netzke.classes.PagingFormWithSearch.superclass.initComponent.call(this);
31
+
32
+ this.getChildComponent('search_panel').on('conditionsupdate', function(query){
33
+ this.getChildComponent('paging_form_panel').getStore().baseParams.query = Ext.encode(query);
34
+ this.getChildComponent('paging_form_panel').getStore().load();
35
+ }, this);
36
+ }
37
+ JS
38
+
39
+ end
@@ -2,7 +2,7 @@ class UserGrid < Netzke::Basepack::GridPanel
2
2
  js_property :title, "Users"
3
3
  def configuration
4
4
  super.merge(
5
- :model => "User",
5
+ :model => "User"
6
6
  # :columns => [:first_name, {:name => :address__city}]
7
7
  # :edit_form_config => {:items => [{:name => :first_name, :xtype => :htmleditor}]}
8
8
  )
@@ -1,4 +1,5 @@
1
1
  class Author < ActiveRecord::Base
2
+ has_many :books
2
3
 
3
4
  # virtual attribute
4
5
  def name
@@ -31,7 +31,9 @@ module RailsApp
31
31
 
32
32
  # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
33
33
  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
34
- # config.i18n.default_locale = :en
34
+ # config.i18n.default_locale = :es
35
+ # config.i18n.locale = :es
36
+ # I18n.locale = :es
35
37
 
36
38
  # JavaScript files you want as :defaults (application.js is always included).
37
39
  # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
@@ -41,5 +43,8 @@ module RailsApp
41
43
 
42
44
  # Configure sensitive parameters which will be filtered from the log file.
43
45
  config.filter_parameters += [:password]
46
+
47
+ # config.netzke.basepack.grid_panel.edit_in_form_available = false
48
+ # config.netzke.basepack.grid_panel.extended_search_available = false
44
49
  end
45
50
  end
@@ -1,5 +1,3 @@
1
- # SQLite version 3.x
2
- # gem install sqlite3-ruby (not necessary on OS X Leopard)
3
1
  development:
4
2
  adapter: mysql2
5
3
  encoding: utf8
@@ -29,7 +27,11 @@ test:
29
27
  socket: /tmp/mysql.sock
30
28
 
31
29
  production:
32
- adapter: sqlite3
33
- database: db/production.sqlite3
30
+ adapter: mysql2
31
+ encoding: utf8
32
+ reconnect: false
33
+ database: nbt_production
34
34
  pool: 5
35
- timeout: 5000
35
+ username: root
36
+ password:
37
+ socket: /tmp/mysql.sock
@@ -18,7 +18,7 @@ RailsApp::Application.configure do
18
18
  config.action_dispatch.show_exceptions = false
19
19
 
20
20
  # Disable request forgery protection in test environment
21
- config.action_controller.allow_forgery_protection = false
21
+ config.action_controller.allow_forgery_protection = true
22
22
 
23
23
  # Tell Action Mailer not to deliver emails to the real world.
24
24
  # The :test delivery method accumulates sent emails in the
@@ -0,0 +1,35 @@
1
+ de:
2
+ netzke:
3
+ basepack:
4
+ generic:
5
+ confirm: Confirmation
6
+ are_you_sure: Are you sure?
7
+ grid_panel:
8
+ actions:
9
+ add: Zufügen
10
+ edit: Verandern
11
+ del: Delete
12
+ apply: Apply
13
+ add_in_form: Add in form
14
+ edit_in_form: Edit in form
15
+ search: Search
16
+ deleted_n_records: "Deleted %{n} record(s)"
17
+ cannot_delete: "You don't have permissions to delete data"
18
+ search_panel:
19
+ presets: Vorlagen
20
+ equals: Ist gleich
21
+ greater_than: Ist größer als
22
+ less_than: Ist kleiner als
23
+ contains: Enthält
24
+ matches: Entspricht
25
+ is_true: "Ja"
26
+ is_false: "Nein"
27
+ date_equals: Am
28
+ before: Vor dem
29
+ after: Nach dem
30
+ preset_saved: Vorlage erfolgreich gespeichert
31
+ preset_deleted: Vorlage erfolgreich gelöscht..
32
+ formats:
33
+ date: Y-m-d
34
+ datetime: Y-m-d H:i:s
35
+ time: H:i:s
@@ -1,16 +1,92 @@
1
1
  es:
2
+ # book_paging_form_panel:
3
+ # actions:
4
+ # search: Buscar
5
+ # apply: Apply
2
6
  netzke:
3
7
  basepack:
4
8
  grid_panel:
5
- add: Aggregar
6
- edit: Editar
7
- delete: Borrar
8
- apply: Aplicar
9
- add_in_form: Aggregar en forma
10
- edit_in_form: Editar en forma
11
- search: Buscar
9
+ actions:
10
+ add: Aggregar
11
+ add_tooltip: Aggregar
12
+ edit: Editar
13
+ edit_tooltip: Editar
14
+ del: Borrar
15
+ del_tooltip: Borrar
16
+ apply: Aplicar
17
+ apply_tooltip: Aplicar
18
+ add_in_form: Aggregar en forma
19
+ add_in_form_tooltip: Aggregar en forma
20
+ edit_in_form: Editar en forma
21
+ edit_in_form_tooltip: Editar en forma
22
+ search: Buscar
23
+ deleted_n_records: "%{n} entrada(s) borrado"
24
+ cannot_delete: "No se puede borrar"
25
+
26
+ empty_msg: Vacio
27
+ first_text: Primer pagina
28
+ prev_text: Anterior pagina
29
+ next_text: Siguiente pagina
30
+ last_text: Última pagina
31
+ before_page_text: Pagina
32
+ after_page_text: "de {0}"
33
+ refresh_text: Bajar de nuevo
34
+ display_msg: "Mostrando {0} - {1} de {2}"
35
+
36
+ search_window:
37
+ title: Busqueda avanzada
38
+ actions:
39
+ search: Buscar
40
+ cancel: Cancelar
41
+
12
42
  form_panel:
13
- apply: Aplicar
43
+ actions:
44
+ apply: Aplicar
45
+ apply_tooltip: Aplicar
46
+ search: Buscar
47
+ search_tooltip: Buscar
48
+ cancel: Cancelar
49
+ cancel_tooltip: Cancelar
50
+ edit: Editar
51
+ edit_tooltip: Editar
52
+
53
+ search_panel:
54
+ equals: Es igual a
55
+ greater_than: Más de
56
+ less_than: Menos de
57
+ contains: Contiene
58
+ matches: Corresponde a
59
+ yes: Sí
60
+ no: No
61
+ before: Antes de
62
+ after: Después de
63
+
64
+ paging_form_panel:
65
+ actions:
66
+ search: Buscar
67
+ search_tooltip: Busqueda avanzada
68
+
69
+
70
+ query_builder:
71
+ presets: Presets
72
+ preset_saved: Preset grabado
73
+ preset_deleted: Preset borrado
74
+ overwrite_confirm: "Está seguro: '{0}'?"
75
+ overwrite_confirm_title: "Overwriting preset"
76
+ delete_confirm: "Are you sure you want to delete preset '{0}'?"
77
+ delete_confirm_title: "Deleting preset"
78
+ actions:
79
+ clear_all: Borrar
80
+ clear_all_tooltip: Borrar todas conditiones
81
+ reset: Reiniciar
82
+ reset_tooltip: Reiniciar
83
+ save_preset: Guardar preset
84
+ save_preset_tooltip: Guardar preset
85
+ delete_preset: Borrar preset
86
+ delete_preset_tooltip: Borrar preset
87
+ apply: Aplicar
88
+ apply_tooltip: Aplicar conditiones actualizadas
89
+
14
90
  activerecord:
15
91
  models:
16
92
  book: Libro