Skip to content

Commit 77571f2

Browse files
authored
Merge pull request #3213 from fuegas/master
Only hide empty values if compact mode is enabled
2 parents 03baf72 + 0a6924b commit 77571f2

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

app/views/rails_admin/main/show.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
- @model_config.show.with(object: @object, view: self, controller: self.controller).visible_groups.each do |fieldset|
22
- unless (fields = fieldset.with(object: @object, view: self, controller: self.controller).visible_fields).empty?
3-
- unless (fields = fields.reject{ |f| RailsAdmin::config.compact_show_view && f.formatted_value.nil? || f.formatted_value == '' }).empty?
3+
- unless (fields = fields.reject{ |f| RailsAdmin::config.compact_show_view && (f.formatted_value.nil? || f.formatted_value == '') }).empty?
44
.fieldset
55
%h4
66
= fieldset.label

spec/integration/actions/show_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,26 @@
7676
end
7777
end
7878

79+
context 'when compact_show_view is disabled' do
80+
before do
81+
RailsAdmin.config do |c|
82+
c.compact_show_view = false
83+
end
84+
end
85+
86+
it 'shows nil fields' do
87+
team.update logo_url: nil
88+
visit show_path(model_name: 'team', id: team.id)
89+
is_expected.to have_css('.logo_url_field')
90+
end
91+
92+
it 'shows blank fields' do
93+
team.update logo_url: ''
94+
visit show_path(model_name: 'team', id: team.id)
95+
is_expected.to have_css('.logo_url_field')
96+
end
97+
end
98+
7999
describe 'bindings' do
80100
it 'should be present' do
81101
RailsAdmin.config Team do |_c|

0 commit comments

Comments
 (0)