formatic 0.1.6 → 0.1.8
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/app/components/formatic/time.rb +35 -23
- data/lib/formatic/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: c41c5d0a31c9c2470b3c0b87101052362513df9fe3e5b73d86be38901a85cfbd
|
4
|
+
data.tar.gz: 71b086cd5b6628753d31085af7f71a0893ae9176d47cd0739cc25ae081b4eacc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dff60aea5e27b4621d517e80b18b557e0ed808ae7a2de705dd4d2b34f98f6fc59ba2209bbee08f289e4bcfb06260ed539f87476a844e0e57b45115af02126ced
|
7
|
+
data.tar.gz: 8ad1c7de70335be6b10c402ac8ef1f7c2570ac892ed7f6d97bd75deea03c0215c40dff9423834e9bd69262e8de19905afe6718278d4a37e3424ff3e4d071b5b5
|
@@ -5,7 +5,7 @@ require 'formatic/templates/date'
|
|
5
5
|
module Formatic
|
6
6
|
# Date/calendar
|
7
7
|
class Time < ::Formatic::Base
|
8
|
-
option :minute_step, default: -> {
|
8
|
+
option :minute_step, default: -> { 1 }
|
9
9
|
|
10
10
|
erb_template <<~ERB
|
11
11
|
<%= render wrapper do |wrap| -%>
|
@@ -13,27 +13,27 @@ module Formatic
|
|
13
13
|
<% wrap.with_input do -%>
|
14
14
|
<div class="c-formatic-time s-formatic">
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
16
|
+
<% if readonly %>
|
17
|
+
<div class="s-markdown">
|
18
|
+
<p>
|
19
|
+
<%= value.to_fs(:time) %>
|
20
|
+
</p>
|
21
|
+
</div>
|
22
|
+
<% else %>
|
23
|
+
<div class="c-formatic-time__inputs">
|
24
|
+
<%= select_tag hour_attribute_name,
|
25
|
+
options_for_hour,
|
26
|
+
id: hour_input_id,
|
27
|
+
class: 'c-formatic-time__select' %>
|
28
|
+
|
29
|
+
<%= select_tag minute_attribute_name,
|
30
|
+
options_for_minute,
|
31
|
+
id: minute_input_id,
|
32
|
+
class: 'c-formatic-time__select' %>
|
33
|
+
</div>
|
34
|
+
<% end -%>
|
35
|
+
</div>
|
36
|
+
|
37
37
|
<% end -%>
|
38
38
|
<% end -%>
|
39
39
|
ERB
|
@@ -70,6 +70,11 @@ module Formatic
|
|
70
70
|
|
71
71
|
private
|
72
72
|
|
73
|
+
def minute_value
|
74
|
+
candidate = f.object.public_send(attribute_name)
|
75
|
+
candidate.min if candidate&.between?(0, 59)
|
76
|
+
end
|
77
|
+
|
73
78
|
def collection_for_hour
|
74
79
|
result = (0..23).map { [_1, _1] }
|
75
80
|
result.prepend([nil, nil]) if wrapper.optional?
|
@@ -79,7 +84,14 @@ module Formatic
|
|
79
84
|
def collection_for_minute
|
80
85
|
sanitized_minute_step = minute_step.clamp(1, 60)
|
81
86
|
steps = (0..59).step(sanitized_minute_step).to_a
|
82
|
-
|
87
|
+
|
88
|
+
# Add the current minute if it's not already in the steps
|
89
|
+
if minute_value
|
90
|
+
steps.push(minute_value)
|
91
|
+
steps.sort!
|
92
|
+
end
|
93
|
+
|
94
|
+
result = steps.map { [_1.to_s.rjust(2, '0'), _1] }
|
83
95
|
result.prepend([nil, nil]) if wrapper.optional?
|
84
96
|
result
|
85
97
|
end
|
data/lib/formatic/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formatic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- halo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-04-
|
11
|
+
date: 2025-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|