rails_table_for 0.2.1 → 0.2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/lib/rails_table_for.rb +1 -1
- data/lib/rails_table_for/elements/block_column.rb +4 -4
- data/lib/rails_table_for/elements/column.rb +6 -2
- data/lib/rails_table_for/elements/field_column.rb +4 -4
- data/lib/rails_table_for/elements/table.rb +2 -2
- data/lib/rails_table_for/table_helper.rb +21 -0
- data/lib/rails_table_for/version.rb +1 -1
- metadata +4 -3
- data/lib/rails_table_for/action_view_ext.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 155237f1a1d730b42f5163e83f94f851b333abb4629337028eb46921fdb803ea
|
4
|
+
data.tar.gz: de618efd0f8849900c52e83db411a7960c12039cfc9e1e5437cc427e4cee7a44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a936961884260f6ffed048e9838fa08b1b089903b5a8d6e81618076215452579e73400025f863ca97aebc3c95669eda880ede96e209b62d91cde3b93ceae4073
|
7
|
+
data.tar.gz: 23f1e6a33f112248ca84233af07fcdc815857e348b86a1183cb5bc72b332ae295da34ce229fca428eae3000625cc380b7d541eeb6576c2c5c681a42e35043e47
|
data/CHANGELOG.md
ADDED
data/Gemfile.lock
CHANGED
data/lib/rails_table_for.rb
CHANGED
@@ -3,8 +3,7 @@ require 'rails_table_for/elements/column'
|
|
3
3
|
|
4
4
|
module Elements
|
5
5
|
class BlockColumn < Column
|
6
|
-
include Helpers::AutoLink
|
7
|
-
attr_reader :title
|
6
|
+
include Helpers::AutoLink, ActionView::Helpers::TagHelper
|
8
7
|
|
9
8
|
def initialize(block, **options)
|
10
9
|
@block = block
|
@@ -12,9 +11,10 @@ module Elements
|
|
12
11
|
@auto_link = options[:auto_link] || false
|
13
12
|
end
|
14
13
|
|
15
|
-
def
|
14
|
+
def td(record)
|
16
15
|
text = @block.call(record)
|
17
|
-
@auto_link ? auto_link(record, text) : text
|
16
|
+
content = @auto_link ? auto_link(record, text) : text
|
17
|
+
content_tag :td, content
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -3,8 +3,7 @@ require 'rails_table_for/elements/column'
|
|
3
3
|
|
4
4
|
module Elements
|
5
5
|
class FieldColumn < Column
|
6
|
-
include Helpers::AutoLink
|
7
|
-
attr_reader :title
|
6
|
+
include Helpers::AutoLink, ActionView::Helpers::TagHelper
|
8
7
|
|
9
8
|
def initialize(field, **options)
|
10
9
|
if field.nil?
|
@@ -15,9 +14,10 @@ module Elements
|
|
15
14
|
@auto_link = options[:auto_link] || false
|
16
15
|
end
|
17
16
|
|
18
|
-
def
|
17
|
+
def td(record)
|
19
18
|
text = record.send(@field)
|
20
|
-
@auto_link ? auto_link(record, text) : text
|
19
|
+
content = @auto_link ? auto_link(record, text) : text
|
20
|
+
content_tag :td, content
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -43,7 +43,7 @@ module Elements
|
|
43
43
|
def head
|
44
44
|
content_tag :thead do
|
45
45
|
content_tag :tr do
|
46
|
-
@columns.map
|
46
|
+
@columns.map(&:th).join.html_safe
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -56,7 +56,7 @@ module Elements
|
|
56
56
|
|
57
57
|
def body_row(record)
|
58
58
|
content_tag :tr do
|
59
|
-
@columns.map {|column|
|
59
|
+
@columns.map {|column| column.td(record) }.join.html_safe
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rails_table_for/elements/table'
|
2
|
+
|
3
|
+
module TableHelper
|
4
|
+
include ActionView::Helpers::TagHelper
|
5
|
+
|
6
|
+
def table_for(records, **options)
|
7
|
+
options.merge({
|
8
|
+
request_url: request.original_url,
|
9
|
+
request_params: request.params
|
10
|
+
})
|
11
|
+
table = Elements::Table.new(options)
|
12
|
+
if block_given?
|
13
|
+
yield table
|
14
|
+
end
|
15
|
+
table.build(records)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
ActionView::Base.class_eval do
|
20
|
+
include TableHelper
|
21
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_table_for
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Austin Roos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -164,6 +164,7 @@ files:
|
|
164
164
|
- ".github/ISSUE_TEMPLATE/new-user-story.md"
|
165
165
|
- ".github/workflows/tests.yml"
|
166
166
|
- ".gitignore"
|
167
|
+
- CHANGELOG.md
|
167
168
|
- Gemfile
|
168
169
|
- Gemfile.lock
|
169
170
|
- LICENSE
|
@@ -177,13 +178,13 @@ files:
|
|
177
178
|
- docs/_config.yml
|
178
179
|
- docs/index.md
|
179
180
|
- lib/rails_table_for.rb
|
180
|
-
- lib/rails_table_for/action_view_ext.rb
|
181
181
|
- lib/rails_table_for/elements/block_column.rb
|
182
182
|
- lib/rails_table_for/elements/column.rb
|
183
183
|
- lib/rails_table_for/elements/field_column.rb
|
184
184
|
- lib/rails_table_for/elements/table.rb
|
185
185
|
- lib/rails_table_for/helpers/auto_link.rb
|
186
186
|
- lib/rails_table_for/railtie.rb
|
187
|
+
- lib/rails_table_for/table_helper.rb
|
187
188
|
- lib/rails_table_for/version.rb
|
188
189
|
- lib/tasks/rails_table_for_tasks.rake
|
189
190
|
- rails_table_for.gemspec
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'rails_table_for/elements/table'
|
2
|
-
|
3
|
-
module TableHelper
|
4
|
-
include ActionView::Helpers::TagHelper
|
5
|
-
|
6
|
-
def table_for(records, **options)
|
7
|
-
def table_for(records, **options)
|
8
|
-
table = Elements::Table.new(options)
|
9
|
-
if block_given?
|
10
|
-
yield table
|
11
|
-
end
|
12
|
-
table.build(records)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
ActionView::Base.class_eval do
|
18
|
-
include TableHelper
|
19
|
-
end
|