table_help 0.1.7 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/table_help/table_for.rb +17 -6
- data/lib/table_help/version.rb +1 -1
- data/spec/fake_app/log/development.log +16 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83bae016ff083d16a91ed0fad825fc5101d6e3fbf077e5ce3119292ef4892f02
|
4
|
+
data.tar.gz: c564ba4d849a4d873deb048e42364cfea7aef495bfea2fdc35fb45bbe6898987
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a3c5a0ce4c1a1ff8471b33af2a4538a86c74aa45246486b05a9536029714a0e1aea69c1cde704f676e5bfd1ff639fd474acdf63c6d6b084e714f35273595d97
|
7
|
+
data.tar.gz: 822e84442656dda89a3d9f1b310185dcef248da15e0c18f4cf97dacc05ffecaa622c6a2f97e342ed95cf56feabfcce979ae378dbef8d30216e6c83423df8c996
|
data/lib/table_help/table_for.rb
CHANGED
@@ -1,18 +1,21 @@
|
|
1
1
|
module TableHelp
|
2
2
|
class TableFor
|
3
|
-
|
4
|
-
|
3
|
+
Column = Struct.new(:name, :human_name)
|
4
|
+
|
5
|
+
attr_reader :collection, :context, :options, :columns, :strategies, :q
|
6
|
+
delegate :concat, :capture, :tag, :sort_link, to: :context
|
5
7
|
|
6
8
|
def initialize(collection, context, options = {})
|
7
9
|
@collection = collection
|
8
10
|
@context = context
|
9
11
|
@options = default_options.merge(options)
|
10
|
-
@
|
12
|
+
@columns = []
|
11
13
|
@strategies = []
|
14
|
+
@q = @options.delete(:q)
|
12
15
|
end
|
13
16
|
|
14
17
|
def column(name = nil, method_name = nil, &block)
|
15
|
-
|
18
|
+
columns << Column.new(name, Formatter.format_attribute_name(name, collection))
|
16
19
|
strategies << Strategy.new(name, block_given? ? block : method_name)
|
17
20
|
end
|
18
21
|
|
@@ -30,13 +33,21 @@ module TableHelp
|
|
30
33
|
def thead
|
31
34
|
tag.thead do
|
32
35
|
tag.tr do
|
33
|
-
|
34
|
-
|
36
|
+
columns.each do |column|
|
37
|
+
if sortable?
|
38
|
+
concat tag.th(sort_link(q, column.name, column.human_name))
|
39
|
+
else
|
40
|
+
concat tag.th(column.human_name)
|
41
|
+
end
|
35
42
|
end
|
36
43
|
end
|
37
44
|
end
|
38
45
|
end
|
39
46
|
|
47
|
+
def sortable?
|
48
|
+
!q.nil? && respond_to?(:sort_link)
|
49
|
+
end
|
50
|
+
|
40
51
|
def tbody
|
41
52
|
tag.tbody do
|
42
53
|
collection.each do |record|
|
data/lib/table_help/version.rb
CHANGED
@@ -818,3 +818,19 @@ Processing by ArticlesController#show as HTML
|
|
818
818
|
Completed 200 OK in 18ms (Views: 12.5ms)
|
819
819
|
|
820
820
|
|
821
|
+
DEPRECATION WARNING: You didn't set `secret_key_base`. Read the upgrade documentation to learn more about this new config option. (called from block (3 levels) in <top (required)> at /Users/yhirano/dev/src/github.com/yhirano55/table_help/spec/table_help_spec.rb:14)
|
822
|
+
Started GET "/articles" for 127.0.0.1 at 2018-06-15 18:09:49 +0900
|
823
|
+
Processing by ArticlesController#index as HTML
|
824
|
+
Rendering articles/index.html.erb
|
825
|
+
Rendered articles/index.html.erb (4.5ms)
|
826
|
+
Completed 200 OK in 19ms (Views: 17.2ms)
|
827
|
+
|
828
|
+
|
829
|
+
Started GET "/articles/5" for 127.0.0.1 at 2018-06-15 18:09:49 +0900
|
830
|
+
Processing by ArticlesController#show as HTML
|
831
|
+
Parameters: {"id"=>"5"}
|
832
|
+
Rendering articles/show.html.erb
|
833
|
+
Rendered articles/show.html.erb (1.7ms)
|
834
|
+
Completed 200 OK in 19ms (Views: 12.2ms)
|
835
|
+
|
836
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: table_help
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshiyuki Hirano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
87
|
rubyforge_project:
|
88
|
-
rubygems_version: 2.7.
|
88
|
+
rubygems_version: 2.7.6
|
89
89
|
signing_key:
|
90
90
|
specification_version: 4
|
91
91
|
summary: Provide helper methods to build collection or resource tables for Rails 5
|