formatic 0.1.6 → 0.1.7
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 +14 -2
- 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: 419489534fb00fc23c39c515d7d0dd58421c3c43dfd7af397d50c72f797e1aff
|
4
|
+
data.tar.gz: '099d23636b6a68148c9cd7c6c3a2c05f3301c9cd4b2afdf299fb976131dfb7ed'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91a2483ea6ca6b3faf6a22d2d1139b78a6c2a5187572beba7aec17d4a05464b386fa5d2ffa0e71a78f4a0202cea3bb4a2c81a98b6391e839a26a05396a840226
|
7
|
+
data.tar.gz: c4a495cac1a261fbaecb01d194de5d8b5c3d3522d97473ebb2a7c1639da6d0644dc4c54412b93669789c828dd810ced8b9e6b5e36a1dcf457372abe36f06c2a1
|
@@ -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| -%>
|
@@ -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.7
|
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
|