dynamic_scaffold 1.8.1 → 1.9.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: 3125035e4f7e839f4277b447b187755759e3ee6cfcdc5c4c9a926bd78cbb9da5
4
- data.tar.gz: 981d59b31ace4c0a528139b09a277347598d255de8ff31ef27e822198adeb77a
3
+ metadata.gz: 7d0ca43e5c5f7d3eac65d3ecb58f9c8db1c5fc56c16afa34ecd09dd5d04ee4e4
4
+ data.tar.gz: ef7f572241d232e3579d991d501e49da461baac0297598014b1f145cca959c83
5
5
  SHA512:
6
- metadata.gz: a8104becf673ebdfc863b1bd0d88bd148b68320c1d60068957dc1080640a4543a5c972562dc0713842dee33a21d405a2de61105b84bc78077a28e9db84ac7c33
7
- data.tar.gz: 82c701212363527a4ec1b74c1401080a86286faf11708e55dd610364e98696d5c17748c44226010ca19d999549c3cfe16829af2145c66f84c5febd284c4e07c1
6
+ metadata.gz: f5df70910ffc6358f63638bd48748910176a889a89ca0ec9667c01aa37a4e3bd97a2981e3915b4efc2a6542a134bb12b7892271a7e438ebd3eb8078bb9d8cf59
7
+ data.tar.gz: bcf91e27f537462fe3f9417f0230c21d95c76fb1e13db923121951f6001437d3b328aaf303c2b60c6d1ca0b86c8f96e418851ad7994f5addba7fbdfc3b301169
data/README.md CHANGED
@@ -253,6 +253,9 @@ class ShopController < ApplicationController
253
253
  config.form.item(:collection_check_boxes, :state_ids, State.all, :id, :name)
254
254
  config.form.item(:collection_radio_buttons, :status, Shop.statuses.map{|k, _v| [k, k.titleize]}, :first, :last)
255
255
 
256
+ # If you want to use parameters to get list, Pass Proc or Lambda to argument. It will be called in view scope.
257
+ config.form.item(:collection_select, :status, -> { Shop.where(area_id: params[:area_id]) }, :first, :last)
258
+
256
259
  # If you want to display more free form field, use block.
257
260
  # The block is executed in the context of view, so you can call the method of view.
258
261
  config.form.item :block, :free do |form, field|
@@ -184,6 +184,14 @@ module DynamicScaffold
184
184
  options[:class] = classnames_list.join(' ') unless classnames_list.empty?
185
185
  options
186
186
  end
187
+
188
+ def build_args(view, args)
189
+ args.map do |arg|
190
+ next arg unless arg.is_a? Proc
191
+
192
+ view.instance_exec(&arg)
193
+ end
194
+ end
187
195
  end
188
196
  end
189
197
  end
@@ -9,11 +9,11 @@ module DynamicScaffold
9
9
  super(config, type, name, html_attributes)
10
10
  end
11
11
 
12
- def render(_view, form, classnames = nil)
12
+ def render(view, form, classnames = nil)
13
13
  html_attributes = build_html_attributes(classnames)
14
14
  # Retain the value of the password field on error.
15
15
  html_attributes[:value] = form.object.public_send(@name) if @type == :password_field
16
- form.public_send(@type, @name, *@args, html_attributes)
16
+ form.public_send(@type, @name, *build_args(view, @args), html_attributes)
17
17
  end
18
18
  end
19
19
  end
@@ -18,9 +18,9 @@ module DynamicScaffold
18
18
  super(config, type, name, html_attributes)
19
19
  end
20
20
 
21
- def render(_view, form, classnames = nil)
21
+ def render(view, form, classnames = nil)
22
22
  html_attributes = build_html_attributes(classnames)
23
- form.public_send(@type, @name, *@args, @options, html_attributes)
23
+ form.public_send(@type, @name, *build_args(view, @args), @options, html_attributes)
24
24
  end
25
25
  end
26
26
  end
@@ -2,11 +2,11 @@ module DynamicScaffold
2
2
  module Form
3
3
  module Item
4
4
  class TwoOptionsWithBlock < TwoOptions
5
- def render(_view, form, classnames = nil)
5
+ def render(view, form, classnames = nil)
6
6
  form.public_send(
7
7
  @type,
8
8
  @name,
9
- *@args,
9
+ *build_args(view, @args),
10
10
  @options,
11
11
  build_html_attributes(classnames)
12
12
  ) do |builder|
@@ -1,3 +1,3 @@
1
1
  module DynamicScaffold
2
- VERSION = '1.8.1'.freeze
2
+ VERSION = '1.9.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.8.1
4
+ version: 1.9.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: 2021-07-13 00:00:00.000000000 Z
11
+ date: 2021-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: classnames-rails-view