From b651dbf6c5a388b8a9cee4ef69cb88acd835ddf4 Mon Sep 17 00:00:00 2001 From: efalcy <efalcy@afi-sa.fr> Date: Mon, 29 Jun 2020 18:00:16 +0200 Subject: [PATCH] hotline #10927: liste verticale intercation bootstrap fix --- cosmogramme/VERSIONS_HOTLINE/109427 | 1 + .../Library/AjaxPaginatedListHelper.php | 1 + .../View/RenderAjaxPaginatedList.php | 5 +- tests/scenarios/Templates/TemplatesTest.php | 57 +++++++++++++++++++ 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 cosmogramme/VERSIONS_HOTLINE/109427 diff --git a/cosmogramme/VERSIONS_HOTLINE/109427 b/cosmogramme/VERSIONS_HOTLINE/109427 new file mode 100644 index 00000000000..67d1cb05dee --- /dev/null +++ b/cosmogramme/VERSIONS_HOTLINE/109427 @@ -0,0 +1 @@ + - ticket #109427 : Magasin de thème : correction de la pagination/recherche dans la liste verticale à intercations \ No newline at end of file diff --git a/library/templates/Intonation/Library/AjaxPaginatedListHelper.php b/library/templates/Intonation/Library/AjaxPaginatedListHelper.php index c1e5214d987..7addcc30dc3 100644 --- a/library/templates/Intonation/Library/AjaxPaginatedListHelper.php +++ b/library/templates/Intonation/Library/AjaxPaginatedListHelper.php @@ -147,6 +147,7 @@ class Intonation_Library_AjaxPaginatedListHelper { { $element ->setView($this->_view) + ->setModel($element->getModel()) ->inJsSearch(); return false !== strpos(strtolower($element->getContentForJSSearch()), $term); }); diff --git a/library/templates/Intonation/View/RenderAjaxPaginatedList.php b/library/templates/Intonation/View/RenderAjaxPaginatedList.php index be784809222..f1e45a2033d 100644 --- a/library/templates/Intonation/View/RenderAjaxPaginatedList.php +++ b/library/templates/Intonation/View/RenderAjaxPaginatedList.php @@ -32,6 +32,7 @@ class Intonation_View_RenderAjaxPaginatedList extends ZendAfi_View_Helper_BaseHe $callback = function($element) use ($helper) { $element->setView($this->view); + $element->setModel($element->getModel()); return call_user_func_array([$this->view, $helper->getRendering()], [$element]); }; @@ -62,7 +63,7 @@ class Intonation_View_RenderAjaxPaginatedList extends ZendAfi_View_Helper_BaseHe $page_size = $helper->getPageSize(); $count_pages = ceil( $count_result / $page_size ); - + $count_pages = $count_pages < 1 ? 1 : $count_pages ; return $this->view->div([], implode([$this->view->tagAnchor(['controller' => 'index', 'action' => 'ajax-paginated-list', @@ -79,6 +80,7 @@ class Intonation_View_RenderAjaxPaginatedList extends ZendAfi_View_Helper_BaseHe $this->view->tagAnchor(['controller' => 'index', 'action' => 'ajax-paginated-list', + 'id_profil' => Class_Profil::getCurrentProfil()->getId(), 'id' => $this->_id, 'page' => $current_page +1], $this->_tag('i','',['class' => 'fas fa-chevron-right m-0']), @@ -95,6 +97,7 @@ class Intonation_View_RenderAjaxPaginatedList extends ZendAfi_View_Helper_BaseHe $form ->setAction($this->view->url(['controller' => 'index', 'action' => 'ajax-paginated-list', + 'id_profil' => Class_Profil::getCurrentProfil()->getId(), 'id' => $this->_id, 'size' => $helper->getPageSize(), 'page' => 1], null, true)) diff --git a/tests/scenarios/Templates/TemplatesTest.php b/tests/scenarios/Templates/TemplatesTest.php index 41ca0673d88..4fba2a66461 100644 --- a/tests/scenarios/Templates/TemplatesTest.php +++ b/tests/scenarios/Templates/TemplatesTest.php @@ -3491,6 +3491,63 @@ class TemplatesDispatchAbonneLoansTest extends TemplatesIntonationAccountTestCas } + /** @test */ + public function page2ReviewsShouldContainsSearchInputWithMd5Key() { + Storm_Cache::beVolatile(); + $this->fixture('Class_AvisNotice', + ['id' => 4, + 'id_user' => 666, + 'id_notice' => 2, + 'clef_oeuvre' => 'PSYKO', + 'note' => '4', + 'entete' => 'Le Roi', + 'avis' => 'Le Roi des cons sur son throne', + 'source_author' => null]); + + + $this->fixture('Class_AvisNotice', + ['id' => 5, + 'id_user' => 666, + 'id_notice' => 3, + 'clef_oeuvre' => 'PSYKO', + 'note' => '4', + 'entete' => 'Le Roi des cons avec sa couronne', + 'avis' => 'Le Roi des cons avec sa couronne', + 'source_author' => null]); + + $this->fixture('Class_Notice', + ['id' => 2, + 'clef_oeuvre' => 'PSYKO', + ]); + + $this->fixture('Class_Notice', + ['id' => 3, + 'clef_oeuvre' => 'PSYKOTIC', + ]); + + + $reviews = Class_AvisNotice::groupByRecords(Class_AvisNotice::findAll()); + $reviews = array_map(function($review) + { + return (new Intonation_Library_View_Wrapper_ReviewsByRecord) + ->setModel($review) + ->setView($this->view); + }, $reviews); + + $collection = new Storm_Collection($reviews); + + $helper = (new Intonation_Library_AjaxPaginatedListHelper) + ->setCollection($collection) + ->setRendering('cardifyHorizontal'); + + $id = $helper->getId(); + + $this->dispatch('/opac/index/ajax-paginated-list/id/' . $id . '/page/2/render/ajax/id_profil/72/size/1/search/roi'); + $this->assertContains('input_69219ce1da1a3a70c6511767a99d5a05', $this->_response->getBody()); + $this->assertContains('avec sa couronne', $this->_response->getBody()); + } + + /** @test */ public function loansShouldContainsDrHouse() { Storm_Cache::beVolatile(); -- GitLab