netzke-basepack 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. data/CHANGELOG +18 -0
  2. data/LICENSE +20 -0
  3. data/Manifest +64 -0
  4. data/README.mdown +74 -0
  5. data/Rakefile +14 -0
  6. data/generators/netzke_basepack/USAGE +8 -0
  7. data/generators/netzke_basepack/netzke_basepack_generator.rb +8 -0
  8. data/generators/netzke_basepack/netzke_grid_generator.rb +7 -0
  9. data/generators/netzke_basepack/templates/create_netzke_grid_columns.rb +21 -0
  10. data/init.rb +1 -0
  11. data/install.rb +1 -0
  12. data/javascripts/basepack.js +52 -0
  13. data/javascripts/filters.js +7 -0
  14. data/lib/app/models/netzke_grid_column.rb +23 -0
  15. data/lib/netzke-basepack.rb +28 -0
  16. data/lib/netzke/accordion.rb +11 -0
  17. data/lib/netzke/ar_ext.rb +163 -0
  18. data/lib/netzke/column.rb +43 -0
  19. data/lib/netzke/container.rb +81 -0
  20. data/lib/netzke/grid.rb +120 -0
  21. data/lib/netzke/grid_interface.rb +156 -0
  22. data/lib/netzke/grid_js_builder.rb +276 -0
  23. data/lib/netzke/preference_grid.rb +43 -0
  24. data/lib/netzke/properties_tool.rb +66 -0
  25. data/lib/netzke/property_grid.rb +60 -0
  26. data/netzke-basepack.gemspec +38 -0
  27. data/tasks/netzke_basepack_tasks.rake +4 -0
  28. data/test/app_root/app/controllers/application.rb +2 -0
  29. data/test/app_root/app/models/book.rb +9 -0
  30. data/test/app_root/app/models/category.rb +2 -0
  31. data/test/app_root/app/models/city.rb +3 -0
  32. data/test/app_root/app/models/continent.rb +2 -0
  33. data/test/app_root/app/models/country.rb +3 -0
  34. data/test/app_root/app/models/genre.rb +3 -0
  35. data/test/app_root/config/boot.rb +114 -0
  36. data/test/app_root/config/database.yml +21 -0
  37. data/test/app_root/config/environment.rb +13 -0
  38. data/test/app_root/config/environments/in_memory.rb +0 -0
  39. data/test/app_root/config/environments/mysql.rb +0 -0
  40. data/test/app_root/config/environments/postgresql.rb +0 -0
  41. data/test/app_root/config/environments/sqlite.rb +0 -0
  42. data/test/app_root/config/environments/sqlite3.rb +0 -0
  43. data/test/app_root/config/routes.rb +4 -0
  44. data/test/app_root/db/migrate/20081222033343_create_books.rb +15 -0
  45. data/test/app_root/db/migrate/20081222033440_create_genres.rb +14 -0
  46. data/test/app_root/db/migrate/20081222035855_create_netzke_preferences.rb +18 -0
  47. data/test/app_root/db/migrate/20081223024935_create_categories.rb +13 -0
  48. data/test/app_root/db/migrate/20081223025635_create_countries.rb +14 -0
  49. data/test/app_root/db/migrate/20081223025653_create_continents.rb +13 -0
  50. data/test/app_root/db/migrate/20081223025732_create_cities.rb +15 -0
  51. data/test/app_root/script/console +7 -0
  52. data/test/ar_ext_test.rb +39 -0
  53. data/test/column_test.rb +27 -0
  54. data/test/console_with_fixtures.rb +4 -0
  55. data/test/fixtures/books.yml +9 -0
  56. data/test/fixtures/categories.yml +7 -0
  57. data/test/fixtures/cities.yml +21 -0
  58. data/test/fixtures/continents.yml +7 -0
  59. data/test/fixtures/countries.yml +9 -0
  60. data/test/fixtures/genres.yml +9 -0
  61. data/test/grid_test.rb +43 -0
  62. data/test/netzke_basepack_test.rb +8 -0
  63. data/test/schema.rb +10 -0
  64. data/test/test_helper.rb +20 -0
  65. data/uninstall.rb +1 -0
  66. metadata +162 -0
@@ -0,0 +1,14 @@
1
+ class CreateGenres < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :genres do |t|
4
+ t.string :name
5
+ t.integer :category_id
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :genres
13
+ end
14
+ end
@@ -0,0 +1,18 @@
1
+ class CreateNetzkePreferences < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :netzke_preferences do |t|
4
+ t.string :name
5
+ t.string :pref_type
6
+ t.string :value
7
+ t.integer :user_id
8
+ t.integer :role_id
9
+ t.string :custom_field
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+
15
+ def self.down
16
+ drop_table :netzke_preferences
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ class CreateCategories < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :categories do |t|
4
+ t.string :name
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ drop_table :categories
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ class CreateCountries < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :countries do |t|
4
+ t.string :name
5
+ t.integer :continent_id
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :countries
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ class CreateContinents < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :continents do |t|
4
+ t.string :name
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ drop_table :continents
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ class CreateCities < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :cities do |t|
4
+ t.string :name
5
+ t.integer :population
6
+ t.integer :country_id
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+
12
+ def self.down
13
+ drop_table :cities
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
2
+ libs = " -r irb/completion"
3
+ libs << " -r test/test_helper"
4
+ libs << " -r test/console_with_fixtures"
5
+ libs << " -r console_app"
6
+ libs << " -r console_with_helpers"
7
+ exec "#{irb} #{libs} --simple-prompt"
@@ -0,0 +1,39 @@
1
+ require 'test_helper'
2
+
3
+ require 'netzke/ar_ext'
4
+
5
+ class ArExtTest < ActiveSupport::TestCase
6
+ fixtures :cities, :countries, :continents
7
+
8
+ test "default column config" do
9
+ cc = Book.default_column_config(:title)
10
+
11
+ assert_equal("Title", cc[:label])
12
+ assert_equal(:text_field, cc[:shows_as])
13
+
14
+ cc = Book.default_column_config({:name => :amount, :label => 'AMOUNT'})
15
+
16
+ assert_equal("AMOUNT", cc[:label])
17
+ assert_equal(:number_field, cc[:shows_as])
18
+ end
19
+
20
+ test "choices for column" do
21
+ # TODO: test virtual columns, too
22
+ cities = City.choices_for("name")
23
+ assert_equal(3, cities.size)
24
+ assert(cities.include?('Cordoba') && cities.include?('Buenos Aires'))
25
+
26
+ countries = City.choices_for("country__name")
27
+ assert_equal(2, countries.size)
28
+ assert(countries.include?('Spain') && countries.include?('Argentina'))
29
+
30
+ continents = City.choices_for("country__continent__name")
31
+ assert_equal(2, continents.size)
32
+ assert(continents.include?('Europe') && continents.include?('South America'))
33
+
34
+ cities = City.choices_for("name", "Co")
35
+ assert_equal(2, cities.size)
36
+ assert(cities.include?('Cordoba') && cities.include?('Concordia'))
37
+ end
38
+ end
39
+
@@ -0,0 +1,27 @@
1
+ require 'test_helper'
2
+
3
+ require 'netzke/ar_ext'
4
+
5
+ ActiveRecord::Base.class_eval do
6
+ include Netzke::ActiveRecordExtensions
7
+ end
8
+
9
+ require 'netzke/column'
10
+
11
+ class ColumnTest < ActiveSupport::TestCase
12
+ test "default columns" do
13
+ stub_widget = Object.new
14
+ def stub_widget.config
15
+ {:name => 'widget', :data_class_name => 'Book', :columns => [:title, {:name => :amount, :read_only => true}, :recent]}
16
+ end
17
+
18
+ columns = Netzke::Column.default_columns_for_widget(stub_widget)
19
+
20
+ assert_equal(false, columns[0][:read_only])
21
+ assert_equal(true, columns[1][:read_only])
22
+ assert_equal("Amount", columns[1][:label])
23
+ assert_equal("Recent", columns[2][:label])
24
+ assert_equal(true, columns[2][:read_only]) # read_only specified in the model itself
25
+ # puts "!!! columns: #{columns.inspect}"
26
+ end
27
+ end
@@ -0,0 +1,4 @@
1
+ # Loads fixtures into the database when running the test app via the console
2
+ (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(Rails.root, '../fixtures/*.{yml,csv}'))).each do |fixture_file|
3
+ Fixtures.create_fixtures(File.join(Rails.root, '../fixtures'), File.basename(fixture_file, '.*'))
4
+ end
@@ -0,0 +1,9 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ one:
4
+ title: Separate Reality
5
+ genre_id: 1
6
+
7
+ two:
8
+ title: The Journey to Ixtlan
9
+ genre_id: 1
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ one:
4
+ name: Bestseller
5
+
6
+ two:
7
+ name: Misc
@@ -0,0 +1,21 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ one:
4
+ name: Cordoba
5
+ population: 323_600
6
+ country_id: 1
7
+
8
+ two:
9
+ name: Buenos Aires
10
+ population: 10000000
11
+ country_id: 2
12
+
13
+ three:
14
+ name: Cordoba
15
+ population: 1_315_500
16
+ country_id: 2
17
+
18
+ four:
19
+ name: Concordia
20
+ population: 148_000
21
+ country_id: 2
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ one:
4
+ name: Europe
5
+
6
+ two:
7
+ name: South America
@@ -0,0 +1,9 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ one:
4
+ name: Spain
5
+ continent_id: 1
6
+
7
+ two:
8
+ name: Argentina
9
+ continent_id: 2
@@ -0,0 +1,9 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ one:
4
+ name: MyString
5
+ category_id: 1
6
+
7
+ two:
8
+ name: MyString
9
+ category_id: 2
data/test/grid_test.rb ADDED
@@ -0,0 +1,43 @@
1
+ require 'test_helper'
2
+ require 'netzke-core'
3
+
4
+ require 'netzke/properties_tool'
5
+ require 'netzke/container'
6
+ require 'netzke/accordion'
7
+
8
+ require 'netzke/grid_interface'
9
+ require 'netzke/grid_js_builder'
10
+ require 'netzke/grid'
11
+
12
+ require 'netzke/ar_ext'
13
+ require 'netzke/column'
14
+
15
+ class GridTest < ActiveSupport::TestCase
16
+
17
+ test "interface" do
18
+ grid = Netzke::Grid.new(:name => 'grid', :data_class_name => 'Book', :layout_manager => false, :columns => [:id, :title, :recent])
19
+
20
+ # post
21
+ grid.post_data(:created_records => [{:title => 'Lord of the Rings'}].to_json)
22
+ assert_equal('Lord of the Rings', Book.first.title)
23
+
24
+ grid.post_data(:updated_records => [{:id => Book.first.id, :title => 'Lolita'}].to_json)
25
+ assert_equal('Lolita', Book.first.title)
26
+
27
+ grid.post_data(:created_records => [{:title => 'Upanishad'}].to_json)
28
+
29
+ # get
30
+ data = grid.get_data
31
+ assert_equal('Lolita', data[:data][0][1]) # title of the first book
32
+ assert_equal('Yes', data[:data][1][2]) # "recent" virtual column in the second book
33
+
34
+ # delete
35
+ res = grid.delete_data(:records => [1,2].to_json)
36
+ assert_equal(true, res[:success])
37
+ assert_equal(nil, Book.first)
38
+
39
+ end
40
+
41
+ # TODO: add tests with association columns
42
+
43
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class NetzkeBasepackTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+ end
data/test/schema.rb ADDED
@@ -0,0 +1,10 @@
1
+ ActiveRecord::Schema.define(:version => 0) do
2
+ create_table :books, :force => true do |t|
3
+ t.string :name
4
+ t.integer :amount
5
+ t.integer :genre_id
6
+ end
7
+ create_table :genres, :force => true do |t|
8
+ t.string :name
9
+ end
10
+ end
@@ -0,0 +1,20 @@
1
+ # Set the default environment to sqlite3's in_memory database
2
+ ENV['RAILS_ENV'] ||= 'in_memory'
3
+
4
+ # Load the Rails environment and testing framework
5
+ require "#{File.dirname(__FILE__)}/app_root/config/environment"
6
+ require 'test_help'
7
+ require 'action_view/test_case' # Load additional test classes not done automatically by < Rails 2.2.2
8
+
9
+ # Undo changes to RAILS_ENV
10
+ silence_warnings {RAILS_ENV = ENV['RAILS_ENV']}
11
+
12
+ # Run the migrations
13
+ ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate")
14
+
15
+ # Set default fixture loading properties
16
+ Test::Unit::TestCase.class_eval do
17
+ self.use_transactional_fixtures = true
18
+ self.use_instantiated_fixtures = false
19
+ self.fixture_path = "#{File.dirname(__FILE__)}/fixtures"
20
+ end
data/uninstall.rb ADDED
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: netzke-basepack
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Sergei Kozlov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-01 00:00:00 -06:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: searchlogic
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.6.2
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: netzke-core
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ - - "="
35
+ - !ruby/object:Gem::Version
36
+ version: 0.1.1.1
37
+ version:
38
+ description: Base Netzke widgets - grid, form, tree, and more
39
+ email: sergei@writelesscode.com
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ extra_rdoc_files:
45
+ - CHANGELOG
46
+ - lib/app/models/netzke_grid_column.rb
47
+ - lib/netzke/accordion.rb
48
+ - lib/netzke/ar_ext.rb
49
+ - lib/netzke/column.rb
50
+ - lib/netzke/container.rb
51
+ - lib/netzke/grid.rb
52
+ - lib/netzke/grid_interface.rb
53
+ - lib/netzke/grid_js_builder.rb
54
+ - lib/netzke/preference_grid.rb
55
+ - lib/netzke/properties_tool.rb
56
+ - lib/netzke/property_grid.rb
57
+ - lib/netzke-basepack.rb
58
+ - LICENSE
59
+ - README.mdown
60
+ - tasks/netzke_basepack_tasks.rake
61
+ files:
62
+ - CHANGELOG
63
+ - generators/netzke_basepack/netzke_basepack_generator.rb
64
+ - generators/netzke_basepack/netzke_grid_generator.rb
65
+ - generators/netzke_basepack/templates/create_netzke_grid_columns.rb
66
+ - generators/netzke_basepack/USAGE
67
+ - init.rb
68
+ - install.rb
69
+ - javascripts/basepack.js
70
+ - javascripts/filters.js
71
+ - lib/app/models/netzke_grid_column.rb
72
+ - lib/netzke/accordion.rb
73
+ - lib/netzke/ar_ext.rb
74
+ - lib/netzke/column.rb
75
+ - lib/netzke/container.rb
76
+ - lib/netzke/grid.rb
77
+ - lib/netzke/grid_interface.rb
78
+ - lib/netzke/grid_js_builder.rb
79
+ - lib/netzke/preference_grid.rb
80
+ - lib/netzke/properties_tool.rb
81
+ - lib/netzke/property_grid.rb
82
+ - lib/netzke-basepack.rb
83
+ - LICENSE
84
+ - Manifest
85
+ - Rakefile
86
+ - README.mdown
87
+ - tasks/netzke_basepack_tasks.rake
88
+ - test/app_root/app/controllers/application.rb
89
+ - test/app_root/app/models/book.rb
90
+ - test/app_root/app/models/category.rb
91
+ - test/app_root/app/models/city.rb
92
+ - test/app_root/app/models/continent.rb
93
+ - test/app_root/app/models/country.rb
94
+ - test/app_root/app/models/genre.rb
95
+ - test/app_root/config/boot.rb
96
+ - test/app_root/config/database.yml
97
+ - test/app_root/config/environment.rb
98
+ - test/app_root/config/environments/in_memory.rb
99
+ - test/app_root/config/environments/mysql.rb
100
+ - test/app_root/config/environments/postgresql.rb
101
+ - test/app_root/config/environments/sqlite.rb
102
+ - test/app_root/config/environments/sqlite3.rb
103
+ - test/app_root/config/routes.rb
104
+ - test/app_root/db/migrate/20081222033343_create_books.rb
105
+ - test/app_root/db/migrate/20081222033440_create_genres.rb
106
+ - test/app_root/db/migrate/20081222035855_create_netzke_preferences.rb
107
+ - test/app_root/db/migrate/20081223024935_create_categories.rb
108
+ - test/app_root/db/migrate/20081223025635_create_countries.rb
109
+ - test/app_root/db/migrate/20081223025653_create_continents.rb
110
+ - test/app_root/db/migrate/20081223025732_create_cities.rb
111
+ - test/app_root/script/console
112
+ - test/ar_ext_test.rb
113
+ - test/column_test.rb
114
+ - test/console_with_fixtures.rb
115
+ - test/fixtures/books.yml
116
+ - test/fixtures/categories.yml
117
+ - test/fixtures/cities.yml
118
+ - test/fixtures/continents.yml
119
+ - test/fixtures/countries.yml
120
+ - test/fixtures/genres.yml
121
+ - test/grid_test.rb
122
+ - test/netzke_basepack_test.rb
123
+ - test/schema.rb
124
+ - test/test_helper.rb
125
+ - uninstall.rb
126
+ - netzke-basepack.gemspec
127
+ has_rdoc: true
128
+ homepage: http://writelesscode.com
129
+ post_install_message:
130
+ rdoc_options:
131
+ - --line-numbers
132
+ - --inline-source
133
+ - --title
134
+ - Netzke-basepack
135
+ - --main
136
+ - README.mdown
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: "0"
144
+ version:
145
+ required_rubygems_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: "1.2"
150
+ version:
151
+ requirements: []
152
+
153
+ rubyforge_project: netzke-basepack
154
+ rubygems_version: 1.3.1
155
+ signing_key:
156
+ specification_version: 2
157
+ summary: Base Netzke widgets - grid, form, tree, and more
158
+ test_files:
159
+ - test/ar_ext_test.rb
160
+ - test/column_test.rb
161
+ - test/grid_test.rb
162
+ - test/netzke_basepack_test.rb