forest_admin_datasource_toolkit 1.0.0.pre.beta.71 → 1.0.0.pre.beta.73

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: 204966187a7512ce7c713abe86d214077dec4a18b8bbce7f7a9fed21d7cd9ab7
4
- data.tar.gz: c0b65b0882c3235a7b19b34129111b09192a9d531c12425eb70930fde86fb6e1
3
+ metadata.gz: 2634924a0be0624dfb4d8b88ea7820b0b0a758ff01aa2dd5819cb0450ab08234
4
+ data.tar.gz: ece413eb1f5d7c363cecd5d69059cb2423e4741fcfbe8847189ee5506965beb3
5
5
  SHA512:
6
- metadata.gz: def45e51a3d0c19bc25e27ec3e07c064bc6c65ee4080036df7fb6b09f2c041169afb5b93ab050c8cb9326a820aa6941722ff17294cefd8226f0369bfd82b8c59
7
- data.tar.gz: 37918d296068efd822247bb5817d66296d43af2d1e89cf373d779926121b9a6f7d0d68e4c7f097a8d546170664419f3e2122c92156959a10686f153817453d1b
6
+ metadata.gz: 177bcdd7ac53927498c2805c31d1817610d30e1f5614af39370cb1fff75e8076b8234510f40ba9322911bb67a298fe1c1fbd3f65bf4d4625122e0463aa7ec9c6
7
+ data.tar.gz: 65492c3ef7aff8904c544e43905140d91d54ea12b5e25969f2a5dfba9213bd97f26a7e65a7e6bbcf6ab63a3a7fecc7156ea5f41ed82078d576c6cc1fe387399e
@@ -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.71"
2
+ VERSION = "1.0.0-beta.73"
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.71
4
+ version: 1.0.0.pre.beta.73
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-10-04 00:00:00.000000000 Z
12
+ date: 2024-10-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport