simple_table 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- # options[:id] = dom_id(record) if record.respond_to?(:new_record?)
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
@@ -8,6 +8,7 @@ module SimpleTable
8
8
  @value = options.delete(:value)
9
9
  @options = options.dup || {}
10
10
  @options[:class] ||= name
11
+ @options[:id] ||= "#{name.to_s.downcase}_header" if name
11
12
  end
12
13
 
13
14
  def content
@@ -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
- add_class!(options, current_column_class) if parent.is_a?(Body)
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module SimpleTable
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
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: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
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-08-03 00:00:00 +02:00
19
+ date: 2010-10-17 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency