tabulatr2 0.9.29 → 0.9.30

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5aec598ddedf0f1456066f02bcf64ed3957f5d6
4
- data.tar.gz: bad8a12efe47459bd4f5e7739365ba4dd36fc380
3
+ metadata.gz: af8e5204add46d949b53ab203ff3eb544217d60f
4
+ data.tar.gz: 79455bf0881803cf94f77fb50f553c5ac0a4ea60
5
5
  SHA512:
6
- metadata.gz: 92c342b899122045438c240753c535abd1589b10ecbcbeb77a6ce4fcc6786de4f4fbdb69ca42acf014e7578502f9a710f3a9ab2305838e7a794b45b48f6083ee
7
- data.tar.gz: 95cad2508988b6cd350682306152878a40df059d0c78b5a60ee87a0a9c9fc0230c5ef007681d6b0f2534e54deed4b79f731ea01d881d18fbcf92237611bbd865
6
+ metadata.gz: 5db3fe6c8d03c691e552128fc04300fc95aec3438e3718d298d1794e49661d4bb6dfb5463d8d4d874555ea99951e9b235175af513e841fe991f3b806faf054c8
7
+ data.tar.gz: 60d58e2003677d4f4949432c3a2b5c4283ca4ce306fac7fcfd4a2a61490e3c74364558f07e8c62ea84c031a632fab9604f4192e3b165342b4eece68cefa152b1
data/README.md CHANGED
@@ -168,6 +168,24 @@ class UserTabulatrData < Tabulatr::Data
168
168
  end
169
169
  ```
170
170
 
171
+ ### Accessing controller
172
+
173
+ You may want to show actions and/or buttons depending on a condition,
174
+ e.g., user's role. You can access controller helpers with
175
+ `@controller`. Here is how to check, if you are
176
+ using [Pundit](https://github.com/elabs/pundit) (or any other
177
+ authorization gem):
178
+
179
+ ```ruby
180
+ class UserTabulatrData < Tabulatr::Data
181
+ buttons do |b,r|
182
+ if @controller.policy(r).show?
183
+ b.button :eye, product_path(r), class: 'btn-success'
184
+ end
185
+ end
186
+ end
187
+ ```
188
+
171
189
  ### Search
172
190
 
173
191
  The DSL provides you with a `search` method to define a custom fuzzy search method which is not bound
@@ -23,7 +23,14 @@
23
23
 
24
24
  class Tabulatr::Renderer::Association < Tabulatr::Renderer::Column
25
25
  def human_name
26
- col_options.header || klass.model_name.human + ' ' + klass.human_attribute_name(name)
26
+ h = col_options.header
27
+ if h && h.respond_to?(:call)
28
+ h.()
29
+ elsif h
30
+ h
31
+ else
32
+ klass.model_name.human + ' ' + klass.human_attribute_name(name)
33
+ end
27
34
  end
28
35
 
29
36
  def coltype() 'association' end
@@ -46,7 +46,18 @@ class Tabulatr::Renderer::Column
46
46
  end
47
47
 
48
48
  def klassname() @_klassname ||= @klass.name.underscore end
49
- def human_name() col_options.header || klass.human_attribute_name(name) end
49
+
50
+ def human_name()
51
+ h = col_options.header
52
+ if h && h.respond_to?(:call)
53
+ h.()
54
+ elsif h
55
+ h
56
+ else
57
+ klass.human_attribute_name(name)
58
+ end
59
+ end
60
+
50
61
  def sort_param() "#{klassname}_sort" end
51
62
  def full_name() [table_name, name].compact.join(":") end
52
63
  def coltype() 'column' end
@@ -22,5 +22,5 @@
22
22
  #++
23
23
 
24
24
  module Tabulatr
25
- VERSION = "0.9.29"
25
+ VERSION = "0.9.30"
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tabulatr2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.29
4
+ version: 0.9.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Horn
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-04-15 00:00:00.000000000 Z
13
+ date: 2017-02-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails