simple_table 0.0.5 → 0.0.6
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/lib/simple_table/body.rb +1 -1
- data/lib/simple_table/column.rb +1 -0
- data/lib/simple_table/row.rb +10 -2
- data/lib/simple_table/tag.rb +7 -0
- data/lib/simple_table/version.rb +1 -1
- metadata +4 -4
data/lib/simple_table/body.rb
CHANGED
@@ -18,7 +18,7 @@ module SimpleTable
|
|
18
18
|
|
19
19
|
def options_for_record(record, ix, options = {})
|
20
20
|
options.dup.tap do |options|
|
21
|
-
|
21
|
+
options[:id] = "#{table.collection_name.singularize}_#{record.id}" #dom_id(record) if record.respond_to?(:new_record?)
|
22
22
|
add_class!(options, 'alternate') if ix % 2 == 1
|
23
23
|
end
|
24
24
|
end
|
data/lib/simple_table/column.rb
CHANGED
data/lib/simple_table/row.rb
CHANGED
@@ -2,7 +2,7 @@ module SimpleTable
|
|
2
2
|
class Row < Tag
|
3
3
|
self.level = 2
|
4
4
|
self.tag_name = :tr
|
5
|
-
|
5
|
+
|
6
6
|
attr_reader :cells
|
7
7
|
|
8
8
|
def initialize(parent, record = nil, options = {}, &block)
|
@@ -17,7 +17,10 @@ module SimpleTable
|
|
17
17
|
|
18
18
|
def cell(*contents)
|
19
19
|
options = contents.last.is_a?(Hash) ? contents.pop : {}
|
20
|
-
|
20
|
+
if parent.is_a?(Body)
|
21
|
+
add_class!(options, current_column_class)
|
22
|
+
add_header!(options, current_column_id)
|
23
|
+
end
|
21
24
|
contents.each do |content|
|
22
25
|
cells << Cell.new(self, content, options)
|
23
26
|
end
|
@@ -38,5 +41,10 @@ module SimpleTable
|
|
38
41
|
column = table.columns[cells.size]
|
39
42
|
column && column.options[:class] || ''
|
40
43
|
end
|
44
|
+
|
45
|
+
def current_column_id
|
46
|
+
column = table.columns[cells.size]
|
47
|
+
column && column.options[:id] || ''
|
48
|
+
end
|
41
49
|
end
|
42
50
|
end
|
data/lib/simple_table/tag.rb
CHANGED
@@ -54,5 +54,12 @@ module SimpleTable
|
|
54
54
|
options[:class] = options[:class].split(' ').push(klass).join(' ')
|
55
55
|
end
|
56
56
|
end
|
57
|
+
|
58
|
+
def add_header!(options, headers)
|
59
|
+
unless headers.blank?
|
60
|
+
options[:headers] ||= ''
|
61
|
+
options[:headers] = options[:headers].split(' ').push(headers).join(' ')
|
62
|
+
end
|
63
|
+
end
|
57
64
|
end
|
58
65
|
end
|
data/lib/simple_table/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_table
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 6
|
10
|
+
version: 0.0.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sven Fuchs
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-
|
19
|
+
date: 2010-10-17 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|