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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd20b566bfd12f246ccae474d8f30d49f311b0b9a9b049cfa81064838336d1d3
4
- data.tar.gz: c404e5bae2b92b32a1e1d56f0c6e116ea85c4e41439372ade147dcbdaea1ce25
3
+ metadata.gz: c41c5d0a31c9c2470b3c0b87101052362513df9fe3e5b73d86be38901a85cfbd
4
+ data.tar.gz: 71b086cd5b6628753d31085af7f71a0893ae9176d47cd0739cc25ae081b4eacc
5
5
  SHA512:
6
- metadata.gz: 8c4e6f8ae8a654b46bb918f6b908cbbd594e9da5d933b191b5d94d251e82c493443fa0bc789cdad585e58931d2f1c8b8f5cb2307c6d6b95ddf38b00a838c30ec
7
- data.tar.gz: d964411598e580472fc4182af3750a56caa13109223c0b25dab8b53e161bfad685848a5ea40f8fad8ff8d9c9b89c9822de3fa522400464a1055e36aba858833c
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: -> { 5 }
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
- <% if readonly %>
17
- <div class="s-markdown">
18
- <p>
19
- <%= value.to_fs(:time) %>
20
- </p>
21
- </div>
22
- <% else %>
23
-
24
- <div class="c-formatic-time__inputs">
25
- <%= select_tag hour_attribute_name,
26
- options_for_hour,
27
- id: hour_input_id,
28
- class: 'c-formatic-time__select' %>
29
-
30
- <%= select_tag minute_attribute_name,
31
- options_for_minute,
32
- id: minute_input_id,
33
- class: 'c-formatic-time__select' %>
34
- </div>
35
-
36
- <% end -%>
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
- result = steps.map { [_1, _1] }
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Formatic
4
- VERSION = '0.1.6'
4
+ VERSION = '0.1.8'
5
5
  end
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.6
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-03 00:00:00.000000000 Z
11
+ date: 2025-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview