action_table 0.1.0 → 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/action_table.rb +4 -2
- data/lib/action_table/helper.rb +17 -3
- data/lib/action_table/version.rb +1 -1
- data/lib/action_table/view.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6e8c82366ee5b6617d572217e5fe97b46b899ec4b0c56d427c4684488901b76
|
4
|
+
data.tar.gz: d0a6e30baf0df782de4d3f49db62b5511bcb3b176cdd77e1fcb76223e4ae7f9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 906cab2332e2eee5af9642e44ec5f12d2634b1202ec0b1a72fa743898c3f1789a452d413901616b02d1ebbf40ff5ff70058c986473240ad9d2b5ffd1e5e924db
|
7
|
+
data.tar.gz: 2c30d01e88ea05929947f753e454eb518957941ca5be2a8716d2ae694fbeba8a607dfc79f07bdead36c0e59d37065aa725815338ba739081b7e25f2e9d8cf139
|
data/lib/action_table.rb
CHANGED
@@ -18,12 +18,14 @@ module ActionTable
|
|
18
18
|
end
|
19
19
|
|
20
20
|
class Configuration
|
21
|
-
attr_accessor :
|
21
|
+
attr_accessor :styles, :actions, :link_method
|
22
22
|
attr_writer :rails_host_app
|
23
23
|
|
24
24
|
def initialize
|
25
25
|
@rails_host_app = nil
|
26
|
-
@
|
26
|
+
@styles = []
|
27
|
+
@actions = []
|
28
|
+
@link_method = :name
|
27
29
|
end
|
28
30
|
|
29
31
|
def rails_host_app
|
data/lib/action_table/helper.rb
CHANGED
@@ -5,13 +5,27 @@ require 'action_table/view'
|
|
5
5
|
|
6
6
|
module ActionTable
|
7
7
|
module Helper
|
8
|
+
# Renders an ActiveRecord collection as a HTML table.
|
9
|
+
# @return [String] returns a HTML string representing the ActiveRecord collection.
|
10
|
+
# @param [ActiveRecord::Collection]
|
11
|
+
# records ActiveRecord collection to render
|
12
|
+
# @param [Array<String>, Array<Symbol>]
|
13
|
+
# table columns (must map to methods on each ActiveRecord instance)
|
14
|
+
# @param styles [Array<String>, Array<Symbol>]
|
15
|
+
# no, one or many of bootstrap table styles (table- prefix will be added)
|
16
|
+
# @param link [Symbol]
|
17
|
+
# method name for the default name to use for anchor-tags
|
18
|
+
# @param paginate [true, false]
|
19
|
+
# whether to render pagination links (default: false)
|
20
|
+
# @param actions [Array<String>, Array<Symbol>]
|
21
|
+
# render action lins (show, edit and delete)
|
8
22
|
def action_table(
|
9
23
|
records,
|
10
24
|
fields,
|
11
|
-
styles: %i[bordered striped hover],
|
12
|
-
link: :name,
|
13
25
|
paginate: false,
|
14
|
-
|
26
|
+
link: ActionTable.config.link_method,
|
27
|
+
actions: ActionTable.config.actions,
|
28
|
+
styles: ActionTable.config.styles
|
15
29
|
)
|
16
30
|
action_table = View.new(
|
17
31
|
cols: fields,
|
data/lib/action_table/version.rb
CHANGED
data/lib/action_table/view.rb
CHANGED
@@ -13,9 +13,9 @@ module ActionTable
|
|
13
13
|
cols:,
|
14
14
|
records:,
|
15
15
|
paginate: false,
|
16
|
-
link:
|
17
|
-
actions:
|
18
|
-
styles: ActionTable.config.
|
16
|
+
link: ActionTable.config.link_method,
|
17
|
+
actions: ActionTable.config.actions,
|
18
|
+
styles: ActionTable.config.styles
|
19
19
|
)
|
20
20
|
@col_names = cols.map(&:to_s)
|
21
21
|
@rows = records
|