actionview 4.2.11.1 → 7.0.2.4
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.
Potentially problematic release.
This version of actionview might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +229 -215
- data/MIT-LICENSE +1 -1
- data/README.rdoc +9 -8
- data/lib/action_view/base.rb +116 -43
- data/lib/action_view/buffers.rb +20 -3
- data/lib/action_view/cache_expiry.rb +66 -0
- data/lib/action_view/context.rb +8 -12
- data/lib/action_view/dependency_tracker/erb_tracker.rb +154 -0
- data/lib/action_view/dependency_tracker/ripper_tracker.rb +59 -0
- data/lib/action_view/dependency_tracker.rb +21 -122
- data/lib/action_view/digestor.rb +92 -85
- data/lib/action_view/flows.rb +15 -16
- data/lib/action_view/gem_version.rb +6 -4
- data/lib/action_view/helpers/active_model_helper.rb +17 -12
- data/lib/action_view/helpers/asset_tag_helper.rb +356 -101
- data/lib/action_view/helpers/asset_url_helper.rb +180 -74
- data/lib/action_view/helpers/atom_feed_helper.rb +21 -19
- data/lib/action_view/helpers/cache_helper.rb +156 -43
- data/lib/action_view/helpers/capture_helper.rb +21 -14
- data/lib/action_view/helpers/controller_helper.rb +16 -5
- data/lib/action_view/helpers/csp_helper.rb +26 -0
- data/lib/action_view/helpers/csrf_helper.rb +8 -6
- data/lib/action_view/helpers/date_helper.rb +288 -132
- data/lib/action_view/helpers/debug_helper.rb +9 -6
- data/lib/action_view/helpers/form_helper.rb +956 -173
- data/lib/action_view/helpers/form_options_helper.rb +178 -97
- data/lib/action_view/helpers/form_tag_helper.rb +220 -101
- data/lib/action_view/helpers/javascript_helper.rb +33 -19
- data/lib/action_view/helpers/number_helper.rb +88 -63
- data/lib/action_view/helpers/output_safety_helper.rb +38 -6
- data/lib/action_view/helpers/rendering_helper.rb +21 -10
- data/lib/action_view/helpers/sanitize_helper.rb +31 -32
- data/lib/action_view/helpers/tag_helper.rb +332 -71
- data/lib/action_view/helpers/tags/base.rb +123 -99
- data/lib/action_view/helpers/tags/check_box.rb +21 -20
- data/lib/action_view/helpers/tags/checkable.rb +4 -2
- data/lib/action_view/helpers/tags/collection_check_boxes.rb +12 -34
- data/lib/action_view/helpers/tags/collection_helpers.rb +69 -36
- data/lib/action_view/helpers/tags/collection_radio_buttons.rb +6 -12
- data/lib/action_view/helpers/tags/collection_select.rb +5 -3
- data/lib/action_view/helpers/tags/color_field.rb +4 -3
- data/lib/action_view/helpers/tags/date_field.rb +3 -2
- data/lib/action_view/helpers/tags/date_select.rb +38 -37
- data/lib/action_view/helpers/tags/datetime_field.rb +4 -3
- data/lib/action_view/helpers/tags/datetime_local_field.rb +3 -2
- data/lib/action_view/helpers/tags/datetime_select.rb +2 -0
- data/lib/action_view/helpers/tags/email_field.rb +2 -0
- data/lib/action_view/helpers/tags/file_field.rb +18 -0
- data/lib/action_view/helpers/tags/grouped_collection_select.rb +4 -2
- data/lib/action_view/helpers/tags/hidden_field.rb +6 -0
- data/lib/action_view/helpers/tags/label.rb +7 -2
- data/lib/action_view/helpers/tags/month_field.rb +3 -2
- data/lib/action_view/helpers/tags/number_field.rb +2 -0
- data/lib/action_view/helpers/tags/password_field.rb +3 -1
- data/lib/action_view/helpers/tags/placeholderable.rb +3 -1
- data/lib/action_view/helpers/tags/radio_button.rb +7 -6
- data/lib/action_view/helpers/tags/range_field.rb +2 -0
- data/lib/action_view/helpers/tags/search_field.rb +14 -9
- data/lib/action_view/helpers/tags/select.rb +11 -10
- data/lib/action_view/helpers/tags/tel_field.rb +2 -0
- data/lib/action_view/helpers/tags/text_area.rb +4 -2
- data/lib/action_view/helpers/tags/text_field.rb +8 -8
- data/lib/action_view/helpers/tags/time_field.rb +12 -2
- data/lib/action_view/helpers/tags/time_select.rb +2 -0
- data/lib/action_view/helpers/tags/time_zone_select.rb +3 -1
- data/lib/action_view/helpers/tags/translator.rb +15 -16
- data/lib/action_view/helpers/tags/url_field.rb +2 -0
- data/lib/action_view/helpers/tags/week_field.rb +3 -2
- data/lib/action_view/helpers/tags/weekday_select.rb +28 -0
- data/lib/action_view/helpers/tags.rb +5 -2
- data/lib/action_view/helpers/text_helper.rb +80 -51
- data/lib/action_view/helpers/translation_helper.rb +120 -69
- data/lib/action_view/helpers/url_helper.rb +398 -171
- data/lib/action_view/helpers.rb +29 -27
- data/lib/action_view/layouts.rb +68 -63
- data/lib/action_view/log_subscriber.rb +77 -10
- data/lib/action_view/lookup_context.rb +137 -113
- data/lib/action_view/model_naming.rb +4 -2
- data/lib/action_view/path_set.rb +28 -32
- data/lib/action_view/railtie.rb +74 -13
- data/lib/action_view/record_identifier.rb +53 -26
- data/lib/action_view/render_parser.rb +188 -0
- data/lib/action_view/renderer/abstract_renderer.rb +152 -15
- data/lib/action_view/renderer/collection_renderer.rb +196 -0
- data/lib/action_view/renderer/object_renderer.rb +34 -0
- data/lib/action_view/renderer/partial_renderer/collection_caching.rb +102 -0
- data/lib/action_view/renderer/partial_renderer.rb +51 -333
- data/lib/action_view/renderer/renderer.rb +68 -11
- data/lib/action_view/renderer/streaming_template_renderer.rb +60 -56
- data/lib/action_view/renderer/template_renderer.rb +87 -74
- data/lib/action_view/rendering.rb +73 -47
- data/lib/action_view/ripper_ast_parser.rb +198 -0
- data/lib/action_view/routing_url_for.rb +35 -24
- data/lib/action_view/tasks/cache_digests.rake +25 -0
- data/lib/action_view/template/error.rb +151 -41
- data/lib/action_view/template/handlers/builder.rb +12 -13
- data/lib/action_view/template/handlers/erb/erubi.rb +89 -0
- data/lib/action_view/template/handlers/erb.rb +29 -89
- data/lib/action_view/template/handlers/html.rb +11 -0
- data/lib/action_view/template/handlers/raw.rb +4 -4
- data/lib/action_view/template/handlers.rb +14 -10
- data/lib/action_view/template/html.rb +12 -13
- data/lib/action_view/template/inline.rb +22 -0
- data/lib/action_view/template/raw_file.rb +25 -0
- data/lib/action_view/template/renderable.rb +24 -0
- data/lib/action_view/template/resolver.rb +139 -300
- data/lib/action_view/template/sources/file.rb +17 -0
- data/lib/action_view/template/sources.rb +13 -0
- data/lib/action_view/template/text.rb +10 -12
- data/lib/action_view/template/types.rb +28 -26
- data/lib/action_view/template.rb +123 -91
- data/lib/action_view/template_details.rb +66 -0
- data/lib/action_view/template_path.rb +64 -0
- data/lib/action_view/test_case.rb +70 -53
- data/lib/action_view/testing/resolvers.rb +25 -35
- data/lib/action_view/unbound_template.rb +57 -0
- data/lib/action_view/version.rb +3 -1
- data/lib/action_view/view_paths.rb +73 -58
- data/lib/action_view.rb +16 -11
- data/lib/assets/compiled/rails-ujs.js +746 -0
- metadata +52 -32
- data/lib/action_view/helpers/record_tag_helper.rb +0 -108
- data/lib/action_view/tasks/dependencies.rake +0 -23
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/core_ext/time/calculations"
|
2
4
|
|
3
5
|
module ActionView
|
4
6
|
module Helpers
|
@@ -11,61 +13,60 @@ module ActionView
|
|
11
13
|
end
|
12
14
|
|
13
15
|
def render
|
14
|
-
error_wrapping(datetime_selector(@options, @html_options).
|
16
|
+
error_wrapping(datetime_selector(@options, @html_options).public_send("select_#{select_type}").html_safe)
|
15
17
|
end
|
16
18
|
|
17
19
|
class << self
|
18
20
|
def select_type
|
19
|
-
@select_type ||=
|
21
|
+
@select_type ||= name.split("::").last.sub("Select", "").downcase
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
23
25
|
private
|
26
|
+
def select_type
|
27
|
+
self.class.select_type
|
28
|
+
end
|
24
29
|
|
25
|
-
|
26
|
-
|
27
|
-
|
30
|
+
def datetime_selector(options, html_options)
|
31
|
+
datetime = options.fetch(:selected) { value || default_datetime(options) }
|
32
|
+
@auto_index ||= nil
|
28
33
|
|
29
|
-
|
30
|
-
|
31
|
-
|
34
|
+
options = options.dup
|
35
|
+
options[:field_name] = @method_name
|
36
|
+
options[:include_position] = true
|
37
|
+
options[:prefix] ||= @object_name
|
38
|
+
options[:index] = @auto_index if @auto_index && !options.has_key?(:index)
|
32
39
|
|
33
|
-
|
34
|
-
|
35
|
-
options[:include_position] = true
|
36
|
-
options[:prefix] ||= @object_name
|
37
|
-
options[:index] = @auto_index if @auto_index && !options.has_key?(:index)
|
40
|
+
DateTimeSelector.new(datetime, options, html_options)
|
41
|
+
end
|
38
42
|
|
39
|
-
|
40
|
-
|
43
|
+
def default_datetime(options)
|
44
|
+
return if options[:include_blank] || options[:prompt]
|
41
45
|
|
42
|
-
|
43
|
-
|
46
|
+
case options[:default]
|
47
|
+
when nil
|
48
|
+
Time.current
|
49
|
+
when Date, Time
|
50
|
+
options[:default]
|
51
|
+
else
|
52
|
+
default = options[:default].dup
|
44
53
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
when Date, Time
|
49
|
-
options[:default]
|
50
|
-
else
|
51
|
-
default = options[:default].dup
|
54
|
+
# Rename :minute and :second to :min and :sec
|
55
|
+
default[:min] ||= default[:minute]
|
56
|
+
default[:sec] ||= default[:second]
|
52
57
|
|
53
|
-
|
54
|
-
default[:min] ||= default[:minute]
|
55
|
-
default[:sec] ||= default[:second]
|
58
|
+
time = Time.current
|
56
59
|
|
57
|
-
|
60
|
+
[:year, :month, :day, :hour, :min, :sec].each do |key|
|
61
|
+
default[key] ||= time.public_send(key)
|
62
|
+
end
|
58
63
|
|
59
|
-
|
60
|
-
|
64
|
+
Time.utc(
|
65
|
+
default[:year], default[:month], default[:day],
|
66
|
+
default[:hour], default[:min], default[:sec]
|
67
|
+
)
|
61
68
|
end
|
62
|
-
|
63
|
-
Time.utc(
|
64
|
-
default[:year], default[:month], default[:day],
|
65
|
-
default[:hour], default[:min], default[:sec]
|
66
|
-
)
|
67
69
|
end
|
68
|
-
end
|
69
70
|
end
|
70
71
|
end
|
71
72
|
end
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
4
6
|
class DatetimeField < TextField # :nodoc:
|
5
7
|
def render
|
6
8
|
options = @options.stringify_keys
|
7
|
-
options["value"] ||= format_date(value
|
9
|
+
options["value"] ||= format_date(value)
|
8
10
|
options["min"] = format_date(datetime_value(options["min"]))
|
9
11
|
options["max"] = format_date(datetime_value(options["max"]))
|
10
12
|
@options = options
|
@@ -12,9 +14,8 @@ module ActionView
|
|
12
14
|
end
|
13
15
|
|
14
16
|
private
|
15
|
-
|
16
17
|
def format_date(value)
|
17
|
-
|
18
|
+
raise NotImplementedError
|
18
19
|
end
|
19
20
|
|
20
21
|
def datetime_value(value)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
@@ -9,9 +11,8 @@ module ActionView
|
|
9
11
|
end
|
10
12
|
|
11
13
|
private
|
12
|
-
|
13
14
|
def format_date(value)
|
14
|
-
value
|
15
|
+
value&.strftime("%Y-%m-%dT%T")
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -1,7 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
4
6
|
class FileField < TextField # :nodoc:
|
7
|
+
def render
|
8
|
+
include_hidden = @options.delete(:include_hidden)
|
9
|
+
options = @options.stringify_keys
|
10
|
+
add_default_name_and_id(options)
|
11
|
+
|
12
|
+
if options["multiple"] && include_hidden
|
13
|
+
hidden_field_for_multiple_file(options) + super
|
14
|
+
else
|
15
|
+
super
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def hidden_field_for_multiple_file(options)
|
21
|
+
tag("input", "name" => options["name"], "type" => "hidden", "value" => "", "autocomplete" => "off")
|
22
|
+
end
|
5
23
|
end
|
6
24
|
end
|
7
25
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
@@ -15,8 +17,8 @@ module ActionView
|
|
15
17
|
|
16
18
|
def render
|
17
19
|
option_tags_options = {
|
18
|
-
:
|
19
|
-
:
|
20
|
+
selected: @options.fetch(:selected) { value },
|
21
|
+
disabled: @options[:disabled]
|
20
22
|
}
|
21
23
|
|
22
24
|
select_content_tag(
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
@@ -17,12 +19,16 @@ module ActionView
|
|
17
19
|
method_and_value = @tag_value.present? ? "#{@method_name}.#{@tag_value}" : @method_name
|
18
20
|
|
19
21
|
content ||= Translator
|
20
|
-
.new(object, @object_name, method_and_value, "helpers.label")
|
22
|
+
.new(object, @object_name, method_and_value, scope: "helpers.label")
|
21
23
|
.translate
|
22
24
|
content ||= @method_name.humanize
|
23
25
|
|
24
26
|
content
|
25
27
|
end
|
28
|
+
|
29
|
+
def to_s
|
30
|
+
translation
|
31
|
+
end
|
26
32
|
end
|
27
33
|
|
28
34
|
def initialize(object_name, method_name, template_object, content_or_options = nil, options = nil)
|
@@ -69,7 +75,6 @@ module ActionView
|
|
69
75
|
end
|
70
76
|
|
71
77
|
private
|
72
|
-
|
73
78
|
def render_component(builder)
|
74
79
|
builder.translation
|
75
80
|
end
|
@@ -1,11 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
4
6
|
class MonthField < DatetimeField # :nodoc:
|
5
7
|
private
|
6
|
-
|
7
8
|
def format_date(value)
|
8
|
-
value
|
9
|
+
value&.strftime("%Y-%m")
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
4
6
|
class PasswordField < TextField # :nodoc:
|
5
7
|
def render
|
6
|
-
@options = {:
|
8
|
+
@options = { value: nil }.merge!(@options)
|
7
9
|
super
|
8
10
|
end
|
9
11
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
@@ -10,7 +12,7 @@ module ActionView
|
|
10
12
|
method_and_value = tag_value.is_a?(TrueClass) ? @method_name : "#{@method_name}.#{tag_value}"
|
11
13
|
|
12
14
|
placeholder ||= Tags::Translator
|
13
|
-
.new(object, @object_name, method_and_value, "helpers.placeholder")
|
15
|
+
.new(object, @object_name, method_and_value, scope: "helpers.placeholder")
|
14
16
|
.translate
|
15
17
|
placeholder ||= @method_name.humanize
|
16
18
|
@options[:placeholder] = placeholder
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "action_view/helpers/tags/checkable"
|
2
4
|
|
3
5
|
module ActionView
|
4
6
|
module Helpers
|
@@ -15,16 +17,15 @@ module ActionView
|
|
15
17
|
options = @options.stringify_keys
|
16
18
|
options["type"] = "radio"
|
17
19
|
options["value"] = @tag_value
|
18
|
-
options["checked"] = "checked" if input_checked?(
|
20
|
+
options["checked"] = "checked" if input_checked?(options)
|
19
21
|
add_default_name_and_id_for_value(@tag_value, options)
|
20
22
|
tag("input", options)
|
21
23
|
end
|
22
24
|
|
23
25
|
private
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
26
|
+
def checked?(value)
|
27
|
+
value.to_s == @tag_value.to_s
|
28
|
+
end
|
28
29
|
end
|
29
30
|
end
|
30
31
|
end
|
@@ -1,20 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
4
6
|
class SearchField < TextField # :nodoc:
|
5
7
|
def render
|
6
|
-
|
7
|
-
if options["autosave"]
|
8
|
-
if options["autosave"] == true
|
9
|
-
options["autosave"] = request.host.split(".").reverse.join(".")
|
10
|
-
end
|
11
|
-
options["results"] ||= 10
|
12
|
-
end
|
8
|
+
options = @options.stringify_keys
|
13
9
|
|
14
|
-
|
15
|
-
|
10
|
+
if options["autosave"]
|
11
|
+
if options["autosave"] == true
|
12
|
+
options["autosave"] = request.host.split(".").reverse.join(".")
|
16
13
|
end
|
14
|
+
options["results"] ||= 10
|
17
15
|
end
|
16
|
+
|
17
|
+
if options["onsearch"]
|
18
|
+
options["incremental"] = true unless options.has_key?("incremental")
|
19
|
+
end
|
20
|
+
|
21
|
+
@options = options
|
22
|
+
super
|
18
23
|
end
|
19
24
|
end
|
20
25
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
@@ -13,8 +15,8 @@ module ActionView
|
|
13
15
|
|
14
16
|
def render
|
15
17
|
option_tags_options = {
|
16
|
-
:
|
17
|
-
:
|
18
|
+
selected: @options.fetch(:selected) { value.nil? ? "" : value },
|
19
|
+
disabled: @options[:disabled]
|
18
20
|
}
|
19
21
|
|
20
22
|
option_tags = if grouped_choices?
|
@@ -27,14 +29,13 @@ module ActionView
|
|
27
29
|
end
|
28
30
|
|
29
31
|
private
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
32
|
+
# Grouped choices look like this:
|
33
|
+
#
|
34
|
+
# [nil, []]
|
35
|
+
# { nil => [] }
|
36
|
+
def grouped_choices?
|
37
|
+
!@choices.blank? && @choices.first.respond_to?(:last) && Array === @choices.first.last
|
38
|
+
end
|
38
39
|
end
|
39
40
|
end
|
40
41
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "action_view/helpers/tags/placeholderable"
|
2
4
|
|
3
5
|
module ActionView
|
4
6
|
module Helpers
|
@@ -14,7 +16,7 @@ module ActionView
|
|
14
16
|
options["cols"], options["rows"] = size.split("x") if size.respond_to?(:split)
|
15
17
|
end
|
16
18
|
|
17
|
-
content_tag("textarea", options.delete("value") { value_before_type_cast
|
19
|
+
content_tag("textarea", options.delete("value") { value_before_type_cast }, options)
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "action_view/helpers/tags/placeholderable"
|
2
4
|
|
3
5
|
module ActionView
|
4
6
|
module Helpers
|
@@ -10,23 +12,21 @@ module ActionView
|
|
10
12
|
options = @options.stringify_keys
|
11
13
|
options["size"] = options["maxlength"] unless options.key?("size")
|
12
14
|
options["type"] ||= field_type
|
13
|
-
options["value"] = options.fetch("value") { value_before_type_cast
|
14
|
-
yield options if block_given?
|
15
|
+
options["value"] = options.fetch("value") { value_before_type_cast } unless field_type == "file"
|
15
16
|
add_default_name_and_id(options)
|
16
17
|
tag("input", options)
|
17
18
|
end
|
18
19
|
|
19
20
|
class << self
|
20
21
|
def field_type
|
21
|
-
@field_type ||=
|
22
|
+
@field_type ||= name.split("::").last.sub("Field", "").downcase
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
25
26
|
private
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
27
|
+
def field_type
|
28
|
+
self.class.field_type
|
29
|
+
end
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -1,11 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
4
6
|
class TimeField < DatetimeField # :nodoc:
|
5
|
-
|
7
|
+
def initialize(object_name, method_name, template_object, options = {})
|
8
|
+
@include_seconds = options.delete(:include_seconds) { true }
|
9
|
+
super
|
10
|
+
end
|
6
11
|
|
12
|
+
private
|
7
13
|
def format_date(value)
|
8
|
-
|
14
|
+
if @include_seconds
|
15
|
+
value&.strftime("%T.%L")
|
16
|
+
else
|
17
|
+
value&.strftime("%H:%M")
|
18
|
+
end
|
9
19
|
end
|
10
20
|
end
|
11
21
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
@@ -11,7 +13,7 @@ module ActionView
|
|
11
13
|
|
12
14
|
def render
|
13
15
|
select_content_tag(
|
14
|
-
time_zone_options_for_select(value
|
16
|
+
time_zone_options_for_select(value || @options[:default], @priority_zones, @options[:model] || ActiveSupport::TimeZone), @options, @html_options
|
15
17
|
)
|
16
18
|
end
|
17
19
|
end
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
4
6
|
class Translator # :nodoc:
|
5
|
-
def initialize(object, object_name, method_and_value, scope)
|
7
|
+
def initialize(object, object_name, method_and_value, scope:)
|
6
8
|
@object_name = object_name.gsub(/\[(.*)_attributes\]\[\d+\]/, '.\1')
|
7
9
|
@method_and_value = method_and_value
|
8
10
|
@scope = scope
|
@@ -14,26 +16,23 @@ module ActionView
|
|
14
16
|
translated_attribute || human_attribute_name
|
15
17
|
end
|
16
18
|
|
17
|
-
protected
|
18
|
-
|
19
|
-
attr_reader :object_name, :method_and_value, :scope, :model
|
20
|
-
|
21
19
|
private
|
20
|
+
attr_reader :object_name, :method_and_value, :scope, :model
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
def i18n_default
|
23
|
+
if model
|
24
|
+
key = model.model_name.i18n_key
|
25
|
+
["#{key}.#{method_and_value}".to_sym, ""]
|
26
|
+
else
|
27
|
+
""
|
28
|
+
end
|
29
29
|
end
|
30
|
-
end
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
def human_attribute_name
|
32
|
+
if model && model.class.respond_to?(:human_attribute_name)
|
33
|
+
model.class.human_attribute_name(method_and_value)
|
34
|
+
end
|
35
35
|
end
|
36
|
-
end
|
37
36
|
end
|
38
37
|
end
|
39
38
|
end
|
@@ -1,11 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
4
6
|
class WeekField < DatetimeField # :nodoc:
|
5
7
|
private
|
6
|
-
|
7
8
|
def format_date(value)
|
8
|
-
value
|
9
|
+
value&.strftime("%Y-W%V")
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActionView
|
4
|
+
module Helpers
|
5
|
+
module Tags # :nodoc:
|
6
|
+
class WeekdaySelect < Base # :nodoc:
|
7
|
+
def initialize(object_name, method_name, template_object, options, html_options)
|
8
|
+
@html_options = html_options
|
9
|
+
|
10
|
+
super(object_name, method_name, template_object, options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def render
|
14
|
+
select_content_tag(
|
15
|
+
weekday_options_for_select(
|
16
|
+
value || @options[:selected],
|
17
|
+
index_as_value: @options.fetch(:index_as_value, false),
|
18
|
+
day_format: @options.fetch(:day_format, :day_names),
|
19
|
+
beginning_of_week: @options.fetch(:beginning_of_week, Date.beginning_of_week)
|
20
|
+
),
|
21
|
+
@options,
|
22
|
+
@html_options
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
|
-
module Helpers
|
3
|
-
module Tags
|
4
|
+
module Helpers # :nodoc:
|
5
|
+
module Tags # :nodoc:
|
4
6
|
extend ActiveSupport::Autoload
|
5
7
|
|
6
8
|
eager_autoload do
|
@@ -36,6 +38,7 @@ module ActionView
|
|
36
38
|
autoload :TimeZoneSelect
|
37
39
|
autoload :UrlField
|
38
40
|
autoload :WeekField
|
41
|
+
autoload :WeekdaySelect
|
39
42
|
end
|
40
43
|
end
|
41
44
|
end
|