ui_bibz 3.0.0.beta12 → 3.0.0.beta13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ui_bibz/infos.rb +1 -1
- data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_radio_field_input.rb +2 -13
- data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_switch_field_input.rb +1 -13
- data/lib/ui_bibz/ui/core/forms/choices/checkbox_field.rb +10 -2
- data/lib/ui_bibz/ui/core/forms/choices/radio_field.rb +1 -20
- data/lib/ui_bibz/ui/core/forms/choices/switch_field.rb +2 -2
- data/test/simple_form_test.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8e9f704fae6975451f3f51f700ee7df8e880045c95b686065e2992b9ed027ea
|
4
|
+
data.tar.gz: 6ae209045ca11867361a63347150cf8435984976f00026b89c556fcf2dea5674
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d387972cb0c0b4a0d4d8768782e92608876e0c90fb16a1f3895c5b130707df80901317440b5e69cfaecefebc691d03a614935d595bbcf8246664340d564923df
|
7
|
+
data.tar.gz: 5786310071a16944f8a45d3c0bb0e282cd21c151fd8513d45a8d31b5e43892e44113e8f2800a326e528b6f424b73db8952b27c508cc6ffca1e1ea063b4591027
|
data/Gemfile.lock
CHANGED
data/lib/ui_bibz/infos.rb
CHANGED
@@ -1,20 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module UiBibzInputs
|
4
|
-
class UiRadioFieldInput <
|
5
|
-
include UiBibz::Ui::Core::Forms::Choices
|
6
|
-
|
4
|
+
class UiRadioFieldInput < UiCheckboxFieldInput
|
7
5
|
def input(_wrapper_options)
|
8
|
-
|
9
|
-
options[:item_wrapper_tag] = :div
|
10
|
-
options[:item_wrapper_class] = i.html_options[:class]
|
11
|
-
|
12
|
-
label_method, value_method = detect_collection_methods
|
13
|
-
|
14
|
-
@builder.send(:collection_radio_buttons,
|
15
|
-
attribute_name, collection, value_method, label_method,
|
16
|
-
input_options, i.html_options,
|
17
|
-
&collection_block_for_nested_boolean_style)
|
6
|
+
UiBibz::Ui::Core::Forms::Choices::RadioField.new(input_attribute_name, new_options, input_html_options).render
|
18
7
|
end
|
19
8
|
end
|
20
9
|
end
|
@@ -1,23 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module UiBibzInputs
|
4
|
-
class UiSwitchFieldInput <
|
4
|
+
class UiSwitchFieldInput < UiCheckboxFieldInput
|
5
5
|
include UiBibz::Ui::Core::Forms::Choices
|
6
6
|
|
7
7
|
def input(_wrapper_options)
|
8
8
|
UiBibz::Ui::Core::Forms::Choices::SwitchField.new(input_attribute_name, new_options, new_input_html_options).render
|
9
9
|
end
|
10
|
-
|
11
|
-
def new_input_html_options
|
12
|
-
input_html_options.merge({ checked: value.nil? ? false : value })
|
13
|
-
end
|
14
|
-
|
15
|
-
def value
|
16
|
-
@value ||= @builder.object.send(attribute_name)
|
17
|
-
end
|
18
|
-
|
19
|
-
def new_options
|
20
|
-
options.merge({ label: attribute_name.to_s.titleize })
|
21
|
-
end
|
22
10
|
end
|
23
11
|
end
|
@@ -65,13 +65,13 @@ module UiBibz::Ui::Core::Forms::Choices
|
|
65
65
|
|
66
66
|
def wrapper_html_options
|
67
67
|
(options[:wrapper_html] || {}).tap do |option|
|
68
|
-
option[:class] = UiBibz::Utils::Screwdriver.join_classes(
|
68
|
+
option[:class] = UiBibz::Utils::Screwdriver.join_classes(wrapper_classes, inline, options[:wrapper_html].try(:[], :class))
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
def label_html_options
|
73
73
|
(options[:label_html] || {}).tap do |option|
|
74
|
-
option[:class] = UiBibz::Utils::Screwdriver.join_classes(
|
74
|
+
option[:class] = UiBibz::Utils::Screwdriver.join_classes(label_classes, options[:label_html].try(:[], :class))
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
@@ -111,5 +111,13 @@ module UiBibz::Ui::Core::Forms::Choices
|
|
111
111
|
def inline
|
112
112
|
'form-check-inline' if options[:inline]
|
113
113
|
end
|
114
|
+
|
115
|
+
def wrapper_classes
|
116
|
+
'form-check'
|
117
|
+
end
|
118
|
+
|
119
|
+
def label_classes
|
120
|
+
'form-check-label'
|
121
|
+
end
|
114
122
|
end
|
115
123
|
end
|
@@ -61,27 +61,8 @@ module UiBibz::Ui::Core::Forms::Choices
|
|
61
61
|
|
62
62
|
private
|
63
63
|
|
64
|
-
def wrapper_html_options
|
65
|
-
(options[:wrapper_html] || {}).tap do |option|
|
66
|
-
option[:class] = UiBibz::Utils::Screwdriver.join_classes('form-check', inline, options[:wrapper_html].try(:[], :class))
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def label_html_options
|
71
|
-
(options[:label_html] || {}).tap do |option|
|
72
|
-
option[:class] = UiBibz::Utils::Screwdriver.join_classes('form-check-label', options[:label_html].try(:[], :class))
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def radio_field_html_tag
|
77
|
-
content_tag :div, html_options.except(:id) do
|
78
|
-
concat radio_button_tag content, options[:value], options[:checked] || false, checkbox_html_options
|
79
|
-
concat label_tag(label_name, label_content, class: 'form-check-label') if options[:label] != false
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
64
|
def label_name
|
84
|
-
"#{content}_#{options[:value]}"
|
65
|
+
html_options[:id] || "#{content}_#{options[:value]}"
|
85
66
|
end
|
86
67
|
end
|
87
68
|
end
|
data/test/simple_form_test.rb
CHANGED
@@ -132,10 +132,10 @@ test1</textarea></div></form>"
|
|
132
132
|
|
133
133
|
test 'radio field input in simple form' do
|
134
134
|
actual = simple_form_for @user do |f|
|
135
|
-
f.input :name_fr, as: :ui_radio_field,
|
135
|
+
f.input :name_fr, as: :ui_radio_field, label: 'Radio 1', input_html: { id: "radio_1" }
|
136
136
|
end
|
137
137
|
|
138
|
-
expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_radio_field optional user_name_fr\"><
|
138
|
+
expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_radio_field optional user_name_fr\"><div class=\"form-check\"><input type=\"radio\" name=\"user[name_fr]\" id=\"radio_1\" value=\"test1\" class=\"ui_radio_field optional form-check-input\" /><label class=\"form-check-label\" for=\"radio_1\">Radio 1</label></div></div></form>"
|
139
139
|
|
140
140
|
assert_equal expected, actual
|
141
141
|
end
|