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 +4 -4
- data/lib/forest_admin_datasource_customizer/decorators/action/action_collection_decorator.rb +1 -1
- data/lib/forest_admin_datasource_customizer/decorators/action/base_action.rb +3 -1
- data/lib/forest_admin_datasource_customizer/decorators/action/form_layout_element.rb +34 -1
- data/lib/forest_admin_datasource_customizer/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: e1c8a06acb9a7a54a9b3307d8ced770afb79f524830002e3df64a0c4d2942663
|
4
|
+
data.tar.gz: 42839a7a96efa461771180ccfc4c7eeba8c111d35fef2c9677f09a9e264b2dad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d0c9a2a6baa9054af52915b4987b570acc90376dc2f66ecaaae3749c1b59752968e6e4f85c8f91f2f7a1910312b9f9ebd51e1225a2c5dbfafd43bfc360a6a70
|
7
|
+
data.tar.gz: e184b1912374f9f8aca77f44a97b1d4b3d0e09d87eccaab1a9332d1e3039e040ff9a201cafefb3641f27e0fe90b11d4424aded5b503a43e42f67dd56162b052c
|
data/lib/forest_admin_datasource_customizer/decorators/action/action_collection_decorator.rb
CHANGED
@@ -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
|
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.
|
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-
|
12
|
+
date: 2024-09-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|