cheveret 1.1.1 → 1.1.2
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.md +2 -0
- data/VERSION +1 -1
- data/cheveret.gemspec +1 -1
- data/lib/cheveret.rb +6 -3
- metadata +3 -3
data/README.md
CHANGED
@@ -96,6 +96,8 @@ Todo
|
|
96
96
|
* Make the documentation tell fewer lies
|
97
97
|
* Support i18n translations for table headers
|
98
98
|
* Handle exceeding table width, drop columns
|
99
|
+
* Better support for ActiveRecord model objects
|
100
|
+
* Write some tests
|
99
101
|
|
100
102
|
Note on Patches/Pull Requests
|
101
103
|
-----------------------------
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.2
|
data/cheveret.gemspec
CHANGED
data/lib/cheveret.rb
CHANGED
@@ -27,8 +27,9 @@ module Cheveret
|
|
27
27
|
class Table
|
28
28
|
attr_accessor :columns
|
29
29
|
|
30
|
-
def initialize()
|
30
|
+
def initialize(&block)
|
31
31
|
@columns = ::ActiveSupport::OrderedHash.new
|
32
|
+
yield self if block_given?
|
32
33
|
end
|
33
34
|
|
34
35
|
def columns(*args, &block)
|
@@ -155,7 +156,7 @@ module Cheveret
|
|
155
156
|
# view helper that facilities the rendering of tables for a collection of similar
|
156
157
|
# objects
|
157
158
|
#
|
158
|
-
# behaves much in the same way as Rails +
|
159
|
+
# behaves much in the same way as Rails +form_for+ helper in that it takes a proc
|
159
160
|
# and provides access to a table builder object. the entire block is captured, so
|
160
161
|
# additional markup can be output at any point
|
161
162
|
#
|
@@ -169,13 +170,15 @@ module Cheveret
|
|
169
170
|
# * <tt>:width</tt> - the total width of the table in pixels
|
170
171
|
# * <tt>:html</tt> - a hash of html attributes used for the form container
|
171
172
|
# * <tt>:url</tt> - used to generate urls for sortable columns
|
173
|
+
# * <tt>:table</tt> - specify a pre-configured table to render
|
172
174
|
#
|
173
175
|
# === Examples
|
174
176
|
def table_for(collection, options={}, &block)
|
175
177
|
builder = options.delete(:builder) || ActionView::Base.default_table_builder
|
178
|
+
table = options.delete(:table) || Table.new
|
176
179
|
|
177
180
|
options.merge!({ :collection => collection })
|
178
|
-
builder.render(
|
181
|
+
builder.render(table, self, options, &block)
|
179
182
|
end
|
180
183
|
|
181
184
|
# the default #TableBuilder class generates an HTML table using div tags
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cheveret
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 2
|
10
|
+
version: 1.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ben Caldwell
|