wice_grid 3.0.4 → 3.2.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/CHANGELOG +24 -2
  2. data/README.rdoc +282 -316
  3. data/RELEASE_NOTES_3.2.pre1.rdoc +82 -0
  4. data/Rakefile +4 -2
  5. data/SAVED_QUERIES_HOWTO.rdoc +18 -31
  6. data/VERSION +1 -1
  7. data/lib/generators/wice_grid/add_migration_for_serialized_queries_generator.rb +22 -0
  8. data/lib/generators/wice_grid/install_generator.rb +20 -0
  9. data/lib/generators/wice_grid/templates/create_wice_grid_serialized_queries.rb +13 -0
  10. data/lib/generators/wice_grid/templates/wice_grid.css.scss +139 -0
  11. data/lib/generators/wice_grid/templates/wice_grid.yml +113 -19
  12. data/lib/generators/wice_grid/templates/wice_grid_config.rb +17 -41
  13. data/lib/grid_output_buffer.rb +3 -2
  14. data/lib/grid_renderer.rb +63 -102
  15. data/lib/helpers/js_calendar_helpers.rb +27 -157
  16. data/lib/helpers/wice_grid_misc_view_helpers.rb +1 -66
  17. data/lib/helpers/wice_grid_serialized_queries_view_helpers.rb +41 -32
  18. data/lib/helpers/wice_grid_view_helpers.rb +138 -274
  19. data/lib/table_column_matrix.rb +11 -11
  20. data/lib/view_columns.rb +41 -350
  21. data/lib/view_columns/action_view_column.rb +45 -0
  22. data/lib/view_columns/column_processor_index.rb +16 -0
  23. data/lib/view_columns/view_column_boolean.rb +23 -0
  24. data/lib/view_columns/view_column_custom_dropdown.rb +81 -0
  25. data/lib/view_columns/view_column_date.rb +17 -0
  26. data/lib/view_columns/view_column_datetime.rb +85 -0
  27. data/lib/view_columns/view_column_float.rb +7 -0
  28. data/lib/view_columns/view_column_integer.rb +38 -0
  29. data/lib/view_columns/view_column_string.rb +63 -0
  30. data/lib/wice_grid.rb +23 -26
  31. data/lib/wice_grid_controller.rb +14 -15
  32. data/lib/wice_grid_misc.rb +3 -3
  33. data/lib/wice_grid_serialized_queries_controller.rb +15 -18
  34. data/lib/wice_grid_spreadsheet.rb +2 -2
  35. data/lib/will_paginate_paginator.rb +31 -0
  36. data/test/readme.txt +1 -0
  37. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/arrow_down.gif +0 -0
  38. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/arrow_up.gif +0 -0
  39. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/calendar_view_month.png +0 -0
  40. data/vendor/assets/images/icons/grid/collapse.gif +0 -0
  41. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/delete.png +0 -0
  42. data/vendor/assets/images/icons/grid/expand.gif +0 -0
  43. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/page_white_excel.png +0 -0
  44. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/page_white_find.png +0 -0
  45. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/table.png +0 -0
  46. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/table_refresh.png +0 -0
  47. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/tick_all.png +0 -0
  48. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/untick_all.png +0 -0
  49. data/vendor/assets/javascripts/wice_grid.js +3 -0
  50. data/vendor/assets/javascripts/wice_grid_init.js.coffee +247 -0
  51. data/vendor/assets/javascripts/wice_grid_processor.js.coffee +128 -0
  52. data/vendor/assets/javascripts/wice_grid_saved_queries_init.js.coffee +103 -0
  53. data/wice_grid.gemspec +44 -50
  54. metadata +68 -94
  55. data/lib/generators/wice_grid/templates/calendarview.css +0 -107
  56. data/lib/generators/wice_grid/templates/calendarview.js +0 -1168
  57. data/lib/generators/wice_grid/templates/icons/expand.png +0 -0
  58. data/lib/generators/wice_grid/templates/wice_grid.css +0 -173
  59. data/lib/generators/wice_grid/templates/wice_grid_jquery.js +0 -162
  60. data/lib/generators/wice_grid/templates/wice_grid_prototype.js +0 -154
  61. data/lib/generators/wice_grid/wice_grid_assets_jquery_generator.rb +0 -32
  62. data/lib/generators/wice_grid/wice_grid_assets_prototype_generator.rb +0 -34
  63. data/lib/js_adaptors/jquery_adaptor.rb +0 -157
  64. data/lib/js_adaptors/js_adaptor.rb +0 -12
  65. data/lib/js_adaptors/prototype_adaptor.rb +0 -179
  66. data/lib/tasks/wice_grid_tasks.rake +0 -28
  67. data/lib/views/create.rjs +0 -13
  68. data/lib/views/create_jq.rjs +0 -31
  69. data/lib/views/delete.rjs +0 -12
  70. data/lib/views/delete_jq.rjs +0 -26
  71. data/test/.gitignore +0 -2
  72. data/test/database.yml +0 -21
  73. data/test/schema.rb +0 -33
  74. data/test/test_helper.rb +0 -89
  75. data/test/views/projects_and_people_grid.html.erb +0 -12
  76. data/test/views/projects_and_people_grid_invalid.html.erb +0 -12
  77. data/test/views/simple_projects_grid.html.erb +0 -9
  78. data/test/wice_grid_core_ext_test.rb +0 -183
  79. data/test/wice_grid_functional_test.rb +0 -68
  80. data/test/wice_grid_misc_test.rb +0 -41
  81. data/test/wice_grid_test.rb +0 -42
  82. data/test/wice_grid_view_helper_test.rb +0 -12
data/lib/views/create.rjs DELETED
@@ -1,13 +0,0 @@
1
- if @notification_messages
2
- page.replace_html(@notification_messages_dom_id, %!<div class="wice_grid_notice"> #{h @notification_messages}</div>!)
3
- end
4
-
5
- if @error_messages
6
- page.replace_html(@notification_messages_dom_id, %!<div class="errorExplanation"> #{h @error_messages} </div>!)
7
- else
8
- page.replace(@query_list_dom_id, saved_queries_list(@grid_name, @saved_query, controller.extra))
9
- page[@query_list_dom_id].visual_effect :highlight
10
- page.replace_html(@grid_title_id, content_tag(:h3,@saved_query.name))
11
- end
12
-
13
- page[@notification_messages_dom_id].show
@@ -1,31 +0,0 @@
1
- if @notification_messages
2
-
3
- notification_messages = ActiveSupport::JSON.encode(
4
- %!<div class="wice_grid_notice"> #{h @notification_messages}</div>!
5
- )
6
-
7
- page << "$('##{@notification_messages_dom_id}').html(#{notification_messages});"
8
- end
9
-
10
- if @error_messages
11
- error_messages = ActiveSupport::JSON.encode(
12
- %!<div class="errorExplanation"> #{h @error_messages} </div>!
13
- )
14
-
15
- page << "$('##{@notification_messages_dom_id}').html(#{error_messages});"
16
- else
17
- new_list = ActiveSupport::JSON.encode(
18
- saved_queries_list(@grid_name, @saved_query, controller.extra)
19
- )
20
- page << "$('##{@query_list_dom_id}').replaceWith(#{new_list});"
21
-
22
- page << "$('##{@query_list_dom_id}').effect('highlight');"
23
-
24
- new_grid_name = ActiveSupport::JSON.encode(
25
- content_tag(:h3,@saved_query.name)
26
- )
27
-
28
- page << "$('##{@grid_title_id}').html(#{new_grid_name});"
29
- end
30
-
31
- page << %!$("##{@notification_messages_dom_id}").show();!
data/lib/views/delete.rjs DELETED
@@ -1,12 +0,0 @@
1
- if @notification_messages
2
- page.replace_html(@notification_messages_dom_id, %!<div class="wice_grid_notice"> #{h @notification_messages}</div>!)
3
- end
4
-
5
- if @error_messages
6
- page.replace_html(@notification_messages_dom_id, %!<div class="errorExplanation"> #{h @error_messages} </div>!)
7
- else
8
- page.replace(@query_list_dom_id, saved_queries_list(@grid_name, @current, controller.extra))
9
- page[@query_list_dom_id].visual_effect :highlight
10
- end
11
-
12
- page[@notification_messages_dom_id].show
@@ -1,26 +0,0 @@
1
- if @notification_messages
2
- notification_messages = ActiveSupport::JSON.encode(
3
- %!<div class="wice_grid_notice"> #{h @notification_messages}</div>!
4
- )
5
-
6
- page << "$('##{@notification_messages_dom_id}').html(#{notification_messages});"
7
- end
8
-
9
-
10
-
11
- if @error_messages
12
- error_messages = ActiveSupport::JSON.encode(
13
- %!<div class="errorExplanation"> #{h @error_messages} </div>!
14
- )
15
-
16
- page << "$('##{@notification_messages_dom_id}').html(#{error_messages});"
17
- else
18
- new_list = ActiveSupport::JSON.encode(
19
- saved_queries_list(@grid_name, @saved_query, controller.extra)
20
- )
21
- page << "$('##{@query_list_dom_id}').replaceWith(#{new_list});"
22
-
23
- page << "$('##{@query_list_dom_id}').effect('highlight');"
24
- end
25
-
26
- page << %!$("##{@notification_messages_dom_id}").show();!
data/test/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- *.log
2
- *.db
data/test/database.yml DELETED
@@ -1,21 +0,0 @@
1
- sqlite:
2
- :adapter: sqlite
3
- :dbfile: vendor/plugins/wice_grid/test/wice_grid_plugin.sqlite.db
4
-
5
- sqlite3:
6
- :adapter: sqlite3
7
- :dbfile: vendor/plugins/wice_grid/test/wice_grid_plugin.sqlite3.db
8
-
9
- postgresql:
10
- :adapter: postgresql
11
- :username: postgres
12
- :password: postgres
13
- :database: wice_grid_plugin_test
14
- :min_messages: ERROR
15
-
16
- mysql:
17
- :adapter: mysql
18
- :host: localhost
19
- :username: root
20
- :password:
21
- :database: wice_grid_plugin_test
data/test/schema.rb DELETED
@@ -1,33 +0,0 @@
1
- ActiveRecord::Schema.define(:version => 0) do
2
-
3
- create_table :people, :force => true do |t|
4
- t.string :firstname
5
- t.string :lastname
6
- t.string :email
7
- t.timestamps
8
- end
9
-
10
- create_table :projects, :force => true do |t|
11
- t.string :name
12
- t.integer :person_id
13
- t.timestamps
14
- end
15
-
16
- create_table :tasks, :force => true do |t|
17
- t.integer :project_id
18
- t.integer :person_id
19
- t.string :name
20
- t.text :description
21
- t.boolean :done
22
- t.timestamps
23
- end
24
-
25
- create_table :saved_queries, :force => true do |t|
26
- t.column :name, :string
27
- t.column :grid_name, :string
28
- t.column :query, :text
29
- t.column :grid_hash, :string
30
-
31
- t.timestamps
32
- end
33
- end
data/test/test_helper.rb DELETED
@@ -1,89 +0,0 @@
1
- ENV['RAILS_ENV'] = 'test'
2
- ENV['RAILS_ROOT'] ||= File.dirname(__FILE__) + '/../../../..'
3
-
4
- ENV['DB'] = 'mysql'
5
-
6
- require 'test/unit'
7
- require File.expand_path(File.join(ENV['RAILS_ROOT'], 'config/environment.rb'))
8
-
9
- def load_schema
10
-
11
- config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
12
- ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
13
-
14
- db_adapter = ENV['DB']
15
-
16
- # no db passed, try one of these fine config-free DBs before bombing.
17
- db_adapter ||=
18
- begin
19
- require 'rubygems'
20
- require 'sqlite'
21
- 'sqlite'
22
- rescue MissingSourceFile
23
- begin
24
- require 'sqlite3'
25
- 'sqlite3'
26
- rescue MissingSourceFile
27
- end
28
- end
29
-
30
- if db_adapter.nil?
31
- raise "No DB Adapter selected. Pass the DB= option to pick one, or install Sqlite or Sqlite3."
32
- end
33
-
34
- ActiveRecord::Base.establish_connection(config[db_adapter])
35
- load(File.dirname(__FILE__) + "/schema.rb")
36
- require File.dirname(__FILE__) + '/../init.rb'
37
-
38
- end
39
-
40
- #
41
- #
42
- #
43
-
44
- require File.join(File.dirname(__FILE__), '../generators/wice_grid_assets/templates/initializers/wice_grid_config.rb')
45
-
46
- load_schema
47
-
48
- class Person < ActiveRecord::Base
49
- has_many :projects
50
- has_many :tasks
51
- end
52
-
53
- class Project < ActiveRecord::Base
54
- belongs_to :person
55
- validates_presence_of :person_id
56
- end
57
-
58
- class Task < ActiveRecord::Base
59
- belongs_to :project
60
- belongs_to :person
61
- validates_presence_of :project_id
62
- validates_presence_of :person_id
63
- end
64
-
65
- class SavedQuery < ActiveRecord::Base
66
- def self.list(a, b)
67
- end
68
- end
69
-
70
- NUM_PEOPLE = 10
71
- NUM_PROJECTS = 5
72
- NUM_TASKS = 1000
73
-
74
- NUM_PEOPLE.times do |i|
75
- Person.create!(:firstname => "Firstname%02d" % i, :lastname => "Lastname%02d" % i, :email => "user%02d@example.com" % i)
76
- end
77
-
78
- NUM_PROJECTS.times do |i|
79
- Project.create!(:name => "Project%02d" % i, :person => Person.all[i % NUM_PEOPLE])
80
- end
81
-
82
- NUM_TASKS.times do |i|
83
- project = Project.find(:first, :order => 'RAND()')
84
- owner = Person.find(:first, :order => 'RAND()')
85
- Task.create!(:name => "Task%03d" % i,
86
- :description => "Description%03d" % i,
87
- :person => Person.all[i % NUM_PEOPLE],
88
- :project => Project.all[i % NUM_PROJECTS])
89
- end
@@ -1,12 +0,0 @@
1
- <%= grid(@grid) do |g|
2
-
3
- g.column(:attribute_name => 'name')
4
-
5
- g.column(:attribute_name => 'firstname', :model_class => 'Person')
6
- g.column(:attribute_name => 'lastname', :model_class => 'Person')
7
-
8
- g.column(:attribute_name => 'updated_at') do |project|
9
- project.updated_at.strftime("%d/%m/%Y %H:%M")
10
- end
11
-
12
- end -%>
@@ -1,12 +0,0 @@
1
- <%= grid(@grid) do |g|
2
-
3
- g.column(:attribute_name => 'name')
4
-
5
- g.column(:attribute_name => 'firstname', :model_class => 'Person')
6
- g.column(:attribute_name => 'lastname', :model_class => 'Person')
7
-
8
- g.column(:attribute_name => 'updated_at') do |project|
9
- project.updated_at.strftime("%d/%m/%Y %H:%M")
10
- end
11
-
12
- end -%>
@@ -1,9 +0,0 @@
1
- <%= grid(@grid) do |g|
2
-
3
- g.column(:attribute_name => 'name')
4
-
5
- g.column(:attribute_name => 'updated_at') do |project|
6
- project.updated_at.strftime("%d/%m/%Y %H:%M")
7
- end
8
-
9
- end -%>
@@ -1,183 +0,0 @@
1
- # More or less complete
2
-
3
- require 'test/unit'
4
- require File.dirname(__FILE__) + '/test_helper.rb'
5
-
6
- class WiceGridCoreExtTest < Test::Unit::TestCase
7
-
8
- #
9
- # Hash
10
- #
11
-
12
- def test_rec_merge
13
-
14
- # required for will_paginate
15
- # read this - http://err.lighthouseapp.com/projects/466/tickets/197-using-param_name-something-page-leads-to-invalid-behavior
16
-
17
- a_hash = {34 => 12, :key1 => 87, :key2 => {:f => 67} }
18
- b_hash = {34 => 'x', :key3 => 987, :key2 => {:key4 => {:key5 => 0} } }
19
-
20
- assert_equal({:key3 => 987, 34 => "x", :key1 => 87, :key2 => {:key4 => {:key5 => 0}, :f => 67}} , a_hash.rec_merge(b_hash))
21
-
22
- a_hash = {34 => 12, :key1 => 87}
23
- b_hash = {34 => 12}
24
-
25
- assert_equal({34 => 12, :key1 => 87} , a_hash.rec_merge(b_hash))
26
-
27
- a_hash = {34 => { :f => :moo}, :key1 => 87}
28
- b_hash = {34 => { :k => [1,2, { :z => :baz }]}, :key1 => 87}
29
-
30
- assert_equal({34 => { :f => :moo, :k => [1,2, { :z => :baz}]}, :key1 => 87} , a_hash.rec_merge(b_hash))
31
-
32
- end
33
-
34
- def test_hash_make_hash
35
-
36
- assert_equal({}, Hash.make_hash(:key, nil))
37
- assert_equal({}, Hash.make_hash(:key, ''))
38
-
39
- assert_equal({:key => "value"}, Hash.make_hash(:key, "value"))
40
-
41
- end
42
-
43
- def test_hash_deep_clone_yl
44
-
45
- a = {}
46
- b = a.deep_clone_yl
47
- assert_equal a, b
48
- assert_not_same a, b
49
-
50
- a = {'a' => 'b'}
51
- b = a.deep_clone_yl
52
- assert_equal a, b
53
- assert_not_same a, b
54
-
55
- a = {'a' => 'b', 'c' => {'d' => 'e'}}
56
- b = a.deep_clone_yl
57
- assert_equal a, b
58
- assert_equal a['c'], b['c']
59
- assert_not_same a, b
60
- assert_not_same a['c'], b['c']
61
-
62
- end
63
-
64
- def test_hash_add_or_append_class_value_on_empty_hash
65
-
66
- h = {}
67
-
68
- h.add_or_append_class_value!('foo')
69
- assert_equal({:class => 'foo'}, h)
70
-
71
- res = h.add_or_append_class_value!('bar')
72
- assert_equal({:class => 'foo bar'}, h)
73
-
74
- assert_equal(res, h)
75
-
76
- end
77
-
78
- def test_hash_add_or_append_class_value_key_normalization
79
-
80
- h = {'class' => 'foo'}
81
-
82
- h.add_or_append_class_value!('bar')
83
- assert_equal({:class => 'foo bar'}, h)
84
-
85
- end
86
-
87
- def test_hash_parameter_names_and_values
88
-
89
- assert_equal([], {}.parameter_names_and_values)
90
- assert_equal([], {}.parameter_names_and_values(%w(foo)))
91
-
92
-
93
- assert_equal([['a', 'b']], {'a' => 'b'}.parameter_names_and_values)
94
- assert_equal([['a', 'b'], ['c[d]', 'e']], {'a' => 'b', 'c' => {'d' => 'e'}}.parameter_names_and_values)
95
-
96
- assert_equal([['foo[a]', 'b']], {'a' => 'b'}.parameter_names_and_values(%w(foo)))
97
- assert_equal([['foo[a]', 'b'], ['foo[c][d]', 'e']], {'a' => 'b', 'c' => {'d' => 'e'}}.parameter_names_and_values(%w(foo)))
98
-
99
- assert_equal(
100
- [["a[d][e]", 5], ["a[b]", 3], ["a[c]", 4]].sort,
101
- { :a => { :b => 3, :c => 4, :d => { :e => 5 }} }.parameter_names_and_values.sort
102
- )
103
-
104
- assert_equal(
105
- [["foo[baz][a][d][e]", 5], ["foo[baz][a][b]", 3], ["foo[baz][a][c]", 4]].sort,
106
- { :a => { :b => 3, :c => 4, :d => { :e => 5 }} }.parameter_names_and_values(['foo', 'baz']).sort
107
- )
108
-
109
- end
110
-
111
- #
112
- # Enumerable
113
- #
114
-
115
- def test_enumerable_all_items_are_of_class
116
-
117
- assert([].respond_to?(:all_items_are_of_class))
118
- assert({}.respond_to?(:all_items_are_of_class))
119
-
120
- assert_equal false, [].all_items_are_of_class(Object)
121
-
122
- assert_equal true, [1, 2, 3].all_items_are_of_class(Numeric)
123
- assert_equal true, %(one two three).all_items_are_of_class(String)
124
-
125
- assert_equal false, [1, 2, "apple"].all_items_are_of_class(String)
126
- assert_equal false, [1, 2, nil].all_items_are_of_class(String)
127
- assert_equal false, [1, 2.5].all_items_are_of_class(String)
128
-
129
- assert_equal true, [1, 2, "apple"].all_items_are_of_class(Object)
130
-
131
- end
132
-
133
- #
134
- # Object
135
- #
136
-
137
- def test_object_deep_send
138
-
139
- wrapper = Struct.new(:hop)
140
-
141
- z = wrapper.new(123)
142
- y = wrapper.new(z)
143
- x = wrapper.new(y)
144
-
145
- assert_equal x, x.deep_send
146
- assert_equal y, x.deep_send(:hop)
147
- assert_equal z, x.deep_send(:hop, :hop)
148
- assert_equal 123, x.deep_send(:hop, :hop, :hop)
149
-
150
- assert_nil x.deep_send(:non_existing_method)
151
- assert_nil x.deep_send(:hop, :non_existing_method)
152
-
153
- end
154
-
155
-
156
- #
157
- # Array
158
- #
159
-
160
- def test_array_to_parameter_name
161
-
162
- assert_equal '', [].to_parameter_name
163
- assert_equal 'foo', %w(foo).to_parameter_name
164
- assert_equal 'foo[bar]', %w(foo bar).to_parameter_name
165
- assert_equal 'foo[bar][baz]', %w(foo bar baz).to_parameter_name
166
-
167
- end
168
-
169
- #
170
- # ActionView
171
- #
172
-
173
- include ActionView::Helpers::TagHelper
174
-
175
- def test_action_view_tag_options_visibility
176
- assert_nothing_raised {
177
- tag_options({})
178
- }
179
- assert_equal(%! class="foo" style="baz"!, tag_options({:class => 'foo', :style => 'baz'}))
180
- end
181
-
182
-
183
- end