Skip to content

Commit

Permalink
[#2996] - Change boolean field to show dash when null (#2997)
Browse files Browse the repository at this point in the history
* Change boolean field to show dash when null

* Update app/components/avo/fields/boolean_field/index_component.html.erb

* Update app/components/avo/fields/boolean_field/show_component.html.erb

---------

Co-authored-by: Paul Bob <69730720+Paul-Bob@users.noreply.github.com>
  • Loading branch information
serene and Paul-Bob authored Jul 17, 2024
1 parent 014241a commit 46fb7d8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<%= index_field_wrapper **field_wrapper_args, dash_if_blank: false, flush: true do %>
<%= index_field_wrapper **field_wrapper_args, flush: true do %>
<%= render Avo::Fields::Common::BooleanCheckComponent.new checked: @field.value %>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<%= field_wrapper **field_wrapper_args, dash_if_blank: false do %>
<%= field_wrapper **field_wrapper_args do %>
<%= render Avo::Fields::Common::BooleanCheckComponent.new checked: @field.value %>
<% end %>
17 changes: 17 additions & 0 deletions spec/system/avo/boolean_field_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require "rails_helper"

RSpec.describe "BooleanField", type: :system do
describe "with regular input" do
let!(:post) { create :post, name: "My Post", is_featured: nil }

context "show" do
it "displays the post values" do
visit "/admin/resources/posts/#{post.id}"

expect(page).to have_text "IS FEATURED"

expect(find_field_value_element("is_featured")).to have_text empty_dash
end
end
end
end

0 comments on commit 46fb7d8

Please sign in to comment.