html_tables 0.0.4 → 0.0.5
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 +6 -0
- data/lib/html_tables/data_table_helper.rb +10 -6
- data/lib/html_tables/version.rb +1 -1
- data/lib/html_tables/yielded_object.rb +6 -0
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -82,17 +82,16 @@ module HtmlTables
|
|
82
82
|
end
|
83
83
|
|
84
84
|
v = if opts[:checkbox]
|
85
|
-
checked =
|
85
|
+
checked = opts[:checked]
|
86
86
|
checked = opts[:block].call(item) if opts[:block]
|
87
|
-
|
88
|
-
check_box_tag "#{column}[]", item.id, checked, ck_opts
|
87
|
+
check_box_tag "#{column}[]", item.public_send(opts.fetch(:value_method, :id)), checked, extract_check_box_tag_options(opts)
|
89
88
|
elsif opts[:radio]
|
90
|
-
radio_button_tag "#{column}[]", item.id
|
89
|
+
radio_button_tag "#{column}[]", item.public_send(opts.fetch(:value_method, :id))
|
91
90
|
elsif opts[:block]
|
92
91
|
capture(item, &opts[:block])
|
93
92
|
else
|
94
|
-
tmp = item.
|
95
|
-
tmp = item.
|
93
|
+
tmp = item.public_send(column)
|
94
|
+
tmp = item.public_send("#{column}_text") rescue tmp if tmp.is_a?(Symbol)
|
96
95
|
tmp
|
97
96
|
end
|
98
97
|
|
@@ -115,5 +114,10 @@ module HtmlTables
|
|
115
114
|
|
116
115
|
content_tag(:td, v, td_options)
|
117
116
|
end
|
117
|
+
|
118
|
+
def extract_check_box_tag_options(opts)
|
119
|
+
valid_options = [:disabled]
|
120
|
+
opts.select { |k, _| valid_options.include?(k) }
|
121
|
+
end
|
118
122
|
end
|
119
123
|
end
|
data/lib/html_tables/version.rb
CHANGED
@@ -10,12 +10,18 @@ module HtmlTables
|
|
10
10
|
|
11
11
|
# Adds a checkbox column to the DataTable.
|
12
12
|
# If a block is supplied, it is used to determine the initial state of the checkbox.
|
13
|
+
# @param [Hash] options the checkbox options
|
14
|
+
# @option options [TrueClass,FalseClass] checked the initial state of the checkbox.
|
15
|
+
# @option options [Proc] block a block which will be evaluated to define the initial state of the checkbox.
|
16
|
+
# @option options [String] value_method the method to be called to define the checkbox value. Default = :id
|
13
17
|
def checkbox(id = nil, options = { }, &block)
|
14
18
|
options[:block] = block if block_given?
|
15
19
|
t.columns[id] = options.reverse_merge! checkbox: true, align: :center
|
16
20
|
end
|
17
21
|
|
18
22
|
# Adds a radio button column to the DataTable.
|
23
|
+
# @param [Hash] options the radio options
|
24
|
+
# @option options [String] value_method the method to be called to define the radio value. Default = :id
|
19
25
|
def radio(id = nil, options = { })
|
20
26
|
t.columns[id] = options.reverse_merge! radio: true, align: :center
|
21
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html_tables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: i18n
|