active_element 0.0.29 → 0.0.30

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1cb0aa53f1b0832280482cb35d23d5bbcc7ece8f7b03001f81e9d18d290cc831
4
- data.tar.gz: c1a34228e6c2529294ab30a4e9232d2ce6bef50f396951224b5740d67d992cf8
3
+ metadata.gz: 1469f981b1ca1a72146c9e6a241d79ba89151468deb8cc23a6f684eeb491b0a1
4
+ data.tar.gz: acdbd91537ee25169fb7639f083661b70fa04d536ebf96cf24c4bb50bbcac087
5
5
  SHA512:
6
- metadata.gz: d64eb7cc1f58b62c0e15d8b8e47029ea41073afbd058a2ce35bcee0d9e41de90ffcf32551d5d0c5a3bd2bea39d4ec7578ef99854a2530d96707b9f9bbd79e8d8
7
- data.tar.gz: bd7207c7873eda19bcba2e458e78753a95a653371f07576df7b47da2a280ad3c83fb14d85f78a1193b3ce9ba0c0cb26586a0e6ef553a2013343aa6618dc8f69f
6
+ metadata.gz: 9e6d03d68afd27853fa96de0ae0fabd0cbb3dbad46d329eacdfc45c523c770fe9d85649191f5d2215f6b4a494fa14169b2986ac39ca8f25f07547ed5a62599e5
7
+ data.tar.gz: 79751155402da2ab9f72710db51517d214cf55b15e4240c444d3489d33f703e944123e1fa9146d5c2a8c47c8426bb42269801dba30c230c7f1f231ed248cba9a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_element (0.0.29)
4
+ active_element (0.0.30)
5
5
  bootstrap (~> 5.3.0alpha3)
6
6
  kaminari (~> 1.2)
7
7
  paintbrush (~> 0.1.2)
@@ -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
- return record.controller_name.constantize.controller_path.underscore.singularize.tr('/', '_') + '_path' if record.try(:controller_name).present?
94
- "#{record_path_prefix}#{namespace_prefix}#{record_name}_path"
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)
@@ -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 :type, :options, :value
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveElement
4
- VERSION = '0.0.29'
4
+ VERSION = '0.0.30'
5
5
  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.29
4
+ version: 0.0.30
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-14 00:00:00.000000000 Z
11
+ date: 2024-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootstrap