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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50692a30f39e9110cec4b66aca482aac06b5954f6785350c66e0e3f5b34fb79f
4
- data.tar.gz: 1dcf3b39d353062f5ba6e5265339a98474f78e0fa74b7822f1269db13a036c52
3
+ metadata.gz: c8e9f704fae6975451f3f51f700ee7df8e880045c95b686065e2992b9ed027ea
4
+ data.tar.gz: 6ae209045ca11867361a63347150cf8435984976f00026b89c556fcf2dea5674
5
5
  SHA512:
6
- metadata.gz: 5ea403acad7678809350b802ebaab7f3c96b13daa26c3637b46c3b40da038930b2a0a921b96efb7f044bc562d4604ab57c0826781d88bb73b0b2b458f3f76b52
7
- data.tar.gz: 1b22114c6aaf66f7de20b8dfd80e8e790eea1a07e1695a3ba31f7c26a95fd30d404babc9981332731605c2015733fa03dd570bb719c4689ba7430102efa6f791
6
+ metadata.gz: d387972cb0c0b4a0d4d8768782e92608876e0c90fb16a1f3895c5b130707df80901317440b5e69cfaecefebc691d03a614935d595bbcf8246664340d564923df
7
+ data.tar.gz: 5786310071a16944f8a45d3c0bb0e282cd21c151fd8513d45a8d31b5e43892e44113e8f2800a326e528b6f424b73db8952b27c508cc6ffca1e1ea063b4591027
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ui_bibz (3.0.0.beta12)
4
+ ui_bibz (3.0.0.beta13)
5
5
  will-paginate-i18n
6
6
  will_paginate (~> 3.3.0)
7
7
  will_paginate-bootstrap4
data/lib/ui_bibz/infos.rb CHANGED
@@ -12,6 +12,6 @@ module UiBibz
12
12
  REPO = 'git+https://github.com/thooams/ui_bibz.git'
13
13
  EMAIL = 'thomas@hummel.link'
14
14
  AUTHOR = 'Thooams [Thomas HUMMEL]'
15
- VERSION = '3.0.0.beta12'
15
+ VERSION = '3.0.0.beta13'
16
16
  AUTHORS = ['Thooams'].freeze
17
17
  end
@@ -1,20 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UiBibzInputs
4
- class UiRadioFieldInput < SimpleForm::Inputs::CollectionRadioButtonsInput
5
- include UiBibz::Ui::Core::Forms::Choices
6
-
4
+ class UiRadioFieldInput < UiCheckboxFieldInput
7
5
  def input(_wrapper_options)
8
- i = UiBibz::Ui::Core::Forms::Choices::RadioField.new(attribute_name, options, input_html_options)
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 < BaseInput
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('form-check', inline, options[:wrapper_html].try(:[], :class))
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('form-check-label', options[:label_html].try(:[], :class))
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
@@ -47,8 +47,8 @@ module UiBibz::Ui::Core::Forms::Choices
47
47
  { boolean: true }
48
48
  end
49
49
 
50
- def component_html_classes
51
- ['form-check', 'form-switch', inline]
50
+ def wrapper_classes
51
+ %w[form-check form-switch]
52
52
  end
53
53
  end
54
54
  end
@@ -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, collection: @users, label_method: :name_fr
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\"><label class=\"control-label ui_radio_field optional\">Name fr</label><input type=\"hidden\" name=\"user[name_fr]\" value=\"\" /><div class=\"radio ui_radio_field optional form-check-input\"><input class=\"ui_radio_field optional form-check-input\" type=\"radio\" value=\"1\" name=\"user[name_fr]\" id=\"user_name_fr_1\" /><label class=\"collection_radio_buttons\" for=\"user_name_fr_1\">test1</label></div><div class=\"radio ui_radio_field optional form-check-input\"><input class=\"ui_radio_field optional form-check-input\" type=\"radio\" value=\"2\" name=\"user[name_fr]\" id=\"user_name_fr_2\" /><label class=\"collection_radio_buttons\" for=\"user_name_fr_2\">test2</label></div></div></form>"
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ui_bibz
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.beta12
4
+ version: 3.0.0.beta13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thooams [Thomas HUMMEL]