From f8e573773883a57661d3b55305efe6602e2bd5ae Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Mon, 14 Dec 2020 15:29:15 +0100 Subject: [PATCH] hotline MT #120427 remove old javascript behavior in search widget --- VERSIONS_HOTLINE/120427 | 1 + .../Intonation/Library/Widget/Search/View.php | 8 --- tests/scenarios/Templates/TemplatesTest.php | 63 +++++++++++++++++++ 3 files changed, 64 insertions(+), 8 deletions(-) create mode 100644 VERSIONS_HOTLINE/120427 diff --git a/VERSIONS_HOTLINE/120427 b/VERSIONS_HOTLINE/120427 new file mode 100644 index 00000000000..36fea88d59b --- /dev/null +++ b/VERSIONS_HOTLINE/120427 @@ -0,0 +1 @@ + - ticket #120427 : Magasin de thèmes : correction du sélecteur de types de documents de la boite de recherche qui forçait l'expression de recherche précédente. \ No newline at end of file diff --git a/library/templates/Intonation/Library/Widget/Search/View.php b/library/templates/Intonation/Library/Widget/Search/View.php index 25920440904..a0de04aa56b 100644 --- a/library/templates/Intonation/Library/Widget/Search/View.php +++ b/library/templates/Intonation/Library/Widget/Search/View.php @@ -61,15 +61,7 @@ class Intonation_Library_Widget_Search_View extends ZendAfi_View_Helper_Accueil_ protected function _renderHeadScriptsOn($script_loader) { $id = '#expressionRecherche' . $this->id_module; - - $criteria = $this->view->search_result - ? $this->view->search_result->getCriteresRecherche() - : new Class_CriteresRecherche(); - - $url = $criteria->getUrlCriteresWithoutFacettes(); - $script_loader - ->addJQueryReady('var form = $("' . $id . '").closest("form"); form.find("select").on("change", function() {form.attr("action", "' . $this->view->url($url, null, true) . '");});') ->addJQueryReady('$("' . $id . '").attr("x-webkit-speech","x-webkit-speech")') ->addOPACPluginScript('search_autocomplete/search_autocomplete') ->addJQueryReady('$("' . $id . '").search_autocomplete('. $this->getAutocompleteOptions() .')') diff --git a/tests/scenarios/Templates/TemplatesTest.php b/tests/scenarios/Templates/TemplatesTest.php index 2b9c15240df..08fc862e648 100644 --- a/tests/scenarios/Templates/TemplatesTest.php +++ b/tests/scenarios/Templates/TemplatesTest.php @@ -1995,6 +1995,69 @@ class TemplatesSearchInSessionTest extends TemplatesIntonationTestCase { } + /** @test */ + public function searchWidgetShouldNotHaveDocTypeLivreSelected() { + $widget = (new Class_Systeme_Widget_Widget) + ->setId(8) + ->setProfileId(72) + ->load(); + $widget->setNewDatas(['facets_in_session' => 0, + 'select_doc' => 1, + 'type_doc' => '', + ]); + $widget->updateProfile(); + Zend_Registry::get('session')->last_search = ['expressionRecherche' => 'trolls de troy', + 'custom_multifacet_doctype' => 'T1']; + + Class_Profil::clearCache(); + + $this->dispatch('/opac/index/index/id_profil/72'); + $this->assertNotXPath('//div[contains(@id, "8")]//select[contains(@id, "custom_multifacets_doctype")]//option[@selected]'); + } + + + /** @test */ + public function searchWidgetShouldNotHaveDocTypeLivreSelectedInSearchView() { + $widget = (new Class_Systeme_Widget_Widget) + ->setId(8) + ->setProfileId(72) + ->load(); + $widget->setNewDatas(['facets_in_session' => 0, + 'always_new_search' => 1, + 'select_doc' => 1, + 'type_doc' => '', + ]); + $widget->updateProfile(); + Zend_Registry::get('session')->last_search = ['expressionRecherche' => 'trolls de troy', + 'custom_multifacet_doctype' => 'T1']; + + Class_Profil::clearCache(); + + $this->dispatch('/opac/recherche/simple/expressionRecherche/Pomme/id_profil/72'); + $this->assertNotXPath('//div[contains(@id, "8")]//select[contains(@id, "custom_multifacets_doctype")]//option[@selected]'); + } + + + /** @test */ + public function searchResultShouldNotContainsScriptOnChange() { + $widget = (new Class_Systeme_Widget_Widget) + ->setId(8) + ->setProfileId(72) + ->load(); + $widget->setNewDatas(['facets_in_session' => 0, + 'always_new_search' => 1, + 'select_doc' => 1, + 'type_doc' => '', + ]); + $widget->updateProfile(); + + Class_Profil::clearCache(); + + $this->dispatch('/opac/recherche/simple/expressionRecherche/avatar/id_profil/72'); + $this->assertNotXPathContentContains('//script', 'form.find("select").on("change", function() {form.attr("action", "/recherche/simple/expressionRecherche/avatar");'); + } + + /** @test */ public function searchSessionShouldBeEmpty() { $this->dispatch('/opac/recherche/clear-last-search-session'); -- GitLab