forest_admin_datasource_customizer 1.16.10 → 1.17.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: 70fe0567691a8a5b8756e2d496bbd7ccedf76addb33c5583d68b4a1674cd57d5
4
- data.tar.gz: 63fc44d807d94547ea9a4af31302b4383450ea003996ef738f20efa13c41a59e
3
+ metadata.gz: c9c95e8a551caeae67df075b259546380b628bf9a257ebc1d628bc884b092134
4
+ data.tar.gz: ced3f70bcb914aa2e1fe92a025d8af0837e60c5ba7cff2390767a4e5800a242d
5
5
  SHA512:
6
- metadata.gz: 75ce84b3e19ba3a7814b9b146b649096d624fce7c26060bf757e1362e94fca0334882c798b42abbdd8372e388b4c3c05fc8faf2f521a874a9bfd413587f28f18
7
- data.tar.gz: 178413026421120a43380e92822c788c48c4b67c38dac409f1c81136134ecf3167b4ca6f828d68a15bc5d25a7c64a027109fb424dad4b23dfb41498a1b68db8c
6
+ metadata.gz: 4f1ca864c6717009770c37e5cb3e467f774b76bf55eeb13f80df90b5a9c2e8402f1ccf4fe43bed38529e7578315c450ee8efdfe94e2c3a24095f33179aff990e
7
+ data.tar.gz: '037035979065a13448e006af30892530285ec463ae2463718d6a9b31942eec6c995454f9ebc4a04aecbf751774ecf864f6d8adfccb8e54493d91513b4fbd5a51'
@@ -4,7 +4,7 @@ module ForestAdminDatasourceCustomizer
4
4
  module DSL
5
5
  # FormBuilder provides a fluent DSL for building action forms
6
6
  #
7
- # @example
7
+ # @example Basic form
8
8
  # form do
9
9
  # field :email, type: :string, widget: 'TextInput'
10
10
  # field :age, type: :number
@@ -15,6 +15,14 @@ module ForestAdminDatasourceCustomizer
15
15
  # field :city, type: :string
16
16
  # end
17
17
  # end
18
+ #
19
+ # @example Dynamic form with conditionals
20
+ # form do
21
+ # field :amount, type: :number, required: true
22
+ # field :reason, type: :string,
23
+ # required: ->(ctx) { ctx.get_form_value('amount').to_i > 1000 },
24
+ # if_condition: ->(ctx) { ctx.get_form_value('amount').to_i > 500 }
25
+ # end
18
26
  class FormBuilder
19
27
  attr_reader :fields
20
28
 
@@ -26,14 +34,18 @@ module ForestAdminDatasourceCustomizer
26
34
  # @param name [String, Symbol] field name
27
35
  # @param type [String, Symbol] field type (:string, :number, :boolean, :date, :file, etc.)
28
36
  # @param widget [String] optional widget type
29
- # @param options [Array<Hash>] options for dropdown/radio widgets
30
- # @param readonly [Boolean] whether field is read-only
31
- # @param default [Object] default value
32
- # @param description [String] field description
33
- # @param placeholder [String] placeholder text
37
+ # @param options [Array<Hash>, Proc] options for dropdown/radio widgets (static or dynamic)
38
+ # @param readonly [Boolean, Proc] whether field is read-only (static or dynamic)
39
+ # @param required [Boolean, Proc] whether field is required (static or dynamic)
40
+ # @param default [Object, Proc] default value (static or dynamic)
41
+ # @param description [String, Proc] field description (static or dynamic)
42
+ # @param placeholder [String, Proc] placeholder text (static or dynamic)
43
+ # @param if_condition [Proc] condition to display the field (dynamic only)
44
+ # @param enum_values [Array, Proc] enum values for enum fields (static or dynamic)
45
+ # @param collection_name [String, Proc] target collection name (static or dynamic)
34
46
  # @param block [Proc] optional proc for computed values
35
- def field(name, type:, widget: nil, options: nil, readonly: false, default: nil,
36
- description: nil, placeholder: nil, &block)
47
+ def field(name, type:, widget: nil, options: nil, readonly: nil, required: nil, default: nil,
48
+ description: nil, placeholder: nil, if_condition: nil, enum_values: nil, collection_name: nil, &block)
37
49
  field_def = {
38
50
  label: name.to_s,
39
51
  type: normalize_type(type)
@@ -42,9 +54,13 @@ module ForestAdminDatasourceCustomizer
42
54
  field_def[:widget] = widget if widget
43
55
  field_def[:options] = options if options
44
56
  field_def[:is_read_only] = readonly if readonly
57
+ field_def[:is_required] = required if required
45
58
  field_def[:default_value] = default if default
46
59
  field_def[:description] = description if description
47
60
  field_def[:placeholder] = placeholder if placeholder
61
+ field_def[:if_condition] = if_condition if if_condition
62
+ field_def[:enum_values] = enum_values if enum_values
63
+ field_def[:collection_name] = collection_name if collection_name
48
64
  field_def[:value] = block if block
49
65
 
50
66
  @fields << field_def
@@ -1,3 +1,3 @@
1
1
  module ForestAdminDatasourceCustomizer
2
- VERSION = "1.16.10"
2
+ VERSION = "1.17.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_admin_datasource_customizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.16.10
4
+ version: 1.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthieu
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2025-12-09 00:00:00.000000000 Z
12
+ date: 2025-12-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport