hellobase-formtastic 0.2.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a6709435108ea76c05c1a914d7de6130d8b2fa24d86df30332ec4c485e92a1e
4
- data.tar.gz: 9d85ba91be22e249e95810d78ba805cd7caf84de03e64bc1fff6d47d8375e4ca
3
+ metadata.gz: 91ed20f61e12cb7e7f2ae092cd5bb50bc1046e67e1ea1951e9f5c34cae10f438
4
+ data.tar.gz: 8622f461fbe818499fe85bde5fb22561f8a9ecddd3c86d3e15b5ca32946cb247
5
5
  SHA512:
6
- metadata.gz: 0db3da06a01a65b1a8a91ba4e628b3fbd9fa5925bf4cd01d37fba417a0f52059407314c50af31b59ca6e90b49412ac6b5d9580396bfe2a75ba2aa7552971ead2
7
- data.tar.gz: de834bfc586a0300774efd8f2ed1f394fb983b8b06ae8ebb195a208e16a5484b8d2507120e624e298abdf116aea4531ec39761c9b196a18bc80965b12b26b10a
6
+ metadata.gz: a47ca291dfc839b4884d42180c840b5adb03931a7213e16198280ae518710f5ef6d243d83f4d8fb2f5b913bd943975528385cd5b518fb7c2f9d2b6375e76e994
7
+ data.tar.gz: 1ed1b99f2dc90f92361732e65c9f38d2b7043ff2ddb7990ff4bba6751272213db762c58f62a5eb1309afe70bad02187fc9ef57704314a9f240080f04bf1dd537
@@ -7,7 +7,7 @@ module Hellobase
7
7
  include ::Formtastic::Inputs::Base
8
8
 
9
9
  def self.virtual_attributes(base)
10
- [:"_dpwt_#{base}_d", :"_dpwt_#{base}_h", :"_dpwt_#{base}_m"]
10
+ [:"_dpwt_#{base}_d", :"_dpwt_#{base}_h", :"_dpwt_#{base}_m", :"_dpwt_#{base}_z"]
11
11
  end
12
12
 
13
13
  def self.define_virtual_attributes(klass, base)
@@ -28,6 +28,10 @@ module Hellobase
28
28
  send(base)&.strftime('%M')
29
29
  end
30
30
 
31
+ define_method attrs[3] do
32
+ send(base)&.strftime('%Z')
33
+ end
34
+
31
35
  attrs.each_with_index do |a, i|
32
36
  define_method :"#{a}=" do |val|
33
37
  instance_variable_set ivars[i], val
@@ -38,16 +42,19 @@ module Hellobase
38
42
  end
39
43
 
40
44
  define_method method do
41
- send :"#{base}=",
42
- ivars.any? {|v| instance_variable_get(v).blank? } ?
43
- nil :
44
- [
45
- instance_variable_get(ivars[0]),
46
- [
47
- instance_variable_get(ivars[1]),
48
- instance_variable_get(ivars[2])
49
- ].join(':')
50
- ].join(' ')
45
+ val = if ivars.any? {|v| !instance_variable_defined?(v) || instance_variable_get(v).blank? }
46
+ nil
47
+ else
48
+ begin
49
+ Time.use_zone(instance_variable_get(ivars[3])) do
50
+ Time.parse("#{instance_variable_get(ivars[0])} #{instance_variable_get(ivars[1])}:#{instance_variable_get(ivars[2])}")
51
+ end
52
+ rescue ArgumentError
53
+ nil
54
+ end
55
+ end
56
+
57
+ send :"#{base}=", val
51
58
  end
52
59
 
53
60
  private method
@@ -58,13 +65,17 @@ module Hellobase
58
65
  datepicker_html = ::ActiveAdmin::Inputs::DatepickerInput.new(builder, template, object, object_name, :"_dpwt_#{method}_d", datepicker_options).to_html
59
66
  hour_select_html = ::Formtastic::Inputs::SelectInput.new(builder, template, object, object_name, :"_dpwt_#{method}_h", hour_select_options).to_html
60
67
  minute_select_html = ::Formtastic::Inputs::SelectInput.new(builder, template, object, object_name, :"_dpwt_#{method}_m", minute_select_options).to_html
61
- zone_display_html = options[:time_zone] ? template.content_tag(:span, options[:time_zone]) : nil
68
+
69
+ timezone = options[:timezone] || 'UTC'
70
+ timezone_span_html = template.content_tag(:span, timezone, id: "#{object_name}__dpwt_#{method}_timezone")
71
+ timezone_hidden_input_html = template.hidden_field_tag("#{object_name}[_dpwt_#{method}_z]", timezone, :id => "#{object_name}__dpwt_#{method}_z")
62
72
 
63
73
  wrapper_contents = [
64
74
  replace_li_tag(datepicker_html),
65
75
  replace_li_tag(hour_select_html),
66
76
  replace_li_tag(minute_select_html),
67
- zone_display_html,
77
+ timezone_span_html,
78
+ timezone_hidden_input_html,
68
79
  error_html,
69
80
  hint_html,
70
81
  ].compact.join("\n").html_safe
@@ -1,5 +1,5 @@
1
1
  module Hellobase
2
2
  module Formtastic
3
- VERSION = '0.2.0'
3
+ VERSION = '0.4.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hellobase-formtastic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Wang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-16 00:00:00.000000000 Z
11
+ date: 2025-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeadmin
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  requirements: []
161
- rubygems_version: 3.2.32
161
+ rubygems_version: 3.1.6
162
162
  signing_key:
163
163
  specification_version: 4
164
164
  summary: Custom Formtastic inputs