From d7099dc2fb19434649fbde5607e29c8140f0160a Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@git-test.afi-sa.fr> Date: Tue, 12 Mar 2013 14:32:53 +0000 Subject: [PATCH] OPAC Mobile: prise en compte de la configuration profil pour l'affichage des bibs, annexes, date retour et dispo --- .../controllers/RechercheController.php | 1 + .../views/scripts/recherche/exemplaires.phtml | 56 ++++++++++++------- library/Class/Exemplaire.php | 5 ++ .../telephone/skins/original/css/global.css | 26 +++++++++ .../RechercheControllerHarryPotterTest.php | 54 ++++++++++++++---- 5 files changed, 111 insertions(+), 31 deletions(-) diff --git a/application/modules/telephone/controllers/RechercheController.php b/application/modules/telephone/controllers/RechercheController.php index 3bb9f5e0601..2e704adb9a8 100644 --- a/application/modules/telephone/controllers/RechercheController.php +++ b/application/modules/telephone/controllers/RechercheController.php @@ -60,6 +60,7 @@ class Telephone_RechercheController extends RechercheController { public function exemplairesAction() { + $this->view->preferences_exemplaires = Class_Profil::getCurrentProfil()->getCfgNoticeAsArray()['exemplaires']; if (!$this->view->notice = Class_Notice::getLoader()->find($this->_getParam('id'))) $this->_redirect('/'); } diff --git a/application/modules/telephone/views/scripts/recherche/exemplaires.phtml b/application/modules/telephone/views/scripts/recherche/exemplaires.phtml index da848e67abb..016ab16522c 100644 --- a/application/modules/telephone/views/scripts/recherche/exemplaires.phtml +++ b/application/modules/telephone/views/scripts/recherche/exemplaires.phtml @@ -9,31 +9,47 @@ if (0 == count($exemplaires = $this->notice->getExemplaires())) echo $this->_('Aucun exemplaire.'); $num = 0; + +$dt_dd = '<dt>%s: </dt><dd>%s</dd>'; + foreach ($exemplaires as $exemplaire) { $sigb_exemplaire = $exemplaire->getSigbExemplaire(); ?> -<ul class="ui-listview ui-listview-inset ui-corner-all ui-shadow"> +<ul class="ui-listview ui-listview-inset ui-corner-all ui-shadow exemplaires"> <li class="ui-li ui-li-static ui-body-c ui-corner-top"> - <table style="font-weight:normal;"> - <tr><td colspan="2"><strong><?php echo $this->_('n°') . ' ' . ++$num;?></strong></td></tr> - <tr> - <td align="right"><?php echo $this->_('Bibliothèque');?> : </td> - <td><?php echo $this->escape($exemplaire->getBib()->getLibelle());?></td> - </tr> - <?php if ($cote = $exemplaire->getCote()) { ?> - <tr> - <td align="right"><?php echo $this->_('Cote');?> : </td> - <td><?php echo $this->escape($cote);?></td> - </tr> - <?php } ?> - <tr> - <td align="right"><?php echo $this->_('Disponibilité');?> : </td> - <td><?php - echo ($sigb_exemplaire) ? $sigb_exemplaire->getDisponibilite() : $this->_('non connue'); - ?></td> - </tr> - </table> + <div><?php echo $this->_('n°') . ' ' . ++$num;?></div> + <dl> + <?php + if ($this->preferences_exemplaires['bib']) + echo sprintf($dt_dd, + $this->_('Bibliothèque'), + $this->escape($exemplaire->getBib()->getLibelle())); + + if ($this->preferences_exemplaires['annexe'] && ($annexe = $exemplaire->getCodifAnnexe())) + echo sprintf($dt_dd, + $this->_('Bibliothèque'), + $this->escape($annexe->getLibelle())); + + + if ($cote = $exemplaire->getCote()) + echo sprintf($dt_dd, + $this->_('Cote'), + $this->escape($cote)); + + if ($this->preferences_exemplaires['dispo']) + echo sprintf($dt_dd, + $this->_('Disponibilite'), + $sigb_exemplaire ? $sigb_exemplaire->getDisponibilite() : $this->_('non connue')); + + $date_retour = $sigb_exemplaire ? $sigb_exemplaire->getDateRetour() : null; + if ($this->preferences_exemplaires['date_retour'] && (null != $date_retour)) + echo sprintf($dt_dd, + $this->_('Date de retour'), + $date_retour); + ?> + </dl> </li> + <li class="ui-li ui-li-static ui-body-c ui-corner-bottom"> <div class="ui-grid-a"> <div class="ui-block-a"> diff --git a/library/Class/Exemplaire.php b/library/Class/Exemplaire.php index a98aae37eef..2107b223233 100644 --- a/library/Class/Exemplaire.php +++ b/library/Class/Exemplaire.php @@ -103,6 +103,11 @@ class Class_Exemplaire extends Storm_Model_Abstract { public function getMailIntBib() { return $this->getIntBib()->getMail(); } + + + public function getCodifAnnexe() { + return Class_CodifAnnexe::findFirstBy(['code' => $this->getAnnexe()]); + } } ?> \ No newline at end of file diff --git a/public/telephone/skins/original/css/global.css b/public/telephone/skins/original/css/global.css index fac68586ea7..fdcb34578c7 100644 --- a/public/telephone/skins/original/css/global.css +++ b/public/telephone/skins/original/css/global.css @@ -163,6 +163,32 @@ form{ } +ul.exemplaires li div:first-child { + font-weight: bold; +} + +ul.exemplaires li dl { + margin: 0; + padding: 0; +} + +ul.exemplaires li dd, +ul.exemplaires li dt { + width: 49%; + margin: 0; + display: inline-block; +} + +ul.exemplaires li dt { + text-align: right; +} + +ul.exemplaires li dd { + text-align: left; +} + + + /* Lien retour au site en mode simulation */ diff --git a/tests/application/modules/telephone/controllers/RechercheControllerHarryPotterTest.php b/tests/application/modules/telephone/controllers/RechercheControllerHarryPotterTest.php index 16e96761ec4..eb687ee4e5b 100644 --- a/tests/application/modules/telephone/controllers/RechercheControllerHarryPotterTest.php +++ b/tests/application/modules/telephone/controllers/RechercheControllerHarryPotterTest.php @@ -347,15 +347,34 @@ class Telephone_RechercheControllerHarryPotterGrandeImageTest extends Telephone_ class Telephone_RechercheControllerHarryPotterExemplaireReservableTest extends Telephone_RechercheControllerHarryPotterTestCase { public function setUp() { parent::setUp(); + + Class_Profil::getCurrentProfil()->setCfgNotice(['exemplaires' => [ + 'bib' => 1, + 'annexe' => 1, + 'section' => 1, + 'emplacement' => 1, + 'dispo' => 1, + 'date_retour' => 1, + 'resa' => 1]]); + + $annexe_moulins = Class_CodifAnnexe::newInstanceWithId(4, ['code' => 'MOUL', + 'libelle' => 'Archives']); + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CodifAnnexe') + ->whenCalled('findFirstBy') + ->with(['code' => 'MOUL']) + ->answers($annexe_moulins); + + Class_Notice::find(4) ->setExemplaires([Class_Exemplaire::getLoader() - ->newInstanceWithId(33) - ->setCote('JRROW') - ->setBib(Class_Bib::getLoader() - ->newInstanceWithId(1) - ->setLibelle('Bibliotheque du florilege') - ->setInterdireResa(0)) - ]); + ->newInstanceWithId(33) + ->setCote('JRROW') + ->setAnnexe('MOUL') + ->setBib(Class_Bib::getLoader() + ->newInstanceWithId(1) + ->setLibelle('Bibliotheque du florilege') + ->setInterdireResa(0)) + ]); Storm_Test_ObjectWrapper::onLoaderOfModel('Class_IntBib') ->whenCalled('find') @@ -365,6 +384,7 @@ class Telephone_RechercheControllerHarryPotterExemplaireReservableTest extends T ->answers(Class_WebService_SIGB_Exemplaire::newInstance() ->setDisponibiliteIndisponible() ->setCodeAnnexe('MOUL') + ->setDateRetour('10/12/2013') ->beReservable())); Class_AdminVar::getLoader() @@ -377,25 +397,37 @@ class Telephone_RechercheControllerHarryPotterExemplaireReservableTest extends T /** @test */ public function pageShouldContainsOneExemplaire() { - $this->assertXPathContentContains('//td', 'n° 1', $this->_response->getBody()); + $this->assertXPathContentContains('//div', 'n° 1', $this->_response->getBody()); } /** @test */ public function pageShouldContainsBibFlorilege() { - $this->assertXPathContentContains('//td', 'Bibliotheque du florilege'); + $this->assertXPathContentContains('//dd', 'Bibliotheque du florilege'); + } + + + /** @test */ + public function pageShouldContainsAnnexeArchives() { + $this->assertXPathContentContains('//dd', 'Archives'); + } + + + /** @test */ + public function pageShouldContainsDateRetour() { + $this->assertXPathContentContains('//dd', '10/12/2013'); } /** $test */ public function pageShouldContainsCoteJRROW() { - $this->assertXPathContentContains('//td', 'JRROW'); + $this->assertXPathContentContains('//dd', 'JRROW'); } /** @test */ public function pageShouldContainsDispoIndisponible() { - $this->assertXPathContentContains('//td', 'Indisponible'); + $this->assertXPathContentContains('//dd', 'Indisponible'); } -- GitLab