table-for 3.4.1 → 3.5.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +9 -0
- data/app/views/table_for/_table_for.html.erb +1 -1
- data/lib/table_for/base.rb +6 -1
- data/lib/table_for/version.rb +1 -1
- data/spec/integration/table_for_spec.rb +21 -0
- data/table-for.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9751a4f3656971cf37a04524b681722bfc6fcf1
|
4
|
+
data.tar.gz: d77d7951df1fa1f1bd74da3150fb3d6f992fcab3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97340910721e9cda2be1ae4b0f1f5a39eefb55cb5b555d2c222340a17a138376ad15b61da245e7f0b23b295a45dbb1d9c3ba8a72c0523a02961f1990b5652d5d
|
7
|
+
data.tar.gz: d2138119120ae4125872b464f6bc413106a522a8be157e838527b1f269a61380f2a3c948220af5676d5c49e9eb7353de19bd95561234b557db629a1da7c5e00a
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
3.5.0
|
2
|
+
* table_for now keeps track of the current index of the row being render, per
|
3
|
+
suggestion by @jlfy. Example:
|
4
|
+
<%= table_for @users do |table| %>
|
5
|
+
<% table.column :id do |user| %>
|
6
|
+
"User id #{user.id} rendering with row index #{table.current_index}"
|
7
|
+
<% end %>
|
8
|
+
<% end %>
|
9
|
+
|
1
10
|
3.4.1
|
2
11
|
* Fixed bug introduced in version 3.4.0 where link_namespace defined globally
|
3
12
|
on the table_for call was getting completely ignored. Thanks @panyamin for reporting.
|
@@ -36,7 +36,7 @@
|
|
36
36
|
<% end %>
|
37
37
|
|
38
38
|
<% table.define :data_row do |record, options| %>
|
39
|
-
<% table.
|
39
|
+
<% table.set_current_record_and_index(record, options[:current_index]) %>
|
40
40
|
<%= content_tag :tr, table.call_each_hash_value_with_params(options[:data_row_html], record) do %>
|
41
41
|
<%= table.render :data_column, record, :collection => table.columns %>
|
42
42
|
<% end %>
|
data/lib/table_for/base.rb
CHANGED
@@ -8,6 +8,10 @@ module TableFor
|
|
8
8
|
attr_accessor :current_record
|
9
9
|
alias_method :current_row, :current_record
|
10
10
|
|
11
|
+
attr_accessor :current_index
|
12
|
+
alias_method :current_row_index, :current_index
|
13
|
+
|
14
|
+
|
11
15
|
def initialize(view, options={})
|
12
16
|
super(view, TableFor.config.merge(options))
|
13
17
|
end
|
@@ -92,8 +96,9 @@ module TableFor
|
|
92
96
|
end
|
93
97
|
end
|
94
98
|
|
95
|
-
def
|
99
|
+
def set_current_record_and_index(record, index)
|
96
100
|
self.current_record = record
|
101
|
+
self.current_index = index
|
97
102
|
end
|
98
103
|
|
99
104
|
def header_sort_link(column, options={}, &block)
|
data/lib/table_for/version.rb
CHANGED
@@ -529,6 +529,17 @@ describe "table_for" do
|
|
529
529
|
</table>%)
|
530
530
|
XmlSimple.xml_in(buffer, 'NormaliseSpace' => 2).should eql xml
|
531
531
|
end
|
532
|
+
|
533
|
+
it "should be able to use the table's current_index in a cell's data_column_html" do
|
534
|
+
buffer = @view.table_for @users do |table|
|
535
|
+
table.column :id, data_column_html: {
|
536
|
+
class: lambda { |record| "column-for-row-#{table.current_index}"
|
537
|
+
}
|
538
|
+
}
|
539
|
+
end
|
540
|
+
html_includes?(buffer, "<td class='column-for-row-0'>1</td>")
|
541
|
+
html_includes?(buffer, "<td class='column-for-row-1'>2</td>")
|
542
|
+
end
|
532
543
|
end
|
533
544
|
|
534
545
|
describe "column data contents block" do
|
@@ -541,6 +552,16 @@ describe "table_for" do
|
|
541
552
|
end
|
542
553
|
end
|
543
554
|
|
555
|
+
it "should be able to use the table's current_index in the content of a cell" do
|
556
|
+
buffer = @view.table_for @users do |table|
|
557
|
+
table.column :id do |user|
|
558
|
+
"User id #{user.id} rendering with row index #{table.current_index}"
|
559
|
+
end
|
560
|
+
end
|
561
|
+
html_includes?(buffer, "User id 1 rendering with row index 0")
|
562
|
+
html_includes?(buffer, "User id 2 rendering with row index 1")
|
563
|
+
end
|
564
|
+
|
544
565
|
it "should allow a link_url proc to render a link surrounding a table cell's content" do
|
545
566
|
buffer = @view.table_for @users do |table|
|
546
567
|
table.column :email, link_url: lambda {|user| "/admin/users/#{user.id}"}
|
data/table-for.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency "rails", ">= 3.0.0"
|
22
|
-
spec.add_dependency "with_template", "~> 0.
|
22
|
+
spec.add_dependency "with_template", "~> 0.2.0"
|
23
23
|
|
24
24
|
spec.add_development_dependency "rspec-rails", ">= 2.0.0.beta.20"
|
25
25
|
spec.add_development_dependency "mocha", "0.10.3"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: table-for
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Hunter
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.2.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.2.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec-rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|