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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf3b17d46afaa1ab042b61676da77b28c45cd47310a2a732244d1c5cc87046a6
4
- data.tar.gz: 14d761c446ee13aa507fa7482db9a0b9ceb9d01249dbee256a0d3bcd642f9434
3
+ metadata.gz: e6e8c82366ee5b6617d572217e5fe97b46b899ec4b0c56d427c4684488901b76
4
+ data.tar.gz: d0a6e30baf0df782de4d3f49db62b5511bcb3b176cdd77e1fcb76223e4ae7f9e
5
5
  SHA512:
6
- metadata.gz: 827a3e9853fb70eb2cf5c5a95cd7df169ef74c765aed64a9e7066bfe80b29a66c0a1b3313d6cb768e8d6ac968731eb3ec208fd93435fd92a16ddf7a4bed0994b
7
- data.tar.gz: b3092add50499a80c5e033ab206094d42cea7371cb78eafaf85e386fb422931393ca8439ca426a21d7283c0cc5ca0ceef078b95f2c7018479d5dfac8b6bb3518
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 :table_styles
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
- @table_styles = []
26
+ @styles = []
27
+ @actions = []
28
+ @link_method = :name
27
29
  end
28
30
 
29
31
  def rails_host_app
@@ -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
- actions: []
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,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActionTable
4
- VERSION = '0.1.0'.freeze
4
+ VERSION = '0.2.0'.freeze
5
5
  end
@@ -13,9 +13,9 @@ module ActionTable
13
13
  cols:,
14
14
  records:,
15
15
  paginate: false,
16
- link: nil,
17
- actions: [],
18
- styles: ActionTable.config.table_styles
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_table
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Burenstam