diff --git a/VERSIONS_HOTLINE/124536 b/VERSIONS_HOTLINE/124536 new file mode 100644 index 0000000000000000000000000000000000000000..81e9909c291c1865da3054f43e40312f1c4cc30e --- /dev/null +++ b/VERSIONS_HOTLINE/124536 @@ -0,0 +1 @@ + - ticket #124536 : Magasin de thèmes : amélioration des liste de prêts et de réservations. \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/Hold.php b/library/templates/Intonation/Library/View/Wrapper/Hold.php index 3bf19958318f0847a6f1fc0a4d24eb1d08343f06..3dcebcb02d30b85f0721fb41092b24b14cf41902 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Hold.php +++ b/library/templates/Intonation/Library/View/Wrapper/Hold.php @@ -161,6 +161,8 @@ class Intonation_Library_View_Wrapper_Hold extends Intonation_Library_View_Wrapp public function getBadges() { + $rang = $this->_model->getRang(); + $badges = [ ((new Intonation_Library_Badge) ->setTag('span') @@ -170,7 +172,7 @@ class Intonation_Library_View_Wrapper_Hold extends Intonation_Library_View_Wrapp ((new Intonation_Library_Badge) ->setTag('span') - ->setClass($this->_model->isWaitingToBePulled() ? 'success' : 'secondary') + ->setClass($this->_model->isWaitingToBePulled() ? 'badge-success' : 'badge-secondary') ->setImage(Class_Template::current()->getIco($this->_view, 'library', 'library')) @@ -186,14 +188,17 @@ class Intonation_Library_View_Wrapper_Hold extends Intonation_Library_View_Wrapp ((new Intonation_Library_Badge) ->setTag('span') ->setClass('badge-secondary') - ->setText($this->_model->getRang()) - ->setTitle($this->_('Rang de la réservation: %s', $this->_model->getRang()))) + ->setText($this->_('Rang %d', $rang)) + ->setTitle($this->_plural($rang - 1, + 'Le prochain document disponible est pour vous.', + 'Il y a 1 réservation avant la votre.', + 'Il y a %d réservations avant la votre.'))) ]; if ($end_availability = $this->_model->getFormattedAvailabilityEndDate()) $badges []= (new Intonation_Library_Badge) ->setTag('span') - ->setClass('warning') + ->setClass('badge-warning') ->setImage(Class_Template::current()->getIco($this->_view, 'library', 'agenda')) diff --git a/library/templates/Intonation/Library/View/Wrapper/Suggestion.php b/library/templates/Intonation/Library/View/Wrapper/Suggestion.php index 3708449999c2b01c66def6823ba64b79d673b74b..f3d5ad3f56899a2d23dd51e127d8476f38048618 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Suggestion.php +++ b/library/templates/Intonation/Library/View/Wrapper/Suggestion.php @@ -131,15 +131,13 @@ class Intonation_Library_View_Wrapper_Suggestion extends Intonation_Library_View ((new Intonation_Library_Badge) ->setTag('span') - ->setClass('badge-primary fs_1em') - ->setImage((Class_Template::current() - ->getIco($this->_view, - $this->getDocTypeLabel(), - 'doc_types'))) + ->setClass('badge-primary fs_1em suggestion_status') + ->setImage(($this->getIco($this->getDocTypeLabel(), + 'doc_types'))) ->setText($this->_model->getStatus()) - ->setTitle($this->_('Statut de la suggestion %s', - $this->getDocTypeLabel(), - $this->_model->getTitre())))]; + ->setTitle($this->_('Statut de la suggestion %s %s', + $this->_model->getTitre(), + $this->_model->getStatus())))]; if ($lib = $this->_model->getLibrary()) $badges [] = ((new Intonation_Library_Badge) diff --git a/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Reviews.php b/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Reviews.php index 1c6a74f71fb88c1c95521984c682338acf628adb..83f7f63186fb2b437445c1bb2b4993170dd81e1b 100644 --- a/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Reviews.php +++ b/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Reviews.php @@ -48,7 +48,7 @@ class Intonation_Library_View_Wrapper_User_RichContent_Reviews extends Intonatio 'add', 'utils')])]; - return $this->_view->renderCollection(new Storm_Collection($reviews), $actions); + return $this->_view->renderCollection(new Storm_Collection($reviews), $actions, null, 20); } diff --git a/library/templates/Intonation/View/Abonne/Holds.php b/library/templates/Intonation/View/Abonne/Holds.php index 6b2b388f4cb767c2b88efa1a0ab8d7bad60948aa..c54e4c9aac775bdfbc87a720b36b96c362d574be 100644 --- a/library/templates/Intonation/View/Abonne/Holds.php +++ b/library/templates/Intonation/View/Abonne/Holds.php @@ -46,6 +46,6 @@ class Intonation_View_Abonne_Holds extends ZendAfi_View_Helper_BaseHelper { 'library')])] : []; - return $this->view->renderCollection(new Storm_Collection($holds), $actions); + return $this->view->renderCollection(new Storm_Collection($holds), $actions, null, 20); } } diff --git a/library/templates/Intonation/View/Abonne/LoansList.php b/library/templates/Intonation/View/Abonne/LoansList.php index ba4141bd734a48d734633270fba277827783c3ca..5b2056b66a2e71f4940f5c5a025b02b5fc469548 100644 --- a/library/templates/Intonation/View/Abonne/LoansList.php +++ b/library/templates/Intonation/View/Abonne/LoansList.php @@ -47,7 +47,7 @@ class Intonation_View_Abonne_LoansList extends ZendAfi_View_Helper_BaseHelper { $actions = $this->_getActions(); - return $this->view->renderCollection(new Storm_Collection($loans), $actions); + return $this->view->renderCollection(new Storm_Collection($loans), $actions, null, 20); } diff --git a/library/templates/Intonation/View/Abonne/PNBLoansList.php b/library/templates/Intonation/View/Abonne/PNBLoansList.php index 77543539c1848d694bb4dadaa78a8b5b5712082f..1d2041e6a842417c702eb3f7b466c1c3dfe30922 100644 --- a/library/templates/Intonation/View/Abonne/PNBLoansList.php +++ b/library/templates/Intonation/View/Abonne/PNBLoansList.php @@ -36,7 +36,7 @@ class Intonation_View_Abonne_PNBLoansList extends Intonation_View_Abonne_LoansLi }, $loans->getArrayCopy()); return $loans - ? $this->view->renderCollection(new Storm_Collection($loans)) + ? $this->view->renderCollection(new Storm_Collection($loans), [], null, 20) : ''; } } diff --git a/library/templates/Intonation/View/Abonne/Selections.php b/library/templates/Intonation/View/Abonne/Selections.php index c312508932f2997ec56c41b15dfcf91a27491619..dcd801d6ccc5d08dc8b655b0437ff9e5572b6c67 100644 --- a/library/templates/Intonation/View/Abonne/Selections.php +++ b/library/templates/Intonation/View/Abonne/Selections.php @@ -41,6 +41,6 @@ class Intonation_View_Abonne_Selections extends ZendAfi_View_Helper_BaseHelper { 'add', 'utils')])]; - return $this->view->renderCollection($collection, $actions); + return $this->view->renderCollection($collection, $actions, null, 20); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderCollection.php b/library/templates/Intonation/View/RenderCollection.php index 9cb7f83e4b6581d01e550dcb95c551666077444a..511d3f4b92de8b1f525b4f49c5b9cf8d665a12c5 100644 --- a/library/templates/Intonation/View/RenderCollection.php +++ b/library/templates/Intonation/View/RenderCollection.php @@ -21,7 +21,7 @@ class Intonation_View_RenderCollection extends ZendAfi_View_Helper_BaseHelper { - public function renderCollection($collection, $actions = [], $callback = null) { + public function renderCollection($collection, $actions = [], $callback = null, $page_size = 3) { $callback = $callback ? $callback : (function($item) @@ -36,7 +36,8 @@ class Intonation_View_RenderCollection extends ZendAfi_View_Helper_BaseHelper { $html = [$this->view->div(['class' => 'col-12'], $this->view->renderActions($actions)), $this->view->div(['class' => 'col-12'], $this->view->renderTruncateList($collection, - $callback))]; + $callback, + $page_size))]; return $this->view->grid(implode($html)); } diff --git a/library/templates/Intonation/View/RenderNewsletters.php b/library/templates/Intonation/View/RenderNewsletters.php index 2c815a3d1d177207fbc5530bdd152f94187e5b1e..fe8c15436496f636b9f83b6ea0e7316289d823b8 100644 --- a/library/templates/Intonation/View/RenderNewsletters.php +++ b/library/templates/Intonation/View/RenderNewsletters.php @@ -39,7 +39,7 @@ class Intonation_View_RenderNewsletters extends ZendAfi_View_Helper_BaseHelper { return $this->_tag('h3', $this->_('Les lettres d\'information')) . $this->_renderNewsletterAction() - . $this->view->renderTruncateList(new Storm_Collection($newsletters), $callback); + . $this->view->renderTruncateList(new Storm_Collection($newsletters), $callback, 20); } diff --git a/library/templates/Intonation/View/RenderTruncateList.php b/library/templates/Intonation/View/RenderTruncateList.php index ca259e99f3765172e06c74a684e00fd20d1f7d33..63ab702e26a707d72c7b88806f5ccbe4df094402 100644 --- a/library/templates/Intonation/View/RenderTruncateList.php +++ b/library/templates/Intonation/View/RenderTruncateList.php @@ -23,20 +23,24 @@ class Intonation_View_RenderTruncateList extends ZendAfi_View_Helper_BaseHelper { protected + $_page_size = 3, + $_ajax_size = 50, $_container_id, $_input_id; - public function renderTruncateList($collection, $callback) { + public function renderTruncateList($collection, $callback, $page_size = 3) { if ($collection->isEmpty()) return ''; + $this->_page_size = $page_size; + $size = $collection->count(); - if (50 < $size) + if ($this->_ajax_size < $size) return $this->_ajaxifyList($collection); - if (3 >= $size) + if ($this->_page_size >= $size) return $this->view->renderList($collection, $callback); $html = $collection @@ -50,13 +54,15 @@ class Intonation_View_RenderTruncateList extends ZendAfi_View_Helper_BaseHelper $this->_container_id = $id = uniqid(); $this->_input_id = 'input_' . $this->_container_id; + $tools = $this->_renderTools($size); return - $this->_renderTools($size) + $tools . $this->_tag('div', $html, ['id' => $this->_container_id, - 'class' => 'list-group bg-transparent no_border']); + 'class' => 'list-group bg-transparent no_border']) + . $tools; } @@ -74,7 +80,7 @@ class Intonation_View_RenderTruncateList extends ZendAfi_View_Helper_BaseHelper $input_keyup = "$('#" . $id . "').val(10000).change();" - . "setTimeout(function() { $('#" . $size_id . "').text($('#" . $this->_container_id . "').children(':visible').length); var searchText = $('#" . $this->_input_id . "').val(); if (!searchText || searchText == '' || searchText == '*') $('#" . $id . "').val(3).change();}, 10);"; + . "setTimeout(function() { $('#" . $size_id . "').text($('#" . $this->_container_id . "').children(':visible').length); var searchText = $('#" . $this->_input_id . "').val(); if (!searchText || searchText == '' || searchText == '*') $('#" . $id . "').val(" . $this->_page_size . ").change();}, 10);"; $multi_options = $this->_getTruncateOptions($size); @@ -118,22 +124,10 @@ class Intonation_View_RenderTruncateList extends ZendAfi_View_Helper_BaseHelper protected function _getTruncateOptions($size) { - if ($size > 50) - return ['3' => $this->_('3'), - '10' => $this->_('10'), - '50' => $this->_('50'), - '10000' => $this->_('Tout')]; - - if ($size > 10) - return ['3' => $this->_('3'), - '10' => $this->_('10'), + return [$this->_page_size => $this->_page_size, + $this->_page_size * 2 => $this->_page_size * 2, + $this->_page_size * 5 => $this->_page_size * 5, '10000' => $this->_('Tout')]; - - if ($size > 3) - return ['3' => $this->_('3'), - '10000' => $this->_('Tout')]; - - return ['10000' => $this->_('Tout')]; } @@ -144,7 +138,7 @@ class Intonation_View_RenderTruncateList extends ZendAfi_View_Helper_BaseHelper '#' . $this->_container_id . ' div.card *, .dropdown, .dropdown-menu') ->addJQueryReady("var container = $('#" . $this->_container_id . "');" - . "setTimeout(function() {container.children().slice(0,3).show();" + . "setTimeout(function() {container.children().slice(0, " . $this->_page_size . ").show();" . "$('#" . $this->_input_id . "').attr('onkeypress', 'return event.keyCode != 13;');}, 10);"); return $this; diff --git a/tests/scenarios/Templates/TemplatesAbonneTest.php b/tests/scenarios/Templates/TemplatesAbonneTest.php index 9c260ca146d81c8a582d083ad8f9181728ccf2cc..e996753107ffe307dab40fc379637befe8a41867 100644 --- a/tests/scenarios/Templates/TemplatesAbonneTest.php +++ b/tests/scenarios/Templates/TemplatesAbonneTest.php @@ -542,10 +542,91 @@ class TemplatesDispatchAbonneHoldsTest extends TemplatesIntonationAccountTestCas public function holdsDobbyPotterBadgeForAvailabilityEndDateShouldContainsSixJuin() { $this->assertXPathContentContains('//div[contains(@class,"badge_group_Intonation_Library_View_Wrapper_Hold")]//span[@title="Expire le: 06 juin"]', '06 juin'); } + + + /** @test */ + public function dobbyPotterHoldShouldHaveRank2() { + $this->assertXPathContentContains('//span[contains(@title, "Il y a 1 réservation avant la votre.")]//span', 'Rang 2'); + } +} + + + + +class TemplatesDispatchAbonneLargeNumberOfHoldsTest extends TemplatesIntonationAccountTestCase { + public function setUp(){ + parent::setUp(); + + $holds = []; + for ($i = 1 ; $i <=25 ; $i ++) + $holds [] = (new Class_WebService_SIGB_Reservation('12', + (new Class_WebService_SIGB_Exemplaire(999123 + $i)) + ->setTitre('Dobby') + ->setExemplaireOPAC(Class_Exemplaire::find(12089)))) + ->parseExtraAttributes(['Etat' => 'Réservation admise', + 'Rang' => '2', + 'Bibliotheque' => 'Tombouctou', + 'N° de notice' => 564]) + ->setAvailabilityEndDate('2020-06-06'); + + $this->_emprunteur + ->reservationsAddAll($holds); + + $this->dispatch('/opac/abonne/reservations/id_profil/72'); + } + + + /** @test */ + public function truncateListShouldHaveASizeOf20() { + $this->assertXPath('//div//select[contains(@title, "Limiter le nombre d")]//option[@value="20"]'); + } + + + /** @test */ + public function truncateListShouldHaveASizeOf40() { + $this->assertXPath('//div//select[contains(@title, "Limiter le nombre d")]//option[@value="40"]'); + } + + + /** @test */ + public function truncateListShouldHaveASizeOf100() { + $this->assertXPath('//div//select[contains(@title, "Limiter le nombre d")]//option[@value="100"]'); + } + + + /** @test */ + public function inputFiltrerShouldBePresent() { + $this->assertXPathContentContains('//form//label', 'Filtrer'); + } + + + /** @test */ + public function selectOnChangeShouldBePresent() { + $this->assertXPath('//select[contains(@onchange,"var container = $(")][contains(@onchange, "container.children().hide();var value=$(")][contains(@onchange, "val();container.children().not(\'.search_input_not_found\').slice(0, value).show()")]'); + } + + + /** @test */ + public function holdsShouldBeDisplaydInListGroup() { + $this->assertXPath('//div[contains(@class, "list-group")]//div[contains(@class, "list-group-item")]//div[contains(@class, "card")]'); + } + + + /** @test */ + public function scriptShouldContainsSearchInput() { + $this->assertXPathContentContains('//script', '.search_input('); + } + + + /** @test */ + public function scriptShouldContainsChildrenSliceShow() { + $this->assertXPathContentContains('//script', 'setTimeout(function() {container.children().slice(0, 20).show();'); + } } + class TemplatesDispatchAbonneSelectionsTest extends TemplatesIntonationAccountTestCase { /** @test */ public function selectionMesBDShouldBeDisplay() {