actionview 7.0.0.rc3 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionview might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd9f0f3f111b5b53b1d0135007aa745a12b40b3f5e87734b14075313627b13a2
4
- data.tar.gz: 5fb7198884640de012c5020ddc54ad5de4d7586c7f03e55cd9da0323c8663666
3
+ metadata.gz: 4404695c53394a381070413d888aa3a233c9f2b20f0f9d95b5d09c7d677bf14b
4
+ data.tar.gz: e2d825223979a9ce8c17024d6f74389f03c7161872bbba807c2cd760769b0922
5
5
  SHA512:
6
- metadata.gz: f94afcca9172b15939d78d3eb27c75285ee2c51f9a5209361c1cdc57ff9fba79ae3ac2505abd60d5adb3ac6eb22ba1e44cc198424afb808723f3de86cf53680d
7
- data.tar.gz: 0fba32b8093eabfce785f98d48cd80c042c4e6856b0da00f14069ed1d1128db2706fc44851b11823b48bff614349e135a25bbdbc2f1912bf9e371d1be464d860
6
+ metadata.gz: 3c2ce1c485c81aa6a4b268e6b1eabb19123b5aebf9b76855c0be654c19c7d5d4ff66b676759352a8978910540ddfb20fd66e9fd95a3cc1887af0cd435d028914
7
+ data.tar.gz: 4ea433d6ba6b950f1f94b3d0e5c1cfd2493d5fb3f56fcd8d904bc0cf06603118443ccc121880eb8bbd7e0920347c6bda74809858a6cd297038e39ec115fed70b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## Rails 7.0.0 (December 15, 2021) ##
2
+
3
+ * Support `include_hidden:` option in calls to
4
+ `ActionView::Helper::FormBuilder#file_field` with `multiple: true` to
5
+ support submitting an empty collection of files.
6
+
7
+ ```ruby
8
+ form.file_field :attachments, multiple: true
9
+ # => <input type="hidden" autocomplete="off" name="post[attachments][]" value="">
10
+ <input type="file" multiple="multiple" id="post_attachments" name="post[attachments][]">
11
+
12
+ form.file_field :attachments, multiple: true, include_hidden: false
13
+ # => <input type="file" multiple="multiple" id="post_attachments" name="post[attachments][]">
14
+ ```
15
+
16
+ *Sean Doyle*
17
+
18
+ * Fix `number_with_precision(raise: true)` always raising even on valid numbers.
19
+
20
+ *Pedro Moreira*
21
+
22
+
1
23
  ## Rails 7.0.0.rc3 (December 14, 2021) ##
2
24
 
3
25
  * No changes.
@@ -5,6 +27,10 @@
5
27
 
6
28
  ## Rails 7.0.0.rc2 (December 14, 2021) ##
7
29
 
30
+ * No changes.
31
+
32
+ ## Rails 7.0.0.rc1 (December 06, 2021) ##
33
+
8
34
  * Support `fields model: [@nested, @model]` the same way as `form_with model:
9
35
  [@nested, @model]`.
10
36
 
@@ -10,7 +10,7 @@ module ActionView
10
10
  MAJOR = 7
11
11
  MINOR = 0
12
12
  TINY = 0
13
- PRE = "rc3"
13
+ PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -258,14 +258,14 @@ module ActionView
258
258
  #
259
259
  # The helper gets the name of the favicon file as first argument, which
260
260
  # defaults to "favicon.ico", and also supports +:rel+ and +:type+ options
261
- # to override their defaults, "shortcut icon" and "image/x-icon"
261
+ # to override their defaults, "icon" and "image/x-icon"
262
262
  # respectively:
263
263
  #
264
264
  # favicon_link_tag
265
- # # => <link href="/assets/favicon.ico" rel="shortcut icon" type="image/x-icon" />
265
+ # # => <link href="/assets/favicon.ico" rel="icon" type="image/x-icon" />
266
266
  #
267
267
  # favicon_link_tag 'myicon.ico'
268
- # # => <link href="/assets/myicon.ico" rel="shortcut icon" type="image/x-icon" />
268
+ # # => <link href="/assets/myicon.ico" rel="icon" type="image/x-icon" />
269
269
  #
270
270
  # Mobile Safari looks for a different link tag, pointing to an image that
271
271
  # will be used if you add the page to the home screen of an iOS device.
@@ -275,7 +275,7 @@ module ActionView
275
275
  # # => <link href="/assets/mb-icon.png" rel="apple-touch-icon" type="image/png" />
276
276
  def favicon_link_tag(source = "favicon.ico", options = {})
277
277
  tag("link", {
278
- rel: "shortcut icon",
278
+ rel: "icon",
279
279
  type: "image/x-icon",
280
280
  href: path_to_image(source, skip_pipeline: options.delete(:skip_pipeline))
281
281
  }.merge!(options.symbolize_keys))
@@ -542,7 +542,7 @@ module ActionView
542
542
  MAX_HEADER_SIZE = 8_000 # Some HTTP client and proxies have a 8kiB header limit
543
543
  def send_preload_links_header(preload_links, max_header_size: MAX_HEADER_SIZE)
544
544
  return if preload_links.empty?
545
- return if response.sending?
545
+ return if respond_to?(:response) && response.sending?
546
546
 
547
547
  if respond_to?(:request) && request
548
548
  request.send_early_hints("Link" => preload_links.join("\n"))
@@ -478,6 +478,8 @@ module ActionView
478
478
 
479
479
  mattr_accessor :form_with_generates_ids, default: false
480
480
 
481
+ mattr_accessor :multiple_file_field_include_hidden, default: false
482
+
481
483
  # Creates a form tag based on mixing URLs, scopes, or models.
482
484
  #
483
485
  # # Using just a URL:
@@ -1214,6 +1216,7 @@ module ActionView
1214
1216
  # * Creates standard HTML attributes for the tag.
1215
1217
  # * <tt>:disabled</tt> - If set to true, the user will not be able to use this input.
1216
1218
  # * <tt>:multiple</tt> - If set to true, *in most updated browsers* the user will be allowed to select multiple files.
1219
+ # * <tt>:include_hidden</tt> - When <tt>multiple: true</tt> and <tt>include_hidden: true</tt>, the field will be prefixed with an <tt><input type="hidden"></tt> field with an empty value to support submitting an empty collection of files.
1217
1220
  # * <tt>:accept</tt> - If set to one or multiple mime-types, the user will be suggested a filter when choosing a file. You still need to set up model validations.
1218
1221
  #
1219
1222
  # ==== Examples
@@ -1232,7 +1235,9 @@ module ActionView
1232
1235
  # file_field(:attachment, :file, class: 'file_input')
1233
1236
  # # => <input type="file" id="attachment_file" name="attachment[file]" class="file_input" />
1234
1237
  def file_field(object_name, method, options = {})
1235
- Tags::FileField.new(object_name, method, self, convert_direct_upload_option_to_url(method, options.dup)).render
1238
+ options = { include_hidden: multiple_file_field_include_hidden }.merge!(options)
1239
+
1240
+ Tags::FileField.new(object_name, method, self, convert_direct_upload_option_to_url(method, options)).render
1236
1241
  end
1237
1242
 
1238
1243
  # Returns a textarea opening and closing tag set tailored for accessing a specified attribute (identified by +method+)
@@ -1744,8 +1749,8 @@ module ActionView
1744
1749
  # <tt>aria-describedby</tt> attribute referencing the <tt><span></tt>
1745
1750
  # element, sharing a common <tt>id</tt> root (<tt>post_title</tt>, in this
1746
1751
  # case).
1747
- def field_id(method, *suffixes, index: @index)
1748
- @template.field_id(@object_name, method, *suffixes, index: index)
1752
+ def field_id(method, *suffixes, namespace: @options[:namespace], index: @index)
1753
+ @template.field_id(@object_name, method, *suffixes, namespace: namespace, index: index)
1749
1754
  end
1750
1755
 
1751
1756
  # Generate an HTML <tt>name</tt> attribute value for the given name and
@@ -2485,6 +2490,7 @@ module ActionView
2485
2490
  # * Creates standard HTML attributes for the tag.
2486
2491
  # * <tt>:disabled</tt> - If set to true, the user will not be able to use this input.
2487
2492
  # * <tt>:multiple</tt> - If set to true, *in most updated browsers* the user will be allowed to select multiple files.
2493
+ # * <tt>:include_hidden</tt> - When <tt>multiple: true</tt> and <tt>include_hidden: true</tt>, the field will be prefixed with an <tt><input type="hidden"></tt> field with an empty value to support submitting an empty collection of files.
2488
2494
  # * <tt>:accept</tt> - If set to one or multiple mime-types, the user will be suggested a filter when choosing a file. You still need to set up model validations.
2489
2495
  #
2490
2496
  # ==== Examples
@@ -2577,7 +2583,7 @@ module ActionView
2577
2583
  # # => <button name='button' type='submit'>Create post</button>
2578
2584
  #
2579
2585
  # button(:draft, value: true)
2580
- # # => <button name="post[draft]" value="true" type="submit">Create post</button>
2586
+ # # => <button id="post_draft" name="post[draft]" value="true" type="submit">Create post</button>
2581
2587
  #
2582
2588
  # button do
2583
2589
  # content_tag(:strong, 'Ask me!')
@@ -2596,7 +2602,7 @@ module ActionView
2596
2602
  # button(:draft, value: true) do
2597
2603
  # content_tag(:strong, "Save as draft")
2598
2604
  # end
2599
- # # => <button name="post[draft]" value="true" type="submit">
2605
+ # # => <button id="post_draft" name="post[draft]" value="true" type="submit">
2600
2606
  # # <strong>Save as draft</strong>
2601
2607
  # # </button>
2602
2608
  #
@@ -2605,7 +2611,7 @@ module ActionView
2605
2611
  when Hash
2606
2612
  value, options = nil, value
2607
2613
  when Symbol
2608
- value, options[:name] = nil, field_name(value)
2614
+ value, options = nil, { name: field_name(value), id: field_id(value) }.merge!(options.to_h)
2609
2615
  end
2610
2616
  value ||= submit_default_value
2611
2617
 
@@ -96,7 +96,7 @@ module ActionView
96
96
  # <tt>aria-describedby</tt> attribute referencing the <tt><span></tt>
97
97
  # element, sharing a common <tt>id</tt> root (<tt>post_title</tt>, in this
98
98
  # case).
99
- def field_id(object_name, method_name, *suffixes, index: nil)
99
+ def field_id(object_name, method_name, *suffixes, index: nil, namespace: nil)
100
100
  if object_name.respond_to?(:model_name)
101
101
  object_name = object_name.model_name.singular
102
102
  end
@@ -105,16 +105,13 @@ module ActionView
105
105
 
106
106
  sanitized_method_name = method_name.to_s.delete_suffix("?")
107
107
 
108
- # a little duplication to construct fewer strings
109
- if sanitized_object_name.empty?
110
- sanitized_method_name
111
- elsif suffixes.any?
112
- [sanitized_object_name, index, sanitized_method_name, *suffixes].compact.join("_")
113
- elsif index
114
- "#{sanitized_object_name}_#{index}_#{sanitized_method_name}"
115
- else
116
- "#{sanitized_object_name}_#{sanitized_method_name}"
117
- end
108
+ [
109
+ namespace,
110
+ sanitized_object_name.presence,
111
+ (index unless sanitized_object_name.empty?),
112
+ sanitized_method_name,
113
+ *suffixes,
114
+ ].tap(&:compact!).join("_")
118
115
  end
119
116
 
120
117
  # Generate an HTML <tt>name</tt> attribute value for the given name and
@@ -450,6 +450,7 @@ module ActionView
450
450
  def parse_float(number, raise_error)
451
451
  result = Float(number, exception: false)
452
452
  raise InvalidNumberError, number if result.nil? && raise_error
453
+ result
453
454
  end
454
455
  end
455
456
  end
@@ -97,7 +97,7 @@ module ActionView
97
97
  options["name"] = options.fetch("name") { tag_name(options["multiple"], index) }
98
98
 
99
99
  if generate_ids?
100
- options["id"] = options.fetch("id") { tag_id(index) }
100
+ options["id"] = options.fetch("id") { tag_id(index, options.delete("namespace")) }
101
101
  if namespace = options.delete("namespace")
102
102
  options["id"] = options["id"] ? "#{namespace}_#{options['id']}" : namespace
103
103
  end
@@ -108,8 +108,8 @@ module ActionView
108
108
  @template_object.field_name(@object_name, sanitized_method_name, multiple: multiple, index: index)
109
109
  end
110
110
 
111
- def tag_id(index = nil)
112
- @template_object.field_id(@object_name, @method_name, index: index)
111
+ def tag_id(index = nil, namespace = nil)
112
+ @template_object.field_id(@object_name, @method_name, index: index, namespace: namespace)
113
113
  end
114
114
 
115
115
  def sanitized_method_name
@@ -4,6 +4,22 @@ module ActionView
4
4
  module Helpers
5
5
  module Tags # :nodoc:
6
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
7
23
  end
8
24
  end
9
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionview
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0.rc3
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-14 00:00:00.000000000 Z
11
+ date: 2021-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 7.0.0.rc3
19
+ version: 7.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 7.0.0.rc3
26
+ version: 7.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: builder
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -92,28 +92,28 @@ dependencies:
92
92
  requirements:
93
93
  - - '='
94
94
  - !ruby/object:Gem::Version
95
- version: 7.0.0.rc3
95
+ version: 7.0.0
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - '='
101
101
  - !ruby/object:Gem::Version
102
- version: 7.0.0.rc3
102
+ version: 7.0.0
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: activemodel
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - '='
108
108
  - !ruby/object:Gem::Version
109
- version: 7.0.0.rc3
109
+ version: 7.0.0
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - '='
115
115
  - !ruby/object:Gem::Version
116
- version: 7.0.0.rc3
116
+ version: 7.0.0
117
117
  description: Simple, battle-tested conventions and helpers for building web pages.
118
118
  email: david@loudthinking.com
119
119
  executables: []
@@ -246,12 +246,12 @@ licenses:
246
246
  - MIT
247
247
  metadata:
248
248
  bug_tracker_uri: https://github.com/rails/rails/issues
249
- changelog_uri: https://github.com/rails/rails/blob/v7.0.0.rc3/actionview/CHANGELOG.md
250
- documentation_uri: https://api.rubyonrails.org/v7.0.0.rc3/
249
+ changelog_uri: https://github.com/rails/rails/blob/v7.0.0/actionview/CHANGELOG.md
250
+ documentation_uri: https://api.rubyonrails.org/v7.0.0/
251
251
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
252
- source_code_uri: https://github.com/rails/rails/tree/v7.0.0.rc3/actionview
252
+ source_code_uri: https://github.com/rails/rails/tree/v7.0.0/actionview
253
253
  rubygems_mfa_required: 'true'
254
- post_install_message:
254
+ post_install_message:
255
255
  rdoc_options: []
256
256
  require_paths:
257
257
  - lib
@@ -262,13 +262,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
262
262
  version: 2.7.0
263
263
  required_rubygems_version: !ruby/object:Gem::Requirement
264
264
  requirements:
265
- - - ">"
265
+ - - ">="
266
266
  - !ruby/object:Gem::Version
267
- version: 1.3.1
267
+ version: '0'
268
268
  requirements:
269
269
  - none
270
- rubygems_version: 3.2.15
271
- signing_key:
270
+ rubygems_version: 3.2.32
271
+ signing_key:
272
272
  specification_version: 4
273
273
  summary: Rendering framework putting the V in MVC (part of Rails).
274
274
  test_files: []