action_table 0.3.0 → 0.4.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 +5 -5
- data/CHANGELOG.md +4 -0
- data/lib/action_table/helper.rb +3 -3
- data/lib/action_table/version.rb +1 -1
- data/lib/action_table/view.rb +25 -11
- data/lib/action_table/views/action_table/_table.html.erb +2 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 78aecafe799ebdad113b9a962e1e4e92bca747d9
|
4
|
+
data.tar.gz: f4e741f5003ec2434df34891ba9f5fb394edbddf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e02d126244c84e84129c5740c1253ea9fed1e900ae8007d9fe4735ea3cf460d2394b5bc60b21195a54fdeda7eafa6a36cb49e4ebb4d696cd7c0760a862d4520a
|
7
|
+
data.tar.gz: 34e256d1887e30cfbac9617148375e3b9ebd1cc2c5b8eb07b2d1188dd8fad074e8a177aa9423369f2b50abfac147a707be8008717348d90f75ac2e470c99b814
|
data/CHANGELOG.md
CHANGED
data/lib/action_table/helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'action_table/bootstrap_styles'
|
4
4
|
require 'action_table/view'
|
5
5
|
|
6
6
|
module ActionTable
|
@@ -33,10 +33,10 @@ module ActionTable
|
|
33
33
|
paginate: paginate,
|
34
34
|
links: links,
|
35
35
|
actions: actions,
|
36
|
-
styles: styles,
|
37
36
|
)
|
38
37
|
|
39
|
-
|
38
|
+
styles = BootstrapStyles.new(styles)
|
39
|
+
render('action_table/table', table: action_table, styles: styles)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
data/lib/action_table/version.rb
CHANGED
data/lib/action_table/view.rb
CHANGED
@@ -1,31 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'set'
|
4
|
-
require 'action_table/bootstrap_styles'
|
5
4
|
|
6
5
|
module ActionTable
|
7
6
|
class View
|
8
7
|
include ActionView::Helpers::UrlHelper
|
9
8
|
include ActionTable.config.rails_host_app.routes.url_helpers
|
10
9
|
|
11
|
-
attr_reader :
|
10
|
+
attr_reader :rows
|
12
11
|
|
13
12
|
def initialize(
|
14
13
|
columns:,
|
15
14
|
records:,
|
16
15
|
paginate: false,
|
17
16
|
links: ActionTable.config.links,
|
18
|
-
actions: ActionTable.config.actions
|
19
|
-
styles: ActionTable.config.styles
|
17
|
+
actions: ActionTable.config.actions
|
20
18
|
)
|
21
|
-
@columns = columns.map(&:to_s)
|
19
|
+
@columns = Array(columns).map(&:to_s)
|
22
20
|
@rows = records
|
23
|
-
@table_name = records.table_name
|
24
|
-
@model_name = @table_name.singularize
|
25
21
|
@paginate = paginate
|
26
22
|
@links = Set.new(Array(links).map(&:to_s)).reject(&:empty?)
|
27
23
|
@actions = Array(actions).map(&:to_s)
|
28
|
-
@styles = BootstrapStyles.new(styles)
|
29
24
|
end
|
30
25
|
|
31
26
|
def headers
|
@@ -65,7 +60,7 @@ module ActionTable
|
|
65
60
|
|
66
61
|
# This must be defined for record_path to work
|
67
62
|
def controller
|
68
|
-
|
63
|
+
table_name
|
69
64
|
end
|
70
65
|
|
71
66
|
# Contstruct path to record, i.e programs_path(record)
|
@@ -75,6 +70,8 @@ module ActionTable
|
|
75
70
|
public_send(path, record)
|
76
71
|
end
|
77
72
|
|
73
|
+
private
|
74
|
+
|
78
75
|
def t_actions
|
79
76
|
@actions.map { |name| t_action(name) }
|
80
77
|
end
|
@@ -85,8 +82,25 @@ module ActionTable
|
|
85
82
|
end
|
86
83
|
|
87
84
|
def t_col(col_name)
|
88
|
-
|
89
|
-
|
85
|
+
if model_name?
|
86
|
+
t_key = "activerecord.attributes.#{model_name}.#{col_name}"
|
87
|
+
return I18n.t(t_key, default: col_name.titleize)
|
88
|
+
end
|
89
|
+
|
90
|
+
col_name.humanize.titleize
|
91
|
+
end
|
92
|
+
|
93
|
+
def table_name
|
94
|
+
rows.table_name
|
95
|
+
end
|
96
|
+
|
97
|
+
def model_name
|
98
|
+
table_name.singularize
|
99
|
+
end
|
100
|
+
|
101
|
+
def table_name?
|
102
|
+
rows.respond_to?(:table_name)
|
90
103
|
end
|
104
|
+
alias_method :model_name?, :table_name?
|
91
105
|
end
|
92
106
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
<% wrapper_class =
|
1
|
+
<% wrapper_class = styles.responsive_wrapper_class %>
|
2
2
|
|
3
3
|
<% if wrapper_class %>
|
4
4
|
<div class="<%= wrapper_class %>">
|
5
5
|
<% end %>
|
6
6
|
|
7
|
-
<table class="<%=
|
7
|
+
<table class="<%= styles.table_classes %>">
|
8
8
|
<thead>
|
9
9
|
<% table.headers.each do |header| %>
|
10
10
|
<th><%= header %></th>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_table
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Burenstam
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -114,8 +114,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
116
|
rubyforge_project:
|
117
|
-
rubygems_version: 2.
|
117
|
+
rubygems_version: 2.5.2.3
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: Render ActiveRecord objects as HTML tables with one line of Ruby.
|
121
121
|
test_files: []
|
122
|
+
has_rdoc:
|