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 +4 -4
- data/README.md +3 -0
- data/lib/dynamic_scaffold/form/item/base.rb +8 -0
- data/lib/dynamic_scaffold/form/item/single_option.rb +2 -2
- data/lib/dynamic_scaffold/form/item/two_options.rb +2 -2
- data/lib/dynamic_scaffold/form/item/two_options_with_block.rb +2 -2
- data/lib/dynamic_scaffold/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d0ca43e5c5f7d3eac65d3ecb58f9c8db1c5fc56c16afa34ecd09dd5d04ee4e4
|
4
|
+
data.tar.gz: ef7f572241d232e3579d991d501e49da461baac0297598014b1f145cca959c83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(
|
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,
|
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(
|
21
|
+
def render(view, form, classnames = nil)
|
22
22
|
html_attributes = build_html_attributes(classnames)
|
23
|
-
form.public_send(@type, @name,
|
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(
|
5
|
+
def render(view, form, classnames = nil)
|
6
6
|
form.public_send(
|
7
7
|
@type,
|
8
8
|
@name,
|
9
|
-
|
9
|
+
*build_args(view, @args),
|
10
10
|
@options,
|
11
11
|
build_html_attributes(classnames)
|
12
12
|
) do |builder|
|
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.
|
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-
|
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
|