forest_admin_datasource_customizer 1.50.2 → 1.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/forest_admin_datasource_customizer/decorators/action/base_action.rb +5 -2
- data/lib/forest_admin_datasource_customizer/decorators/action/dynamic_field.rb +4 -2
- data/lib/forest_admin_datasource_customizer/dsl/builders/action_builder.rb +8 -0
- data/lib/forest_admin_datasource_customizer/dsl/builders/form_builder.rb +3 -1
- data/lib/forest_admin_datasource_customizer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9b26c9a68554922fa0f5d0302d8789049b31bd199dfee20e41726b953dd86b3f
|
|
4
|
+
data.tar.gz: 12217da00d7cde2f488b3b6851a6457cf87bfc4865fc66b38cfb6a9f2cf82f81
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ce718458a7c787db63015d5fbce7221f5b187bc5bee7755f9a8ed6c1ec8cd6d0946d68cd502608f447a4edd94b934a678c8f36ec2e4d0a6cde7290e013f475f6
|
|
7
|
+
data.tar.gz: 5dcbec9ade5e7ac9680d2ec86a6f78e1ed43d90db957abe281e81e3ba78084d42054505d6edcd7235f80e929282b9399ab0e2dce419b8601890ac8ef24ea3369
|
|
@@ -2,16 +2,18 @@ module ForestAdminDatasourceCustomizer
|
|
|
2
2
|
module Decorators
|
|
3
3
|
module Action
|
|
4
4
|
class BaseAction
|
|
5
|
-
attr_reader :scope, :form, :is_generate_file, :description, :submit_button_label, :
|
|
5
|
+
attr_reader :scope, :form, :is_generate_file, :description, :submit_button_label, :pending_refresh_interval,
|
|
6
|
+
:execute, :static_form
|
|
6
7
|
|
|
7
8
|
# rubocop:disable Metrics/ParameterLists
|
|
8
9
|
def initialize(scope:, form: nil, is_generate_file: false, description: nil,
|
|
9
|
-
submit_button_label: nil, static_form: false, &execute)
|
|
10
|
+
submit_button_label: nil, pending_refresh_interval: nil, static_form: false, &execute)
|
|
10
11
|
@scope = scope
|
|
11
12
|
@form = form
|
|
12
13
|
@is_generate_file = is_generate_file
|
|
13
14
|
@description = description
|
|
14
15
|
@submit_button_label = submit_button_label
|
|
16
|
+
@pending_refresh_interval = pending_refresh_interval
|
|
15
17
|
@execute = execute
|
|
16
18
|
@static_form = static_form
|
|
17
19
|
end
|
|
@@ -24,6 +26,7 @@ module ForestAdminDatasourceCustomizer
|
|
|
24
26
|
is_generate_file: action[:is_generate_file],
|
|
25
27
|
description: action[:description],
|
|
26
28
|
submit_button_label: action[:submit_button_label],
|
|
29
|
+
pending_refresh_interval: action[:pending_refresh_interval],
|
|
27
30
|
static_form: action[:static_form] || false,
|
|
28
31
|
&action[:execute]
|
|
29
32
|
)
|
|
@@ -2,8 +2,8 @@ module ForestAdminDatasourceCustomizer
|
|
|
2
2
|
module Decorators
|
|
3
3
|
module Action
|
|
4
4
|
class DynamicField < BaseFormElement
|
|
5
|
-
attr_accessor :type, :label, :description, :is_required, :is_read_only, :
|
|
6
|
-
:collection_name, :enum_values, :placeholder, :id
|
|
5
|
+
attr_accessor :type, :label, :description, :is_required, :is_read_only, :is_pending, :if_condition, :value,
|
|
6
|
+
:default_value, :collection_name, :enum_values, :placeholder, :id
|
|
7
7
|
|
|
8
8
|
def initialize(
|
|
9
9
|
type:,
|
|
@@ -12,6 +12,7 @@ module ForestAdminDatasourceCustomizer
|
|
|
12
12
|
description: nil,
|
|
13
13
|
is_required: false,
|
|
14
14
|
is_read_only: false,
|
|
15
|
+
is_pending: false,
|
|
15
16
|
if_condition: nil,
|
|
16
17
|
value: nil,
|
|
17
18
|
default_value: nil,
|
|
@@ -32,6 +33,7 @@ module ForestAdminDatasourceCustomizer
|
|
|
32
33
|
@description = description
|
|
33
34
|
@is_required = is_required
|
|
34
35
|
@is_read_only = is_read_only
|
|
36
|
+
@is_pending = is_pending
|
|
35
37
|
@if_condition = if_condition
|
|
36
38
|
@value = value
|
|
37
39
|
@default_value = default_value
|
|
@@ -33,6 +33,7 @@ module ForestAdminDatasourceCustomizer
|
|
|
33
33
|
@execute_block = nil
|
|
34
34
|
@description = nil
|
|
35
35
|
@submit_button_label = nil
|
|
36
|
+
@pending_refresh_interval = nil
|
|
36
37
|
@generate_file = false
|
|
37
38
|
end
|
|
38
39
|
|
|
@@ -48,6 +49,12 @@ module ForestAdminDatasourceCustomizer
|
|
|
48
49
|
@submit_button_label = label
|
|
49
50
|
end
|
|
50
51
|
|
|
52
|
+
# Set the delay between two form refreshes while a field is pending
|
|
53
|
+
# @param seconds [Integer] refresh interval in seconds
|
|
54
|
+
def pending_refresh_interval(seconds)
|
|
55
|
+
@pending_refresh_interval = seconds
|
|
56
|
+
end
|
|
57
|
+
|
|
51
58
|
# Mark action as generating a file
|
|
52
59
|
def generates_file!
|
|
53
60
|
@generate_file = true
|
|
@@ -85,6 +92,7 @@ module ForestAdminDatasourceCustomizer
|
|
|
85
92
|
is_generate_file: @generate_file,
|
|
86
93
|
description: @description,
|
|
87
94
|
submit_button_label: @submit_button_label,
|
|
95
|
+
pending_refresh_interval: @pending_refresh_interval,
|
|
88
96
|
&@execute_block
|
|
89
97
|
)
|
|
90
98
|
end
|
|
@@ -38,6 +38,7 @@ module ForestAdminDatasourceCustomizer
|
|
|
38
38
|
# @param options [Array<Hash>, Proc] options for dropdown/radio widgets (static or dynamic)
|
|
39
39
|
# @param readonly [Boolean, Proc] whether field is read-only (static or dynamic)
|
|
40
40
|
# @param required [Boolean, Proc] whether field is required (static or dynamic)
|
|
41
|
+
# @param pending [Boolean, Proc] whether field is waiting for its data (static or dynamic)
|
|
41
42
|
# @param default [Object, Proc] default value (static or dynamic)
|
|
42
43
|
# @param description [String, Proc] field description (static or dynamic)
|
|
43
44
|
# @param placeholder [String, Proc] placeholder text (static or dynamic)
|
|
@@ -45,7 +46,7 @@ module ForestAdminDatasourceCustomizer
|
|
|
45
46
|
# @param enum_values [Array, Proc] enum values for enum fields (static or dynamic)
|
|
46
47
|
# @param collection_name [String, Proc] target collection name (static or dynamic)
|
|
47
48
|
# @param block [Proc] optional proc for computed values
|
|
48
|
-
def field(name, type:, widget: nil, options: nil, readonly: nil, required: nil, default: nil,
|
|
49
|
+
def field(name, type:, widget: nil, options: nil, readonly: nil, required: nil, pending: nil, default: nil,
|
|
49
50
|
description: nil, placeholder: nil, if_condition: nil, enum_values: nil, collection_name: nil, &block)
|
|
50
51
|
field_def = {
|
|
51
52
|
label: name.to_s,
|
|
@@ -56,6 +57,7 @@ module ForestAdminDatasourceCustomizer
|
|
|
56
57
|
field_def[:options] = options if options
|
|
57
58
|
field_def[:is_read_only] = readonly if readonly
|
|
58
59
|
field_def[:is_required] = required if required
|
|
60
|
+
field_def[:is_pending] = pending if pending
|
|
59
61
|
field_def[:default_value] = default if default
|
|
60
62
|
field_def[:description] = description if description
|
|
61
63
|
field_def[:placeholder] = placeholder if placeholder
|