Skip to content

Commit

Permalink
Add ability to show a help text under the search box
Browse files Browse the repository at this point in the history
  • Loading branch information
mshibuya committed Aug 7, 2022
1 parent b9ee7f0 commit 94f16fb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/views/rails_admin/main/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
<i class="fas fa-times"></i>
</button>
</div>
<% if @model_config.list.search_help.present? %>
<div class="form-text"><%= @model_config.list.search_help %></div>
<% end %>
</div>
<div class="col-sm-6 text-end">
<% if export_action %>
Expand Down
4 changes: 4 additions & 0 deletions lib/rails_admin/config/sections/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class List < RailsAdmin::Config::Sections::Base
nil
end

register_instance_option :search_help do
nil
end

register_instance_option :sort_by do
parent.abstract_model.primary_key
end
Expand Down
10 changes: 10 additions & 0 deletions spec/integration/actions/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,16 @@
},
]
end

it 'shows the help text below the search box' do
RailsAdmin.config Player do
list do
search_help 'Use this box to search!'
end
end
visit index_path(model_name: 'player')
is_expected.to have_css('.form-text', text: /Use this box/)
end
end

describe 'fields' do
Expand Down

0 comments on commit 94f16fb

Please sign in to comment.