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: 1ec7cdc76e8ce7354d2680798ed7639e63494054a7c61edb7d68c64531065d9f
4
- data.tar.gz: 46b7e3cf3f0c39750042cfb5c14abacf9f1a773cc7be045233941fc3a82530db
3
+ metadata.gz: 250a2c4a19974f9d4658a54b9bed10460bb810d3ee48fd7d54635eb084ae93b5
4
+ data.tar.gz: 9a523b41aaffe9a6b17a50e4237458ebd1bb5a5a0d21db64afe8ffac3ec955a0
5
5
  SHA512:
6
- metadata.gz: 9b8a421a9a493b1817fd7a9f6cfdfa870279963fa55d27c1f8aec7e6db901b387f729e6c52dacf5ee6e65574221992b23a326c5f45db91804f3c519bd2ec3ab0
7
- data.tar.gz: cc960dcc8d061dd901550cf760a19159a32548efa2681ddcdb580749aa6ef65cdb5229b11754e54ec6994a763b3282e4de3e27c889af2a40c11097eb66bab715
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.label == key }
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? && form_elements[:layout].empty?
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.label,
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[:default_value] = new_field[:value]
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
- layout << element
132
- has_real_layout = true
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.label)
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
@@ -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.68"
10
+ LIANA_VERSION = "1.0.0-beta.70"
11
11
 
12
12
  def self.get_serialized_schema(datasource)
13
13
  schema_path = Facades::Container.cache(:schema_path)
@@ -1,3 +1,3 @@
1
1
  module ForestAdminAgent
2
- VERSION = "1.0.0-beta.68"
2
+ VERSION = "1.0.0-beta.70"
3
3
  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.68
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-23 00:00:00.000000000 Z
12
+ date: 2024-09-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport