forest_admin_datasource_customizer 1.0.0.pre.beta.67 → 1.0.0.pre.beta.69
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/lib/forest_admin_datasource_customizer/decorators/action/action_collection_decorator.rb +1 -1
- data/lib/forest_admin_datasource_customizer/decorators/action/base_action.rb +5 -1
- data/lib/forest_admin_datasource_customizer/decorators/action/form_layout_element.rb +44 -2
- 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'
|
@@ -70,6 +70,10 @@ module ForestAdminDatasourceCustomizer
|
|
70
70
|
case field[:component]
|
71
71
|
when 'Separator'
|
72
72
|
FormLayoutElement::SeparatorElement.new(**field)
|
73
|
+
when 'HtmlBlock'
|
74
|
+
FormLayoutElement::HtmlBlockElement.new(**field)
|
75
|
+
when 'Row'
|
76
|
+
FormLayoutElement::RowElement.new(**field)
|
73
77
|
else
|
74
78
|
raise ForestAdminDatasourceToolkit::Exceptions::ForestException,
|
75
79
|
"Unknow component type: #{field[:component]}"
|
@@ -77,7 +81,7 @@ module ForestAdminDatasourceCustomizer
|
|
77
81
|
end
|
78
82
|
|
79
83
|
def static_form?
|
80
|
-
return form&.all?(&:static?) if form
|
84
|
+
return form&.all?(&:static?) && form&.none? { |field| field.type == 'Layout' } if form
|
81
85
|
|
82
86
|
true
|
83
87
|
end
|
@@ -3,23 +3,65 @@ 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
|
16
16
|
end
|
17
17
|
|
18
18
|
class SeparatorElement < LayoutElement
|
19
|
-
def initialize(options)
|
19
|
+
def initialize(**options)
|
20
20
|
super(component: 'Separator', **options)
|
21
21
|
end
|
22
22
|
end
|
23
|
+
|
24
|
+
class HtmlBlockElement < LayoutElement
|
25
|
+
attr_accessor :content
|
26
|
+
|
27
|
+
def initialize(content:, **options)
|
28
|
+
super(component: 'HtmlBlock', **options)
|
29
|
+
@content = content
|
30
|
+
end
|
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
|
23
65
|
end
|
24
66
|
end
|
25
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
|