active_element 0.0.29 → 0.0.31
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/Gemfile.lock +1 -1
- data/lib/active_element/components/util/record_path.rb +11 -3
- data/lib/active_element/default_controller/params.rb +10 -1
- data/lib/active_element/default_controller/search.rb +8 -0
- data/lib/active_element/field_options.rb +6 -1
- data/lib/active_element/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4674930632a2913f699ce77bb0ee31d83b8e11a0356a013beaa6b7d740337a0a
|
4
|
+
data.tar.gz: 3d8ed9fde6a7a6072075afb7db1c12892ca5113b5beaf14221888fd7a7f96da8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 137906e98706fe08498ebebc90fb37d2ca85ba5dc2e4ca55411cc750c515312b55473f17b0815a554744d8db6fa0f5239c3c06dbef2d22098c07258242e4a37f
|
7
|
+
data.tar.gz: 45f050797338f9c7d6ebd47f203a2fb3db6974a92a160df50606c91a43d20cab7956dbfe3673d53c5283347825cafa273f92ee4a00654f6c30cfad058960b23b
|
data/Gemfile.lock
CHANGED
@@ -65,7 +65,7 @@ module ActiveElement
|
|
65
65
|
attr_reader :record, :controller, :type
|
66
66
|
|
67
67
|
def record_path(**kwargs) # rubocop:disable Metrics/AbcSize
|
68
|
-
return nil if record.nil?
|
68
|
+
return nil if record.nil? || default_record_path.nil?
|
69
69
|
|
70
70
|
controller.helpers.public_send(default_record_path, *path_arguments, **kwargs)
|
71
71
|
rescue NoMethodError
|
@@ -90,8 +90,16 @@ module ActiveElement
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def default_record_path
|
93
|
-
|
94
|
-
|
93
|
+
if record.try(:active_element_controller_name).present?
|
94
|
+
record.active_element_controller_name
|
95
|
+
.constantize.controller_path
|
96
|
+
.underscore
|
97
|
+
.singularize.tr('/', '_') + '_path'
|
98
|
+
else
|
99
|
+
"#{record_path_prefix}#{namespace_prefix}#{record_name}_path"
|
100
|
+
end
|
101
|
+
rescue NameError
|
102
|
+
nil
|
95
103
|
end
|
96
104
|
|
97
105
|
def record_path_for(name)
|
@@ -46,11 +46,20 @@ module ActiveElement
|
|
46
46
|
|
47
47
|
def scalar?(field)
|
48
48
|
return true if relation?(field)
|
49
|
-
return true if %i[json jsonb].exclude?(
|
49
|
+
return true if %i[json jsonb].exclude?(field_type(field))
|
50
50
|
|
51
51
|
false
|
52
52
|
end
|
53
53
|
|
54
|
+
def field_type(field)
|
55
|
+
options_proc = controller.active_element.state.field_options[field]
|
56
|
+
return column(field)&.type if options_proc.nil?
|
57
|
+
|
58
|
+
field_options = FieldOptions.from_state(field, controller.active_element.state, nil, controller)
|
59
|
+
options_proc.call(field_options)
|
60
|
+
field_options.type || column(field)&.type
|
61
|
+
end
|
62
|
+
|
54
63
|
def json_params(fields)
|
55
64
|
# XXX: We assume all non-scalar fields are JSON fields, i.e. they must have a definition
|
56
65
|
# defined as `config/forms/<model>/<field>.yml`. If that file does not exist, allow
|
@@ -53,6 +53,14 @@ module ActiveElement
|
|
53
53
|
attr_reader :controller, :model
|
54
54
|
|
55
55
|
def string_like_column?(key)
|
56
|
+
exact = controller.active_element.state.field_options&.find do |field, options_proc|
|
57
|
+
field_options = FieldOptions.new(key)
|
58
|
+
options_proc.call(field_options, nil, controller)
|
59
|
+
field_options.exact_match
|
60
|
+
end
|
61
|
+
|
62
|
+
return false if exact
|
63
|
+
|
56
64
|
[:string, :text].include?(
|
57
65
|
model.columns.find { |column| column.name.to_s == key.to_s }&.type&.to_sym
|
58
66
|
)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module ActiveElement
|
2
2
|
class FieldOptions
|
3
|
-
attr_accessor :
|
3
|
+
attr_accessor :options, :value, :exact_match
|
4
|
+
attr_writer :type
|
4
5
|
attr_reader :field
|
5
6
|
|
6
7
|
def self.from_state(field, state, record, controller)
|
@@ -16,5 +17,9 @@ module ActiveElement
|
|
16
17
|
@field = field
|
17
18
|
@options = {}
|
18
19
|
end
|
20
|
+
|
21
|
+
def type
|
22
|
+
@type || :text_field
|
23
|
+
end
|
19
24
|
end
|
20
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_element
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Farrell
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bootstrap
|