From ef81f32f10d1d877f1ee2587fb97bffe731eb25c Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT <hdlaurent@afi-sa.net> Date: Thu, 14 Mar 2024 16:16:50 +0000 Subject: [PATCH] =?UTF-8?q?hotline#190952=20:=20Affichage=20Exemplaire=20:?= =?UTF-8?q?=20Meilleur=20ordre=20d'affichage=20des=20exemplaires=20de=20p?= =?UTF-8?q?=C3=A9riodiques?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VERSIONS_HOTLINE/190592 | 1 + .../View/RenderRecord/RenderItems.php | 48 ++++---------- .../Templates/TemplatesRecordsTest.php | 66 +++++++++++++++++++ 3 files changed, 80 insertions(+), 35 deletions(-) create mode 100644 VERSIONS_HOTLINE/190592 diff --git a/VERSIONS_HOTLINE/190592 b/VERSIONS_HOTLINE/190592 new file mode 100644 index 00000000000..badcc7f6123 --- /dev/null +++ b/VERSIONS_HOTLINE/190592 @@ -0,0 +1 @@ + - correctif #190592 : Exemplaires : Si un tri est précisé dans la configuration, mieux tenir compte de ce paramétrage pour les périodiques. \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderRecord/RenderItems.php b/library/templates/Intonation/View/RenderRecord/RenderItems.php index 6127e12f317..8d439f1a234 100644 --- a/library/templates/Intonation/View/RenderRecord/RenderItems.php +++ b/library/templates/Intonation/View/RenderRecord/RenderItems.php @@ -184,7 +184,7 @@ abstract class Intonation_View_RenderRecord_RenderItemsStrategy { protected function _renderItemsHTMLInner(array $items) : string { return ($this->_view->newHelper('WallGrid')) - ->wallGrid($this->_initCollection($this->_sortItems($items), + ->wallGrid($this->_initCollection($items, $this->_getItemWrapper()), fn($element) => $this->_view->renderingDescription($element)); } @@ -281,22 +281,24 @@ abstract class Intonation_View_RenderRecord_RenderItemsStrategy { protected function _itemsWithMap(array $items, array $same_work, array $html) : array { $html [] = $this->_renderMapHTML($items, $same_work); - return $this->_itemsWithoutMap($items, - $same_work, - $html); + return $this->_renderSimpleItems($items, + $same_work, + $html); } - protected function _itemsWithoutMap(array $items, array $same_work, array $html) : array { - $html [] = $this->_renderItemsHTML($items); + protected function _renderSimpleItems (array $items, array $same_work, array $html) : array + { + $html [] = $this->_renderItemsHTML($this->_sortItems($items)); $html [] = $this->_renderSameWorkItemsHTML($same_work); return array_filter($html); } - abstract public function renderItems(array $items, - array $same_work, - array $html) : array; + public function renderItems(array $items, array $same_work, array $html) : array + { + return $this->_renderSimpleItems($items, $same_work, $html); + } abstract protected function _getItemWrapper() : string; @@ -313,10 +315,7 @@ class Intonation_View_RenderRecord_RenderItemsStrategyMap public function renderItems(array $items, array $same_work, array $html) : array { - $html [] = $this->_renderMapHTML($items, $same_work); - $html [] = $this->_renderItemsHTML($items); - $html [] = $this->_renderSameWorkItemsHTML($same_work); - return array_filter($html); + return $this->_itemsWithMap($items, $same_work, $html); } @@ -337,13 +336,6 @@ class Intonation_View_RenderRecord_RenderItemsStrategyPagination extends Intonation_View_RenderRecord_RenderItemsStrategy { - public function renderItems(array $items, array $same_work, array $html) : array { - $html [] = $this->_renderItemsHTML($items); - $html [] = $this->_renderSameWorkItemsHTML($same_work); - return array_filter($html); - } - - protected function _renderItemsHTMLInner(array $items) : string { return $this->_renderPaginatedItemsHTML($items); } @@ -366,13 +358,6 @@ class Intonation_View_RenderRecord_RenderItemsStrategyILS extends Intonation_View_RenderRecord_RenderItemsStrategy { - public function renderItems(array $items, array $same_work, array $html) : array { - $html [] = $this->_renderItemsHTML($items); - $html [] = $this->_renderSameWorkItemsHTML($same_work); - return array_filter($html); - } - - protected function _sortByAvailability(array $items) : array { return $this->_sortByILSAvailability($items); } @@ -395,13 +380,6 @@ class Intonation_View_RenderRecord_RenderItemsStrategyILSAndPagination extends Intonation_View_RenderRecord_RenderItemsStrategy { - public function renderItems(array $items, array $same_work, array $html) : array { - $html [] = $this->_renderItemsHTML($items); - $html [] = $this->_renderSameWorkItemsHTML($same_work); - return array_filter($html); - } - - protected function _sortByAvailability(array $items) : array { return $this->_sortByILSAvailability($items); } @@ -474,7 +452,7 @@ class Intonation_View_RenderRecord_RenderItemsStrategyNoMapNoILSNoPagination public function renderItems(array $items, array $same_work, array $html) : array { - return $this->_itemsWithoutMap($items, $same_work, $html); + return $this->_renderSimpleItems($items, $same_work, $html); } diff --git a/tests/scenarios/Templates/TemplatesRecordsTest.php b/tests/scenarios/Templates/TemplatesRecordsTest.php index 46caaf1689b..8caa70a4859 100644 --- a/tests/scenarios/Templates/TemplatesRecordsTest.php +++ b/tests/scenarios/Templates/TemplatesRecordsTest.php @@ -1836,3 +1836,69 @@ class TemplateRecordsViewNoticeCyrillic extends AbstractControllerTestCase { $this->assertXPathContentContains('//div[@class="card-subtitle"]', 'ИоÑиф ВиÑÑарионович Сталин'); } } + + + + +class TemplateRecordsViewPeriodiqueSortByPeriodicTitle extends AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + + $this->_buildTemplateProfil(['id' => 34, + 'template' => 'INTONATION']); + + (new Class_Profil_ItemsSettings(Class_Profil::find(34))) + ->setSettings(['datas_items_code' => ['h'], + 'datas_items_label' => ['Numero Periodique'], + 'order_by' => 'h', + 'order_direction' => 'DESC' + ]); + + $this->fixture(Class_Notice::class, + ['id' => 134, + 'type_doc' => Class_TypeDoc::PERIODIQUE, + 'alpha_titres' => 'REVUE INTERNATIONALE DE POLITIQUE COMPAREE', + 'matieres' => 'POLITIQUE INTERNATIONAL', + 'clef_oeuvre' => 'REVUE-INTERNATIONALE-POLITIQUE-COMPAREE---1', + 'date_creation' => '1999-12-14', + 'titre_principal' => 'Revue internationale de politique comparée', + ]); + + for($i=100; $i<105; $i++) + $this->fixture(Class_Exemplaire::class, + ['id' => $i, + 'id_notice' => 134, + 'id_bib' => 1, + 'code_barres' => '9381243'+(string)$i, + 'annexe' => 1 + ]) + ->setZone995(serialize([ + ['code' => 'a', + 'valeur' => 'UMEA'], + ['code' => 'c', + 'valeur' => 'qdsf'], + ['code' => 'h', + 'valeur' => '1998, V. 05, N. '. $i ]])); + + $this->dispatch('/opac/noticeajax/exemplaires/id/134/profile_id/34'); + } + + + public function getPositionAndSerialName(){ + return [ [ 1, '1998, V. 05, N. 104'], + [ 2, '1998, V. 05, N. 103'], + [ 3, '1998, V. 05, N. 102'], + [ 4, '1998, V. 05, N. 101'], + [ 5, '1998, V. 05, N. 100'] + ]; + } + + + /** @test + * @dataProvider getPositionAndSerialName + */ + public function orderShouldBeAsExpected($position, $serial_name) { + $this->assertXPathContentContains('(//span[contains(@class,"datas_items_995_h")])['.$position.']', + $serial_name); + } +} -- GitLab