diff --git a/VERSIONS_HOTLINE/149634 b/VERSIONS_HOTLINE/149634 new file mode 100644 index 0000000000000000000000000000000000000000..0f929ced1d6e2325be2da3654d1328043afd2140 --- /dev/null +++ b/VERSIONS_HOTLINE/149634 @@ -0,0 +1 @@ + - fonctionnalité #149634 : Magasin de thèmes : Les badges des prêts et des réservations d'un lecteur sont enrichis par des données d'exemplaire. Les données d'exemplaire affichées en plus sont le volume et les données exemplaires configurées dans l'affichage des exemplaires. \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/AbstractCardOperation.php b/library/templates/Intonation/Library/View/Wrapper/AbstractCardOperation.php index eddd7fe15c0edc29ef3c6da9c6ce244eb8d41baa..32e271faa8acad494bad049bd27a80f5a42bd1b8 100644 --- a/library/templates/Intonation/Library/View/Wrapper/AbstractCardOperation.php +++ b/library/templates/Intonation/Library/View/Wrapper/AbstractCardOperation.php @@ -25,6 +25,7 @@ abstract class Intonation_Library_View_Wrapper_AbstractCardOperation extends Int protected $_operation, $_record_cache, + $_item_wrapper_cache, $_ready, $_library_label, $_end_availability; @@ -38,6 +39,27 @@ abstract class Intonation_Library_View_Wrapper_AbstractCardOperation extends Int } + protected function _getMainTitleFor(string $label, string $class) : string { + $operation = [$label, + $this->_tag('span', + $this->_model->getUser()->getIdabon(), + ['class' => 'by_idabon']), + $this->_model->getUserFullName()]; + + return + $this->_div(['class' => $class], implode(' ', $operation)) + . $this->_div(['class' => 'document_title'], + $this->_getRecordMainTitle()); + } + + + protected function _getRecordMainTitle() { + return ($record = $this->_getRecord()) + ? $record->getMainTitle() + : $this->_model->getTitre(); + } + + public function getSecondaryTitle() { return ($record = $this->_getRecord()) ? $record->getSecondaryTitle() @@ -45,6 +67,37 @@ abstract class Intonation_Library_View_Wrapper_AbstractCardOperation extends Int } + protected function _addItemVolumeBadge(array $badges) : array { + if ( $wrapper = $this->_getItemWrapper()) + $badges [] = $wrapper->getVolumeBadge(); + + return $badges; + } + + + protected function _addItemDatasBadges(array $badges) : array { + if ( $wrapper = $this->_getItemWrapper()) + $badges = array_merge($badges, + $wrapper->getDatasItemsBadges()); + return $badges; + } + + + protected function _getItemWrapper() : ?Intonation_Library_View_Wrapper_Item { + if ( $this->_item_wrapper_cache ) + return $this->_item_wrapper_cache; + + if ( ! $operation = $this->_model->getOperation()) + return null; + + if ( !$item = $operation->getExemplaireOpac()) + return null; + + return $this->_item_wrapper_cache = + (new Intonation_Library_View_Wrapper_Item($item, $this->_view)); + } + + public function getPicture() { return ($record = $this->_getRecord()) ? $record->getPicture() diff --git a/library/templates/Intonation/Library/View/Wrapper/Hold.php b/library/templates/Intonation/Library/View/Wrapper/Hold.php index fc55c390f6c6319fdd213e606d7437034909b0db..0b659efce8bc3da878ce3c8a5589acd0e0611867 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Hold.php +++ b/library/templates/Intonation/Library/View/Wrapper/Hold.php @@ -24,23 +24,7 @@ class Intonation_Library_View_Wrapper_Hold extends Intonation_Library_View_Wrapp public function getMainTitle() { - $hold_by = $this->_('Réservé par %s %s', - $this->_tag('span', - $this->_model->getUser()->getIdabon(), - ['class' => 'by_idabon']), - $this->_model->getUserFullName()); - - $hold_by = $this->_div(['class' => 'hold_by'], - $hold_by); - - if ( ! $record = $this->_getRecord()) - return $hold_by . - $this->_div(['class' => 'document_title'], - $this->_model->getTitre()); - - return $hold_by - . $this->_div(['class' => 'document_title'], - $record->getMainTitle()); + return parent::_getMainTitleFor($this->_('Réservé par'), 'hold_by'); } @@ -127,6 +111,9 @@ class Intonation_Library_View_Wrapper_Hold extends Intonation_Library_View_Wrapp ->setText($this->_('Expire le %s', $this->_end_availability)) ->setTitle($this->_('La réservation expire le %s', $this->_end_availability)); + $badges = $this->_addItemVolumeBadge($badges); + $badges = $this->_addItemDatasBadges($badges); + return $this->_view->renderBadges($badges, $this); } diff --git a/library/templates/Intonation/Library/View/Wrapper/Item.php b/library/templates/Intonation/Library/View/Wrapper/Item.php index 41e36b0303be93f45c02bf453b5087281c6004c8..90174e1072c0d28fbd86b81f246e906cfed78e36 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Item.php +++ b/library/templates/Intonation/Library/View/Wrapper/Item.php @@ -113,9 +113,9 @@ class Intonation_Library_View_Wrapper_Item extends Intonation_Library_View_Wrapp $badges [] = $this->_getCoteBadge(); $badges [] = $this->_getDateRetourBadge(); $badges [] = $this->_getReservationsBadge(); - $badges [] = $this->_getVolumeBadge(); + $badges [] = $this->getVolumeBadge(); - foreach( $this->_getDatasItemsBadges() as $item_badge) + foreach( $this->getDatasItemsBadges() as $item_badge) $badges[] = $item_badge; return $this->_view->renderBadges(array_filter($badges), $this); @@ -207,7 +207,7 @@ class Intonation_Library_View_Wrapper_Item extends Intonation_Library_View_Wrapp } - protected function _getVolumeBadge() { + public function getVolumeBadge() { return (new Intonation_Library_Badge) ->setTag('span') ->setClass('badge-secondary badge-volume') @@ -249,7 +249,7 @@ class Intonation_Library_View_Wrapper_Item extends Intonation_Library_View_Wrapp } - protected function _getDatasItemsBadges() { + public function getDatasItemsBadges() { $item_fields = new Class_Exemplaire_Fields($this->_model); $subfield_settings = Class_Profil_ItemsSettings::current()->getIncludedSubfields(); @@ -261,6 +261,7 @@ class Intonation_Library_View_Wrapper_Item extends Intonation_Library_View_Wrapp $badges->addAll($this->_badgesForSubfield($label, $item_fields, $subfield)); } + return $badges->getArrayCopy(); } diff --git a/library/templates/Intonation/Library/View/Wrapper/Loan.php b/library/templates/Intonation/Library/View/Wrapper/Loan.php index dae713a8679c2fe0ff443215c72f124f3cd6fa31..f62c9360d500422b66e5370a550faed1039e0dc8 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Loan.php +++ b/library/templates/Intonation/Library/View/Wrapper/Loan.php @@ -22,22 +22,8 @@ class Intonation_Library_View_Wrapper_Loan extends Intonation_Library_View_Wrapper_AbstractCardOperation { - public function getMainTitle() { - $loan_by = $this->_('Emprunté par %s %s', - $this->_tag('span', - $this->_model->getUser()->getIdabon(), - ['class' => 'by_idabon']), - $this->_model->getUserFullName()); - - $loan_by = $this->_div(['class' => 'loan_by'], $loan_by); - - $title = $this->_div(['class' => 'document_title'], - (($record = $this->_getRecord()) - ? $record->getMainTitle() - : $this->_model->getTitre())); - - return $loan_by . $title; + return parent::_getMainTitleFor($this->_('Emprunté par'), 'loan_by'); } @@ -119,6 +105,9 @@ class Intonation_Library_View_Wrapper_Loan extends Intonation_Library_View_Wrapp ->setTitle($this->_('Exemplaire déjà prolongé'))) ]; + $badges = $this->_addItemVolumeBadge($badges); + $badges = $this->_addItemDatasBadges($badges); + return $this->_view->renderBadges($badges, $this); } diff --git a/tests/scenarios/Templates/TemplatesAbonneTest.php b/tests/scenarios/Templates/TemplatesAbonneTest.php index b028fd18b00b85d999457a5972490d5b61aec544..131ad804011eee4bccd6f2170a5345b80e5bd9f5 100644 --- a/tests/scenarios/Templates/TemplatesAbonneTest.php +++ b/tests/scenarios/Templates/TemplatesAbonneTest.php @@ -27,24 +27,28 @@ abstract class TemplatesIntonationAccountTestCase extends TemplatesIntonationTes public function setUp() { parent::setUp(); + $item = $this->fixture('Class_Exemplaire', + ['id' => 967, + 'code_barres' => 123, + 'id_int_bib' => 1, + 'id_origine' => 1234, + 'zone995' => serialize([['code' => 'a', 'valeur' => 'PotterItem'], + ['code' => 'v', 'valeur' => '7'], + ['code' => 'h', 'valeur' => 'Numero 23']]), + 'notice' => $this->fixture('Class_Notice', + ['id' => 889, + 'titre_principal' => 'Potter', + 'type_doc' => Class_TypeDoc::LIVRE, + 'url_image' => 'https://monimage.org', + 'unimarc' => '00577nam0 2200181 450 001001500000010001800015100004100033101000800074200010700082210003000189215001100219461002000230606002900250676000800279700004500287801005600332940000700388frOr1314913787 a9781408812792 a20140320 0103 aEng1 aHarry Potter and the deathly hallowsdHarry Potter et les reliques de la mortfJoanne Kathleen Rowling aLondrescBloomsburyd2010 a831 p. 1tHarry Potterv7 aAnglais (langue)2Rameau a420 1aRowlingbJoanne Kathleenf1965-....4070 aFRbBibliothèque de l\'agglomération de Saint-Omer apm'])]); + $potter = new Class_WebService_SIGB_Emprunt('12', new Class_WebService_SIGB_Exemplaire(123)); $potter ->setCodeBarre(123) ->getExemplaire() ->setTitre('Potter') ->setRenewals(1) - ->setExemplaireOPAC($this->fixture('Class_Exemplaire', - ['id' => 967, - 'code_barres' => 123, - 'id_int_bib' => 1, - 'id_origine' => 1234, - 'zone995' => serialize([['clef' => 'a', 'valeur' => 'PotterItem']]), - 'notice' => $this->fixture('Class_Notice', - ['id' => 889, - 'titre_principal' => 'Potter', - 'type_doc' => Class_TypeDoc::LIVRE, - 'url_image' => 'https://monimage.org', - 'unimarc' => '00577nam0 2200181 450 001001500000010001800015100004100033101000800074200010700082210003000189215001100219461002000230606002900250676000800279700004500287801005600332940000700388frOr1314913787 a9781408812792 a20140320 0103 aEng1 aHarry Potter and the deathly hallowsdHarry Potter et les reliques de la mortfJoanne Kathleen Rowling aLondrescBloomsburyd2010 a831 p. 1tHarry Potterv7 aAnglais (langue)2Rameau a420 1aRowlingbJoanne Kathleenf1965-....4070 aFRbBibliothèque de l\'agglomération de Saint-Omer apm'])])); + ->setExemplaireOPAC($item); $potter ->parseExtraAttributes(['Dateretourprevue' => '29/10/1990', @@ -54,18 +58,6 @@ abstract class TemplatesIntonationAccountTestCase extends TemplatesIntonationTes 'N° de notice' => '1234', 'Type' => 'P1']); - $this->fixture('Class_Exemplaire', - ['id' => 967, - 'id_origine' => 1234, - 'code_barres' => 123, - 'id_int_bib' => 1, - 'zone995' => serialize([['clef' => 'a', 'valeur' => 'PotterItem']]), - 'notice' => $this->fixture('Class_Notice', - ['id' => 889, - 'titre_principal' => 'Potter', - 'type_doc' => 1, - 'unimarc' => '00577nam0 2200181 450 001001500000010001800015100004100033101000800074200010700082210003000189215001100219461002000230606002900250676000800279700004500287801005600332940000700388frOr1314913787 a9781408812792 a20140320 0103 aEng1 aHarry Potter and the deathly hallowsdHarry Potter et les reliques de la mortfJoanne Kathleen Rowling aLondrescBloomsburyd2010 a831 p. 1tHarry Potterv7 aAnglais (langue)2Rameau a420 1aRowlingbJoanne Kathleenf1965-....4070 aFRbBibliothèque de l\'agglomération de Saint-Omer apm'])]); - $alice = new Class_WebService_SIGB_Emprunt('13', new Class_WebService_SIGB_Exemplaire(456)); $alice ->setCodeBarre(124) @@ -99,10 +91,24 @@ abstract class TemplatesIntonationAccountTestCase extends TemplatesIntonationTes 'titre_principal' => 'Alice', 'type_doc' => 1])]); + (new Class_Profil_ItemsSettings(Class_Profil::find(72))) + ->setSettings(['datas_items_code' => ['h'], + 'datas_items_label' => ['Périodique :']]); + + $this->fixture(Class_IntProfilDonnees::class, + ['id' => 22, + 'attributs' => serialize([0 => ['item_numero_periodique' => 'h', + 'item_label_numero_periodique' => ' : ']]) + ]); + + $exemplaire_dobby = $this->fixture('Class_Exemplaire', ['id' => 12089, 'code_barres' => 123, 'id_int_bib' => 1, + 'zone_995' => serialize([['code' => 'a', 'valeur' => 'Dobby'], + ['code' => 'v', 'valeur' => '7'], + ['code' => 'h', 'valeur' => 'Numero 23']]), 'id_notice' => 820]); $exemplaire_troy = $this->fixture('Class_Exemplaire', @@ -437,6 +443,7 @@ class TemplatesDispatchAbonneLoansPaginatedTest extends TemplatesIntonationAccou class TemplatesDispatchAbonneAjaxLoansTest extends TemplatesIntonationAccountTestCase { public function setUp(){ parent::setUp(); + $this->dispatch('/opac/abonne/ajax-loans/id_profil/72'); } @@ -447,6 +454,21 @@ class TemplatesDispatchAbonneAjaxLoansTest extends TemplatesIntonationAccountTes } + /** @test */ + public function badgeShouldContainsNumero23() { + $this->assertXPathContentContains('//div//span[contains(@class,"datas_items_995_h")]', + 'Numero 23'); + } + + + /** @test */ + public function badgeVolumeShouldContains7() { + $this->assertXPathContentContains('//div//span[contains(@class,"badge-volume")]', '7'); + } + + + + /** @test */ public function shouldContainsLoanAlice() { $this->assertXPathContentContains('//div', 'Alice'); @@ -616,13 +638,21 @@ class TemplatesDispatchAbonneLoansWithHistoryTest extends TemplatesIntonationAcc class TemplatesDispatchAbonneHoldsTest extends TemplatesIntonationAccountTestCase { public function setUp(){ parent::setUp(); + $this->dispatch('/opac/abonne/reservations/id_profil/72'); } /** @test */ - public function holdDobbyPotterTitleShouldBeDisplay() { - $this->assertXPathContentContains('//div[@class="document_title"]', 'Dobby Potter'); + public function badgeShouldContainsNumero23() { + $this->assertXPathContentContains('//div//span[contains(@class,"datas_items_995_h")]', + 'Numero 23'); + } + + + /** @test */ + public function badgeVolumeShouldContains7() { + $this->assertXPathContentContains('//div//span[contains(@class,"badge-volume")]', '7'); }