From 8717b2f36fade32068699b6b9026a7529a9871b7 Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@afi-sa.fr> Date: Fri, 12 Jun 2015 10:55:46 +0200 Subject: [PATCH] hotline #25358 sito search fix search in sub category --- .../Controller/Action/Helper/SitothequeListViewMode.php | 6 ++++++ library/ZendAfi/View/Helper/Admin/ListViewMode.php | 8 +++----- .../modules/opac/controllers/SitoControllerTest.php | 8 ++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/library/ZendAfi/Controller/Action/Helper/SitothequeListViewMode.php b/library/ZendAfi/Controller/Action/Helper/SitothequeListViewMode.php index dc3e105de9f..5dbb6e517b3 100644 --- a/library/ZendAfi/Controller/Action/Helper/SitothequeListViewMode.php +++ b/library/ZendAfi/Controller/Action/Helper/SitothequeListViewMode.php @@ -78,6 +78,12 @@ class ZendAfi_Controller_Action_Helper_SitothequeListViewMode extends ZendAfi_Co } + + public function getSearchUrl() { + return parent::getSearchUrl() + ['start_cat' => $this->getRequestParam('start_cat')]; + } + + protected function getSearchParams() { $search_params = ['where' => 'titre like \'%' . trim($this->getSearch()) . '%\'', 'order' => 'titre']; diff --git a/library/ZendAfi/View/Helper/Admin/ListViewMode.php b/library/ZendAfi/View/Helper/Admin/ListViewMode.php index b8a5e1d2878..364668f1d3c 100644 --- a/library/ZendAfi/View/Helper/Admin/ListViewMode.php +++ b/library/ZendAfi/View/Helper/Admin/ListViewMode.php @@ -42,9 +42,6 @@ class ZendAfi_View_Helper_Admin_ListViewMode extends ZendAfi_View_Helper_BaseHel if (!$this->_list->isSearchEnabled()) return ''; - $url = $this->view->url($this->_list->getSearchUrl(), null, true); - $submit = "$('#list_search_form').submit(function(event) {event.preventDefault(); event.stopImmediatePropagation(); var search = $('#list_title_search').val();var url = '". $url ."' + search; document.location.href = url;});"; - $search_input = $this->_tag('input', '', ['type' => 'text', 'name' => 'title_search', @@ -52,13 +49,14 @@ class ZendAfi_View_Helper_Admin_ListViewMode extends ZendAfi_View_Helper_BaseHel 'placeholder' => $this->_('titre du document'), 'value' => $this->_list->getSearchValue()]); - Class_ScriptLoader::getInstance()->addJQueryReady($submit); - $search_button = $this->_tag('button', $this->_('Filtrer'), ['id' => 'list_filter_button']); return $this->_tag('form', $search_input . $search_button, ['style' => 'text-align: right;', + 'action' => $this->view->url(array_filter($this->_list->getSearchUrl()), + null, + true), 'id' => 'list_search_form']); } diff --git a/tests/application/modules/opac/controllers/SitoControllerTest.php b/tests/application/modules/opac/controllers/SitoControllerTest.php index 04b3be18fbf..3bda4499b92 100644 --- a/tests/application/modules/opac/controllers/SitoControllerTest.php +++ b/tests/application/modules/opac/controllers/SitoControllerTest.php @@ -59,6 +59,7 @@ abstract class SitoControllerTestCase extends AbstractControllerTestCase { + abstract class SitoControllerViewCategoyTestCase extends SitoControllerTestCase { public function setUp() { parent::setUp(); @@ -195,6 +196,13 @@ class SitoControllerViewCategorySearchTest extends SitoControllerViewCategoyTest $this->assertNotXPath('//div[@class="sitotheque"]//a[@href="http://linuxfr.org"]', $this->_response->getBody()); } + + + /** @test */ + public function formTitleSearchShouldContainsStartCat() { + $this->assertXPath('//form[@id="list_search_form"][@action="/sito/viewcategory/start_cat/12"]', + $this->_response->getBody()); + } } -- GitLab