From ac58310286ecb413bc1d7b40e8a3dfc3f287f4e1 Mon Sep 17 00:00:00 2001 From: Laurent Laffont <llaffont@afi-sa.fr> Date: Thu, 4 Oct 2018 14:53:30 +0200 Subject: [PATCH] dev #59497 : do not display selection menu when feature is not active --- library/ZendAfi/View/Helper/Search/Header.php | 8 +++++++- library/ZendAfi/View/Helper/TagSelectRecord.php | 3 +++ .../SearchSelection/SearchSelectionTest.php | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/library/ZendAfi/View/Helper/Search/Header.php b/library/ZendAfi/View/Helper/Search/Header.php index 77cba1c37c1..43f4bed600b 100644 --- a/library/ZendAfi/View/Helper/Search/Header.php +++ b/library/ZendAfi/View/Helper/Search/Header.php @@ -41,7 +41,7 @@ class ZendAfi_View_Helper_Search_Header extends ZendAfi_View_Helper_BaseHelper { $this->_tagDomainBrowser(), $this->_tagSearchActions(), $this->view->tagSearchExtension($this->_criteria), - $this->view->getHelper('TagSelectRecord')->tagRecordSelectionCount($this->_criteria)]; + $this->_tagRecordSelectionCount()]; return $this->_tag('div', implode( @@ -171,4 +171,10 @@ class ZendAfi_View_Helper_Search_Header extends ZendAfi_View_Helper_BaseHelper { 'data-popup' => true]), ['class' => 'save']); } + + + protected function _tagRecordSelectionCount() { + return $this->view->getHelper('TagSelectRecord') + ->tagRecordSelectionCount($this->_criteria); + } } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/TagSelectRecord.php b/library/ZendAfi/View/Helper/TagSelectRecord.php index 0df8172959e..9f862b9011e 100644 --- a/library/ZendAfi/View/Helper/TagSelectRecord.php +++ b/library/ZendAfi/View/Helper/TagSelectRecord.php @@ -40,6 +40,9 @@ class ZendAfi_View_Helper_TagSelectRecord extends ZendAfi_View_Helper_BaseHelper public function tagRecordSelectionCount($criteria) { + if (!Class_AdminVar::isModuleEnabled('ENABLE_SEARCH_MULTIPLE_RECORD_SELECTION')) + return ''; + Class_ScriptLoader::getInstance() ->addInlineScript('function updateRecordSelectionCount(data) {' . '$(\'.record-selection span\').text(data.count); ' diff --git a/tests/scenarios/SearchSelection/SearchSelectionTest.php b/tests/scenarios/SearchSelection/SearchSelectionTest.php index e6bb3878235..cedd474ccd0 100644 --- a/tests/scenarios/SearchSelection/SearchSelectionTest.php +++ b/tests/scenarios/SearchSelection/SearchSelectionTest.php @@ -71,6 +71,23 @@ abstract class SearchSelectionTestCase extends AbstractControllerTestCase { +class SearchSelectionNotActivatedTest extends SearchSelectionTestCase { + public function setUp() { + parent::setUp(); + Class_AdminVar::set('ENABLE_SEARCH_MULTIPLE_RECORD_SELECTION', 0); + + $this->dispatch('/recherche/simple/expressionRecherche/*', true); + } + + + /** @test */ + public function pageShouldNotContainsselectionMenu() { + $this->assertNotXPath('//div[@class="record-selection"]/a[text()="Sélection : "]'); + } +} + + + class SearchSelectionWithEmptySessionTest extends SearchSelectionTestCase { public function setUp() { -- GitLab