dynamic_scaffold 1.1.2 → 1.1.3
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 +4 -4
- data/README.md +21 -2
- data/lib/dynamic_scaffold.rb +1 -0
- data/lib/dynamic_scaffold/form/item/base.rb +3 -34
- data/lib/dynamic_scaffold/form/item/type.rb +38 -0
- data/lib/dynamic_scaffold/form_builder.rb +3 -3
- data/lib/dynamic_scaffold/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 365b8e05efc2852a35a0840740894c49b9a051897bd9387d7f6e06bcdfd2426c
|
4
|
+
data.tar.gz: a51453803cdf66dfbc725249305ab9441fb30ecc4a7c44db3d4c6d4edad0ed3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f5a0f3fc09e45b7cefe2be46f812714f4391c1a1bb331f907469218b496886a74c3af7965f51529df7bbcf0c4a4e57280b7d835eb96b098ca2a2643351fb1b9
|
7
|
+
data.tar.gz: f2532cef4c3ad993fc700ec4d5845599201e03768abc9049707d88a73652062d43bcb03d9b7b385288a96c80e5896a9490a8f5d303a34fa3ee1cd1861d49dfc1
|
data/README.md
CHANGED
@@ -271,8 +271,7 @@ class ShopController < ApplicationController
|
|
271
271
|
end
|
272
272
|
end
|
273
273
|
|
274
|
-
# You need to permit the new form parameters
|
275
|
-
# And if necessary, add virtual attributes to the model.
|
274
|
+
# IF You need to permit the new form parameters, Call config.form.permit_params.
|
276
275
|
config.form.permit_params(:delete_image)
|
277
276
|
|
278
277
|
# You can also add a note to the form field.
|
@@ -364,6 +363,26 @@ We support [cocoon](https://github.com/nathanvda/cocoon).
|
|
364
363
|
end
|
365
364
|
```
|
366
365
|
|
366
|
+
#### Overwrite actions
|
367
|
+
|
368
|
+
You can pass the block to super in index/create/update actions.
|
369
|
+
|
370
|
+
```rb
|
371
|
+
def index
|
372
|
+
super do |records|
|
373
|
+
# `records` is ActiveRecord::Relation.
|
374
|
+
# You must return ActiveRecord::Relation instance.
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
def update|create
|
379
|
+
super do |record|
|
380
|
+
# `record` is a Model.
|
381
|
+
# This block is called before saving.
|
382
|
+
end
|
383
|
+
end
|
384
|
+
```
|
385
|
+
|
367
386
|
|
368
387
|
### Sorting
|
369
388
|
|
data/lib/dynamic_scaffold.rb
CHANGED
@@ -25,6 +25,7 @@ module DynamicScaffold
|
|
25
25
|
|
26
26
|
module Form
|
27
27
|
module Item
|
28
|
+
autoload :Type, 'dynamic_scaffold/form/item/type'
|
28
29
|
autoload :Base, 'dynamic_scaffold/form/item/base'
|
29
30
|
autoload :Block, 'dynamic_scaffold/form/item/block'
|
30
31
|
autoload :CarrierWaveImage, 'dynamic_scaffold/form/item/carrier_wave_image'
|
@@ -2,47 +2,16 @@ module DynamicScaffold
|
|
2
2
|
module Form
|
3
3
|
module Item
|
4
4
|
class Base # rubocop:disable Metrics/ClassLength
|
5
|
-
ITEM_TYPES = {
|
6
|
-
check_box: Form::Item::SingleOption,
|
7
|
-
radio_button: Form::Item::SingleOption,
|
8
|
-
text_area: Form::Item::SingleOption,
|
9
|
-
text_field: Form::Item::SingleOption,
|
10
|
-
date_field: Form::Item::SingleOption,
|
11
|
-
password_field: Form::Item::SingleOption,
|
12
|
-
hidden_field: Form::Item::SingleOption,
|
13
|
-
file_field: Form::Item::SingleOption,
|
14
|
-
color_field: Form::Item::SingleOption,
|
15
|
-
number_field: Form::Item::SingleOption,
|
16
|
-
telephone_field: Form::Item::SingleOption,
|
17
|
-
|
18
|
-
time_select: Form::Item::TwoOptions,
|
19
|
-
date_select: Form::Item::TwoOptions,
|
20
|
-
datetime_select: Form::Item::TwoOptions,
|
21
|
-
collection_select: Form::Item::TwoOptions,
|
22
|
-
grouped_collection_select: Form::Item::TwoOptions,
|
23
|
-
|
24
|
-
collection_check_boxes: Form::Item::TwoOptionsWithBlock,
|
25
|
-
collection_radio_buttons: Form::Item::TwoOptionsWithBlock,
|
26
|
-
|
27
|
-
block: Form::Item::Block,
|
28
|
-
|
29
|
-
carrierwave_image: Form::Item::CarrierWaveImage,
|
30
|
-
|
31
|
-
globalize_fields: Form::Item::GlobalizeFields,
|
32
|
-
|
33
|
-
cocoon: Form::Item::Cocoon
|
34
|
-
}.freeze
|
35
|
-
|
36
5
|
class << self
|
37
6
|
def create(config, type, *args, &block)
|
38
|
-
if
|
7
|
+
if Form::Item::Type::LIST[type].nil?
|
39
8
|
raise(
|
40
9
|
DynamicScaffold::Error::InvalidParameter,
|
41
|
-
"Unknown form item type #{type}. supported: #{
|
10
|
+
"Unknown form item type #{type}. supported: #{Form::Item::Type::LIST.keys.join(', ')}"
|
42
11
|
)
|
43
12
|
end
|
44
13
|
|
45
|
-
|
14
|
+
Form::Item::Type::LIST[type].new(config, type, *args, &block)
|
46
15
|
end
|
47
16
|
end
|
48
17
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module DynamicScaffold
|
2
|
+
module Form
|
3
|
+
module Item
|
4
|
+
class Type
|
5
|
+
LIST = {
|
6
|
+
check_box: Form::Item::SingleOption,
|
7
|
+
radio_button: Form::Item::SingleOption,
|
8
|
+
text_area: Form::Item::SingleOption,
|
9
|
+
text_field: Form::Item::SingleOption,
|
10
|
+
date_field: Form::Item::SingleOption,
|
11
|
+
password_field: Form::Item::SingleOption,
|
12
|
+
hidden_field: Form::Item::SingleOption,
|
13
|
+
file_field: Form::Item::SingleOption,
|
14
|
+
color_field: Form::Item::SingleOption,
|
15
|
+
number_field: Form::Item::SingleOption,
|
16
|
+
telephone_field: Form::Item::SingleOption,
|
17
|
+
|
18
|
+
time_select: Form::Item::TwoOptions,
|
19
|
+
date_select: Form::Item::TwoOptions,
|
20
|
+
datetime_select: Form::Item::TwoOptions,
|
21
|
+
collection_select: Form::Item::TwoOptions,
|
22
|
+
grouped_collection_select: Form::Item::TwoOptions,
|
23
|
+
|
24
|
+
collection_check_boxes: Form::Item::TwoOptionsWithBlock,
|
25
|
+
collection_radio_buttons: Form::Item::TwoOptionsWithBlock,
|
26
|
+
|
27
|
+
block: Form::Item::Block,
|
28
|
+
|
29
|
+
carrierwave_image: Form::Item::CarrierWaveImage,
|
30
|
+
|
31
|
+
globalize_fields: Form::Item::GlobalizeFields,
|
32
|
+
|
33
|
+
cocoon: Form::Item::Cocoon
|
34
|
+
}.freeze
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
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.1.
|
4
|
+
version: 1.1.3
|
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-
|
11
|
+
date: 2019-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: classnames-rails-view
|
@@ -270,6 +270,7 @@ files:
|
|
270
270
|
- lib/dynamic_scaffold/form/item/single_option.rb
|
271
271
|
- lib/dynamic_scaffold/form/item/two_options.rb
|
272
272
|
- lib/dynamic_scaffold/form/item/two_options_with_block.rb
|
273
|
+
- lib/dynamic_scaffold/form/item/type.rb
|
273
274
|
- lib/dynamic_scaffold/form_builder.rb
|
274
275
|
- lib/dynamic_scaffold/icons/fontawesome.rb
|
275
276
|
- lib/dynamic_scaffold/list/item.rb
|