hellobase 0.1.8 → 0.1.9

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: 46694043401a358a06c4d8cc43fed3e74ddf49e756da77bf3e501f5368d587a1
4
- data.tar.gz: 425faddf86643febe8bed91dd8d8da3e44806f6279f57f7a4a40b690112f811b
3
+ metadata.gz: 61c5d3e9cf754c5b79f4c40d8f81d386eefdd9b4d0cc5ac1e6e6d20c99750cba
4
+ data.tar.gz: 54c85b5b7e21630f79bff2138663a7d4075495d55b5a35d31803ffcc66aa1351
5
5
  SHA512:
6
- metadata.gz: 87c87f82adc496b5126a32a373998521c79dd61a45111323c5247c78064921873dd7655eb4f26693d57197644813d1d16cbee5ec6d0e99647482d1a96eab6885
7
- data.tar.gz: 8dfddd47d74040a1edaf77c6e90f24ddb0660a1fc00d5b2fdfe006a201e6973d3c3fb195f403e1196b9fab1c397f9dc3a0c5860110783e304435a28ecc36ec79
6
+ metadata.gz: 06263c3bf10883966e08359e07470355e587e62e35827c170f8b833b042a485f899672c135823a18333e7d2f719a67035c87d2d0dbf5a71ef7c8c8f38ee9df65
7
+ data.tar.gz: a37f2ef4a5364b2e619e484b91dcd17650973eb9433e16c9dc486e0d6fcc599dca0fbd04bfb844fd633d3a5f14709fc9701250abbe97cb098d65b899b46cdda7
@@ -1,6 +1,7 @@
1
1
  require 'active_support' # formtastic needs ActiveSupport::Autoload
2
2
  require 'formtastic'
3
3
 
4
+ require 'hellobase/formtastic/content_input'
5
+ require 'hellobase/formtastic/datepicker_with_time_input'
4
6
  require 'hellobase/formtastic/inline_checkbox_input'
5
- require 'hellobase/formtastic/read_only_input'
6
7
  require 'hellobase/formtastic/time_of_day_input'
@@ -0,0 +1,8 @@
1
+ class ContentInput < ::Formtastic::Inputs::StringInput
2
+ def to_html
3
+ input_wrapping do
4
+ label_html <<
5
+ template.content_tag(:span, options[:content])
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,75 @@
1
+ require 'active_admin/inputs'
2
+
3
+ class DatepickerWithTimeInput
4
+ include ::Formtastic::Inputs::Base
5
+
6
+ def to_html
7
+ init_object
8
+
9
+ datepicker_html = ActiveAdmin::Inputs::DatepickerInput.new(builder, template, object, object_name, "#{method}_date", datepicker_options).to_html
10
+ time_select_html = Formtastic::Inputs::SelectInput.new(builder, template, object, object_name, "#{method}_time", time_select_options).to_html
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
+
15
+ wrapper_contents = [
16
+ replace_li_tag(datepicker_html),
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
24
+
25
+ template.content_tag(:li, wrapper_contents, wrapper_html_options)
26
+ end
27
+
28
+ private
29
+
30
+ def init_object
31
+ if value = object.send(method)
32
+ object.send "#{method}=", value.in_time_zone(time_zone)
33
+ end
34
+
35
+ object.class_eval <<-RUBY
36
+ define_method(:#{method}_buffer) do
37
+ @#{method}_v ||= #{method}&.in_time_zone('#{time_zone}')
38
+ end
39
+
40
+ define_method(:#{method}_tz) do
41
+ #{method}_buffer&.strftime('%z')
42
+ end
43
+
44
+ define_method(:#{method}_date) do
45
+ #{method}_buffer&.strftime('%Y-%m-%d')
46
+ end
47
+
48
+ define_method(:#{method}_time) do
49
+ #{method}_buffer&.strftime('%R')
50
+ end
51
+ RUBY
52
+ end
53
+
54
+ def datepicker_options
55
+ {
56
+ label: label_text,
57
+ }.merge(options[:datepicker_options] || {})
58
+ end
59
+
60
+ def time_select_options
61
+ {
62
+ label: false,
63
+ collection: (0..23).map {|h| (0..59).select {|m| m % 5 == 0 }.map {|m| ['%02i' % h, '%02i' % m].join(':') } }.flatten,
64
+ }.merge(options[:time_select_options] || {})
65
+ end
66
+
67
+ def time_zone
68
+ options[:time_zone] || 'UTC'
69
+ end
70
+
71
+ # formtastic inputs generate <li> with no way to override
72
+ def replace_li_tag(html)
73
+ html.strip.sub(/^<li /, '<span ').sub(/<\/li>$/, '</span>').html_safe
74
+ end
75
+ end
@@ -1,3 +1,3 @@
1
1
  module Hellobase
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9'
3
3
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hellobase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Wang
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-07 00:00:00.000000000 Z
11
+ date: 2020-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activeadmin
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.7'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: activesupport
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +52,48 @@ dependencies:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
54
  version: '2.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activemodel
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '6.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '6.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activerecord
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '6.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '6.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: actionview
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '6.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '6.0'
41
97
  - !ruby/object:Gem::Dependency
42
98
  name: minitest
43
99
  requirement: !ruby/object:Gem::Requirement
@@ -58,6 +114,20 @@ dependencies:
58
114
  - - "<"
59
115
  - !ruby/object:Gem::Version
60
116
  version: '5.14'
117
+ - !ruby/object:Gem::Dependency
118
+ name: nokogiri
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '1.10'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '1.10'
61
131
  - !ruby/object:Gem::Dependency
62
132
  name: warning
63
133
  requirement: !ruby/object:Gem::Requirement
@@ -72,7 +142,7 @@ dependencies:
72
142
  - - "~>"
73
143
  - !ruby/object:Gem::Version
74
144
  version: '1.0'
75
- description:
145
+ description:
76
146
  email:
77
147
  - awang@hellobase.com
78
148
  executables: []
@@ -90,15 +160,16 @@ files:
90
160
  - lib/hellobase/core_ext/string_access.rb
91
161
  - lib/hellobase/core_ext/time_creation.rb
92
162
  - lib/hellobase/formtastic.rb
163
+ - lib/hellobase/formtastic/content_input.rb
164
+ - lib/hellobase/formtastic/datepicker_with_time_input.rb
93
165
  - lib/hellobase/formtastic/inline_checkbox_input.rb
94
- - lib/hellobase/formtastic/read_only_input.rb
95
166
  - lib/hellobase/formtastic/time_of_day_input.rb
96
167
  - lib/hellobase/time_zones.rb
97
168
  - lib/hellobase/version.rb
98
- homepage:
169
+ homepage:
99
170
  licenses: []
100
171
  metadata: {}
101
- post_install_message:
172
+ post_install_message:
102
173
  rdoc_options: []
103
174
  require_paths:
104
175
  - lib
@@ -113,9 +184,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
184
  - !ruby/object:Gem::Version
114
185
  version: '0'
115
186
  requirements: []
116
- rubyforge_project:
117
- rubygems_version: 2.7.10
118
- signing_key:
187
+ rubygems_version: 3.1.4
188
+ signing_key:
119
189
  specification_version: 4
120
190
  summary: Ruby runtime environment for Hellobase
121
191
  test_files: []
@@ -1,8 +0,0 @@
1
- class ReadOnlyInput < ::Formtastic::Inputs::StringInput
2
- def to_html
3
- input_wrapping do
4
- label_html <<
5
- template.content_tag(:div, options[:content])
6
- end
7
- end
8
- end