table_for 0.0.3 → 0.0.4
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/README.rdoc +1 -1
- data/lib/table_for.rb +16 -1
- data/lib/table_for/table_builder.rb +6 -9
- data/lib/table_for/version.rb +1 -1
- data/spec/spec_helper.rb +2 -3
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -37,7 +37,7 @@ Or:
|
|
37
37
|
<% end %>
|
38
38
|
<% end %>
|
39
39
|
|
40
|
-
The footer
|
40
|
+
The footer and rows can be filtered out through the TableFor.footer_filter/row_filter methods.
|
41
41
|
|
42
42
|
== Credits and contributors
|
43
43
|
|
data/lib/table_for.rb
CHANGED
@@ -4,4 +4,19 @@ module TableFor
|
|
4
4
|
autoload :Table, 'table_for/table'
|
5
5
|
autoload :TableBuilder, 'table_for/table_builder'
|
6
6
|
autoload :RowBuilder, 'table_for/row_builder'
|
7
|
-
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def footer_filter(&block)
|
10
|
+
@footer_filter = block if block
|
11
|
+
@footer_filter
|
12
|
+
end
|
13
|
+
|
14
|
+
def row_filter(&block)
|
15
|
+
@row_filter = block if block
|
16
|
+
@row_filter
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
TableFor.footer_filter { |table| true }
|
22
|
+
TableFor.row_filter { |table, record| true }
|
@@ -20,15 +20,17 @@ module TableFor
|
|
20
20
|
def body(*columns, &block)
|
21
21
|
content_tag(:tbody) do
|
22
22
|
table.row_builders.map do |builder|
|
23
|
-
|
24
|
-
|
23
|
+
if TableFor.row_filter.call(table, builder.record)
|
24
|
+
content_tag(:tr) do
|
25
|
+
if block then capture(builder, &block) else builder.cells(*columns) end
|
26
|
+
end
|
25
27
|
end
|
26
|
-
end.join.html_safe
|
28
|
+
end.compact.join.html_safe
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
30
32
|
def foot(&block)
|
31
|
-
if
|
33
|
+
if TableFor.footer_filter.call(table)
|
32
34
|
content_tag(:tfoot) do
|
33
35
|
content_tag(:tr) do
|
34
36
|
content_tag(:td, capture(&block), :colspan => table.columns.size)
|
@@ -36,10 +38,5 @@ module TableFor
|
|
36
38
|
end.html_safe
|
37
39
|
end
|
38
40
|
end
|
39
|
-
|
40
|
-
def admin?
|
41
|
-
return true unless template.respond_to?(:admin?)
|
42
|
-
template.admin?
|
43
|
-
end
|
44
41
|
end
|
45
42
|
end
|
data/lib/table_for/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -6,6 +6,5 @@ require 'rails'
|
|
6
6
|
require 'rubygems'
|
7
7
|
require 'bundler/setup'
|
8
8
|
require "rails/test_help"
|
9
|
-
|
10
|
-
|
11
|
-
Dir["#{File.expand_path(File.dirname(__FILE__))}/support/*.rb"].each {|f| require(f) }
|
9
|
+
require 'table_for'
|
10
|
+
require 'support/user'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: table_for
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Nicklas Ramh\xC3\xB6j"
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date:
|
19
|
+
date: 2011-03-01 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|