Skip to content
Snippets Groups Projects
Commit 02c9936d authored by Ghislain Loas's avatar Ghislain Loas
Browse files

hotline MT #122926 : Improve hold button in record page

parent 72579dc6
Branches
Tags
No related merge requests found
Pipeline #12226 passed with stage
in 1 hour, 38 minutes, and 46 seconds
- ticket #122926 : Magasin de thèmes : Amélioration du bouton réserver de la page notice.
\ No newline at end of file
......@@ -22,15 +22,13 @@
class Chili_View_RenderRecord_RenderItems extends Intonation_View_RenderRecord_RenderItems {
protected function _hookForMoreHtml($items) {
if ( ! $first_item = reset($items))
return '';
if ( ! $first_item = $this->_getFirstHoldableItem($items))
return $this->_noHoldableItem();
if ( ! $record = $first_item->getNotice())
return '';
return $this->_noHoldableItem();
$hold = new Intonation_Library_Link(['Url' => $this->view->url(['controller' => 'abonne',
'action' => 'reserver',
'record_id' => $record->getId()]),
$hold = new Intonation_Library_Link(['Url' => $first_item->getHoldLink(),
'Text' => $this->_('Réserver'),
'Image' => (Class_Template::current()
->getIco($this->view,
......@@ -42,5 +40,21 @@ class Chili_View_RenderRecord_RenderItems extends Intonation_View_RenderRecord_R
return $this->view->div(['class' => 'items_hold_link'],
$this->view->tagAction($hold));
}
protected function _noHoldableItem() {
return $this->view->div(['class' => 'items_hold_link no_holdable_item'],
$this->_('Réservation impossible, pas d\'exemplaire réservable'));
}
protected function _getFirstHoldableItem($items) {
return (new Storm_Collection($items))
->detect( function($item)
{
return $item->getHoldLink();
} );
}
}
......@@ -45,7 +45,47 @@ class ChiliItemsDispatchTest extends AbstractControllerTestCase {
/** @test */
public function pageShouldContainsLinkToHold() {
$this->assertXPathContentContains('//div[@class="items_hold_link col-12 p-3 my-3 text-center"]//a[contains(@href, "abonne/reserver")]',
utf8_encode('Réserver'));
$this->assertXPathContentContains('//div[@class="items_hold_link col-12 p-3 my-3 text-center"]//a[contains(@href, "/recherche/reservation/id_int_bib/0/id_bib/0/id_notice/2")]',
utf8_encode('Réserver'),$this->_response->getBody());
}
}
class ChiliItemsNoHoldableItemsDispatchTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$this->_buildTemplateProfil(['id' => 3,
'template' => 'CHILI']);
$this->fixture('Class_Notice',
['id' => 2,
]);
$this->fixture('Class_Exemplaire',
['id' => 1,
'id_notice' => 2,
'id_bib' => 1
]);
$this->fixture('Class_Bib',
['id' => 1,
'libelle' => 'Montmin',
'interdire_resa' => 1
]);
$this->dispatch('noticeajax/items-resources/id/2');
}
/** @test */
public function pageShouldContainsNoHoldableItemMessage() {
$this->assertXPathContentContains('//div[@class="items_hold_link no_holdable_item col-12 p-3 my-3 text-center"]',
utf8_encode('Réservation impossible, pas d\'exemplaire réservable'),$this->_response->getBody());
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment