hellobase 0.1.9 → 0.1.14
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/lib/hellobase/formtastic/datepicker_with_time_input.rb +67 -37
- data/lib/hellobase/version.rb +1 -1
- metadata +3 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 925574afb7726175b0a972403d9e805692779cbbb8f6e87ff8fbe911a135df28
|
4
|
+
data.tar.gz: a2ca4330eca04f5b069e00f7c4fdcca8d245c394044c34eefd922c2619d3ce72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41a29344cdece20c0f7ec4485d7db02f7297775892032763083f62fc3d823cf0253efeb09266ae50866c715cf7e089ce9215ba14cdec494d1625c63b58a514d6
|
7
|
+
data.tar.gz: be6935db61dfb6320d9a3bcbb5a00b6326c27bcce4a7a850322e0aad7180fdb0fe5f49000d3791512a1a7ddc85b347e37dd21431f384f8d697b4dd4643a5177f
|
@@ -1,71 +1,101 @@
|
|
1
|
+
# require these here so we can load this as a standalone file - see formtastic.rb
|
2
|
+
require 'active_support'
|
3
|
+
require 'formtastic'
|
4
|
+
|
1
5
|
require 'active_admin/inputs'
|
2
6
|
|
3
7
|
class DatepickerWithTimeInput
|
4
8
|
include ::Formtastic::Inputs::Base
|
5
9
|
|
6
|
-
def
|
7
|
-
|
10
|
+
def self.virtual_attributes(attr)
|
11
|
+
[:"_dpwt_#{attr}_d", :"_dpwt_#{attr}_h", :"_dpwt_#{attr}_m"]
|
12
|
+
end
|
8
13
|
|
9
|
-
|
10
|
-
|
11
|
-
zone_hidden_html = Formtastic::Inputs::HiddenInput.new(builder, template, object, object_name, "#{method}_tz", {}).to_html
|
12
|
-
value_hidden_html = Formtastic::Inputs::HiddenInput.new(builder, template, object, object_name, method, {}).to_html
|
13
|
-
zone_span_html = template.content_tag(:span, time_zone)
|
14
|
+
def self.define_virtual_attributes(klass, attr)
|
15
|
+
return if klass.respond_to? :_dpwt_defined
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
replace_li_tag(time_select_html),
|
18
|
-
replace_li_tag(zone_hidden_html),
|
19
|
-
replace_li_tag(value_hidden_html),
|
20
|
-
zone_span_html,
|
21
|
-
error_html,
|
22
|
-
hint_html,
|
23
|
-
].compact.join("\n").html_safe
|
17
|
+
klass.class_eval <<-RUBY
|
18
|
+
def self._dpwt_defined; end
|
24
19
|
|
25
|
-
|
26
|
-
|
20
|
+
def _dpwt_#{attr}_d
|
21
|
+
self.#{attr}&.strftime('%Y-%m-%d')
|
22
|
+
end
|
27
23
|
|
28
|
-
|
24
|
+
def _dpwt_#{attr}_h
|
25
|
+
self.#{attr}&.strftime('%H')
|
26
|
+
end
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
def _dpwt_#{attr}_m
|
29
|
+
self.#{attr}&.strftime('%M')
|
30
|
+
end
|
31
|
+
|
32
|
+
def _dpwt_#{attr}_d=(val)
|
33
|
+
@_dpwt_#{attr}_d = val
|
34
|
+
_dpwt_set_#{attr}
|
34
35
|
|
35
|
-
|
36
|
-
define_method(:#{method}_buffer) do
|
37
|
-
@#{method}_v ||= #{method}&.in_time_zone('#{time_zone}')
|
36
|
+
val
|
38
37
|
end
|
39
38
|
|
40
|
-
|
41
|
-
#{
|
39
|
+
def _dpwt_#{attr}_h=(val)
|
40
|
+
@_dpwt_#{attr}_h = val
|
41
|
+
_dpwt_set_#{attr}
|
42
|
+
|
43
|
+
val
|
42
44
|
end
|
43
45
|
|
44
|
-
|
45
|
-
#{
|
46
|
+
def _dpwt_#{attr}_m=(val)
|
47
|
+
@_dpwt_#{attr}_m = val
|
48
|
+
_dpwt_set_#{attr}
|
49
|
+
|
50
|
+
val
|
46
51
|
end
|
47
52
|
|
48
|
-
|
49
|
-
|
53
|
+
private
|
54
|
+
|
55
|
+
def _dpwt_set_#{attr}
|
56
|
+
self.#{attr} = @_dpwt_#{attr}_d.blank? || @_dpwt_#{attr}_h.blank? || @_dpwt_#{attr}_m.blank? ? nil : [@_dpwt_#{attr}_d, [@_dpwt_#{attr}_h, @_dpwt_#{attr}_m].join(':')].join(' ')
|
50
57
|
end
|
51
58
|
RUBY
|
52
59
|
end
|
53
60
|
|
61
|
+
def to_html
|
62
|
+
datepicker_html = ActiveAdmin::Inputs::DatepickerInput.new(builder, template, object, object_name, :"_dpwt_#{method}_d", datepicker_options).to_html
|
63
|
+
hour_select_html = Formtastic::Inputs::SelectInput.new(builder, template, object, object_name, :"_dpwt_#{method}_h", hour_select_options).to_html
|
64
|
+
minute_select_html = Formtastic::Inputs::SelectInput.new(builder, template, object, object_name, :"_dpwt_#{method}_m", minute_select_options).to_html
|
65
|
+
zone_display_html = options[:time_zone] ? template.content_tag(:span, options[:time_zone]) : nil
|
66
|
+
|
67
|
+
wrapper_contents = [
|
68
|
+
replace_li_tag(datepicker_html),
|
69
|
+
replace_li_tag(hour_select_html),
|
70
|
+
replace_li_tag(minute_select_html),
|
71
|
+
zone_display_html,
|
72
|
+
error_html,
|
73
|
+
hint_html,
|
74
|
+
].compact.join("\n").html_safe
|
75
|
+
|
76
|
+
template.content_tag(:li, wrapper_contents, wrapper_html_options)
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
54
81
|
def datepicker_options
|
55
82
|
{
|
56
83
|
label: label_text,
|
57
84
|
}.merge(options[:datepicker_options] || {})
|
58
85
|
end
|
59
86
|
|
60
|
-
def
|
87
|
+
def hour_select_options
|
61
88
|
{
|
62
89
|
label: false,
|
63
|
-
collection: (0..23).map {|
|
64
|
-
}.merge(options[:
|
90
|
+
collection: (0..23).map {|i| '%02i' % i },
|
91
|
+
}.merge(options[:hour_select_options] || {})
|
65
92
|
end
|
66
93
|
|
67
|
-
def
|
68
|
-
|
94
|
+
def minute_select_options
|
95
|
+
{
|
96
|
+
label: false,
|
97
|
+
collection: (0..59).map {|i| '%02i' % i },
|
98
|
+
}.merge(options[:minute_select_options] || {})
|
69
99
|
end
|
70
100
|
|
71
101
|
# formtastic inputs generate <li> with no way to override
|
data/lib/hellobase/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hellobase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Wang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeadmin
|
@@ -99,9 +99,6 @@ dependencies:
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '5.13'
|
104
|
-
- - "<"
|
105
102
|
- !ruby/object:Gem::Version
|
106
103
|
version: '5.14'
|
107
104
|
type: :development
|
@@ -109,9 +106,6 @@ dependencies:
|
|
109
106
|
version_requirements: !ruby/object:Gem::Requirement
|
110
107
|
requirements:
|
111
108
|
- - "~>"
|
112
|
-
- !ruby/object:Gem::Version
|
113
|
-
version: '5.13'
|
114
|
-
- - "<"
|
115
109
|
- !ruby/object:Gem::Version
|
116
110
|
version: '5.14'
|
117
111
|
- !ruby/object:Gem::Dependency
|
@@ -184,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
178
|
- !ruby/object:Gem::Version
|
185
179
|
version: '0'
|
186
180
|
requirements: []
|
187
|
-
rubygems_version: 3.
|
181
|
+
rubygems_version: 3.0.8
|
188
182
|
signing_key:
|
189
183
|
specification_version: 4
|
190
184
|
summary: Ruby runtime environment for Hellobase
|