hot_date_rails 1.5.9 → 1.5.10
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/app/helpers/form_helper.rb +20 -10
- data/lib/hot_date_rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dc8f79bd9abf2f5ef9ad296b604f746767ed1ad
|
4
|
+
data.tar.gz: ffc05184af4412204f9b64696f5228ace409e7fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2469dc3b25ba282402f5f7c09711a55c8899263e80eed56cd08880c1d53dbec0ca8f41fe31fca566f719d96a17ae35cccd96b543ad9c43c47dd725e059f25bd0
|
7
|
+
data.tar.gz: c6e2c1cd9a23305ded81c67088ce53a5748b6825543e2cc0c2c6d76a94689e2e6ab538da2b9fc6bdd2b9b1650ac94f5e28fb33d257b5d5ec20e3cd67551d7ae6
|
data/app/helpers/form_helper.rb
CHANGED
@@ -7,12 +7,12 @@ module FormHelper
|
|
7
7
|
end
|
8
8
|
|
9
9
|
private
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
def draw_ext_input_tag(field_name, value, cls, locale_format=nil, opts={})
|
11
|
+
formatted_value = I18n.l(value.to_date) if value.present?
|
12
|
+
input_attrs = InputAttrs.new(field_name, cls, opts)
|
13
|
+
text_field_tag("#{field_name}", formatted_value, input_attrs.to_h.reverse_merge({ id: FormHelper.random_input_id(field_name) })) + \
|
14
|
+
hidden_field_tag(field_name, nil, { class: field_name.to_s + "-alt", id: FormHelper.random_input_id(field_name, "hidden"), value: value })
|
15
|
+
end
|
16
16
|
end
|
17
17
|
|
18
18
|
class ActionView::Helpers::FormBuilder
|
@@ -49,7 +49,7 @@ module FormHelper
|
|
49
49
|
formatted_value = I18n.localize(value, format: locale_format) if value.present?
|
50
50
|
input_attrs = InputAttrs.new(attr, cls, opts)
|
51
51
|
self.text_field("#{attr}", input_attrs.to_h.merge(value: (formatted_value || ""))) + \
|
52
|
-
self.hidden_field(attr, { :class => attr.to_s + "-alt", :
|
52
|
+
self.hidden_field(attr, { :class => attr.to_s + "-alt", id: FormHelper.input_id(object, attr) })
|
53
53
|
end
|
54
54
|
|
55
55
|
def column_type(attr)
|
@@ -64,11 +64,10 @@ module FormHelper
|
|
64
64
|
class InputAttrs < Hash
|
65
65
|
def initialize(attr, hd_cls, opts={})
|
66
66
|
opts.reverse_merge!(html: {})
|
67
|
-
#Set html attribute hash here so :class
|
67
|
+
#Set html attribute hash here so :class always gets overridden in next line
|
68
68
|
self.merge! opts[:html]
|
69
69
|
self[:class] = (self.fetch(:class, "").split(" ") << hd_cls).join(" ")
|
70
|
-
|
71
|
-
opts[:hd_opts] ||= {}
|
70
|
+
opts[:hd_opts] ||= {}
|
72
71
|
opts[:data] ||= {}
|
73
72
|
data = opts[:hd_opts].merge(opts[:data])
|
74
73
|
hd_config = HotDateRails.config
|
@@ -83,4 +82,15 @@ module FormHelper
|
|
83
82
|
self[:data] = data
|
84
83
|
end
|
85
84
|
end
|
85
|
+
|
86
|
+
private
|
87
|
+
def self.input_id(parent_obj, suffix=nil)
|
88
|
+
#Uses the parent object for the id because each scope can only have a single input for each attribute
|
89
|
+
"hdr-hidden-#{parent_obj.class.to_s.downcase}-#{parent_obj.object_id}-#{suffix}"
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.random_input_id(suffix=nil, type="text")
|
93
|
+
random_id = SecureRandom.urlsafe_base64
|
94
|
+
"hdr-#{type}-tag-#{random_id}-#{suffix}"
|
95
|
+
end
|
86
96
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hot_date_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John O'Malley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|