diff --git a/VERSIONS_HOTLINE/123680 b/VERSIONS_HOTLINE/123680 new file mode 100644 index 0000000000000000000000000000000000000000..aa779fa337b0a2b6638b64511a588d8e85198541 --- /dev/null +++ b/VERSIONS_HOTLINE/123680 @@ -0,0 +1 @@ + - ticket #123680 : Magasin de thèmes : ajout des classes CSS 'facet_block_toggle_visibility' et 'facet_block_closed' sur les blocs de facettes pliées par défaut dans le résultat de recherche. \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/Abstract.php b/library/templates/Intonation/Library/View/Wrapper/Abstract.php index 5590d3ff8df827fd49437a964e8da3df9e3e2df0..18cdb61c82d04d7fc1e7b488f5162291902e1459 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Abstract.php +++ b/library/templates/Intonation/Library/View/Wrapper/Abstract.php @@ -124,14 +124,14 @@ abstract class Intonation_Library_View_Wrapper_Abstract { } - protected function _getInUtilsIco($ico_key) { - return $this->getIco($ico_key, 'utils'); + protected function _getInUtilsIco($ico_key, $attribs = []) { + return $this->getIco($ico_key, 'utils', $attribs); } /** @return string */ - public function getIco($key, $category) { - return Class_Template::current()->getIco($this->_view, $key, $category); + public function getIco($key, $category, $attribs = []) { + return $this->_view->templateIco($key, $category, $attribs); } diff --git a/library/templates/Intonation/Library/View/Wrapper/Article.php b/library/templates/Intonation/Library/View/Wrapper/Article.php index ada5e39ba67d962ad3750c3a1a5e10599173c6ef..ad0435f67e05b2da32dfb1cd94d4d6b075e772b5 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Article.php +++ b/library/templates/Intonation/Library/View/Wrapper/Article.php @@ -186,7 +186,7 @@ class Intonation_Library_View_Wrapper_Article extends Intonation_Library_View_Wr if ($this->_model->hasEventsDebut()) $actions [] = new Intonation_Library_Link(['Url' => $this->_urlForModel('opac', 'cms', 'ical'), - 'Image' => $this->_getIco('ical', 'library'), + 'Image' => $this->getIco('ical', 'library'), 'Text' => $this->_('ICAL'), 'Attribs' => ['target' => '_blank'], 'Title' => $this->_('Ajouter l\'événement %s dans mon calendrier', @@ -203,7 +203,7 @@ class Intonation_Library_View_Wrapper_Article extends Intonation_Library_View_Wr if (Class_Users::isCurrentUserCanAccesBackend()) { $actions [] = new Intonation_Library_Link(['Url' => $this->_urlForModel('admin', 'cms', 'edit'), 'Attribs' => ['class' => 'menu_admin_front_anchor'], - 'Image' => $this->_getIco('edit', 'utils'), + 'Image' => $this->_getInUtilsIco('edit'), 'Text' => $this->_('Modifier …'), 'Popup' => true, 'Title' => $this->_('Modifier l\'article %s', @@ -211,7 +211,7 @@ class Intonation_Library_View_Wrapper_Article extends Intonation_Library_View_Wr $actions [] = new Intonation_Library_Link(['Url' => $this->_urlForModel('admin', 'cms', 'version'), 'Attribs' => ['class' => 'menu_admin_front_anchor'], - 'Image' => $this->_getIco('history', 'library'), + 'Image' => $this->getIco('history', 'library'), 'Text' => $this->_('Historique …'), 'Popup' => true, 'Title' => $this->_('Historique des modifications de l\'article %s', @@ -228,17 +228,12 @@ class Intonation_Library_View_Wrapper_Article extends Intonation_Library_View_Wr 'Attribs' => ['class' => 'more_action'], 'Title' => $this->_('Voir plus d\'actions pour %s', $this->_model->getLibelle()), - 'Image' => $this->_getIco('more', 'utils')]); + 'Image' => $this->_getInUtilsIco('more')]); return [$this->_view->renderDropdown($this->_view->renderActions($actions), $button, 'dropleft dropup')]; } - protected function _getIco($ico, $type) { - return Class_Template::current()->getIco($this->_view, $ico, $type); - } - - protected function _urlForModel($module, $controller, $action) { return $this->_view->url(['module' => $module, 'controller' => $controller, diff --git a/library/templates/Intonation/View/Search/Facets.php b/library/templates/Intonation/View/Search/Facets.php index 3a65917dfa17266b207dfeac0b0d8d74f79710a8..6b3b48f31298fd2e3653268eca2ab8cc4c828316 100644 --- a/library/templates/Intonation/View/Search/Facets.php +++ b/library/templates/Intonation/View/Search/Facets.php @@ -37,29 +37,29 @@ class Intonation_View_Search_Facets extends ZendAfi_View_Helper_Facettes { $this->_criteres = (new Intonation_Library_Search_Criteria) ->from($criteres); - $this->_addToggleScript(); - return $this->_HTMLfacets($criteres, $facets); } protected function _rubriqueHTML($rubrique, $type, $facets, $url) { - $onclick = $this->_shouldBeClosed($type) - ? "$(this).next().slideToggle();" + $could_be_closed = $this->_couldBeClosed($type); + $toggle_class = 'facet_block_closed'; + + $onclick = $could_be_closed + ? sprintf('$(this).next().slideToggle(\'complete\', function() {$(this).parent().toggleClass(\'%s\');});', $toggle_class) : ''; - $rubrique = $onclick - ? $rubrique . Class_Template::current()->getIco($this->view, 'below', 'utils', ['class' => 'ml-3']) - : $rubrique; + if ($could_be_closed) + $rubrique .= $this->view->templateIco('below', 'utils', ['class' => 'ml-3']); return $this->_tag('li', - $this->_tag('b', $rubrique, ($onclick ? ['onclick' => $onclick] : [])) - . $this->listeFacettesElementHTML($type, $facets[$type], $url, (boolean) $onclick), - ['class' => 'facette_titre facet_type_' . $type]); + $this->_tag('b', $rubrique, ($could_be_closed ? ['onclick' => $onclick] : [])) + . $this->listeFacettesElementHTML($type, $facets[$type], $url, $could_be_closed), + ['class' => 'facette_titre facet_type_' . $type . ($could_be_closed ? sprintf(' facet_block_toggle_visibility %s', $toggle_class) : '')]); } - protected function _shouldBeClosed($type) { + protected function _couldBeClosed($type) { $facets_closed = $this->_preferences['facets_closed_codes']; return false !== strpos($facets_closed, $type); } diff --git a/library/templates/Intonation/View/TemplateIco.php b/library/templates/Intonation/View/TemplateIco.php new file mode 100644 index 0000000000000000000000000000000000000000..d27f0ed28c9d67793cb2f18639acfafebfd132d4 --- /dev/null +++ b/library/templates/Intonation/View/TemplateIco.php @@ -0,0 +1,27 @@ +<?php +/** + * Copyright (c) 2012-2020, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Intonation_View_TemplateIco extends ZendAfi_View_Helper_BaseHelper { + public function templateIco($key, $category, $attribs = []) { + return Class_Template::current()->getIco($this->view, $key, $category, $attribs); + } +} diff --git a/tests/scenarios/Templates/TemplatesSearchTest.php b/tests/scenarios/Templates/TemplatesSearchTest.php index 8c28bdc616a65d236281b8341639cdb0c0bab866..c8e4a38d8a10d59224c1fdbfc25993c039cc24c0 100644 --- a/tests/scenarios/Templates/TemplatesSearchTest.php +++ b/tests/scenarios/Templates/TemplatesSearchTest.php @@ -397,6 +397,12 @@ class TemplatesSearchDispatchIntonationSearchListFormatWallTest extends Template public function masonryShouldBeLoaded() { $this->assertXPath('//head/script[contains(@src, "/masonry.js")]'); } + + + /** @test */ + public function facetsBlocksShouldContainsOnclickToggleClassFacetBlockClosed() { + $this->assertXPathContentContains('//form[contains(@class, "form_facets")]//ul/li[contains(@class, "facette_titre facet_type_A facet_block_toggle_visibility facet_block_closed")]/b[contains(@onclick, "$(this).parent().toggleClass(\'facet_block_closed\');")]', 'Auteur', $this->_response->getBody()); + } } diff --git a/tests/scenarios/Templates/TemplatesTest.php b/tests/scenarios/Templates/TemplatesTest.php index 08fc862e648d2d183c125af418ef9b2f7ac9e127..c6a11c1bcfd6b80cb2e23de92a3b9bc083410818 100644 --- a/tests/scenarios/Templates/TemplatesTest.php +++ b/tests/scenarios/Templates/TemplatesTest.php @@ -2355,7 +2355,7 @@ class TemplatesDispatchSearchWithFacetsTest extends TemplatesIntonationTestCase /** @test */ public function searchResultWithClosedFacetsShouldHaveOnclick() { - $this->assertXPath('//ul[contains(@class, "facet")]/li/b[contains(@onclick, ".slideToggle()")]'); + $this->assertXPath('//ul[contains(@class, "facet")]/li/b[contains(@onclick, ".slideToggle(")]'); }