forest_admin_datasource_customizer 1.0.0.pre.beta.68 → 1.0.0.pre.beta.69

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: eb4ded1e0af9d04763d01c46f38a3badbbf963689a1b1b3160e8b891e0f193bc
4
- data.tar.gz: 0bbe747df4a860b4569e8da2e4d794790672e3b797df86ac4bf2e7133fa09756
3
+ metadata.gz: e1c8a06acb9a7a54a9b3307d8ced770afb79f524830002e3df64a0c4d2942663
4
+ data.tar.gz: 42839a7a96efa461771180ccfc4c7eeba8c111d35fef2c9677f09a9e264b2dad
5
5
  SHA512:
6
- metadata.gz: a0556831bfd0cc8cc3c7b3f76eb15cd99d664a5b89f33ba4541eab604efb626c4f3281af486d90683f3ab884318fd390110dc7b1f4fad189dd3bf6caa28ecf29
7
- data.tar.gz: e931aa15321451fad8f8d36cd9d3ea615767b9023d008b05f04de4ebc6e46ea932346e50c973fe2bd3434eb380a73aa85e83b74d8d5d8a6672192877fbcd88a8
6
+ metadata.gz: 4d0c9a2a6baa9054af52915b4987b570acc90376dc2f66ecaaae3749c1b59752968e6e4f85c8f91f2f7a1910312b9f9ebd51e1225a2c5dbfafd43bfc360a6a70
7
+ data.tar.gz: e184b1912374f9f8aca77f44a97b1d4b3d0e09d87eccaab1a9332d1e3039e040ff9a201cafefb3641f27e0fe90b11d4424aded5b503a43e42f67dd56162b052c
@@ -48,7 +48,7 @@ module ForestAdminDatasourceCustomizer
48
48
  dynamic_fields = drop_defaults(context, dynamic_fields, form_values)
49
49
  dynamic_fields = drop_ifs(context, dynamic_fields) unless metas[:include_hidden_fields]
50
50
 
51
- fields = drop_deferred(context, metas[:search_values], dynamic_fields)
51
+ fields = drop_deferred(context, metas[:search_values], dynamic_fields).compact
52
52
 
53
53
  fields.each do |field|
54
54
  next if field.type == 'Layout'
@@ -72,6 +72,8 @@ module ForestAdminDatasourceCustomizer
72
72
  FormLayoutElement::SeparatorElement.new(**field)
73
73
  when 'HtmlBlock'
74
74
  FormLayoutElement::HtmlBlockElement.new(**field)
75
+ when 'Row'
76
+ FormLayoutElement::RowElement.new(**field)
75
77
  else
76
78
  raise ForestAdminDatasourceToolkit::Exceptions::ForestException,
77
79
  "Unknow component type: #{field[:component]}"
@@ -79,7 +81,7 @@ module ForestAdminDatasourceCustomizer
79
81
  end
80
82
 
81
83
  def static_form?
82
- return form&.all?(&:static?) if form
84
+ return form&.all?(&:static?) && form&.none? { |field| field.type == 'Layout' } if form
83
85
 
84
86
  true
85
87
  end
@@ -3,13 +3,13 @@ module ForestAdminDatasourceCustomizer
3
3
  module Action
4
4
  module FormLayoutElement
5
5
  include Types
6
+ include ForestAdminDatasourceToolkit::Exceptions
6
7
 
7
8
  class LayoutElement < BaseFormElement
8
9
  attr_accessor :if_condition, :component
9
10
 
10
11
  def initialize(component:, if_condition: nil, **kwargs)
11
12
  super(type: 'Layout', **kwargs)
12
-
13
13
  @component = component
14
14
  @if_condition = if_condition
15
15
  end
@@ -29,6 +29,39 @@ module ForestAdminDatasourceCustomizer
29
29
  @content = content
30
30
  end
31
31
  end
32
+
33
+ class RowElement < LayoutElement
34
+ include ForestAdminDatasourceToolkit::Exceptions
35
+ attr_accessor :fields
36
+
37
+ def initialize(options)
38
+ super(component: 'Row', **options)
39
+ validate_fields_presence!(options)
40
+ validate_no_layout_subfields!(options[:fields])
41
+ @fields = instantiate_subfields(options[:fields] || [])
42
+ end
43
+
44
+ private
45
+
46
+ def validate_fields_presence!(options)
47
+ raise ForestException, "Using 'fields' in a 'Row' configuration is mandatory" unless options.key?(:fields)
48
+ end
49
+
50
+ def validate_no_layout_subfields!(fields)
51
+ fields.each do |field|
52
+ if (field.is_a?(DynamicField) && field.type == 'Layout') ||
53
+ (field.is_a?(Hash) && field[:type] == 'Layout')
54
+ raise ForestException, "A 'Row' form element doesn't allow layout elements as subfields"
55
+ end
56
+ end
57
+ end
58
+
59
+ def instantiate_subfields(fields)
60
+ fields.map do |field|
61
+ ForestAdminDatasourceToolkit::Components::Actions::ActionFieldFactory.build(field.to_h)
62
+ end
63
+ end
64
+ end
32
65
  end
33
66
  end
34
67
  end
@@ -1,3 +1,3 @@
1
1
  module ForestAdminDatasourceCustomizer
2
- VERSION = "1.0.0-beta.68"
2
+ VERSION = "1.0.0-beta.69"
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.0.0.pre.beta.68
4
+ version: 1.0.0.pre.beta.69
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: 2024-09-23 00:00:00.000000000 Z
12
+ date: 2024-09-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport