From f1cc0d55c661bc10f257ae9c3c1faa672aa46277 Mon Sep 17 00:00:00 2001 From: gloas <gloas@git-test.afi-sa.fr> Date: Tue, 4 Jun 2013 09:45:18 +0000 Subject: [PATCH] Skin: modification du hover sur la page resultat de recherche en mode Mur: tooltip avec le resume et la disponibilite --- .../opac/controllers/NoticeajaxController.php | 4 ++ library/Class/Exemplaire.php | 7 +++ library/Class/IntBib.php | 5 +- library/Class/Notice.php | 7 +++ library/Class/WebService/SIGB/Exemplaire.php | 4 ++ library/ZendAfi/View/Helper/ListeNotices.php | 6 +++ library/ZendAfi/View/Helper/Notice/Mur.php | 14 ++++-- .../ZendAfi/View/Helper/Notice/Vignette.php | 4 +- public/opac/css/global.css | 32 ++++++++++++- .../controllers/NoticeAjaxControllerTest.php | 47 ++++++++++++++++++- 10 files changed, 121 insertions(+), 9 deletions(-) diff --git a/application/modules/opac/controllers/NoticeajaxController.php b/application/modules/opac/controllers/NoticeajaxController.php index 9ccff1f3b5b..77f9d431289 100644 --- a/application/modules/opac/controllers/NoticeajaxController.php +++ b/application/modules/opac/controllers/NoticeajaxController.php @@ -193,6 +193,10 @@ class NoticeAjaxController extends Zend_Controller_Action { $this->_sendResponse($resume); } + public function dispoNoticeAction() { + $this->_sendResponse($this->notice->isDisponible() ? 'true' : 'false'); + } + public function vignetteAction() { session_write_close(); diff --git a/library/Class/Exemplaire.php b/library/Class/Exemplaire.php index 2107b223233..23a473ebcb2 100644 --- a/library/Class/Exemplaire.php +++ b/library/Class/Exemplaire.php @@ -108,6 +108,13 @@ class Class_Exemplaire extends Storm_Model_Abstract { public function getCodifAnnexe() { return Class_CodifAnnexe::findFirstBy(['code' => $this->getAnnexe()]); } + + public function isDisponible() { + $sigbExemplaire = $this->getSigbExemplaire(); + if (null == $sigbExemplaire) + return false; + return $sigbExemplaire->isDisponible(); + } } ?> \ No newline at end of file diff --git a/library/Class/IntBib.php b/library/Class/IntBib.php index f82e4900a0d..e471f5fd69a 100644 --- a/library/Class/IntBib.php +++ b/library/Class/IntBib.php @@ -105,7 +105,10 @@ class Class_IntBib extends Storm_Model_Abstract { public function getSigbExemplaire($id_origine, $code_barres) { - return $this->getSIGBComm()->getExemplaire($id_origine, $code_barres); + $comm = $this->getSIGBComm(); + if (null == $comm) + return null; + return $comm->getExemplaire($id_origine, $code_barres); } } diff --git a/library/Class/Notice.php b/library/Class/Notice.php index e6ff9d5f19e..062dc749b05 100644 --- a/library/Class/Notice.php +++ b/library/Class/Notice.php @@ -1683,6 +1683,13 @@ class Class_Notice extends Storm_Model_Abstract { return $enreg; } + + public function isDisponible() { + foreach ($this->getExemplaires() as $exemplaire) + if ($exemplaire->isDisponible()) + return true; + return false; + } } ?> \ No newline at end of file diff --git a/library/Class/WebService/SIGB/Exemplaire.php b/library/Class/WebService/SIGB/Exemplaire.php index a4663f13379..79d41d93985 100644 --- a/library/Class/WebService/SIGB/Exemplaire.php +++ b/library/Class/WebService/SIGB/Exemplaire.php @@ -410,6 +410,10 @@ class Class_WebService_SIGB_Exemplaire { return (null !== $this->getId()); } + public function isDisponible() { + return self::DISPO_LIBRE == $this->disponibilite; + } + /** @codeCoverageIgnore */ public function __toString(){ diff --git a/library/ZendAfi/View/Helper/ListeNotices.php b/library/ZendAfi/View/Helper/ListeNotices.php index 7f2f419566d..9e79054c081 100644 --- a/library/ZendAfi/View/Helper/ListeNotices.php +++ b/library/ZendAfi/View/Helper/ListeNotices.php @@ -236,6 +236,12 @@ class ZendAfi_View_Helper_ListeNotices extends ZendAfi_View_Helper_BaseHelper { // Format 4 : Mur //------------------------------------------------------------------------------------------------------ public function listeMur($data) { + Class_ScriptLoader::getInstance() + ->addInlineScript("var resumeAjaxBaseUrl='".$this->view->url(['controller' => 'noticeajax', 'action' => 'resumenotice'])."';") + ->addInlineScript("var disponibiliteAjaxBaseUrl='".$this->view->url(['controller' => 'noticeajax', 'action' => 'dispo-notice'], null, true)."';") + ->addOPACScript('liste_notices_mur') + ->addJQueryReady("vignetteHover($('.liste_mur .notice[data-id]'));"); + $notices = []; foreach($data as $notice) $notices []= $this->view->notice_Mur($notice); diff --git a/library/ZendAfi/View/Helper/Notice/Mur.php b/library/ZendAfi/View/Helper/Notice/Mur.php index 027afeccc13..76cb58e6f80 100644 --- a/library/ZendAfi/View/Helper/Notice/Mur.php +++ b/library/ZendAfi/View/Helper/Notice/Mur.php @@ -30,12 +30,16 @@ class ZendAfi_View_Helper_Notice_Mur extends Zend_View_Helper_HtmlElement { $this->view->notice_LienRebondAuteur($notice), $notice->getAuteurPrincipal()); - return - '<div class="notice_wrapper"><div class="notice" data-id="'.$notice->getId().'" data-type="'.$notice->getTypeDoc().'">' - .'<div>'.$this->view->iconeSupport($notice->getTypeDoc()).'</div>' - .$vignette - .'<div class="titre_auteur">'.$datas.'</div>' + + $html= + '<div class="notice_wrapper">'. + '<div class="notice" data-id="'.$notice->getId().'" data-type="'.$notice->getTypeDoc().'">'. + '<div>'.$this->view->iconeSupport($notice->getTypeDoc()).'</div>'. + $vignette. + '<div class="titre_auteur">'.$datas.'</div>' .'</div></div>'; + + return $html; } } diff --git a/library/ZendAfi/View/Helper/Notice/Vignette.php b/library/ZendAfi/View/Helper/Notice/Vignette.php index 868c6777cdb..d0467e1c70a 100644 --- a/library/ZendAfi/View/Helper/Notice/Vignette.php +++ b/library/ZendAfi/View/Helper/Notice/Vignette.php @@ -34,9 +34,11 @@ class ZendAfi_View_Helper_Notice_Vignette extends Zend_View_Helper_HtmlElement { return '<div class="nothumbnail_wrapper">'. '<div class="nothumbnail type_doc_'.$notice->getTypeDoc().'" onclick="javascript:window.location=\''.$url.'\'">'. + '<img src="'.URL_ADMIN_IMG.'blank.gif'.'" title="" alt=""/>'. '<a href="'.$url.'">'. + '<div>'.$notice->getAuteurPrincipal().'</div>'. - '<div>'.$notice->getTitrePrincipal().'</div>'. + '<div>'.$notice->getTitrePrincipal().'</div>'. '</a>'. '</div>'. '</div>'; diff --git a/public/opac/css/global.css b/public/opac/css/global.css index e67bf06fed4..4a6a4a601bc 100644 --- a/public/opac/css/global.css +++ b/public/opac/css/global.css @@ -1366,6 +1366,13 @@ body.abonne_multimedia-hold-view .actions a { box-shadow: 0px 10px 30px rgba(0,0,0,0.5); } +.liste_mur .nothumbnail img { + position: absolute; + top:5px; + left:5px; + height:120px; + width: 100px; +} /* entete notice */ .entete_notice dl, .blocs_notice dl{ @@ -1722,8 +1729,31 @@ button.vodeclic_link + img { content:'» '; } +/* Mur Tooltip */ +.notice-mur-tooltip { + position: absolute; + overflow:hidden; + width: 200px; + z-index: 90; +} +.notice-mur-tooltip span { + float:left; + clear:both; + margin:5px; + font-weight: bold; +} + +.notice-mur-tooltip .resume { + overflow:hidden; + max-height: 90px; + font-weight:normal; +} + +.notice-mur-tooltip .dispo , .notice-mur-tooltip .disponible{ + clear:both; +} /** historique recherche */ #contenu .recherche_saisie .criteres_recherche ul { @@ -1751,4 +1781,4 @@ button.vodeclic_link + img { .criteres_recherche ul { margin-bottom: 5px; padding-left: 20px; -} \ No newline at end of file +} diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php index fa1324d317d..56ef977d5cc 100644 --- a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php +++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php @@ -608,7 +608,52 @@ class NoticeAjaxControllerResumeNoticeTest extends AbstractControllerTestCase { $this->dispatch('/noticeajax/resumenotice?id_notice=123',true); $this->assertXPathContentContains('//body', 'homme qui habite dans la jungle',$this->_response->getBody()); } +} + +class NoticeAjaxControllerDisponibiliteNoticeTest extends AbstractControllerTestCase { + protected $_notice; + + public function setUp() { + parent::setUp(); + + $this->_notice = Class_Notice::getLoader() + ->newInstanceWithId(123) + ->setTitrePrincipal('Tarzan') + ->setExemplaires([]); + } + /** @test */ + public function withoutExemplaireShouldNotBeAvailable () { + $this->assertAvailability('false'); + } + + /** @test */ + public function withNonAvailableExemplaireShouldNotBeAvailable() { + $this->prepareExemplaireWithAvailability(false); + $this->assertAvailability('false'); + } + + /** @test */ + public function withAvailableExemplaireShouldBeAvailable() { + $this->prepareExemplaireWithAvailability(true); + $this->assertAvailability('true'); + } + + private function assertAvailability($available) { + $this->dispatch('/noticeajax/dispo-notice?id_notice=123',true); + $this->assertXPathContentContains('//body', $available, $this->_response->getBody()); + } + + private function prepareExemplaireWithAvailability($availability) { + $this->_notice->setExemplaires([Class_Exemplaire::getLoader() + ->newInstanceWithId(34) + ->setIdBib('456') + ->setIdOrigine('12') + ->setCodeBarres('12256663233656') + ->setSigbExemplaire(Storm_Test_ObjectWrapper::mock() + ->whenCalled('isDisponible') + ->answers($availability))]); + } } -?> +?> \ No newline at end of file -- GitLab