diff --git a/VERSIONS_HOTLINE/125267 b/VERSIONS_HOTLINE/125267 new file mode 100644 index 0000000000000000000000000000000000000000..562962b934f56d6f88fd51186eea2903a96ef9be --- /dev/null +++ b/VERSIONS_HOTLINE/125267 @@ -0,0 +1 @@ + - ticket #125267 : Magasin de thèmes : amélioration de l'adaptabilité du carousel à 5 colonnes dans le thème Chili. \ No newline at end of file diff --git a/library/templates/Chili/Template.php b/library/templates/Chili/Template.php index 40c2a81b3f67e6dcb1f2a52f29d38cb4c7c4ec89..25fa421ced79d4f4fb3edb0b50aa71afe9754108 100644 --- a/library/templates/Chili/Template.php +++ b/library/templates/Chili/Template.php @@ -90,6 +90,9 @@ class Chili_Template extends Intonation_Template { if (Intonation_Library_Widget_Carousel_Definition::WALL == $layout) return Chili_View_RenderWall::class; + + if (Intonation_Library_Widget_Carousel_Definition::MULTIPLE_CAROUSEL_PLUS == $layout) + return Chili_View_RenderMultipleCarousel::class; } diff --git a/library/templates/Chili/View/RenderMultipleCarousel.php b/library/templates/Chili/View/RenderMultipleCarousel.php new file mode 100644 index 0000000000000000000000000000000000000000..d1961895b04b6396145cfdd8dba659f82d58c1f6 --- /dev/null +++ b/library/templates/Chili/View/RenderMultipleCarousel.php @@ -0,0 +1,42 @@ +<?php +/** + * Copyright (c) 2012-2021, 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 Chili_View_RenderMultipleCarousel extends Intonation_View_RenderMultipleCarousel { + + protected function _renderCarousel($collection, $callback) { + $md_helper = (new Intonation_View_RenderMultipleCarousel) + ->setView($this->view); + + $html = [ + $this->_div(['class' => 'col-12 d-none d-lg-block'], parent::_renderCarousel($collection, $callback)), + + $this->_div(['class' => 'col-12 d-none d-md-block d-lg-none'], + $md_helper->renderMultipleCarousel($collection, + $callback, + 3)), + + $this->_div(['class' => 'col-12 d-block d-md-none'], $this->view->renderCarousel($collection, $callback)), + ]; + + return $this->view->grid($html, ['class' => 'responsive_multiple_carousel']); + } +} diff --git a/tests/scenarios/Templates/ChiliMultipleCarouselTest.php b/tests/scenarios/Templates/ChiliMultipleCarouselTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c2c23ead57da45fa0fc99fc77f4d4e5071cc1ba0 --- /dev/null +++ b/tests/scenarios/Templates/ChiliMultipleCarouselTest.php @@ -0,0 +1,97 @@ +<?php +/** + * Copyright (c) 2012-2021, 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 ChiliMultipleCarouselResponsiveTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + $profile = + $this->_buildTemplateProfil(['id' => 23, + 'template' => 'CHILI']); + + $profile_patcher = (new Class_Template_ProfilePatcher(null)) + ->setProfile($profile); + + $profile_patcher + ->addWidget(Intonation_Library_Widget_Carousel_Library_Definition::CODE, + Class_Profil::DIV_MAIN, + ['rendering' => 'card-description', + 'libraries' => '1;2;3;4;5;6', + 'layout' => 'multiple_carousel_plus', + 'size' => 10]); + + $this->fixture('Class_Bib', + ['id' => 1, + 'libelle' => 'Esertine']); + + $this->fixture('Class_Bib', + ['id' => 2, + 'libelle' => 'Polliet']); + + $this->fixture('Class_Bib', + ['id' => 3, + 'libelle' => 'Yverdon']); + + $this->fixture('Class_Bib', + ['id' => 4, + 'libelle' => 'Echallens']); + + $this->fixture('Class_Bib', + ['id' => 5, + 'libelle' => 'Sainte Croix']); + + $this->fixture('Class_Bib', + ['id' => 6, + 'libelle' => 'Botten']); + + $this->dispatch('/opac/widget/render/widget_id/1/profile_id/23'); + } + + + /** @test */ + public function widgetShouldBeHtml5Valid() { + $this->assertHTML5(); + } + + + /** @test */ + public function sainteCroixShouldBeInMainPageForLg() { + $this->assertXPathContentContains('//div[contains(@class, "col-12 d-none d-lg-block")]//div[contains(@class, "multiple_carousel")]//div[@class="carousel-item active"]', + 'Sainte Croix'); + } + + + /** @test */ + public function echallensShouldBeInMdActive() { + $this->assertXPathContentContains('//div[contains(@class, "col-12 d-none d-md-block d-lg-none")]//div[contains(@class, "multiple_carousel")]//div[@class="carousel-item active"]', + 'Echallens'); + } + + + /** @test */ + public function bottenShouldBeInSmActive() { + $this->assertXPathContentContains('//div[contains(@class, "col-12 d-block d-md-none")]//div[contains(@class, "carousel")]//div[@class="carousel-item active"]', + 'Botten', $this->_response->getBody()); + } +}