Skip to content

Commit

Permalink
Fix specifying inline class in #datagrid_filter for enum checkboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan committed Nov 16, 2024
1 parent 0f761ca commit 14452df
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/views/datagrid/_enum_checkboxes.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ You can add indent if whitespace doesn't matter for you
<div class="datagrid-enum-checkboxes">
<%- elements.each do |value, text, checked| -%>
<%- id = [form.object_name, filter.name, value].join('_').underscore -%>
<%= form.datagrid_label(filter.name, **options, for: id, class: 'datagrid-enum-checkbox-label') do -%>
<%= form.datagrid_label(filter.name, for: id, class: 'datagrid-enum-checkbox-label', **options) do -%>
<%= form.datagrid_filter_input(filter.name, id: id, value: value) -%>
<%= text -%>
<%- end -%>
Expand Down
15 changes: 15 additions & 0 deletions spec/datagrid/form_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,21 @@ class MyTemplate
let(:view_options) { { partials: "custom_checkboxes" } }
it { should equal_to_dom("custom_enum_checkboxes") }
end

context "when inline class attribute specified" do
let(:_filter_options) { {for: nil, class: 'custom-class'} }

it { should equal_to_dom(<<~HTML) }
<div class="datagrid-enum-checkboxes">
<label class="custom-class">
<input id="report_category_first" value="first" type="checkbox" name="report[category][]">first
</label>
<label class="custom-class">
<input id="report_category_second" value="second" type="checkbox" name="report[category][]">second
</label>
</div>
HTML
end
end
end

Expand Down

0 comments on commit 14452df

Please sign in to comment.