forest_admin_datasource_toolkit 1.0.0.pre.beta.66 → 1.0.0.pre.beta.68

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: 305496bfd7be1c88916369c714cdb1e8ba57e5ba7835d0fc82fd04bf6b632e34
4
- data.tar.gz: e1781bba54219a75ef4c04db914f82da84250989d7141687b5607b0d4d6998d1
3
+ metadata.gz: 782b4a69580cae0ca60ce9458728945e08fd5763e1291a835d0c033d01b04d4d
4
+ data.tar.gz: e83f24fea69a9b998c28e094bfe32c28b07409b423c5359d64d74d9f6a92223e
5
5
  SHA512:
6
- metadata.gz: a1f3820914c3d62d0902a4b6212c03c8cabe66abf2e50187be087e126388776f103a8f4e3a3493b6a2e06c19d99e01b285a4891c32fa18ff06bd5b6d28753487
7
- data.tar.gz: 52dcb685971d80d89435d60adc8513a07f90f3589c8d068cfb67d43ce65d74554b5a469e32c5d695b0e91428282048b65b9c3a592d2e457ef7adcd4da8b5cbc8
6
+ metadata.gz: 6ead7641df99b32fdcd5f1a3b3c96265eaf9cf25e033adacde079c47ec04b6340acd0d53bd99f62c2ab29c784c1c26ffcb527a481c90f33a52ff45567abdbb3a
7
+ data.tar.gz: fa6912d82bbfd90b530449fd73c92af1134b860e812fe0e9e88f4b26cc9a42f463fbde48b4c7c86167d13b2eee519b01f7f8cf7cbebc64d534fb374be9a710ff
@@ -3,6 +3,25 @@ module ForestAdminDatasourceToolkit
3
3
  module Actions
4
4
  class ActionFieldFactory
5
5
  def self.build(field)
6
+ if field.key? :widget
7
+ build_widget(field)
8
+ elsif field[:type] == 'Layout'
9
+ build_layout_element(field)
10
+ else
11
+ ActionField.new(**field)
12
+ end
13
+ end
14
+
15
+ def self.build_layout_element(field)
16
+ case field[:component]
17
+ when 'Separator'
18
+ ActionLayoutElement::SeparatorElement.new(**field)
19
+ when 'HtmlBlock'
20
+ ActionLayoutElement::HtmlBlockElement.new(**field)
21
+ end
22
+ end
23
+
24
+ def self.build_widget(field)
6
25
  case field[:widget]
7
26
  when 'AddressAutocomplete'
8
27
  WidgetField::AddressAutocompleteField.new(**field)
@@ -40,8 +59,6 @@ module ForestAdminDatasourceToolkit
40
59
  WidgetField::TimePickerField.new(**field)
41
60
  when 'UserDropdown'
42
61
  WidgetField::UserDropdownField.new(**field)
43
- else
44
- ActionField.new(**field)
45
62
  end
46
63
  end
47
64
  end
@@ -0,0 +1,49 @@
1
+ module ForestAdminDatasourceToolkit
2
+ module Components
3
+ module Actions
4
+ module ActionLayoutElement
5
+ class BaseLayoutElement
6
+ attr_reader :type, :component
7
+
8
+ def initialize(component:, **_kwargs)
9
+ @type = FieldType::LAYOUT
10
+ @component = component
11
+ end
12
+
13
+ def to_h
14
+ result = {}
15
+ instance_variables.each do |attribute|
16
+ result[attribute.to_s.delete('@').camelize(:lower).to_sym] = instance_variable_get(attribute)
17
+ end
18
+
19
+ result
20
+ end
21
+ end
22
+
23
+ class InputElement < BaseLayoutElement
24
+ attr_reader :field_id
25
+
26
+ def initialize(field_id:, **options)
27
+ super(component: 'Separator', **options)
28
+ @field_id = field_id
29
+ end
30
+ end
31
+
32
+ class HtmlBlockElement < BaseLayoutElement
33
+ attr_reader :content
34
+
35
+ def initialize(content:, **options)
36
+ super(component: 'HtmlBlock', **options)
37
+ @content = content
38
+ end
39
+ end
40
+
41
+ class SeparatorElement < BaseLayoutElement
42
+ def initialize(**options)
43
+ super(component: 'Separator', **options)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -30,6 +30,8 @@ module ForestAdminDatasourceToolkit
30
30
 
31
31
  STRING_LIST = 'StringList'.freeze
32
32
 
33
+ LAYOUT = 'Layout'.freeze
34
+
33
35
  def self.all
34
36
  constants.map { |constant| const_get(constant) }
35
37
  end
@@ -1,3 +1,3 @@
1
1
  module ForestAdminDatasourceToolkit
2
- VERSION = "1.0.0-beta.66"
2
+ VERSION = "1.0.0-beta.68"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_admin_datasource_toolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.beta.66
4
+ version: 1.0.0.pre.beta.68
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-05 00:00:00.000000000 Z
12
+ date: 2024-09-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -57,6 +57,7 @@ files:
57
57
  - lib/forest_admin_datasource_toolkit/collection.rb
58
58
  - lib/forest_admin_datasource_toolkit/components/actions/action_field.rb
59
59
  - lib/forest_admin_datasource_toolkit/components/actions/action_field_factory.rb
60
+ - lib/forest_admin_datasource_toolkit/components/actions/action_layout_element.rb
60
61
  - lib/forest_admin_datasource_toolkit/components/actions/field_type.rb
61
62
  - lib/forest_admin_datasource_toolkit/components/actions/widget_field.rb
62
63
  - lib/forest_admin_datasource_toolkit/components/caller.rb