From f0aceaada4f5b3f411468810972a9f84a7b080ee Mon Sep 17 00:00:00 2001 From: Matt Carmichael Date: Mon, 3 Dec 2018 23:35:32 -0600 Subject: [PATCH 1/3] added show_empty_search_results to settings form --- .../SearchApiFederatedSolrSearchAppSettingsForm.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Form/SearchApiFederatedSolrSearchAppSettingsForm.php b/src/Form/SearchApiFederatedSolrSearchAppSettingsForm.php index 46b80c43e..e99a83fb1 100644 --- a/src/Form/SearchApiFederatedSolrSearchAppSettingsForm.php +++ b/src/Form/SearchApiFederatedSolrSearchAppSettingsForm.php @@ -119,6 +119,14 @@ public function buildForm(array $form, FormStateInterface $form_state) { ], ]; + $form['show_empty_search_results'] = [ + '#type' => 'checkbox', + '#title' => $this->t('Show results for empty search'), + '#default_value' => $config->get('content.show_empty_search_results'), + '#description' => $this + ->t(' When checked, this option allows users to see all results when no search term is entered. By default, empty searches are disabled and yield no results.'), + ]; + $form['no_results_text'] = [ '#type' => 'textfield', '#title' => $this->t('No results text'), @@ -180,6 +188,10 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $set_search_site = $form_state->getValue('set_search_site'); $config->set('facet.site_name.set_default', $set_search_site); + // Set the search app configuration setting for the default search site flag. + $show_empty_search_results = $form_state->getValue('show_empty_search_results'); + $config->set('content.show_empty_search_results', $show_empty_search_results); + // Get the id of the chosen index. $search_index = $form_state->getValue('search_index'); // Save the selected index option in search app config (for form state). From d1624923d8714cf95e2127bdf6f207f8ca2a50eb Mon Sep 17 00:00:00 2001 From: Matt Carmichael Date: Mon, 3 Dec 2018 23:36:18 -0600 Subject: [PATCH 2/3] relay showEmptySearchResults value to javascript app --- src/Controller/SearchController.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Controller/SearchController.php b/src/Controller/SearchController.php index e639905a5..ddced35a1 100644 --- a/src/Controller/SearchController.php +++ b/src/Controller/SearchController.php @@ -62,6 +62,11 @@ public function searchPage() { $federated_search_app_config['noResults'] = $no_results; } + // OPTIONAL: The text to display when a search returns no results. + if ($show_empty_search_results = $config->get('content.show_empty_search_results')) { + $federated_search_app_config['showEmptySearchResults'] = $show_empty_search_results; + } + // OPTIONAL: The number of search results to show per page. if ($rows = $config->get('results.rows')) { $federated_search_app_config['rows'] = intval($rows); From b36894dc4a4d16007192e4331af868ede0d9a46e Mon Sep 17 00:00:00 2001 From: Avi Schwab Date: Sun, 16 Dec 2018 17:21:19 -0600 Subject: [PATCH 3/3] Update react version --- search_api_federated_solr.libraries.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/search_api_federated_solr.libraries.yml b/search_api_federated_solr.libraries.yml index 0d43085e2..53545e8bd 100644 --- a/search_api_federated_solr.libraries.yml +++ b/search_api_federated_solr.libraries.yml @@ -2,9 +2,9 @@ search: version: 1.x css: theme: - https://cdn.jsdelivr.net/gh/palantirnet/federated-search-react@v1.0.9/css/main.cf6a58ce.css: { type: external, minified: true } + https://cdn.jsdelivr.net/gh/palantirnet/federated-search-react@v1.0.10/css/main.cf6a58ce.css: { type: external, minified: true } js: - https://cdn.jsdelivr.net/gh/palantirnet/federated-search-react@v1.0.9/js/main.b294abb7.js: { + https://cdn.jsdelivr.net/gh/palantirnet/federated-search-react@v1.0.10/js/main.d41fc3fe.js: { preprocess: false, minified: true, }