dynamic_scaffold 1.0.0 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92e34ceaa702cf769f2d04c1f6abcf6424a0fe243aba09c3a47deb7cb0b34744
4
- data.tar.gz: 8f14666cf201c3153402d97e12bc12131be4f06cc2afdbed862ccf90d992ff79
3
+ metadata.gz: b6b175048b1ef5379529535b9eb396c9bb1b2723abad953f9b9d159e4950ea4e
4
+ data.tar.gz: 7667532e15c6e87665bc0b453de2698bfbc9cbb2e6fc12f4f6a5124097a80197
5
5
  SHA512:
6
- metadata.gz: f9547447542b99e5dc317381dfa2f253c26bd983f08ca0438b9fe7cd08de4643345eca7fa587f9312c0302f8743f47def9bad39e0655b0b12f41fc49e93ab50b
7
- data.tar.gz: c2923675d8504bdf3e3c9b392a8a9d032ac0160036759ce21e6c69259b1d725004ee488266b6374cca09aa9e8a4c224cc19596d3221cf69b6656e82f478d4a9a
6
+ metadata.gz: 2a3518d23f1d802fc833e2a4765d431b4907d70c5f5c2b8eee6f808f55198c27f46f912e8c7347a469efd48581cf81f23600f97e3f85145241679e0eb8526606
7
+ data.tar.gz: 845f7f9c5e87cb807b7896910383421b9ed4efb9306a2312efd4c9279bb526dfbda0f9ae88e129daa930572f4f1aa18772e585947464c2513472ab9caff3011d
data/README.md CHANGED
@@ -187,6 +187,9 @@ class ShopController < ApplicationController
187
187
  config.list.item do |rec|
188
188
  link_to "Show #{rec.name}", controls_master_shops_path
189
189
  end
190
+
191
+ # You can hide item by calling the show_only method.
192
+ config.list.item(:name).show_only {|rec| rec.foobar? }
190
193
  end
191
194
  end
192
195
  ```
@@ -37,10 +37,12 @@
37
37
  <% end %>
38
38
  <div class="ds-list-items">
39
39
  <%dynamic_scaffold.list.items.each do |disp|%>
40
- <%= content_tag :div, class: class_names('ds-list-item', disp.classnames), **disp.html_attributes do%>
41
- <div class="ds-list-label"><%= disp.label %></div>
42
- <div class="ds-list-value"><%= disp.value self, record %></div>
43
- <%end%>
40
+ <%- if disp.show?(self, record) -%>
41
+ <%= content_tag :div, class: class_names('ds-list-item', disp.classnames), **disp.html_attributes do%>
42
+ <div class="ds-list-label"><%= disp.label %></div>
43
+ <div class="ds-list-value"><%= disp.value self, record %></div>
44
+ <%end%>
45
+ <% end %>
44
46
  <%end%>
45
47
  </div>
46
48
  <div class="ds-list-footer clearfix">
@@ -9,6 +9,18 @@ module DynamicScaffold
9
9
  @classnames = @html_attributes.delete(:class)
10
10
  @attribute_name = args[0]
11
11
  @block = block
12
+ @show_only = nil
13
+ end
14
+
15
+ def show_only(&block)
16
+ @show_only = block
17
+ self
18
+ end
19
+
20
+ def show?(view, record)
21
+ return true if @show_only.nil?
22
+
23
+ view.instance_exec(record, &@show_only)
12
24
  end
13
25
 
14
26
  def value(view, record)
@@ -1,3 +1,3 @@
1
1
  module DynamicScaffold
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masamoto Miyata
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-20 00:00:00.000000000 Z
11
+ date: 2019-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: classnames-rails-view