Skip to content

Commit

Permalink
fix switch input for boolean type as Deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Nov 27, 2023
1 parent af08bb6 commit 0e26249
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/components/switch_input_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def initialize(id:, name: , label: '', value: '', checked: false, boolean_switch
end

def boolean_switch_action
"this.previousElementSibling.value = this.previousElementSibling.value !== 'true'" if @boolean_switch
"this.parentElement.previousElementSibling.value = this.parentElement.previousElementSibling.value !== 'true'" if @boolean_switch
end

def check_box_name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
%div.switch-filter
- if @boolean_switch
= hidden_field_tag @name, @value
- if content || !@label.empty?
= content_tag(:div, content || @label, style: @style)
- if @boolean_switch
= hidden_field_tag @name, @value
%label.switch{for: check_box_id}
= check_box_tag check_box_name, @value, @checked, class: '', id: check_box_id, onChange: "#{boolean_switch_action}"
%span.slider
4 changes: 3 additions & 1 deletion app/helpers/submission_inputs_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,9 @@ def generate_boolean_input(attr)
value = value.to_s unless value.nil?
name = attr.name
content_tag(:div, class: 'd-flex') do
switch_input(id: name, name: name, label: attr_header_label(attr), checked: value.eql?('true'), value: value, boolean_switch: true, style: 'font-size: 14px;')
switch_input(id: name, name: name, label: attr_header_label(attr), checked: value.eql?('true'), value: value,
boolean_switch: true,
style: 'font-size: 14px;')
end
end

Expand Down

0 comments on commit 0e26249

Please sign in to comment.