hellobase 0.1.11 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2067b7cb6544fd57896f092063b337967e49c673e2ceed3ab5ae771b88b73278
|
4
|
+
data.tar.gz: b33677b0a39f2469aa0449e23a72ab86fb8ad09d8b6aec45f3506df7768be8b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e66d67ca7485ab940445ca39ef01355a89b82fb93b9cc95e61dd9b9ee394176339cb8e96b0d5658c5bf86c5fc9d368c06134bef57bef2eb40ce10ab28e386fb9
|
7
|
+
data.tar.gz: 54789c893f773116994819f9003eded25df02276663fade58b05cb432af0fbc4ac1f8e9964a24453f67c159b743b12354be9e3e2f51fb0db8e41dcd910a06926
|
@@ -20,7 +20,7 @@ Time.singleton_class.prepend(
|
|
20
20
|
|
21
21
|
def new(*args)
|
22
22
|
# only allow ActiveSupport::TimeZone to use Time.new
|
23
|
-
unless caller_locations
|
23
|
+
unless caller_locations.any? {|loc| loc.path.end_with? '/active_support/values/time_zone.rb' }
|
24
24
|
raise Hellobase::Error.new(:datetime_new, nil)
|
25
25
|
end
|
26
26
|
|
@@ -1,56 +1,70 @@
|
|
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 self.virtual_attributes(
|
7
|
-
[:"_dpwt_#{
|
10
|
+
def self.virtual_attributes(base)
|
11
|
+
[:"_dpwt_#{base}_d", :"_dpwt_#{base}_h", :"_dpwt_#{base}_m"]
|
8
12
|
end
|
9
13
|
|
10
|
-
def self.define_virtual_attributes(klass,
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
def self._dpwt_defined; end
|
14
|
+
def self.define_virtual_attributes(klass, base)
|
15
|
+
attrs = virtual_attributes(base)
|
16
|
+
ivars = attrs.map {|a| :"@#{a}" }
|
17
|
+
method = :"_dpwt_set_#{base}"
|
15
18
|
|
16
|
-
|
17
|
-
|
19
|
+
klass.class_eval do
|
20
|
+
define_method attrs[0] do
|
21
|
+
send(base)&.strftime('%Y-%m-%d')
|
18
22
|
end
|
19
23
|
|
20
|
-
|
21
|
-
|
24
|
+
define_method attrs[1] do
|
25
|
+
send(base)&.strftime('%H')
|
22
26
|
end
|
23
27
|
|
24
|
-
|
25
|
-
|
26
|
-
_dpwt_set_#{attr}
|
27
|
-
|
28
|
-
val
|
28
|
+
define_method attrs[2] do
|
29
|
+
send(base)&.strftime('%M')
|
29
30
|
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
attrs.each_with_index do |a, i|
|
33
|
+
define_method :"#{a}=" do |val|
|
34
|
+
instance_variable_set ivars[i], val
|
35
|
+
send(method)
|
34
36
|
|
35
|
-
|
37
|
+
val
|
38
|
+
end
|
36
39
|
end
|
37
40
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
41
|
+
define_method method do
|
42
|
+
send :"#{base}=",
|
43
|
+
ivars.any? {|v| instance_variable_get(v).blank? } ?
|
44
|
+
nil :
|
45
|
+
[
|
46
|
+
instance_variable_get(ivars[0]),
|
47
|
+
[
|
48
|
+
instance_variable_get(ivars[1]),
|
49
|
+
instance_variable_get(ivars[2])
|
50
|
+
].join(':')
|
51
|
+
].join(' ')
|
42
52
|
end
|
43
|
-
|
53
|
+
|
54
|
+
private method
|
55
|
+
end
|
44
56
|
end
|
45
57
|
|
46
58
|
def to_html
|
47
59
|
datepicker_html = ActiveAdmin::Inputs::DatepickerInput.new(builder, template, object, object_name, :"_dpwt_#{method}_d", datepicker_options).to_html
|
48
|
-
|
60
|
+
hour_select_html = Formtastic::Inputs::SelectInput.new(builder, template, object, object_name, :"_dpwt_#{method}_h", hour_select_options).to_html
|
61
|
+
minute_select_html = Formtastic::Inputs::SelectInput.new(builder, template, object, object_name, :"_dpwt_#{method}_m", minute_select_options).to_html
|
49
62
|
zone_display_html = options[:time_zone] ? template.content_tag(:span, options[:time_zone]) : nil
|
50
63
|
|
51
64
|
wrapper_contents = [
|
52
65
|
replace_li_tag(datepicker_html),
|
53
|
-
replace_li_tag(
|
66
|
+
replace_li_tag(hour_select_html),
|
67
|
+
replace_li_tag(minute_select_html),
|
54
68
|
zone_display_html,
|
55
69
|
error_html,
|
56
70
|
hint_html,
|
@@ -67,11 +81,18 @@ class DatepickerWithTimeInput
|
|
67
81
|
}.merge(options[:datepicker_options] || {})
|
68
82
|
end
|
69
83
|
|
70
|
-
def
|
84
|
+
def hour_select_options
|
85
|
+
{
|
86
|
+
label: false,
|
87
|
+
collection: (0..23).map {|i| '%02i' % i },
|
88
|
+
}.merge(options[:hour_select_options] || {})
|
89
|
+
end
|
90
|
+
|
91
|
+
def minute_select_options
|
71
92
|
{
|
72
93
|
label: false,
|
73
|
-
collection: (0..
|
74
|
-
}.merge(options[:
|
94
|
+
collection: (0..59).map {|i| '%02i' % i },
|
95
|
+
}.merge(options[:minute_select_options] || {})
|
75
96
|
end
|
76
97
|
|
77
98
|
# 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.16
|
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: 2021-01-20 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
|