From 65032989cd575d07602a5a420056eabd61c1fe94 Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Thu, 31 Mar 2022 09:29:41 +0200 Subject: [PATCH] sandbox #154611 udgrade paginated collection rendering --- VERSIONS_WIP/154611 | 3 + .../opac/controllers/IndexController.php | 6 +- .../Intonation/Assets/css/intonation.css | 4 +- ...lper.php => PaginatedCollectionHelper.php} | 23 +++++- .../Widget/Carousel/PaginatedCollection.php | 53 +++++++++++++ .../Library/Widget/Carousel/View.php | 5 +- .../Intonation/View/Abstract/Layout.php | 8 +- library/templates/Intonation/View/Ajax.php | 4 +- library/templates/Intonation/View/OsmMap.php | 22 ++++-- ...List.php => RenderPaginatedCollection.php} | 21 +++--- ...hp => RenderPaginatedCollectionHelper.php} | 51 ++++++------- .../View/RenderRecord/RenderItems.php | 48 ++++++++---- .../ajaxifyPaginatedList.js | 8 +- public/opac/js/openStreetMap/openStreetMap.js | 21 +++++- .../Templates/TemplatesAbonneTest.php | 10 +-- .../TemplatesAjaxPaginatedListTest.php | 74 +++++++++++++++++-- .../scenarios/Templates/TemplatesRssTest.php | 2 +- .../Templates/TemplatesSearchItemsTest.php | 6 +- .../Templates/TemplatesWebsitesTest.php | 2 +- .../Templates/TemplatesWidgetTest.php | 2 +- 20 files changed, 279 insertions(+), 94 deletions(-) create mode 100644 VERSIONS_WIP/154611 rename library/templates/Intonation/Library/{AjaxPaginatedListHelper.php => PaginatedCollectionHelper.php} (94%) create mode 100644 library/templates/Intonation/Library/Widget/Carousel/PaginatedCollection.php rename library/templates/Intonation/View/{RenderAjaxTruncateList.php => RenderPaginatedCollection.php} (64%) rename library/templates/Intonation/View/{RenderAjaxPaginatedList.php => RenderPaginatedCollectionHelper.php} (85%) diff --git a/VERSIONS_WIP/154611 b/VERSIONS_WIP/154611 new file mode 100644 index 00000000000..346a7b95509 --- /dev/null +++ b/VERSIONS_WIP/154611 @@ -0,0 +1,3 @@ + - fonctionnalité #154611 : Magasin de thèmes : l'affichage liste paginée a été amélioré. + Il garde maintenant l'affichage sélectionné dans le rendu d'un document. + L'affichage des exemplaires bénéfici également de cette amélioration. En effet lorsqu'un document a trop de document l'affichage pouvait passer sur une liste paginée. Maintenant c'est le mur d'exemplaire qui est paginé. \ No newline at end of file diff --git a/application/modules/opac/controllers/IndexController.php b/application/modules/opac/controllers/IndexController.php index 473c7aae284..c77fa3e6718 100644 --- a/application/modules/opac/controllers/IndexController.php +++ b/application/modules/opac/controllers/IndexController.php @@ -121,11 +121,11 @@ class IndexController extends ZendAfi_Controller_Action { public function ajaxPaginatedListAction() { session_write_close(); - if (! $helper = Intonation_Library_AjaxPaginatedListHelper::find($this->_getParam('id'))) + if (! $helper = Intonation_Library_PaginatedCollectionHelper::find($this->_getParam('id'))) return $this->_helper ->ajax(function() { - return $this->view->renderAjaxPaginatedList((new Intonation_Library_AjaxPaginatedListHelper)->beDeprecated()); + return $this->view->renderPaginatedCollectionHelper((new Intonation_Library_PaginatedCollectionHelper)->beDeprecated()); }); $callback = function() use ($helper) { @@ -136,7 +136,7 @@ class IndexController extends ZendAfi_Controller_Action { ->setSearchTerm($this->_getParam('search', '')) ->setNewOrder($this->_getParam('order', '')); - return $this->view->renderAjaxPaginatedList($helper); + return $this->view->renderPaginatedCollectionHelper($helper); }; return $this->_helper->ajax($callback); diff --git a/library/templates/Intonation/Assets/css/intonation.css b/library/templates/Intonation/Assets/css/intonation.css index a72639ff16a..1a4942b6aa4 100644 --- a/library/templates/Intonation/Assets/css/intonation.css +++ b/library/templates/Intonation/Assets/css/intonation.css @@ -352,19 +352,17 @@ pre { padding-right: 0; } -[id*='resources'] .list-group { +[id*='resources'] > :not(.ajaxified) > div > .list-group { max-height: 300px; overflow: auto; margin-top: 0.75rem; } - .record_items [id*='resources'] .list-group { max-height: unset; overflow: unset; } - [id*='resources'] .list-group-item { padding-top: 0; } diff --git a/library/templates/Intonation/Library/AjaxPaginatedListHelper.php b/library/templates/Intonation/Library/PaginatedCollectionHelper.php similarity index 94% rename from library/templates/Intonation/Library/AjaxPaginatedListHelper.php rename to library/templates/Intonation/Library/PaginatedCollectionHelper.php index 48147ae02e6..61acb19cedd 100644 --- a/library/templates/Intonation/Library/AjaxPaginatedListHelper.php +++ b/library/templates/Intonation/Library/PaginatedCollectionHelper.php @@ -20,7 +20,7 @@ */ -class Intonation_Library_AjaxPaginatedListHelper { +class Intonation_Library_PaginatedCollectionHelper { use Trait_Translator; protected @@ -28,6 +28,7 @@ class Intonation_Library_AjaxPaginatedListHelper { $_collection, $_collection_ids, $_rendering = 'cardifyHorizontal', + $_layout = 'renderList', $_search, $_current_page = 1, $_page_size = 10, @@ -50,9 +51,10 @@ class Intonation_Library_AjaxPaginatedListHelper { $cache = new Class_Entity($cache); - return (new Intonation_Library_AjaxPaginatedListHelper) + return (new Intonation_Library_PaginatedCollectionHelper) ->setCollection($cache->get('collection')) ->setRendering($cache->get('rendering')) + ->setLayout($cache->get('layout')) ->setCarouselContext($cache->get('carousel_context')) ->setOrder($cache->get('order')) ->setId($id) @@ -120,6 +122,7 @@ class Intonation_Library_AjaxPaginatedListHelper { 'has_been_slice' => $this->_has_been_sliced, 'collection' => $this->getCollection(), 'rendering' => $this->getRendering(), + 'layout' => $this->getLayout(), 'carousel_context' => $this->getCarouselContext(), 'custom_page_size' => $this->getCustomPageSize(), 'order' => $this->getOrder()]; @@ -362,4 +365,20 @@ class Intonation_Library_AjaxPaginatedListHelper { asort($options); return $options; } + + + public function setLayout(string $layout) : self { + $this->_layout = $layout; + return $this; + } + + + public function getLayout() : string { + return $this->_layout; + } + + + public function getSubCollection() : Storm_Collection { + return $this->getPage($this->getCurrentPage()); + } } diff --git a/library/templates/Intonation/Library/Widget/Carousel/PaginatedCollection.php b/library/templates/Intonation/Library/Widget/Carousel/PaginatedCollection.php new file mode 100644 index 00000000000..446724655ab --- /dev/null +++ b/library/templates/Intonation/Library/Widget/Carousel/PaginatedCollection.php @@ -0,0 +1,53 @@ +<?php +/** + * Copyright (c) 2012-2022, 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_Library_Widget_Carousel_PaginatedCollection extends Intonation_Library_Widget_Carousel_View { + + + + public function setPaginatedCollectionHelper(Intonation_Library_PaginatedCollectionHelper $helper) : self { + $this->_pagination_collection_helper = $helper; + return $this; + } + + + protected function _findElements() : array { + return $this->_pagination_collection_helper + ->getSubCollection() + ->getArrayCopy(); + } + + + protected function _getWrapper() { + return null; + } + + + protected function _getLinkToAllTitle() { + return ''; + } + + + protected function _getRSSUrl() { + return ''; + } +} diff --git a/library/templates/Intonation/Library/Widget/Carousel/View.php b/library/templates/Intonation/Library/Widget/Carousel/View.php index c70df1da201..77d491653fc 100644 --- a/library/templates/Intonation/Library/Widget/Carousel/View.php +++ b/library/templates/Intonation/Library/Widget/Carousel/View.php @@ -198,6 +198,9 @@ abstract class Intonation_Library_Widget_Carousel_View extends Zendafi_View_Help protected function _wrapElements($elements) { + if ( null === ($wrapper = $this->_getWrapper())) + return $elements; + return array_map(function($element) { $wrapper = $this->_getWrapper(); @@ -396,7 +399,7 @@ abstract class Intonation_Library_Widget_Carousel_View extends Zendafi_View_Help } - Abstract protected function _findElements(); + abstract protected function _findElements(); abstract protected function _getWrapper(); abstract protected function _getLinkToAllTitle(); abstract protected function _getRSSUrl(); diff --git a/library/templates/Intonation/View/Abstract/Layout.php b/library/templates/Intonation/View/Abstract/Layout.php index aec10ab2847..be374b7015a 100644 --- a/library/templates/Intonation/View/Abstract/Layout.php +++ b/library/templates/Intonation/View/Abstract/Layout.php @@ -38,13 +38,13 @@ class Intonation_View_Abstract_Layout extends ZendAfi_View_Helper_BaseHelper { } - protected function _ajaxifyList(Storm_Collection $collection, - ?Closure $callback) : string { - $helper = (new Intonation_Library_AjaxPaginatedListHelper($collection)) + protected function _ajaxifyList(Storm_Collection $collection) : string { + + $helper = (new Intonation_Library_PaginatedCollectionHelper($collection)) ->setView($this->view) ->setCarouselContext($this->getRenderingOptions()) ->setOrder($this->getRenderingOptions()->getOrder()); - return $this->view->renderAjaxPaginatedList($helper, $callback); + return $this->view->renderPaginatedCollectionHelper($helper); } } diff --git a/library/templates/Intonation/View/Ajax.php b/library/templates/Intonation/View/Ajax.php index 364fda4eab1..24e5de528bd 100644 --- a/library/templates/Intonation/View/Ajax.php +++ b/library/templates/Intonation/View/Ajax.php @@ -36,6 +36,8 @@ class Intonation_View_Ajax extends Intonation_View_Opac { ->beAjax() ->addJQueryReady('initializePopups();setupAnchorsTarget();'. Class_AdminVar_Cookies::manager()->triggers()); - return $this->_body . Class_ScriptLoader::getInstance()->html(); + $head = $this->_tag('head', Class_ScriptLoader::getInstance()->html()); + + return $head . $this->_body; } } \ No newline at end of file diff --git a/library/templates/Intonation/View/OsmMap.php b/library/templates/Intonation/View/OsmMap.php index b8a0cf234b6..fba31e53752 100644 --- a/library/templates/Intonation/View/OsmMap.php +++ b/library/templates/Intonation/View/OsmMap.php @@ -24,11 +24,6 @@ class Intonation_View_OsmMap extends ZendAfi_View_Helper_BaseHelper { protected $_wrapper_id, $_map_id; - public function init() { - $this->setOSMId(uniqid()); - } - - public function setOSMId($id) { $this->_wrapper_id = 'osm_wrap_' . $id; $this->_map_id = 'osm_map_' . $id; @@ -43,11 +38,16 @@ class Intonation_View_OsmMap extends ZendAfi_View_Helper_BaseHelper { if (!$elements || !($datas = $this->_collectDatas($elements, $html_renderer))) return ''; + $datas = json_encode($datas); + + if ( ! $this->_wrapper_id) + $this->setOSMId(md5($datas)); + $this->renderHeadScriptsOn(Class_ScriptLoader::getInstance()); $map = $this->_div(['id' => $this->_map_id, 'class' => 'leaflet_osm', - 'data-osm' => json_encode($datas), + 'data-osm' => $datas, 'data-osm-geojson' => '', 'data-osm-layer' => 1, 'data-osm-zoom' => 0, @@ -64,12 +64,18 @@ class Intonation_View_OsmMap extends ZendAfi_View_Helper_BaseHelper { public function renderHeadScriptsOn($script_loader) { $script_loader + ->loadJQuery() + ->loadJQueryUI() + ->addOPACScript('subModal') + ->addAdminScripts(['onload_utils', 'global']) ->loadLeafletJS() - ->addOPACScripts(['openStreetMap/openStreetMap.js', 'openStreetMap/leaflet.markercluster.js']) + ->addOPACScripts(['openStreetMap/openStreetMap.js', + 'openStreetMap/leaflet.markercluster.js']) ->addOPACStyleSheets(['../js/openStreetMap/openStreetMap.css', '../js/openStreetMap/MarkerCluster.css', '../js/openStreetMap/MarkerCluster.Default.css']) - ->addJQueryReady('setTimeout(function() {$("#'. $this->_wrapper_id . '").openStreetMap();}, 100);'); + ->addJQueryReady('$("#'. $this->_wrapper_id . '").openStreetMap();'); + return $this; } diff --git a/library/templates/Intonation/View/RenderAjaxTruncateList.php b/library/templates/Intonation/View/RenderPaginatedCollection.php similarity index 64% rename from library/templates/Intonation/View/RenderAjaxTruncateList.php rename to library/templates/Intonation/View/RenderPaginatedCollection.php index 4b127342189..42b11576715 100644 --- a/library/templates/Intonation/View/RenderAjaxTruncateList.php +++ b/library/templates/Intonation/View/RenderPaginatedCollection.php @@ -20,26 +20,25 @@ */ -class Intonation_View_RenderAjaxTruncateList extends Intonation_View_Abstract_Layout { +class Intonation_View_RenderPaginatedCollection extends Intonation_View_Abstract_Layout { - public function renderAjaxTruncateList(Storm_Collection $collection, - ?Closure $callback = null, - int $page_size = 0) : string { + public function renderPaginatedCollection(Storm_Collection $collection, + string $rendering, + string $layout, + int $page_size = 0) : string { - $callback - ? $callback - : fn($item) => $this->view->cardifyHorizontal($item); - - $helper = (new Intonation_Library_AjaxPaginatedListHelper) + $helper = (new Intonation_Library_PaginatedCollectionHelper) ->setView($this->view) ->setCarouselContext($this->getRenderingOptions()) ->setCollection($collection) - ->setOrder($this->getRenderingOptions()->getOrder()); + ->setOrder($this->getRenderingOptions()->getOrder()) + ->setRendering($rendering) + ->setLayout($layout); if (0 != $page_size) $helper->setCustomPageSize($page_size) ->setPageSize($page_size); - return $this->view->renderAjaxPaginatedList($helper, $callback); + return $this->view->renderPaginatedCollectionHelper($helper); } } diff --git a/library/templates/Intonation/View/RenderAjaxPaginatedList.php b/library/templates/Intonation/View/RenderPaginatedCollectionHelper.php similarity index 85% rename from library/templates/Intonation/View/RenderAjaxPaginatedList.php rename to library/templates/Intonation/View/RenderPaginatedCollectionHelper.php index d33e819d514..6273e43d8a6 100644 --- a/library/templates/Intonation/View/RenderAjaxPaginatedList.php +++ b/library/templates/Intonation/View/RenderPaginatedCollectionHelper.php @@ -20,59 +20,60 @@ */ -class Intonation_View_RenderAjaxPaginatedList extends ZendAfi_View_Helper_BaseHelper { +class Intonation_View_RenderPaginatedCollectionHelper extends ZendAfi_View_Helper_BaseHelper { - protected - $_id, - $_available_orders; + public function renderPaginatedCollectionHelper(Intonation_Library_PaginatedCollectionHelper $helper) : string { - public function renderAjaxPaginatedList(Intonation_Library_AjaxPaginatedListHelper $helper, - ?Closure $callback = null) { $this->_id = $helper->getId(); $this->_available_orders = $helper->getCarouselContext()->getAvailableOrders(); - $sub_collection = $helper->getPage($helper->getCurrentPage()); + $sub_collection = $helper->getSubCollection(); $pager = $this->_renderPager($helper); - $callback = $callback - ? $callback - : function($element) use ($helper) { - $element->setView($this->view); - $element->updateWithModel($element->getModel()); - return call_user_func_array([$this->view, $helper->getRendering()], [$element]); - }; - $html_collection = $this->view->div(['class' => 'list-group bg-transparent no_border', 'data-deprecated' => $helper->isDeprecated()], - $this->view->renderList($sub_collection, $callback)); + $this->_renderCollection($helper, $sub_collection)); $html_content = implode([$this->_renderTools($helper, $sub_collection), $pager, $html_collection]); + $this->_getScripts($helper); + return $this->view->div(['id' => 'ajax_paginated_list_' . $this->_id], $this->view->div(['class' => 'ajax_content'], - $html_content)) - . $this->_getScripts($helper); + $html_content)); + } + + + protected function _renderCollection(Intonation_Library_PaginatedCollectionHelper $helper, + Storm_Collection $sub_collection) : string { + + $layout_helper = + ((new Intonation_Library_Widget_Carousel_PaginatedCollection($helper->getId(), + ['layout' => $helper->getLayout(), + 'rendering' => $helper->getRendering()])) + ->setView($this->view) + ->setPaginatedCollectionHelper($helper)); + + $layout_helper->getHtml(); + return $layout_helper->getContent(); } protected function _getScripts($helper) { if ($helper->isDeprecated()) - return ''; + return; $url = Class_Url::relative('/public/opac/js/ajaxifyPaginatedList/ajaxifyPaginatedList.js'); - return Class_ScriptLoader::getInstance() - + Class_ScriptLoader::getInstance() ->addJQueryReady(sprintf('if (undefined == $.fn.ajaxifyPaginatedList) {var script = document.createElement("script"); script.type = "text/javascript"; script.src = "%s"; $("head").append(script);}', $url)) - - ->addJQueryReady(sprintf('setTimeout(function() {$("#ajax_paginated_list_%s:not(.ajaxified)").ajaxifyPaginatedList();}, 100);', - $this->_id)) - ->html(); + ->addJQueryReady(sprintf('$("#ajax_paginated_list_%s:not(.ajaxified)").ajaxifyPaginatedList();', + $this->_id)); } diff --git a/library/templates/Intonation/View/RenderRecord/RenderItems.php b/library/templates/Intonation/View/RenderRecord/RenderItems.php index 8431d998676..e0a80601bc7 100644 --- a/library/templates/Intonation/View/RenderRecord/RenderItems.php +++ b/library/templates/Intonation/View/RenderRecord/RenderItems.php @@ -27,23 +27,25 @@ class Intonation_View_RenderRecord_RenderItems extends ZendAfi_View_Helper_BaseH $_should_use_ILS_items_threshold; - public function RenderRecord_RenderItems($items, $same_work = []) { - if (!$items) + public function RenderRecord_RenderItems(array $items, array $same_work = []) : string { + if ( ! $items) return ''; - if ( $this->_shouldPaginate($items)) - return $this->view->renderAjaxTruncateList(new Storm_Collection($this->_getWrappedItems($items)), - null, - Class_Profil_ItemsSettings::current()->getPaginationThreshold()); - $record = new Intonation_Library_Record(reset($items)->getNotice()); if ($record->isExternalResource()) return $this->view->RenderRecord_ExternalUrl($record->getUrl()); + return $this->_renderItems($items, $same_work); + } + + + protected function _renderItems(array $items, array $same_work) : string { $html = [ $this->_hookForMoreHtml($items) ]; - $html [] = $this->_renderOsmMap($items, $same_work); + if ( $map = $this->_renderOsmMap($items, $same_work)) + $html [] = $this->view->div(['class' => 'col-12 mb-3 items_map'], + $map); $html [] = $this->view->div(['class' => 'col-12 items_wall'], $this->_getHtmlItems($items)); @@ -59,6 +61,15 @@ class Intonation_View_RenderRecord_RenderItems extends ZendAfi_View_Helper_BaseH } + protected function _renderPaginatedItems(array $items) : string { + return + $this->view->renderPaginatedCollection(new Storm_Collection($this->_getWrappedItems($items)), + Intonation_Library_Widget_Carousel_Definition::CARD_DESCRIPTION, + Intonation_Library_Widget_Carousel_Definition::WALL, + Class_Profil_ItemsSettings::current()->getPaginationThreshold()); + } + + protected function _getWrappedItems(array $items) : array { return $this->_shouldCallILSWs($items) ? array_map(fn($item) => @@ -87,7 +98,7 @@ class Intonation_View_RenderRecord_RenderItems extends ZendAfi_View_Helper_BaseH } - protected function _renderOsmMap($items, $same_work) { + protected function _renderOsmMap(array $items, array $same_work) : string { if ( ! Class_Profil_ItemsSettings::current()->isAllItemsMap()) return ''; @@ -102,14 +113,16 @@ class Intonation_View_RenderRecord_RenderItems extends ZendAfi_View_Helper_BaseH $this->view); }); - return ($map = $this->view->osmMap($elements)) - ? $this->view->div(['class' => 'col-12 mb-3 items_map'], - $map) - : ''; + return $this->_shouldPaginate($items) + ? $this->_renderPaginatedMap($elements) + : $this->view->osmMap($elements); } protected function _getHtmlItems($items) { + if ($this->_shouldPaginate($items)) + return $this->_renderPaginatedItems($items); + $items = $this->_sortItems($items); $elements = $this->_getWrappedItems($items); @@ -154,4 +167,13 @@ class Intonation_View_RenderRecord_RenderItems extends ZendAfi_View_Helper_BaseH protected function _hookForMoreHtml($items) { return ''; } + + + protected function _renderPaginatedMap(Storm_Collection $elements) : string { + return + $this->view->renderPaginatedCollection($elements, + Intonation_Library_Widget_Carousel_Definition::CARD_DESCRIPTION, + Intonation_Library_Widget_Carousel_Definition::MAP, + Class_Profil_ItemsSettings::current()->getPaginationThreshold()); + } } diff --git a/public/opac/js/ajaxifyPaginatedList/ajaxifyPaginatedList.js b/public/opac/js/ajaxifyPaginatedList/ajaxifyPaginatedList.js index 76d77e0d5ec..0089b3aedae 100644 --- a/public/opac/js/ajaxifyPaginatedList/ajaxifyPaginatedList.js +++ b/public/opac/js/ajaxifyPaginatedList/ajaxifyPaginatedList.js @@ -51,10 +51,14 @@ if (undefined != $.fn.masonry) widget.masonry(); - + + widget.ajaxifyPaginatedList(); + + if (undefined != $.fn.openStreetMap) + widget.openStreetMap(); + initializePopups(); setupAnchorsTarget(); - widget.ajaxifyPaginatedList(); }; var links = widget.find("a.ajax_anchor"); diff --git a/public/opac/js/openStreetMap/openStreetMap.js b/public/opac/js/openStreetMap/openStreetMap.js index a6311c84c0e..daa160d0efc 100644 --- a/public/opac/js/openStreetMap/openStreetMap.js +++ b/public/opac/js/openStreetMap/openStreetMap.js @@ -24,6 +24,11 @@ var loadMap = function() { var container = widget.find('.leaflet_osm'); + container.innerHTML = ''; + + if(null != (initialized = L.DomUtil.get(container.attr('id')))) + initialized._leaflet_id = null; + var disable_zoom_animation = container.data('osm-disable-zoom-animation'); var map = L.map(container.attr('id'), @@ -125,11 +130,20 @@ map.on('popupopen', function(event) { - $('.leaflet-popup-content img').on('load', function() { + $('.leaflet-popup-content img').on('load', function(e) { event.popup.update(); - }) + }); + + widget.on('mouseover', function(e) { + if ( ! widget.find('.leaflet-popup-content a[data-popup]').length) + return; + + if ( typeof initializePopups === 'function') + initializePopups(); - event.popup.update(); + if ( typeof setupAnchorsTarget === 'function') + setupAnchorsTarget(); + }); if ( typeof initializePopups === 'function') initializePopups(); @@ -138,7 +152,6 @@ setupAnchorsTarget(); }); - originalPosition(); if (relative_zoom) map.zoomIn(relative_zoom); diff --git a/tests/scenarios/Templates/TemplatesAbonneTest.php b/tests/scenarios/Templates/TemplatesAbonneTest.php index 812e585f9a9..13084726dc1 100644 --- a/tests/scenarios/Templates/TemplatesAbonneTest.php +++ b/tests/scenarios/Templates/TemplatesAbonneTest.php @@ -311,7 +311,7 @@ class TemplatesDispatchAbonneLoansPaginatedTest extends TemplatesIntonationAccou $collection = new Storm_Collection($loans); - $helper = (new Intonation_Library_AjaxPaginatedListHelper) + $helper = (new Intonation_Library_PaginatedCollectionHelper) ->setCollection($collection) ->setRendering('cardifyHorizontal'); @@ -367,7 +367,7 @@ class TemplatesDispatchAbonneLoansPaginatedTest extends TemplatesIntonationAccou $collection = new Storm_Collection($reviews); - $helper = (new Intonation_Library_AjaxPaginatedListHelper) + $helper = (new Intonation_Library_PaginatedCollectionHelper) ->setCollection($collection) ->setRendering('cardifyHorizontal'); @@ -396,7 +396,7 @@ class TemplatesDispatchAbonneLoansPaginatedTest extends TemplatesIntonationAccou $collection = new Storm_Collection($loans); - $helper = (new Intonation_Library_AjaxPaginatedListHelper) + $helper = (new Intonation_Library_PaginatedCollectionHelper) ->setCollection($collection) ->setRendering('cardifyHorizontal'); @@ -427,7 +427,7 @@ class TemplatesDispatchAbonneLoansPaginatedTest extends TemplatesIntonationAccou $collection = new Storm_Collection($loans); - $helper = (new Intonation_Library_AjaxPaginatedListHelper) + $helper = (new Intonation_Library_PaginatedCollectionHelper) ->setCollection($collection) ->setRendering('cardifyHorizontal'); @@ -1986,7 +1986,7 @@ class TemplatesAbonneSearchAjaxInReview extends TemplatesIntonationAccountTestCa $collection = new Storm_Collection($reviews); - $helper = (new Intonation_Library_AjaxPaginatedListHelper) + $helper = (new Intonation_Library_PaginatedCollectionHelper) ->setCollection($collection) ->setRendering('cardifyHorizontal'); diff --git a/tests/scenarios/Templates/TemplatesAjaxPaginatedListTest.php b/tests/scenarios/Templates/TemplatesAjaxPaginatedListTest.php index efb30c0fdaa..3e8a5557d14 100644 --- a/tests/scenarios/Templates/TemplatesAjaxPaginatedListTest.php +++ b/tests/scenarios/Templates/TemplatesAjaxPaginatedListTest.php @@ -71,7 +71,7 @@ abstract class TemplatesAjaxPaginatedListTestCase extends AbstractControllerTest $this->_view_renderer = new ZendAfi_Controller_Action_Helper_ViewRenderer; $this->_view_renderer->preDispatch(); - $this->_ajax_paginated_list_helper = (new Intonation_Library_AjaxPaginatedListHelper) + $this->_ajax_paginated_list_helper = (new Intonation_Library_PaginatedCollectionHelper) ->setCollection($this->_getCollection()) ->setRendering('cardifyHorizontal'); @@ -926,11 +926,11 @@ class TemplatesAjaxPaginatedListWithSameCollectionIdsTest extends AbstractContro $items = [$this->fixture(Class_Exemplaire::class, ['id' => 1]), $this->fixture(Class_Exemplaire::class, ['id' => 2])]; - $key_1 = (new Intonation_Library_AjaxPaginatedListHelper) + $key_1 = (new Intonation_Library_PaginatedCollectionHelper) ->setCollection(new Storm_Collection($records)) ->getId(); - $key_2 = (new Intonation_Library_AjaxPaginatedListHelper) + $key_2 = (new Intonation_Library_PaginatedCollectionHelper) ->setCollection(new Storm_Collection($items)) ->getId(); @@ -955,11 +955,11 @@ class TemplatesAjaxPaginatedListWithSameCollectionIdsTest extends AbstractContro $card_operation_decorator_1 = new Class_User_CardsOperationDecorator($loan_1, $user); $card_operation_decorator_2 = new Class_User_CardsOperationDecorator($loan_2, $user); - $key_1 = (new Intonation_Library_AjaxPaginatedListHelper) + $key_1 = (new Intonation_Library_PaginatedCollectionHelper) ->setCollection(new Storm_Collection([new Intonation_Library_View_Wrapper_Loan($card_operation_decorator_1)])) ->getId(); - $key_2 = (new Intonation_Library_AjaxPaginatedListHelper) + $key_2 = (new Intonation_Library_PaginatedCollectionHelper) ->setCollection(new Storm_Collection([new Intonation_Library_View_Wrapper_Loan($card_operation_decorator_2)])) ->getId(); @@ -991,7 +991,7 @@ class TemplatesAjaxPaginatedListWithCustomPageSizeTest extends AbstractControlle $this->_view_renderer = new ZendAfi_Controller_Action_Helper_ViewRenderer; $this->_view_renderer->preDispatch(); - $this->_ajax_paginated_list_helper = (new Intonation_Library_AjaxPaginatedListHelper) + $this->_ajax_paginated_list_helper = (new Intonation_Library_PaginatedCollectionHelper) ->setCollection($this->_getCollection()) ->setCustomPageSize(12) ->setRendering('cardifyHorizontal'); @@ -1025,4 +1025,66 @@ class TemplatesAjaxPaginatedListWithCustomPageSizeTest extends AbstractControlle public function ajaxSelectValue12ShouldBeAvailable() { $this->assertXPath('//div//select[contains(@id,"select_")]//option[@value="12"]'); } +} + + + + +class TemplatesAjaxPaginatedWallTest extends AbstractControllerTestCase { + + + protected + $_storm_default_to_volatile = true, + $_view_renderer, + $_ajax_paginated_list_helper, + $_ajax_paginated_list_helper_id, + $_collection_cache; + + + public function setUp() { + parent::setUp(); + + Storm_Cache::beVolatile(); + + $this->_buildTemplateProfil(['id' => '34']); + + $this->_view_renderer = new ZendAfi_Controller_Action_Helper_ViewRenderer; + $this->_view_renderer->preDispatch(); + + $this->_ajax_paginated_list_helper = (new Intonation_Library_PaginatedCollectionHelper) + ->setCollection($this->_getCollection()) + ->setRendering('cardifyOnlyDescription') + ->setLayout('renderWall'); + + $this->_ajax_paginated_list_helper_id = $this->_ajax_paginated_list_helper->getId(); + + $this->dispatch('/opac/index/ajax-paginated-list/page/2/size/10/id/' . $this->_ajax_paginated_list_helper_id); + } + + + public function tearDown() { + Storm_Cache::setDefaultZendCache(null); + return parent::tearDown(); + } + + + protected function _getCollection() : Storm_Collection { + $models = []; + for ($i = 1 ; $i <= 36 ; $i ++) + $models [] = $this->fixture(Class_Exemplaire::class, + ['id' => $i, + 'id_notice' => 8908]); + + $models = + array_map(fn($model) => new Intonation_Library_View_Wrapper_Item($model), $models); + + return new Storm_Collection($models); + } + + + /** @test */ + public function shouldDisplay10ItemsInWallHasCardDescription() { + $this->assertXPathCount('//div[@class="masonry"]//div[@class="masonry-brick"]//div[contains(@class, "card card_template")]//div[@class ="card-body card_body card_body_Intonation_Library_View_Wrapper_Item"]', + 10); + } } \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesRssTest.php b/tests/scenarios/Templates/TemplatesRssTest.php index 9561c70cc12..536fe5aa3e3 100644 --- a/tests/scenarios/Templates/TemplatesRssTest.php +++ b/tests/scenarios/Templates/TemplatesRssTest.php @@ -190,7 +190,7 @@ class TemplatesRssWidgetWithPaginatedListTest extends AbstractControllerTestCase ->answers('')); }, $rss_items); - $helper = (new Intonation_Library_AjaxPaginatedListHelper) + $helper = (new Intonation_Library_PaginatedCollectionHelper) ->setCollection(new Storm_Collection($rss_items)); $id = $helper->getId(); diff --git a/tests/scenarios/Templates/TemplatesSearchItemsTest.php b/tests/scenarios/Templates/TemplatesSearchItemsTest.php index 225003d66c9..aaede7819a2 100644 --- a/tests/scenarios/Templates/TemplatesSearchItemsTest.php +++ b/tests/scenarios/Templates/TemplatesSearchItemsTest.php @@ -291,8 +291,8 @@ class TemplatesSearchItems15ItemsPaginationThreshold5AndAvailabilityKohaLimit9Te /** @test */ - public function shouldDisplay5Items() { - $this->assertXPathCount('//div[contains(@class,"card-title card_title")]', + public function shouldDisplay5ItemsInWallHasCardDescription() { + $this->assertXPathCount('//div[@class="masonry"]//div[@class="masonry-brick"]//div[contains(@class, "card card_template")]//div[contains(@class,"card-title card_title")]', 5); } @@ -904,4 +904,4 @@ class TemplatesSearchItemsWithoutILSDITest extends TemplatesSearchItemsKohaThres public function spanItemHoldRankShouldNotBePresent() { $this->assertNotXPath('//span[contains(@class, "item_hold_rank")]'); } -} +} \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesWebsitesTest.php b/tests/scenarios/Templates/TemplatesWebsitesTest.php index 5f63027d340..c5fd8305737 100644 --- a/tests/scenarios/Templates/TemplatesWebsitesTest.php +++ b/tests/scenarios/Templates/TemplatesWebsitesTest.php @@ -425,7 +425,7 @@ class TemplatesWebsitesDispatchPaginatedTest extends TemplatesWebsitesFixturesTe foreach (Class_Sitotheque::getSitesCategorie(8) as $website) $melted_websites [] = new Intonation_Library_View_Wrapper_Website($smeltery->meltWebsite($website), $view_renderer->view); - $helper = (new Intonation_Library_AjaxPaginatedListHelper) + $helper = (new Intonation_Library_PaginatedCollectionHelper) ->setCollection(new Storm_Collection($melted_websites)) ->setRendering('cardifyHorizontal'); diff --git a/tests/scenarios/Templates/TemplatesWidgetTest.php b/tests/scenarios/Templates/TemplatesWidgetTest.php index 3ac1b6077e8..a45d52b6040 100644 --- a/tests/scenarios/Templates/TemplatesWidgetTest.php +++ b/tests/scenarios/Templates/TemplatesWidgetTest.php @@ -1646,7 +1646,7 @@ class TemplatesWidgetWithPaginatedListTest extends AbstractControllerTestCase { ->setView(new Zend_View([])) ->setTemplateContext($widget); - $helper = (new Intonation_Library_AjaxPaginatedListHelper) + $helper = (new Intonation_Library_PaginatedCollectionHelper) ->setCollection(new Storm_Collection($records)) ->setCarouselContext($carousel_context) ->setRendering('cardifyHorizontal'); -- GitLab