trusty-cms 4.2 → 4.3.1
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/Gemfile +2 -1
- data/Gemfile.lock +115 -112
- data/LICENSE.md +1 -1
- data/app/assets/config/trusty-cms/manifest.js +7 -0
- data/app/assets/javascripts/admin/custom_file_upload.js +7 -0
- data/app/controllers/admin/pages_controller.rb +1 -1
- data/app/controllers/admin/preferences_controller.rb +1 -1
- data/app/controllers/admin/resource_controller.rb +1 -1
- data/app/controllers/admin/users_controller.rb +1 -1
- data/app/helpers/admin/node_helper.rb +1 -1
- data/app/models/asset.rb +3 -3
- data/app/models/page.rb +5 -5
- data/app/models/standard_tags.rb +3 -3
- data/app/models/user.rb +1 -1
- data/app/views/admin/assets/new.html.haml +2 -0
- data/config/database.mysql.yml +10 -2
- data/config/initializers/assets.rb +0 -4
- data/db/migrate/20210331134718_create_active_storage_tables.active_storage.rb +36 -0
- data/lib/generators/extension/templates/test_helper.rb +6 -8
- data/lib/login_system.rb +1 -1
- data/lib/trusty_cms.rb +1 -1
- data/lib/trusty_cms/setup.rb +1 -1
- data/spec/dummy/config/database.yml +6 -2
- data/trusty_cms.gemspec +3 -4
- data/vendor/extensions/clipped-extension/lib/asset_tags.rb +4 -4
- data/yarn.lock +6 -6
- metadata +323 -184
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/base.rb +0 -195
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/check_box.rb +0 -65
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/checkable.rb +0 -18
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/collection_check_boxes.rb +0 -35
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/collection_helpers.rb +0 -118
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/collection_radio_buttons.rb +0 -30
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/collection_select.rb +0 -30
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/color_field.rb +0 -26
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/date_field.rb +0 -14
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/date_select.rb +0 -73
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/datetime_field.rb +0 -31
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/datetime_local_field.rb +0 -20
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/datetime_select.rb +0 -10
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/email_field.rb +0 -10
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/file_field.rb +0 -10
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/grouped_collection_select.rb +0 -31
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/hidden_field.rb +0 -10
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/label.rb +0 -80
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/month_field.rb +0 -14
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/number_field.rb +0 -20
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/password_field.rb +0 -14
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/placeholderable.rb +0 -24
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/radio_button.rb +0 -32
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/range_field.rb +0 -10
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/search_field.rb +0 -27
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/select.rb +0 -42
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/tel_field.rb +0 -10
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/text_area.rb +0 -24
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/text_field.rb +0 -33
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/time_field.rb +0 -14
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/time_select.rb +0 -10
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/time_zone_select.rb +0 -22
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/translator.rb +0 -39
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/url_field.rb +0 -10
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/week_field.rb +0 -14
@@ -1,195 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActionView
|
4
|
-
module Helpers
|
5
|
-
module Tags # :nodoc:
|
6
|
-
class Base # :nodoc:
|
7
|
-
include Helpers::ActiveModelInstanceTag, Helpers::TagHelper, Helpers::FormTagHelper
|
8
|
-
include FormOptionsHelper
|
9
|
-
|
10
|
-
attr_reader :object
|
11
|
-
|
12
|
-
def initialize(object_name, method_name, template_object, options = {})
|
13
|
-
@object_name, @method_name = object_name.to_s.dup, method_name.to_s.dup
|
14
|
-
@template_object = template_object
|
15
|
-
|
16
|
-
@object_name.sub!(/\[\]$/, "") || @object_name.sub!(/\[\]\]$/, "]")
|
17
|
-
@object = retrieve_object(options.delete(:object))
|
18
|
-
@skip_default_ids = options.delete(:skip_default_ids)
|
19
|
-
@allow_method_names_outside_object = options.delete(:allow_method_names_outside_object)
|
20
|
-
@options = options
|
21
|
-
|
22
|
-
if Regexp.last_match
|
23
|
-
@generate_indexed_names = true
|
24
|
-
@auto_index = retrieve_autoindex(Regexp.last_match.pre_match)
|
25
|
-
else
|
26
|
-
@generate_indexed_names = false
|
27
|
-
@auto_index = nil
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# This is what child classes implement.
|
32
|
-
def render
|
33
|
-
raise NotImplementedError, "Subclasses must implement a render method"
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
def value
|
38
|
-
if @allow_method_names_outside_object
|
39
|
-
object.public_send @method_name if object && object.respond_to?(@method_name)
|
40
|
-
else
|
41
|
-
object.public_send @method_name if object
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def value_before_type_cast
|
46
|
-
unless object.nil?
|
47
|
-
method_before_type_cast = @method_name + "_before_type_cast"
|
48
|
-
|
49
|
-
if value_came_from_user? && object.respond_to?(method_before_type_cast)
|
50
|
-
object.public_send(method_before_type_cast)
|
51
|
-
else
|
52
|
-
value
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def value_came_from_user?
|
58
|
-
method_name = "#{@method_name}_came_from_user?"
|
59
|
-
!object.respond_to?(method_name) || object.public_send(method_name)
|
60
|
-
end
|
61
|
-
|
62
|
-
def retrieve_object(object)
|
63
|
-
if object
|
64
|
-
object
|
65
|
-
elsif @template_object.instance_variable_defined?("@#{@object_name}")
|
66
|
-
@template_object.instance_variable_get("@#{@object_name}")
|
67
|
-
end
|
68
|
-
rescue NameError
|
69
|
-
# As @object_name may contain the nested syntax (item[subobject]) we need to fallback to nil.
|
70
|
-
nil
|
71
|
-
end
|
72
|
-
|
73
|
-
def retrieve_autoindex(pre_match)
|
74
|
-
object = self.object || @template_object.instance_variable_get("@#{pre_match}")
|
75
|
-
if object && object.respond_to?(:to_param)
|
76
|
-
object.to_param
|
77
|
-
else
|
78
|
-
raise ArgumentError, "object[] naming but object param and @object var don't exist or don't respond to to_param: #{object.inspect}"
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def add_default_name_and_id_for_value(tag_value, options)
|
83
|
-
if tag_value.nil?
|
84
|
-
add_default_name_and_id(options)
|
85
|
-
else
|
86
|
-
specified_id = options["id"]
|
87
|
-
add_default_name_and_id(options)
|
88
|
-
|
89
|
-
if specified_id.blank? && options["id"].present?
|
90
|
-
options["id"] += "_#{sanitized_value(tag_value)}"
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def add_default_name_and_id(options)
|
96
|
-
index = name_and_id_index(options)
|
97
|
-
options["name"] = options.fetch("name") { tag_name(options["multiple"], index) }
|
98
|
-
|
99
|
-
if generate_ids?
|
100
|
-
options["id"] = options.fetch("id") { tag_id(index) }
|
101
|
-
if namespace = options.delete("namespace")
|
102
|
-
options["id"] = options["id"] ? "#{namespace}_#{options['id']}" : namespace
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def tag_name(multiple = false, index = nil)
|
108
|
-
# a little duplication to construct less strings
|
109
|
-
case
|
110
|
-
when @object_name.empty?
|
111
|
-
"#{sanitized_method_name}#{multiple ? "[]" : ""}"
|
112
|
-
when index
|
113
|
-
"#{@object_name}[#{index}][#{sanitized_method_name}]#{multiple ? "[]" : ""}"
|
114
|
-
else
|
115
|
-
"#{@object_name}[#{sanitized_method_name}]#{multiple ? "[]" : ""}"
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def tag_id(index = nil)
|
120
|
-
# a little duplication to construct less strings
|
121
|
-
case
|
122
|
-
when @object_name.empty?
|
123
|
-
sanitized_method_name.dup
|
124
|
-
when index
|
125
|
-
"#{sanitized_object_name}_#{index}_#{sanitized_method_name}"
|
126
|
-
else
|
127
|
-
"#{sanitized_object_name}_#{sanitized_method_name}"
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
def sanitized_object_name
|
132
|
-
@sanitized_object_name ||= @object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "")
|
133
|
-
end
|
134
|
-
|
135
|
-
def sanitized_method_name
|
136
|
-
@sanitized_method_name ||= @method_name.sub(/\?$/, "")
|
137
|
-
end
|
138
|
-
|
139
|
-
def sanitized_value(value)
|
140
|
-
value.to_s.gsub(/[\s\.]/, "_").gsub(/[^-[[:word:]]]/, "").downcase
|
141
|
-
end
|
142
|
-
|
143
|
-
def select_content_tag(option_tags, options, html_options)
|
144
|
-
html_options = html_options.stringify_keys
|
145
|
-
add_default_name_and_id(html_options)
|
146
|
-
|
147
|
-
if placeholder_required?(html_options)
|
148
|
-
raise ArgumentError, "include_blank cannot be false for a required field." if options[:include_blank] == false
|
149
|
-
options[:include_blank] ||= true unless options[:prompt]
|
150
|
-
end
|
151
|
-
|
152
|
-
value = options.fetch(:selected) { value() }
|
153
|
-
select = content_tag("select", add_options(option_tags, options, value), html_options)
|
154
|
-
|
155
|
-
if html_options["multiple"] && options.fetch(:include_hidden, true)
|
156
|
-
tag("input", disabled: html_options["disabled"], name: html_options["name"], type: "hidden", value: "") + select
|
157
|
-
else
|
158
|
-
select
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
def placeholder_required?(html_options)
|
163
|
-
# See https://html.spec.whatwg.org/multipage/forms.html#attr-select-required
|
164
|
-
html_options["required"] && !html_options["multiple"] && html_options.fetch("size", 1).to_i == 1
|
165
|
-
end
|
166
|
-
|
167
|
-
def add_options(option_tags, options, value = nil)
|
168
|
-
if options[:include_blank]
|
169
|
-
option_tags = tag_builder.content_tag_string("option", options[:include_blank].kind_of?(String) ? options[:include_blank] : nil, value: "") + "\n" + option_tags
|
170
|
-
end
|
171
|
-
if value.blank? && options[:prompt]
|
172
|
-
tag_options = { value: "" }.tap do |prompt_opts|
|
173
|
-
prompt_opts[:disabled] = true if options[:disabled] == ""
|
174
|
-
prompt_opts[:selected] = true if options[:selected] == ""
|
175
|
-
end
|
176
|
-
option_tags = tag_builder.content_tag_string("option", prompt_text(options[:prompt]), tag_options) + "\n" + option_tags
|
177
|
-
end
|
178
|
-
option_tags
|
179
|
-
end
|
180
|
-
|
181
|
-
def name_and_id_index(options)
|
182
|
-
if options.key?("index")
|
183
|
-
options.delete("index") || ""
|
184
|
-
elsif @generate_indexed_names
|
185
|
-
@auto_index || ""
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
def generate_ids?
|
190
|
-
!@skip_default_ids
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
195
|
-
end
|
data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/check_box.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "action_view/helpers/tags/checkable"
|
4
|
-
|
5
|
-
module ActionView
|
6
|
-
module Helpers
|
7
|
-
module Tags # :nodoc:
|
8
|
-
class CheckBox < Base #:nodoc:
|
9
|
-
include Checkable
|
10
|
-
|
11
|
-
def initialize(object_name, method_name, template_object, checked_value, unchecked_value, options)
|
12
|
-
@checked_value = checked_value
|
13
|
-
@unchecked_value = unchecked_value
|
14
|
-
super(object_name, method_name, template_object, options)
|
15
|
-
end
|
16
|
-
|
17
|
-
def render
|
18
|
-
options = @options.stringify_keys
|
19
|
-
options["type"] = "checkbox"
|
20
|
-
options["value"] = @checked_value
|
21
|
-
options["checked"] = "checked" if input_checked?(options)
|
22
|
-
|
23
|
-
if options["multiple"]
|
24
|
-
add_default_name_and_id_for_value(@checked_value, options)
|
25
|
-
options.delete("multiple")
|
26
|
-
else
|
27
|
-
add_default_name_and_id(options)
|
28
|
-
end
|
29
|
-
|
30
|
-
include_hidden = options.delete("include_hidden") { true }
|
31
|
-
checkbox = tag("input", options)
|
32
|
-
|
33
|
-
if include_hidden
|
34
|
-
hidden = hidden_field_for_checkbox(options)
|
35
|
-
hidden + checkbox
|
36
|
-
else
|
37
|
-
checkbox
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
def checked?(value)
|
43
|
-
case value
|
44
|
-
when TrueClass, FalseClass
|
45
|
-
value == !!@checked_value
|
46
|
-
when NilClass
|
47
|
-
false
|
48
|
-
when String
|
49
|
-
value == @checked_value
|
50
|
-
else
|
51
|
-
if value.respond_to?(:include?)
|
52
|
-
value.include?(@checked_value)
|
53
|
-
else
|
54
|
-
value.to_i == @checked_value.to_i
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def hidden_field_for_checkbox(options)
|
60
|
-
@unchecked_value ? tag("input", options.slice("name", "disabled", "form").merge!("type" => "hidden", "value" => @unchecked_value)) : "".html_safe
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/checkable.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActionView
|
4
|
-
module Helpers
|
5
|
-
module Tags # :nodoc:
|
6
|
-
module Checkable # :nodoc:
|
7
|
-
def input_checked?(options)
|
8
|
-
if options.has_key?("checked")
|
9
|
-
checked = options.delete "checked"
|
10
|
-
checked == true || checked == "checked"
|
11
|
-
else
|
12
|
-
checked?(value)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "action_view/helpers/tags/collection_helpers"
|
4
|
-
|
5
|
-
module ActionView
|
6
|
-
module Helpers
|
7
|
-
module Tags # :nodoc:
|
8
|
-
class CollectionCheckBoxes < Base # :nodoc:
|
9
|
-
include CollectionHelpers
|
10
|
-
|
11
|
-
class CheckBoxBuilder < Builder # :nodoc:
|
12
|
-
def check_box(extra_html_options = {})
|
13
|
-
html_options = extra_html_options.merge(@input_html_options)
|
14
|
-
html_options[:multiple] = true
|
15
|
-
html_options[:skip_default_ids] = false
|
16
|
-
@template_object.check_box(@object_name, @method_name, html_options, @value, nil)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def render(&block)
|
21
|
-
render_collection_for(CheckBoxBuilder, &block)
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
def render_component(builder)
|
26
|
-
builder.check_box + builder.label
|
27
|
-
end
|
28
|
-
|
29
|
-
def hidden_field_name
|
30
|
-
"#{super}[]"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,118 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActionView
|
4
|
-
module Helpers
|
5
|
-
module Tags # :nodoc:
|
6
|
-
module CollectionHelpers # :nodoc:
|
7
|
-
class Builder # :nodoc:
|
8
|
-
attr_reader :object, :text, :value
|
9
|
-
|
10
|
-
def initialize(template_object, object_name, method_name, object,
|
11
|
-
sanitized_attribute_name, text, value, input_html_options)
|
12
|
-
@template_object = template_object
|
13
|
-
@object_name = object_name
|
14
|
-
@method_name = method_name
|
15
|
-
@object = object
|
16
|
-
@sanitized_attribute_name = sanitized_attribute_name
|
17
|
-
@text = text
|
18
|
-
@value = value
|
19
|
-
@input_html_options = input_html_options
|
20
|
-
end
|
21
|
-
|
22
|
-
def label(label_html_options = {}, &block)
|
23
|
-
html_options = @input_html_options.slice(:index, :namespace).merge(label_html_options)
|
24
|
-
html_options[:for] ||= @input_html_options[:id] if @input_html_options[:id]
|
25
|
-
|
26
|
-
@template_object.label(@object_name, @sanitized_attribute_name, @text, html_options, &block)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def initialize(object_name, method_name, template_object, collection, value_method, text_method, options, html_options)
|
31
|
-
@collection = collection
|
32
|
-
@value_method = value_method
|
33
|
-
@text_method = text_method
|
34
|
-
@html_options = html_options
|
35
|
-
|
36
|
-
super(object_name, method_name, template_object, options)
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
def instantiate_builder(builder_class, item, value, text, html_options)
|
41
|
-
builder_class.new(@template_object, @object_name, @method_name, item,
|
42
|
-
sanitize_attribute_name(value), text, value, html_options)
|
43
|
-
end
|
44
|
-
|
45
|
-
# Generate default options for collection helpers, such as :checked and
|
46
|
-
# :disabled.
|
47
|
-
def default_html_options_for_collection(item, value)
|
48
|
-
html_options = @html_options.dup
|
49
|
-
|
50
|
-
[:checked, :selected, :disabled, :readonly].each do |option|
|
51
|
-
current_value = @options[option]
|
52
|
-
next if current_value.nil?
|
53
|
-
|
54
|
-
accept = if current_value.respond_to?(:call)
|
55
|
-
current_value.call(item)
|
56
|
-
else
|
57
|
-
Array(current_value).map(&:to_s).include?(value.to_s)
|
58
|
-
end
|
59
|
-
|
60
|
-
if accept
|
61
|
-
html_options[option] = true
|
62
|
-
elsif option == :checked
|
63
|
-
html_options[option] = false
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
html_options[:object] = @object
|
68
|
-
html_options
|
69
|
-
end
|
70
|
-
|
71
|
-
def sanitize_attribute_name(value)
|
72
|
-
"#{sanitized_method_name}_#{sanitized_value(value)}"
|
73
|
-
end
|
74
|
-
|
75
|
-
def render_collection
|
76
|
-
@collection.map do |item|
|
77
|
-
value = value_for_collection(item, @value_method)
|
78
|
-
text = value_for_collection(item, @text_method)
|
79
|
-
default_html_options = default_html_options_for_collection(item, value)
|
80
|
-
additional_html_options = option_html_attributes(item)
|
81
|
-
|
82
|
-
yield item, value, text, default_html_options.merge(additional_html_options)
|
83
|
-
end.join.html_safe
|
84
|
-
end
|
85
|
-
|
86
|
-
def render_collection_for(builder_class, &block)
|
87
|
-
options = @options.stringify_keys
|
88
|
-
rendered_collection = render_collection do |item, value, text, default_html_options|
|
89
|
-
builder = instantiate_builder(builder_class, item, value, text, default_html_options)
|
90
|
-
|
91
|
-
if block_given?
|
92
|
-
@template_object.capture(builder, &block)
|
93
|
-
else
|
94
|
-
render_component(builder)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
# Prepend a hidden field to make sure something will be sent back to the
|
99
|
-
# server if all radio buttons are unchecked.
|
100
|
-
if options.fetch("include_hidden", true)
|
101
|
-
hidden_field + rendered_collection
|
102
|
-
else
|
103
|
-
rendered_collection
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def hidden_field
|
108
|
-
hidden_name = @html_options[:name] || hidden_field_name
|
109
|
-
@template_object.hidden_field_tag(hidden_name, "", id: nil)
|
110
|
-
end
|
111
|
-
|
112
|
-
def hidden_field_name
|
113
|
-
"#{tag_name(false, @options[:index])}"
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "action_view/helpers/tags/collection_helpers"
|
4
|
-
|
5
|
-
module ActionView
|
6
|
-
module Helpers
|
7
|
-
module Tags # :nodoc:
|
8
|
-
class CollectionRadioButtons < Base # :nodoc:
|
9
|
-
include CollectionHelpers
|
10
|
-
|
11
|
-
class RadioButtonBuilder < Builder # :nodoc:
|
12
|
-
def radio_button(extra_html_options = {})
|
13
|
-
html_options = extra_html_options.merge(@input_html_options)
|
14
|
-
html_options[:skip_default_ids] = false
|
15
|
-
@template_object.radio_button(@object_name, @method_name, @value, html_options)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def render(&block)
|
20
|
-
render_collection_for(RadioButtonBuilder, &block)
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
def render_component(builder)
|
25
|
-
builder.radio_button + builder.label
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|