forest_admin_datasource_toolkit 1.0.0.pre.beta.70 → 1.0.0.pre.beta.72

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: ba5e890be37b6df871a6838cdc56f996a7ccd4fd7177641d899ee2b154fef5ef
4
- data.tar.gz: cfb24313d4da3745ddb1f2bd468e109465c7b523f10b41aea11bc90ecb2522b1
3
+ metadata.gz: d43271ff5fc8f51438f3afe25652101597dea7947b2cc6683f434884715ee6bc
4
+ data.tar.gz: b806cb1ad90460a456f7c23086d663d978ea0317c02017f0c6913c901382fa9f
5
5
  SHA512:
6
- metadata.gz: 8deb273f997354e2e90dd734c6efbc7e19f3f19f2baaaf69d30cf58be6b94cb194d71a294cb8443efb4116944182bbd211356558123edfff56198c1394fd326f
7
- data.tar.gz: 8a4a2a0ce2855c51ce75c8e6aba9026a561ff272373bd71405b50a880b01356d592df48a864659188ac85f305c262d8872dc7b3d318098bac308eb5e7b6abe92
6
+ metadata.gz: 7f5a4cfb7ee82a350e228fa300fe537aab627a0fc1480e61adf15acffe18747001df2f2ae23177afb748d0b3bf31713fec0bccc9f155a96436b25fccab1c9e21
7
+ data.tar.gz: 39ec859443572bb01c5a487ac83298f150a99d32d12f670e553913911a9d9424a650ec1a2603b0d38b5faaaff3d501052405522f0f31af942625283b32109364
@@ -37,6 +37,15 @@ module ForestAdminDatasourceToolkit
37
37
  def watch_changes?
38
38
  @watch_changes
39
39
  end
40
+
41
+ def to_h
42
+ result = {}
43
+ instance_variables.each do |attribute|
44
+ result[attribute.to_s.delete('@').to_sym] = instance_variable_get(attribute)
45
+ end
46
+
47
+ result
48
+ end
40
49
  end
41
50
  end
42
51
  end
@@ -3,7 +3,7 @@ module ForestAdminDatasourceToolkit
3
3
  module Actions
4
4
  class ActionFieldFactory
5
5
  def self.build(field)
6
- if field.key? :widget
6
+ if field.key?(:widget) && !field[:widget].nil?
7
7
  build_widget(field)
8
8
  elsif field[:type] == 'Layout'
9
9
  build_layout_element(field)
@@ -21,6 +21,10 @@ module ForestAdminDatasourceToolkit
21
21
  when 'Row'
22
22
  return ActionLayoutElement::RowElement.new(**field) unless field[:fields].empty?
23
23
 
24
+ nil
25
+ when 'Page'
26
+ return ActionLayoutElement::PageElement.new(**field) unless field[:elements].empty?
27
+
24
28
  nil
25
29
  end
26
30
  end
@@ -1,3 +1,5 @@
1
+ require 'active_support/core_ext/string/inflections'
2
+
1
3
  module ForestAdminDatasourceToolkit
2
4
  module Components
3
5
  module Actions
@@ -49,7 +51,31 @@ module ForestAdminDatasourceToolkit
49
51
 
50
52
  def initialize(fields:, **options)
51
53
  super(component: 'Row', **options)
52
- @fields = fields
54
+ @fields = instantiate_subfields(fields)
55
+ end
56
+
57
+ def instantiate_subfields(fields)
58
+ fields.map do |field|
59
+ ActionFieldFactory.build(field.to_h)
60
+ end
61
+ end
62
+ end
63
+
64
+ class PageElement < BaseLayoutElement
65
+ attr_accessor :elements, :next_button_label, :previous_button_label
66
+
67
+ def initialize(elements:, previous_button_label:, next_button_label:, **options)
68
+ super(component: 'Page', **options)
69
+ @elements = elements
70
+ @next_button_label = next_button_label
71
+ @previous_button_label = previous_button_label
72
+ @elements = instantiate_elements(elements)
73
+ end
74
+
75
+ def instantiate_elements(elements)
76
+ elements.map do |element|
77
+ ActionFieldFactory.build(element.to_h)
78
+ end
53
79
  end
54
80
  end
55
81
  end
@@ -1,3 +1,3 @@
1
1
  module ForestAdminDatasourceToolkit
2
- VERSION = "1.0.0-beta.70"
2
+ VERSION = "1.0.0-beta.72"
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.70
4
+ version: 1.0.0.pre.beta.72
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-27 00:00:00.000000000 Z
12
+ date: 2024-10-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport