forest_admin_datasource_toolkit 1.0.0.pre.beta.71 → 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: 204966187a7512ce7c713abe86d214077dec4a18b8bbce7f7a9fed21d7cd9ab7
4
- data.tar.gz: c0b65b0882c3235a7b19b34129111b09192a9d531c12425eb70930fde86fb6e1
3
+ metadata.gz: d43271ff5fc8f51438f3afe25652101597dea7947b2cc6683f434884715ee6bc
4
+ data.tar.gz: b806cb1ad90460a456f7c23086d663d978ea0317c02017f0c6913c901382fa9f
5
5
  SHA512:
6
- metadata.gz: def45e51a3d0c19bc25e27ec3e07c064bc6c65ee4080036df7fb6b09f2c041169afb5b93ab050c8cb9326a820aa6941722ff17294cefd8226f0369bfd82b8c59
7
- data.tar.gz: 37918d296068efd822247bb5817d66296d43af2d1e89cf373d779926121b9a6f7d0d68e4c7f097a8d546170664419f3e2122c92156959a10686f153817453d1b
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.71"
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.71
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-10-04 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