fluxbit_view_components 0.4.2 → 0.4.3
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 98187d5ac8174cfe0b38638e43b70e8076ec32068cab920e5829105e0e903f6a
|
|
4
|
+
data.tar.gz: 1e7c9b50861f506bb56407ecdd008988a96c9b8d3f79f75e43fbae7f2642c989
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 426024fbf92e4dd34587a9f14057a541e5f00cb501578026c940ffcc98739398cded786b733c36aa0d1d4de2292ce56b7700e9b93d630c4b15a9e58f9098a1e6
|
|
7
|
+
data.tar.gz: 688a8bec19c6def98088f4e59dc8bd96f46c7fc7818612e799bb77f2f44ebced4dc2055d77b7afcad78b6bbd1b5e0d9c16859fcf4ba62866ff472a15955f4c63
|
|
@@ -6,11 +6,7 @@
|
|
|
6
6
|
@other_label || (other_label if other_label?)
|
|
7
7
|
end %>
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
<%= @form.check_box(@attribute, **@props) %>
|
|
11
|
-
<% else %>
|
|
12
|
-
<%= check_box_tag(@name, **@props) %>
|
|
13
|
-
<% end %>
|
|
9
|
+
<%= checkbox_without_wrapper %>
|
|
14
10
|
|
|
15
11
|
<span class="<%= toggle_class %>"></span>
|
|
16
12
|
<%= if @invert_label
|
|
@@ -50,6 +50,7 @@ class Fluxbit::Form::ToggleComponent < Fluxbit::Form::FieldComponent
|
|
|
50
50
|
@invert_label = options(@props.delete(:invert_label), collection: [ true, false ], default: @@invert_label)
|
|
51
51
|
|
|
52
52
|
add to: @props, first_element: true, class: styles[:input]
|
|
53
|
+
@props[:class] = remove_class(@props.delete(:remove_class) || "", @props[:class])
|
|
53
54
|
end
|
|
54
55
|
|
|
55
56
|
def valid_color(color)
|
|
@@ -78,4 +79,25 @@ class Fluxbit::Form::ToggleComponent < Fluxbit::Form::FieldComponent
|
|
|
78
79
|
styles[:toggle][:active][(@props[:disabled] ? :off : :on)]
|
|
79
80
|
].compact.join(" ")
|
|
80
81
|
end
|
|
82
|
+
|
|
83
|
+
# Renders the checkbox without Rails' field_with_errors wrapper
|
|
84
|
+
# We handle errors through help_text instead
|
|
85
|
+
def checkbox_without_wrapper
|
|
86
|
+
return check_box_tag(@name, **@props) unless @form.present? && @attribute.present?
|
|
87
|
+
|
|
88
|
+
# Temporarily remove errors to prevent field_with_errors wrapper
|
|
89
|
+
if @object&.errors&.any? && @object.errors.include?(@attribute)
|
|
90
|
+
# Store the errors for this attribute
|
|
91
|
+
attribute_errors = @object.errors.where(@attribute).to_a
|
|
92
|
+
# Delete them temporarily
|
|
93
|
+
@object.errors.delete(@attribute)
|
|
94
|
+
# Render checkbox without wrapper
|
|
95
|
+
checkbox_html = @form.check_box(@attribute, **@props)
|
|
96
|
+
# Restore the errors
|
|
97
|
+
attribute_errors.each { |error| @object.errors.add(@attribute, error.type, **error.options) }
|
|
98
|
+
checkbox_html
|
|
99
|
+
else
|
|
100
|
+
@form.check_box(@attribute, **@props)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
81
103
|
end
|