Skip to content

Commit

Permalink
Merge pull request #1893 from GregP/search_box_text_clearance
Browse files Browse the repository at this point in the history
Clear Search box text
  • Loading branch information
h-kataria authored Sep 8, 2017
2 parents 4132e21 + 8430b63 commit bbb3b95
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion app/assets/javascripts/miq_application.js
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,7 @@ function miqInitMainContent() {
$('#main-content').css('height', 'calc(100% - ' + height + 'px)');
}

function miqHideSearchClearButton() {
function miqHideSearchClearButton(explorer) {
// Hide the clear button if the search input is empty
$('.search-pf .has-clear .clear').each(function() {
if (! $(this).prev('.form-control').val()) {
Expand All @@ -1488,6 +1488,9 @@ function miqHideSearchClearButton() {
$('.search-pf .has-clear .clear').click(function() {
$(this).prev('.form-control').val('').focus();
$(this).hide();
// Clear Search text values as well
var url = "/" + ManageIQ.controller + "/adv_search_text_clear" + "?in_explorer=" + explorer;
miqJqueryRequest(url);
});
}

Expand Down
7 changes: 7 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,13 @@ def filesystem_download
send_data fs.contents, :filename => fs.name
end

def adv_search_text_clear
if params[:in_explorer] == "true"
@search_text = @sb[:search_text] = nil
reload
end
end

protected

def render_flash(add_flash_text = nil, severity = nil)
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_searchbar.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
:javascript
$(function($) {
$(document).ready(function() {
miqHideSearchClearButton()
miqHideSearchClearButton("#{@explorer}");
});
$("button[data-target='#advsearchModal']").click(function(){
miqJqueryRequest("adv_search_toggle", {beforeSend: true});
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_x_adv_searchbox.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
ManageIQ.explorer.clearSearchToggle(#{clear_search_status});
$(function() {
$(document).ready(function() {
miqHideSearchClearButton();
miqHideSearchClearButton("#{@explorer}");
});
$("button[data-target='#advsearchModal']").click(function(){
miqJqueryRequest("adv_search_toggle", {beforeSend: true});
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
adv_search_load_choice
adv_search_name_typed
adv_search_toggle
adv_search_text_clear
)

button_post = %w(
Expand Down

0 comments on commit bbb3b95

Please sign in to comment.