From 8430b63e26412725bba89417496e50f034e6e523 Mon Sep 17 00:00:00 2001 From: Greg Piatigorski Date: Fri, 11 Aug 2017 13:48:59 -0700 Subject: [PATCH] Clear Search text value https://bugzilla.redhat.com/show_bug.cgi?id=1346996 --- app/assets/javascripts/miq_application.js | 5 ++++- app/controllers/application_controller.rb | 7 +++++++ app/views/layouts/_searchbar.html.haml | 2 +- app/views/layouts/_x_adv_searchbox.html.haml | 2 +- config/routes.rb | 1 + 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/miq_application.js b/app/assets/javascripts/miq_application.js index 0fb0c44bf72..16bf8dbeb6e 100644 --- a/app/assets/javascripts/miq_application.js +++ b/app/assets/javascripts/miq_application.js @@ -1478,7 +1478,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()) { @@ -1494,6 +1494,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); }); } diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e8367fbe366..4d32c227660 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -531,6 +531,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) diff --git a/app/views/layouts/_searchbar.html.haml b/app/views/layouts/_searchbar.html.haml index e24b1fc1920..f243f0447da 100644 --- a/app/views/layouts/_searchbar.html.haml +++ b/app/views/layouts/_searchbar.html.haml @@ -39,7 +39,7 @@ :javascript $(function($) { $(document).ready(function() { - miqHideSearchClearButton() + miqHideSearchClearButton("#{@explorer}"); }); $("button[data-target='#advsearchModal']").click(function(){ miqJqueryRequest("adv_search_toggle", {beforeSend: true}); diff --git a/app/views/layouts/_x_adv_searchbox.html.haml b/app/views/layouts/_x_adv_searchbox.html.haml index 626f187b61b..bb43bad3877 100644 --- a/app/views/layouts/_x_adv_searchbox.html.haml +++ b/app/views/layouts/_x_adv_searchbox.html.haml @@ -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}); diff --git a/config/routes.rb b/config/routes.rb index b9bb4f29aee..03ef4ac7cc2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -13,6 +13,7 @@ adv_search_load_choice adv_search_name_typed adv_search_toggle + adv_search_text_clear ) button_post = %w(