hellobase-formtastic 0.1.1 → 0.3.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23204b79fccf4dbacbe9826a220766e0604923a959673771c8fc38bc6240997e
|
4
|
+
data.tar.gz: f13d31c76387f8646d180dcf65482b85c38cf742de6297b4dcb07a1b0b4fe5a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9561afc8619c56078637790305dc024d0a19e39e58a4b25942ae76ef3a09cd434c1bbe8d3389068dc276709254d1a79fa820973ab911cdc65bfb0318a31a5b8
|
7
|
+
data.tar.gz: 2e5725f7722d104c5ddecdb173614b7457338eb2030802521045842dcea08adcbaac3c27062bf4dcb2fc49b55040d231624712a9fa0e9d5206aad33393738498
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'active_admin/inputs'
|
2
|
+
|
3
|
+
module Hellobase
|
4
|
+
module Formtastic
|
5
|
+
module Inputs
|
6
|
+
class ArrayTextInput < ::Formtastic::Inputs::TextInput
|
7
|
+
def self.virtual_attributes(base)
|
8
|
+
[:"_stra_#{base}_text"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.define_virtual_attributes(klass, base)
|
12
|
+
vattr = virtual_attributes(base).first
|
13
|
+
ivar = :"@#{vattr}"
|
14
|
+
method = :"_stra_set_#{base}"
|
15
|
+
|
16
|
+
klass.class_eval do
|
17
|
+
define_method vattr do
|
18
|
+
send(base)&.join("\n")
|
19
|
+
end
|
20
|
+
|
21
|
+
define_method :"#{vattr}=" do |val|
|
22
|
+
instance_variable_set ivar, val
|
23
|
+
send(method)
|
24
|
+
|
25
|
+
val
|
26
|
+
end
|
27
|
+
|
28
|
+
define_method method do
|
29
|
+
send :"#{base}=", instance_variable_get(ivar)&.split(/[\r\n]+/)
|
30
|
+
end
|
31
|
+
|
32
|
+
private method
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_html
|
37
|
+
input_wrapping do
|
38
|
+
label_html <<
|
39
|
+
builder.text_area(:"_stra_#{method}_text", input_html_options)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -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
|
@@ -46,7 +50,8 @@ module Hellobase
|
|
46
50
|
[
|
47
51
|
instance_variable_get(ivars[1]),
|
48
52
|
instance_variable_get(ivars[2])
|
49
|
-
].join(':')
|
53
|
+
].join(':'),
|
54
|
+
instance_variable_get(ivars[3]),
|
50
55
|
].join(' ')
|
51
56
|
end
|
52
57
|
|
@@ -58,13 +63,17 @@ module Hellobase
|
|
58
63
|
datepicker_html = ::ActiveAdmin::Inputs::DatepickerInput.new(builder, template, object, object_name, :"_dpwt_#{method}_d", datepicker_options).to_html
|
59
64
|
hour_select_html = ::Formtastic::Inputs::SelectInput.new(builder, template, object, object_name, :"_dpwt_#{method}_h", hour_select_options).to_html
|
60
65
|
minute_select_html = ::Formtastic::Inputs::SelectInput.new(builder, template, object, object_name, :"_dpwt_#{method}_m", minute_select_options).to_html
|
61
|
-
|
66
|
+
|
67
|
+
timezone = options[:timezone] || 'UTC'
|
68
|
+
timezone_span_html = template.content_tag(:span, timezone, id: "#{object_name}__dpwt_#{method}_timezone")
|
69
|
+
timezone_hidden_input_html = template.hidden_field_tag("#{object_name}[_dpwt_#{method}_z]", timezone, :id => "#{object_name}__dpwt_#{method}_z")
|
62
70
|
|
63
71
|
wrapper_contents = [
|
64
72
|
replace_li_tag(datepicker_html),
|
65
73
|
replace_li_tag(hour_select_html),
|
66
74
|
replace_li_tag(minute_select_html),
|
67
|
-
|
75
|
+
timezone_span_html,
|
76
|
+
timezone_hidden_input_html,
|
68
77
|
error_html,
|
69
78
|
hint_html,
|
70
79
|
].compact.join("\n").html_safe
|
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.
|
4
|
+
version: 0.3.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:
|
11
|
+
date: 2025-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeadmin
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- lib/hellobase.rb
|
134
134
|
- lib/hellobase/formtastic.rb
|
135
135
|
- lib/hellobase/formtastic/inputs.rb
|
136
|
+
- lib/hellobase/formtastic/inputs/array_text_input.rb
|
136
137
|
- lib/hellobase/formtastic/inputs/content_input.rb
|
137
138
|
- lib/hellobase/formtastic/inputs/datepicker_with_time_input.rb
|
138
139
|
- lib/hellobase/formtastic/inputs/inline_checkbox_input.rb
|
@@ -157,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
158
|
- !ruby/object:Gem::Version
|
158
159
|
version: '0'
|
159
160
|
requirements: []
|
160
|
-
rubygems_version: 3.
|
161
|
+
rubygems_version: 3.1.6
|
161
162
|
signing_key:
|
162
163
|
specification_version: 4
|
163
164
|
summary: Custom Formtastic inputs
|