forest_admin_agent 1.0.0.pre.beta.68 → 1.0.0.pre.beta.70
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 250a2c4a19974f9d4658a54b9bed10460bb810d3ee48fd7d54635eb084ae93b5
|
4
|
+
data.tar.gz: 9a523b41aaffe9a6b17a50e4237458ebd1bb5a5a0d21db64afe8ffac3ec955a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1ff743334eb20133c69b24d48258a0308ac1e6a8820b8dfccf92ffe53bfedae8d4fb3cea940e3664885c59b4eda3100250533138646645cfe3a86bbf7533978
|
7
|
+
data.tar.gz: 63fea12ae51f061c8724fdcd1d4a79b022e49960ee0637207d0c61659a8ae1b90a9459772fada1e3c7b5e43f3b04ad598d437890a259effd4364abdd63fb05e0
|
@@ -58,7 +58,7 @@ module ForestAdminAgent
|
|
58
58
|
def self.make_form_data(datasource, raw_data, fields)
|
59
59
|
data = {}
|
60
60
|
raw_data.each do |key, value|
|
61
|
-
field = fields.find { |f| f.
|
61
|
+
field = fields.find { |f| f.id == key }
|
62
62
|
# Skip fields from the default form
|
63
63
|
next if Schema::GeneratorAction::DEFAULT_FIELDS.map { |f| f[:field] }.include?(key)
|
64
64
|
|
@@ -7,6 +7,7 @@ module ForestAdminAgent
|
|
7
7
|
DEFAULT_FIELDS = [
|
8
8
|
{
|
9
9
|
field: 'Loading...',
|
10
|
+
label: 'Loading...',
|
10
11
|
type: 'String',
|
11
12
|
isReadOnly: true,
|
12
13
|
defaultValue: 'Form is loading',
|
@@ -30,8 +31,7 @@ module ForestAdminAgent
|
|
30
31
|
slug = get_action_slug(name)
|
31
32
|
|
32
33
|
form_elements = extract_fields_and_layout(collection.get_form(nil, name))
|
33
|
-
if action.static_form?
|
34
|
-
# if action.static_form?
|
34
|
+
if action.static_form?
|
35
35
|
fields = build_fields(collection, form_elements[:fields])
|
36
36
|
layout = form_elements[:layout]
|
37
37
|
else
|
@@ -58,12 +58,20 @@ module ForestAdminAgent
|
|
58
58
|
|
59
59
|
return schema unless layout && !layout.empty?
|
60
60
|
|
61
|
-
schema[:layout] = build_layout(layout)
|
61
|
+
# schema[:layout] = build_layout(layout)
|
62
62
|
|
63
63
|
schema
|
64
64
|
end
|
65
65
|
|
66
66
|
def self.build_layout_schema(field)
|
67
|
+
if field.component == 'Row'
|
68
|
+
return {
|
69
|
+
**field.to_h,
|
70
|
+
component: field.component.camelize(:lower),
|
71
|
+
fields: field.fields.map { |f| build_layout_schema(f) }
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
67
75
|
{ **field.to_h, component: field.component.camelize(:lower) }
|
68
76
|
end
|
69
77
|
|
@@ -72,7 +80,8 @@ module ForestAdminAgent
|
|
72
80
|
description: field.description,
|
73
81
|
isRequired: field.is_required,
|
74
82
|
isReadOnly: field.is_read_only,
|
75
|
-
field: field.
|
83
|
+
field: field.id,
|
84
|
+
label: field.label,
|
76
85
|
value: ForestValueConverter.value_to_forest(field),
|
77
86
|
widgetEdit: GeneratorActionFieldWidget.build_widget_options(field)
|
78
87
|
}
|
@@ -101,7 +110,7 @@ module ForestAdminAgent
|
|
101
110
|
if fields
|
102
111
|
return fields.map do |field|
|
103
112
|
new_field = build_field_schema(collection.datasource, field)
|
104
|
-
new_field[:
|
113
|
+
new_field[:defaultValue] = new_field[:value]
|
105
114
|
new_field.delete(:value)
|
106
115
|
|
107
116
|
new_field
|
@@ -112,7 +121,7 @@ module ForestAdminAgent
|
|
112
121
|
end
|
113
122
|
|
114
123
|
def self.build_layout(elements)
|
115
|
-
if elements
|
124
|
+
if elements.any? { |element| element.component != 'Input' }
|
116
125
|
return elements.map do |element|
|
117
126
|
build_layout_schema(element)
|
118
127
|
end
|
@@ -124,21 +133,25 @@ module ForestAdminAgent
|
|
124
133
|
def self.extract_fields_and_layout(form)
|
125
134
|
fields = []
|
126
135
|
layout = []
|
127
|
-
has_real_layout = false
|
128
136
|
|
129
137
|
form&.each do |element|
|
130
138
|
if element.type == Actions::FieldType::LAYOUT
|
131
|
-
|
132
|
-
|
139
|
+
if element.component == 'Row'
|
140
|
+
extract = extract_fields_and_layout(element.fields)
|
141
|
+
element.fields = extract[:layout]
|
142
|
+
layout << element
|
143
|
+
fields.concat(extract[:fields])
|
144
|
+
else
|
145
|
+
layout << element
|
146
|
+
end
|
147
|
+
|
133
148
|
else
|
134
149
|
fields << element
|
135
150
|
# frontend rule
|
136
|
-
layout << Actions::ActionLayoutElement::InputElement.new(component: 'Input', field_id: element.
|
151
|
+
layout << Actions::ActionLayoutElement::InputElement.new(component: 'Input', field_id: element.id)
|
137
152
|
end
|
138
153
|
end
|
139
154
|
|
140
|
-
layout = [] unless has_real_layout
|
141
|
-
|
142
155
|
{ fields: fields, layout: layout }
|
143
156
|
end
|
144
157
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forest_admin_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.pre.beta.
|
4
|
+
version: 1.0.0.pre.beta.70
|
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-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|