forest_admin_agent 1.0.0.pre.beta.66 → 1.0.0.pre.beta.67
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: 102bc16ac3f1558f735da11578c64f728e46a8d4fce2e5226e39446cbd3b83fd
|
4
|
+
data.tar.gz: 9e6cf5a41c4cfdd84733bb2bba8ed63e2b176375e32be57f5c1372fdb1e703e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8be3201acf63fbc863320e1f663f15b18b556e0be542484081f4b0494abfa8f8d62180d6f481efb9db03ee3299da4e00d20b2d17e82b3b12da416b255e8f5996
|
7
|
+
data.tar.gz: f0ff4f00e19244e8440791d9bae621b2616e33003a3467107c1a81bdd5a62900c9dd12c5f53eaacbe46394f17202c110c3dfdec625a4307c74fa04fba79760d6
|
@@ -69,7 +69,11 @@ module ForestAdminAgent
|
|
69
69
|
)
|
70
70
|
|
71
71
|
# Now that we have the field list, we can parse the data again.
|
72
|
-
data = Schema::ForestValueConverter.make_form_data(
|
72
|
+
data = Schema::ForestValueConverter.make_form_data(
|
73
|
+
@datasource,
|
74
|
+
raw_data,
|
75
|
+
fields.reject { |field| field.type == 'Layout' }
|
76
|
+
)
|
73
77
|
|
74
78
|
{ content: @collection.execute(@caller, @action_name, data, filter_for_caller) }
|
75
79
|
end
|
@@ -82,7 +86,7 @@ module ForestAdminAgent
|
|
82
86
|
search_values = {}
|
83
87
|
forest_fields&.each { |field| search_values[field['field']] = field['searchValue'] }
|
84
88
|
|
85
|
-
|
89
|
+
form = @collection.get_form(
|
86
90
|
@caller,
|
87
91
|
@action_name,
|
88
92
|
data,
|
@@ -94,10 +98,12 @@ module ForestAdminAgent
|
|
94
98
|
includeHiddenFields: false
|
95
99
|
}
|
96
100
|
)
|
101
|
+
form_elements = Schema::GeneratorAction.extract_fields_and_layout(form)
|
97
102
|
|
98
103
|
{
|
99
104
|
content: {
|
100
|
-
fields:
|
105
|
+
fields: Schema::GeneratorAction.build_fields(@collection, form_elements[:fields]),
|
106
|
+
layout: Schema::GeneratorAction.build_layout(form_elements[:layout])
|
101
107
|
}
|
102
108
|
}
|
103
109
|
end
|
@@ -2,6 +2,8 @@ module ForestAdminAgent
|
|
2
2
|
module Utils
|
3
3
|
module Schema
|
4
4
|
class GeneratorAction
|
5
|
+
include ForestAdminDatasourceToolkit::Components
|
6
|
+
|
5
7
|
DEFAULT_FIELDS = [
|
6
8
|
{
|
7
9
|
field: 'Loading...',
|
@@ -23,27 +25,46 @@ module ForestAdminAgent
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def self.build_schema(collection, name)
|
26
|
-
|
28
|
+
action = collection.schema[:actions][name]
|
27
29
|
action_index = collection.schema[:actions].keys.index(name)
|
28
30
|
slug = get_action_slug(name)
|
29
|
-
fields = build_fields(collection, name, schema)
|
30
31
|
|
31
|
-
|
32
|
+
form_elements = extract_fields_and_layout(collection.get_form(nil, name))
|
33
|
+
if action.static_form? && form_elements[:layout].empty?
|
34
|
+
# if action.static_form?
|
35
|
+
fields = build_fields(collection, form_elements[:fields])
|
36
|
+
layout = form_elements[:layout]
|
37
|
+
else
|
38
|
+
fields = DEFAULT_FIELDS
|
39
|
+
layout = nil
|
40
|
+
end
|
41
|
+
|
42
|
+
schema = {
|
32
43
|
id: "#{collection.name}-#{action_index}-#{slug}",
|
33
44
|
name: name,
|
34
|
-
type:
|
45
|
+
type: action.scope.downcase,
|
35
46
|
baseUrl: nil,
|
36
47
|
endpoint: "/forest/_actions/#{collection.name}/#{action_index}/#{slug}",
|
37
48
|
httpMethod: 'POST',
|
38
49
|
redirect: nil, # frontend ignores this attribute
|
39
|
-
download:
|
50
|
+
download: action.is_generate_file,
|
40
51
|
fields: fields,
|
41
52
|
hooks: {
|
42
|
-
load: !
|
53
|
+
load: !action.static_form?,
|
43
54
|
# Always registering the change hook has no consequences, even if we don't use it.
|
44
55
|
change: ['changeHook']
|
45
56
|
}
|
46
57
|
}
|
58
|
+
|
59
|
+
return schema unless layout && !layout.empty?
|
60
|
+
|
61
|
+
schema[:layout] = build_layout(layout)
|
62
|
+
|
63
|
+
schema
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.build_layout_schema(field)
|
67
|
+
{ **field.to_h, component: field.component.downcase }
|
47
68
|
end
|
48
69
|
|
49
70
|
def self.build_field_schema(datasource, field)
|
@@ -76,26 +97,49 @@ module ForestAdminAgent
|
|
76
97
|
output
|
77
98
|
end
|
78
99
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
100
|
+
def self.build_fields(collection, fields)
|
101
|
+
if fields
|
102
|
+
return fields.map do |field|
|
103
|
+
new_field = build_field_schema(collection.datasource, field)
|
104
|
+
new_field[:default_value] = new_field[:value]
|
105
|
+
new_field.delete(:value)
|
84
106
|
|
85
|
-
|
107
|
+
new_field
|
108
|
+
end
|
109
|
+
end
|
86
110
|
|
87
|
-
|
88
|
-
|
89
|
-
new_field = build_field_schema(collection.datasource, field)
|
90
|
-
new_field[:default_value] = new_field[:value]
|
91
|
-
new_field.delete(:value)
|
111
|
+
[]
|
112
|
+
end
|
92
113
|
|
93
|
-
|
94
|
-
|
114
|
+
def self.build_layout(elements)
|
115
|
+
if elements
|
116
|
+
return elements.map do |element|
|
117
|
+
build_layout_schema(element)
|
95
118
|
end
|
119
|
+
end
|
120
|
+
|
121
|
+
[]
|
122
|
+
end
|
123
|
+
|
124
|
+
def self.extract_fields_and_layout(form)
|
125
|
+
fields = []
|
126
|
+
layout = []
|
127
|
+
has_real_layout = false
|
96
128
|
|
97
|
-
|
129
|
+
form&.each do |element|
|
130
|
+
if element.type == Actions::FieldType::LAYOUT
|
131
|
+
layout << element
|
132
|
+
has_real_layout = true
|
133
|
+
else
|
134
|
+
fields << element
|
135
|
+
# frontend rule
|
136
|
+
layout << Actions::ActionLayoutElement::InputElement.new(component: 'Input', field_id: element.label)
|
137
|
+
end
|
98
138
|
end
|
139
|
+
|
140
|
+
layout = [] unless has_real_layout
|
141
|
+
|
142
|
+
{ fields: fields, layout: layout }
|
99
143
|
end
|
100
144
|
end
|
101
145
|
end
|
@@ -7,7 +7,7 @@ module ForestAdminAgent
|
|
7
7
|
class SchemaEmitter
|
8
8
|
LIANA_NAME = "agent-ruby"
|
9
9
|
|
10
|
-
LIANA_VERSION = "1.0.0-beta.
|
10
|
+
LIANA_VERSION = "1.0.0-beta.67"
|
11
11
|
|
12
12
|
def self.get_serialized_schema(datasource)
|
13
13
|
schema_path = Facades::Container.cache(:schema_path)
|
@@ -66,6 +66,7 @@ module ForestAdminAgent
|
|
66
66
|
schema[:collections].each do |collection|
|
67
67
|
collection_actions = collection[:actions]
|
68
68
|
collection_segments = collection[:segments]
|
69
|
+
|
69
70
|
collection.delete(:actions)
|
70
71
|
collection.delete(:segments)
|
71
72
|
|
@@ -94,6 +95,7 @@ module ForestAdminAgent
|
|
94
95
|
|
95
96
|
def get_smart_features_by_collection(type, data, with_attributes: false)
|
96
97
|
smart_features = []
|
98
|
+
|
97
99
|
data.each do |value|
|
98
100
|
smart_feature = { id: value[:id], type: type }
|
99
101
|
smart_feature[:attributes] = value if with_attributes
|
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.67
|
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-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|