tabulatr 0.1.0 → 0.1.1

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.
data/Changelog.textile CHANGED
@@ -1,5 +1,20 @@
1
1
  h1. Changelog for tabulatr
2
2
 
3
+ h2. 0.1.1
4
+
5
+ * Fixed bug with "Select ..." buttons introduced in 0.1.0.
6
+ * Added tests for these buttons.
7
+
8
+ h2. v0.1.0
9
+
10
+ * new <tt>find_for_table</tt> option <tt>:stateful</tt>. If
11
+
12
+ <pre>
13
+ MyFancyModel.find_for_table params, :stateful => session
14
+ </pre>
15
+
16
+ is given, the current sorting, filtering, selecting and paging information is stored to the session and restored when reopened. Great for procession specifically filtered lists.
17
+
3
18
  h2. v0.0.5 (2011-03-28)
4
19
 
5
20
  * new column option :map (defaults to true) to disable automatic mapping on the enries of the association as in
data/Gemfile.lock CHANGED
@@ -36,7 +36,6 @@ GEM
36
36
  activemodel (= 3.0.5)
37
37
  activesupport (= 3.0.5)
38
38
  activesupport (3.0.5)
39
- archive-tar-minitar (0.5.2)
40
39
  arel (2.0.9)
41
40
  builder (2.1.2)
42
41
  capybara (0.4.1.2)
@@ -66,8 +65,7 @@ GEM
66
65
  launchy (0.4.0)
67
66
  configuration (>= 0.0.5)
68
67
  rake (>= 0.8.1)
69
- linecache19 (0.5.11)
70
- ruby_core_source (>= 0.1.4)
68
+ linecache (0.43)
71
69
  mail (2.2.15)
72
70
  activesupport (>= 2.3.6)
73
71
  i18n (>= 0.4.0)
@@ -108,16 +106,11 @@ GEM
108
106
  activesupport (~> 3.0)
109
107
  railties (~> 3.0)
110
108
  rspec (~> 2.5.0)
111
- ruby-debug-base19 (0.11.24)
112
- columnize (>= 0.3.1)
113
- linecache19 (>= 0.5.11)
114
- ruby_core_source (>= 0.1.4)
115
- ruby-debug19 (0.11.6)
116
- columnize (>= 0.3.1)
117
- linecache19 (>= 0.5.11)
118
- ruby-debug-base19 (>= 0.11.19)
119
- ruby_core_source (0.1.4)
120
- archive-tar-minitar (>= 0.5.2)
109
+ ruby-debug (0.10.4)
110
+ columnize (>= 0.1)
111
+ ruby-debug-base (~> 0.10.4.0)
112
+ ruby-debug-base (0.10.4)
113
+ linecache (>= 0.3)
121
114
  rubyzip (0.9.4)
122
115
  selenium-webdriver (0.1.4)
123
116
  childprocess (>= 0.1.7)
@@ -144,6 +137,6 @@ DEPENDENCIES
144
137
  launchy
145
138
  rspec
146
139
  rspec-rails
147
- ruby-debug19
140
+ ruby-debug
148
141
  sqlite3-ruby
149
142
  tabulatr!
data/README.textile CHANGED
@@ -1,5 +1,7 @@
1
1
  h1. Tabulatr - Index Tables made easy, finally
2
2
 
3
+ (there is a <a href="https://github.com/provideal/tabulatr-demo">demo app repository</a>)
4
+
3
5
  h2. Mission Objective
4
6
 
5
7
  Tabulatr aims at making the ever-recurring task of creating listings of ActiveRecord models simple and uniform.
@@ -52,7 +52,6 @@ module Tabulatr::Finder
52
52
  filter_name = "#{cname}#{form_options[:filter_postfix]}"
53
53
  batch_name = "#{cname}#{form_options[:batch_postfix]}"
54
54
  check_name = "#{cname}#{form_options[:checked_postfix]}"
55
-
56
55
 
57
56
  # before we do anything else, we find whether there's something to do for batch actions
58
57
  checked_param = ActiveSupport::HashWithIndifferentAccess.new({:checked_ids => '', :current_page => []}).
@@ -67,6 +66,7 @@ module Tabulatr::Finder
67
66
  end
68
67
 
69
68
  # then, we obey any "select" buttons if pushed
69
+ precondition = opts[:precondition] || "(1=1)"
70
70
  if checked_param[:select_all]
71
71
  all = klaz.find :all, :conditions => precondition, :select => :id
72
72
  selected_ids = all.map { |r| r.id.to_s }
@@ -78,14 +78,8 @@ module Tabulatr::Finder
78
78
  elsif checked_param[:unselect_visible]
79
79
  visible_ids = uncompress_id_list(checked_param[:visible])
80
80
  selected_ids = (selected_ids - visible_ids).sort.uniq
81
- elsif checked_param[:select_filtered]
82
- all = klaz.find :all, :conditions => conditions, :select => :id, :include => includes
83
- selected_ids = (selected_ids + all.map { |r| r.id.to_s }).sort.uniq
84
- elsif checked_param[:unselect_filtered]
85
- all = klaz.find :all, :conditions => conditions, :select => :id, :include => includes
86
- selected_ids = (selected_ids - all.map { |r| r.id.to_s }).sort.uniq
87
81
  end
88
-
82
+
89
83
  # at this point, we've retrieved the filter settings, the sorting setting, the pagination settings and
90
84
  # the selected_ids.
91
85
  filter_param = (params[filter_name] || {})
@@ -144,6 +138,15 @@ module Tabulatr::Finder
144
138
  end
145
139
  conditions = [conditions.first] + conditions.last
146
140
 
141
+ # more button handling
142
+ if checked_param[:select_filtered]
143
+ all = klaz.find :all, :conditions => conditions, :select => :id, :include => includes
144
+ selected_ids = (selected_ids + all.map { |r| r.id.to_s }).sort.uniq
145
+ elsif checked_param[:unselect_filtered]
146
+ all = klaz.find :all, :conditions => conditions, :select => :id, :include => includes
147
+ selected_ids = (selected_ids - all.map { |r| r.id.to_s }).sort.uniq
148
+ end
149
+
147
150
  # secondly, find the order_by stuff
148
151
  if sortparam
149
152
  if sortparam[:_resort]
@@ -1,3 +1,3 @@
1
1
  class Tabulatr
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  <%= table_for @products, :batch_actions => {'delete' => "Delete"} do |t|
2
2
  t.checkbox
3
3
  t.column :id
4
- t.column :title
4
+ t.column :title, :filter => :like
5
5
  t.column :price
6
6
  end %>
@@ -26,7 +26,7 @@ describe "Tabulatrs" do
26
26
  # Statful
27
27
  SORTS_STATEFULLY = FILTERS_STATEFULLY = SELECTS_STATEFULLY = true
28
28
  # selecting and batch actions
29
- KNOWS_HOW_TO_SELECT_AND_APPLY_BATCH_ACTIONS = tralse
29
+ SELECT_BUTTONS_WORK = KNOWS_HOW_TO_SELECT_AND_APPLY_BATCH_ACTIONS = tralse
30
30
 
31
31
  vendor1 = Vendor.create!(:name => "ven d'or", :active => true)
32
32
  vendor2 = Vendor.create!(:name => 'producer', :active => true)
@@ -300,8 +300,46 @@ describe "Tabulatrs" do
300
300
 
301
301
  end
302
302
 
303
-
304
303
  describe "Select and Batch actions" do
304
+ it "knows how to interpret the select_... buttons" do
305
+ # Showing 10, total 54, selected 54, matching 54
306
+ n = names.length
307
+ visit index_select_products_path
308
+ click_button('Select All')
309
+ page.should have_content(sprintf(Tabulatr::TABLE_OPTIONS[:info_text], 10, n, n, n))
310
+ click_button('Select None')
311
+ page.should have_content(sprintf(Tabulatr::TABLE_OPTIONS[:info_text], 10, n, 0, n))
312
+ click_button('Select visible')
313
+ page.should have_content(sprintf(Tabulatr::TABLE_OPTIONS[:info_text], 10, n, 10, n))
314
+ click_button('Select None')
315
+ page.should have_content(sprintf(Tabulatr::TABLE_OPTIONS[:info_text], 10, n, 0, n))
316
+ fill_in("product_filter[title][like]", :with => "a")
317
+ click_button("Apply")
318
+ tot = (names.select do |s| s.match /a/ end).length
319
+ page.should have_content(sprintf(Tabulatr::TABLE_OPTIONS[:info_text], 10, n, 0, tot))
320
+ click_button('Select filtered')
321
+ page.should have_content(sprintf(Tabulatr::TABLE_OPTIONS[:info_text], 10, n, tot, tot))
322
+ fill_in("product_filter[title][like]", :with => "")
323
+ click_button("Apply")
324
+ page.should have_content(sprintf(Tabulatr::TABLE_OPTIONS[:info_text], 10, n, tot, n))
325
+ click_button("Unselect visible")
326
+ tot -= (names[0..9].select do |s| s.match /a/ end).length
327
+ page.should have_content(sprintf(Tabulatr::TABLE_OPTIONS[:info_text], 10, n, tot, n))
328
+ click_button('Select None')
329
+ page.should have_content(sprintf(Tabulatr::TABLE_OPTIONS[:info_text], 10, n, 0, n))
330
+ click_button('Select All')
331
+ page.should have_content(sprintf(Tabulatr::TABLE_OPTIONS[:info_text], 10, n, n, n))
332
+ fill_in("product_filter[title][like]", :with => "a")
333
+ click_button("Apply")
334
+ tot = (names.select do |s| s.match /a/ end).length
335
+ page.should have_content(sprintf(Tabulatr::TABLE_OPTIONS[:info_text], 10, n, n, tot))
336
+ click_button('Unselect filtered')
337
+ page.should have_content(sprintf(Tabulatr::TABLE_OPTIONS[:info_text], 10, n, n-tot, tot))
338
+ fill_in("product_filter[title][like]", :with => "")
339
+ click_button("Apply")
340
+ page.should have_content(sprintf(Tabulatr::TABLE_OPTIONS[:info_text], 10, n, n-tot, n))
341
+ end if SELECT_BUTTONS_WORK
342
+
305
343
  it "knows how to select and apply batch actions" do
306
344
  visit index_select_products_path
307
345
  n = names.length
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tabulatr
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 25
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 1
8
- - 0
9
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Peter Horn
@@ -15,7 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-03-29 00:00:00 +02:00
19
+ date: 2011-03-30 00:00:00 +02:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
@@ -26,6 +27,7 @@ dependencies:
26
27
  requirements:
27
28
  - - ~>
28
29
  - !ruby/object:Gem::Version
30
+ hash: 7
29
31
  segments:
30
32
  - 3
31
33
  - 0
@@ -40,6 +42,7 @@ dependencies:
40
42
  requirements:
41
43
  - - ">="
42
44
  - !ruby/object:Gem::Version
45
+ hash: 27
43
46
  segments:
44
47
  - 0
45
48
  - 0
@@ -55,6 +58,7 @@ dependencies:
55
58
  requirements:
56
59
  - - ">="
57
60
  - !ruby/object:Gem::Version
61
+ hash: 29
58
62
  segments:
59
63
  - 0
60
64
  - 0
@@ -201,6 +205,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
201
205
  requirements:
202
206
  - - ">="
203
207
  - !ruby/object:Gem::Version
208
+ hash: 3
204
209
  segments:
205
210
  - 0
206
211
  version: "0"
@@ -209,13 +214,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
214
  requirements:
210
215
  - - ">="
211
216
  - !ruby/object:Gem::Version
217
+ hash: 3
212
218
  segments:
213
219
  - 0
214
220
  version: "0"
215
221
  requirements: []
216
222
 
217
223
  rubyforge_project: tabulatr
218
- rubygems_version: 1.3.7
224
+ rubygems_version: 1.6.2
219
225
  signing_key:
220
226
  specification_version: 3
221
227
  summary: A tight DSL to build tables of ActiveRecord models with sorting, pagination, finding/filtering, selecting and batch actions.