dynamic_scaffold 1.1.2 → 1.1.3

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: 1fd79d19c41b8b8e7c7ec1b0ce2e0cc5cbbf6915ca906e52a641dc50f20a4a65
4
- data.tar.gz: e3b5ab69301b9069565a7dde72b6282b6c7689a565b5226521a0e26374143f07
3
+ metadata.gz: 365b8e05efc2852a35a0840740894c49b9a051897bd9387d7f6e06bcdfd2426c
4
+ data.tar.gz: a51453803cdf66dfbc725249305ab9441fb30ecc4a7c44db3d4c6d4edad0ed3d
5
5
  SHA512:
6
- metadata.gz: 36eec882d489bade2e1fdc81e54cffef6cea32260d2e492b46f9d2aae91539c3cedf401d0e7a1475c7d84e96a15e604e86d6c88d80cf033e7dc11802a809a82e
7
- data.tar.gz: ba528d7d1750bd6631e6d525d8fef7ffe78230c2a24de4edb98faf27cb16242a52436ea58798fc2bfbba4c7c814acbef69ed981ac4c75828059039a5fad6ccb8
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 you inserted.
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
 
@@ -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 ITEM_TYPES[type].nil?
7
+ if Form::Item::Type::LIST[type].nil?
39
8
  raise(
40
9
  DynamicScaffold::Error::InvalidParameter,
41
- "Unknown form item type #{type}. supported: #{ITEM_TYPES.keys.join(', ')}"
10
+ "Unknown form item type #{type}. supported: #{Form::Item::Type::LIST.keys.join(', ')}"
42
11
  )
43
12
  end
44
13
 
45
- ITEM_TYPES[type].new(config, type, *args, &block)
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
@@ -18,11 +18,11 @@ module DynamicScaffold
18
18
  end
19
19
 
20
20
  def permit_params(*params)
21
- if !params.empty?
21
+ if params.empty?
22
+ @permit_params
23
+ else
22
24
  @permit_params.concat(params)
23
25
  self
24
- else
25
- @permit_params
26
26
  end
27
27
  end
28
28
 
@@ -1,3 +1,3 @@
1
1
  module DynamicScaffold
2
- VERSION = '1.1.2'.freeze
2
+ VERSION = '1.1.3'.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.1.2
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-04-16 00:00:00.000000000 Z
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