template_form 0.4.8 → 0.4.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: 408026155358aa91f7c4751f36424be1364a7e21962c93501eaafad752e469ef
4
- data.tar.gz: 8193bbf3b0241df0956e2b4957fea34e33aa6030e997f705ddf063b65caba4a7
3
+ metadata.gz: 9aff3e126bc47f495ad38d2bc5e5ac812383ab514122dc74512102404dd0c22f
4
+ data.tar.gz: 044c58d8cee13e9d154dff0f2ddceed9fcee9baeedd022e724de7c640d0cfee1
5
5
  SHA512:
6
- metadata.gz: 7e8e9c96f173d1ade04629e2f22457d2ea885c3a4262f8e2327b6ab13a172c992469f269922d907491fdd7668f93d43def8c1773a4ceb9cb293d57f922b7eaa4
7
- data.tar.gz: ccf8c4be15bfa0d5e615a2ffa07125fcd58b55d9f2d0c71898d37d1678b2018dab187c48d014bcb1b6a2bbb647039c40a7a63b31a5c604f5feba8442399ed008
6
+ metadata.gz: 0a45dd537b78ed56907aecea11bdad44d93bd4affbcfe4f70d3dd4cb4cb7949d8452047968195b782ea9a9cc9377eee4c4a80f21706cf1b444c56d1bcd582f04
7
+ data.tar.gz: 14af76a55463a878c94b91e162ffb573c8807fcf7a91dc0582a079a5db3379ff929f7ffd6768983aa41adfd58f9edb8ba748b7421f72da3c2146ad65766e739a
@@ -0,0 +1,84 @@
1
+ require 'tilt'
2
+
3
+ module TemplateForm
4
+ class DateSelectInput < BaseInput
5
+
6
+ OPTION_KEYS = %i[
7
+ use_month_numbers
8
+ use_two_digit_numbers
9
+ use_short_month
10
+ add_month_numbers
11
+ use_month_names
12
+ month_format_string
13
+ date_separator
14
+ time_separator
15
+ datetime_separator
16
+ start_year
17
+ end_year
18
+ year_format
19
+ day_format
20
+ discard_day
21
+ discard_month
22
+ discard_year
23
+ order
24
+ include_blank
25
+ default
26
+ selected
27
+ disabled
28
+ prompt
29
+ with_css_classes
30
+ use_hidden
31
+ ]
32
+
33
+ def initialize(builder, attribute_name, options)
34
+ @builder = builder
35
+ @attribute_name = attribute_name
36
+ @view = options.delete(:view)
37
+
38
+ @form_type = options.delete(:form_type) || builder.form_type
39
+
40
+ # Use the `:label` option to override the default label text.
41
+ # Use `label: false` to indicate no label should be shown (check `has_label` in the template).
42
+ @has_label = !(options.has_key?(:label) && options[:label] == false)
43
+ @label_text = options.delete(:label) || ''
44
+ @label_options = Hash.new { |h,k| h[k] = '' }.update(options.delete(:label_options) || {})
45
+
46
+ @hint_text = options.delete(:hint) || ''
47
+
48
+ data_attributes = (options.delete(:data) || {}).transform_keys { |k| "data-#{k}" }
49
+
50
+ @options, @html_options = options.partition { |k,_| OPTION_KEYS.include? k }.map(&:to_h)
51
+
52
+ @html_options.merge! data_attributes
53
+ @html_options[:class] ||= ''
54
+ end
55
+
56
+ def render
57
+ template.render(
58
+ builder,
59
+ attribute_name: attribute_name,
60
+ view: view,
61
+
62
+ has_label: has_label,
63
+ label_text: label_text,
64
+ label_options: label_options,
65
+
66
+ hint_text: hint_text,
67
+
68
+ options: options,
69
+ html_options: html_options,
70
+
71
+ errors: errors,
72
+ ).html_safe
73
+ end
74
+
75
+ private
76
+
77
+ attr_reader *%i[
78
+ view
79
+ html_options
80
+ options
81
+ ]
82
+
83
+ end
84
+ end
@@ -8,6 +8,7 @@ require 'template_form/select_input'
8
8
  require 'template_form/text_input'
9
9
  require 'template_form/textarea_input'
10
10
  require 'template_form/date_input'
11
+ require 'template_form/date_select_input'
11
12
  require 'template_form/file_input'
12
13
 
13
14
  module TemplateForm
@@ -50,6 +51,7 @@ module TemplateForm
50
51
  when :string then TextInput
51
52
  when :text then TextareaInput
52
53
  when :date then DateInput
54
+ when :date_select then DateSelectInput
53
55
  when :boolean then CheckboxInput
54
56
  when :file then FileInput
55
57
  when :select then SelectInput
@@ -1,3 +1,3 @@
1
1
  module TemplateForm
2
- VERSION = "0.4.8"
2
+ VERSION = "0.4.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: template_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.8
4
+ version: 0.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Stewart
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-28 00:00:00.000000000 Z
11
+ date: 2024-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -99,6 +99,7 @@ files:
99
99
  - lib/template_form/base_input.rb
100
100
  - lib/template_form/checkbox_input.rb
101
101
  - lib/template_form/date_input.rb
102
+ - lib/template_form/date_select_input.rb
102
103
  - lib/template_form/errors.rb
103
104
  - lib/template_form/file_input.rb
104
105
  - lib/template_form/form_builder.rb
@@ -137,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
138
  - !ruby/object:Gem::Version
138
139
  version: '0'
139
140
  requirements: []
140
- rubygems_version: 3.4.10
141
+ rubygems_version: 3.5.11
141
142
  signing_key:
142
143
  specification_version: 4
143
144
  summary: A template-based form builder for Rails.