hellobase 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hellobase/formtastic/datepicker_with_time_input.rb +32 -35
- data/lib/hellobase/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bac093aad9f9bedcf9ca8b34666ba172cd71c967a826efcbb41c899158ec329e
|
4
|
+
data.tar.gz: 23798a5a68e2006a4df42258a0344897232c046d5c0f2c6c0fad1b50c1d712fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cac0820e4e285e0b7383c0e6d1a225ec43ca28254a71cfbd1d30a6bb6cd01144ce44c47d2df9d930290b6690d456c5062c61802ba8b1e57d3a34d92e9b2bea75
|
7
|
+
data.tar.gz: 4302db7ea840217079eeb31848e13a3f92b1143b82183781c7d1e6af30447416c0d1ba0eccf442dab1898cb4588d05c25a8fd24c80d135e2edc9831bdc3280d2
|
@@ -7,55 +7,52 @@ require 'active_admin/inputs'
|
|
7
7
|
class DatepickerWithTimeInput
|
8
8
|
include ::Formtastic::Inputs::Base
|
9
9
|
|
10
|
-
def self.virtual_attributes(
|
11
|
-
[:"_dpwt_#{
|
10
|
+
def self.virtual_attributes(base)
|
11
|
+
[:"_dpwt_#{base}_d", :"_dpwt_#{base}_h", :"_dpwt_#{base}_m"]
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.define_virtual_attributes(klass,
|
15
|
-
|
14
|
+
def self.define_virtual_attributes(klass, base)
|
15
|
+
attrs = virtual_attributes(base)
|
16
|
+
ivars = attrs.map {|a| :"@#{a}" }
|
17
|
+
method = :"_dpwt_set_#{base}"
|
16
18
|
|
17
|
-
klass.class_eval
|
18
|
-
|
19
|
-
|
20
|
-
def _dpwt_#{attr}_d
|
21
|
-
self.#{attr}&.strftime('%Y-%m-%d')
|
19
|
+
klass.class_eval do
|
20
|
+
define_method attrs[0] do
|
21
|
+
send(base)&.strftime('%Y-%m-%d')
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
define_method attrs[1] do
|
25
|
+
send(base)&.strftime('%H')
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
28
|
+
define_method attrs[2] do
|
29
|
+
send(base)&.strftime('%M')
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
attrs.each_with_index do |a, i|
|
33
|
+
define_method :"#{a}=" do |val|
|
34
|
+
instance_variable_set ivars[i], val
|
35
|
+
send(method)
|
35
36
|
|
36
|
-
|
37
|
+
val
|
38
|
+
end
|
37
39
|
end
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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(' ')
|
44
52
|
end
|
45
53
|
|
46
|
-
|
47
|
-
|
48
|
-
_dpwt_set_#{attr}
|
49
|
-
|
50
|
-
val
|
51
|
-
end
|
52
|
-
|
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(' ')
|
57
|
-
end
|
58
|
-
RUBY
|
54
|
+
private method
|
55
|
+
end
|
59
56
|
end
|
60
57
|
|
61
58
|
def to_html
|
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.15
|
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-
|
11
|
+
date: 2020-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeadmin
|