From 96c952893995f65b16fa161322b1dbee4a00ba73 Mon Sep 17 00:00:00 2001 From: Laurent Laffont <llaffont@afi-sa.fr> Date: Tue, 27 Nov 2018 10:58:22 +0100 Subject: [PATCH] dev #82369 improve domain administration usability --- .../admin/controllers/CatalogueController.php | 12 ++-- .../scripts/catalogue/_catalogue_row.phtml | 12 ++-- .../admin/views/scripts/catalogue/form.phtml | 27 +++++++-- .../views/scripts/catalogue/paniers.phtml | 32 ++++++++++ .../views/scripts/catalogue/tester.phtml | 54 +++++------------ .../controllers/CatalogueControllerTest.php | 59 +++++++++++++++++-- 6 files changed, 138 insertions(+), 58 deletions(-) diff --git a/application/modules/admin/controllers/CatalogueController.php b/application/modules/admin/controllers/CatalogueController.php index 55427b31337..727c710dd8a 100644 --- a/application/modules/admin/controllers/CatalogueController.php +++ b/application/modules/admin/controllers/CatalogueController.php @@ -41,24 +41,24 @@ class Admin_CatalogueController extends ZendAfi_Controller_Action { $this->_redirect("admin/catalogue/index"); $ret = ['requete' => '', - 'temps_execution' => '', 'nb_notices' => 0, 'avec_vignettes' => 0, 'notices' => '']; $ret = array_merge($ret, $catalogue->getTestCatalogue()); - $catalogue->isIndexable() - ? $catalogue->index() - : $this->view->error = $this->_('Le domaine ne ne peut pas être mis en favori utilisateur sans critères d\'indexation'); + if ($catalogue->isIndexable()) + $catalogue->index(); + + if (!$catalogue->isIndexable() && ($catalogue->numberOfPanierNotices() == 0)) + $this->view->error = $this->_('Le domaine ne peut pas être mis en favori utilisateur sans critères d\'indexation'); $this->view->requete = $ret["requete"]; - $this->view->temps_execution = $ret["temps_execution"] . " secs."; $this->view->nb_notices = $ret["nb_notices"]; $this->view->avec_vignettes = $ret["avec_vignettes"]; $this->view->notices = $ret["notices"]; $this->view->catalogue = $catalogue; - $this->view->titre = $this->_('Test du domaine: %s', $catalogue->getLibelle()); + $this->view->titre = $this->_('Indexation du domaine: %s', $catalogue->getLibelle()); } diff --git a/application/modules/admin/views/scripts/catalogue/_catalogue_row.phtml b/application/modules/admin/views/scripts/catalogue/_catalogue_row.phtml index 23eb183b456..3b16c8d1c27 100644 --- a/application/modules/admin/views/scripts/catalogue/_catalogue_row.phtml +++ b/application/modules/admin/views/scripts/catalogue/_catalogue_row.phtml @@ -9,7 +9,7 @@ $editable = $catalog->canBeDeletedOrModifyByUser($user); <div class="actions"> <?php $actions = [ - ['action' => 'tester', 'icon' => 'test', 'help' => $this->_('Tester')], + ['action' => 'tester', 'icon' => 'test', 'help' => $this->_('Indexer les notices')], ['action' => 'edit', 'icon' => 'edit', 'help' => $this->_('Modifier'), 'display' => $editable], ['action' => 'duplicate', 'icon' => 'copy', 'help' => $this->_('Dupliquer')], ['action' => 'add', 'icon' => 'add_page', 'help' => $this->_('Ajouter un sous-domaine'), 'display' => $editable], @@ -32,11 +32,11 @@ $editable = $catalog->canBeDeletedOrModifyByUser($user); echo $this->tag('a', $this->boutonIco('type=del'), ['href' => BASE_URL . '/admin/catalogue/delete/id_catalogue/'.$catalog->getId()]); - $catalogue_url = $this->absoluteUrl(['module' => 'opac', - 'controller' => 'recherche', - 'action' => 'simple', - 'id_catalogue' => $catalog->getId()], - null, true); + $catalogue_url = $this->url(['module' => 'opac', + 'controller' => 'recherche', + 'action' => 'simple', + 'id_catalogue' => $catalog->getId()], + null, true); echo $this->tagPreview($catalogue_url, $this->_('Visualiser le domaine "%s" dans un nouvel onglet', $catalog->getLibelle())); diff --git a/application/modules/admin/views/scripts/catalogue/form.phtml b/application/modules/admin/views/scripts/catalogue/form.phtml index 42effded8e2..6de346cf616 100644 --- a/application/modules/admin/views/scripts/catalogue/form.phtml +++ b/application/modules/admin/views/scripts/catalogue/form.phtml @@ -1,15 +1,34 @@ <?php -if(!$this->catalogue->isNew()) +if(!$this->catalogue->isNew()) { echo $this->tag('div', $this->tagAnchor($this->url(['action' => 'tester', 'id_catalogue' => $this->catalogue->getId()]), Class_Admin_Skin::current() ->renderActionIconOn('test', $this, - ['alt' => $this->_('Tester'), - 'title' => $this->_('Tester le catalogue "%s"', + ['alt' => $this->_('Indexer les notices'), + 'class' => 'ico', + 'title' => $this->_('Indexer les notices du domaine "%s"', $this->catalogue->getLibelle())]), - ['data-popup' => true]), + ['data-popup' => 'true']) + . + $this->tagAnchor($this->url(['action' => 'paniers', + 'id_catalogue' => $this->catalogue->getId()]), + Class_Admin_Skin::current() + ->renderActionIconOn('basket', + $this, + ['alt' => $this->_('Paniers'), + 'class' => 'ico', + 'title' => $this->_('Paniers rattachés au domaine "%s"', + $this->catalogue->getLibelle())])) + . + $this->tagPreview($this->url(['module' => 'opac', + 'controller' => 'recherche', + 'action' => 'simple', + 'id_catalogue' => $this->catalogue->getId()], + null, true), + $this->_('Visualiser le domaine "%s" dans un nouvel onglet', $this->catalogue->getLibelle())), ['class' => 'header_actions']); +} echo $this->renderForm($this->form); diff --git a/application/modules/admin/views/scripts/catalogue/paniers.phtml b/application/modules/admin/views/scripts/catalogue/paniers.phtml index 1f4d0643c30..7173e03b822 100644 --- a/application/modules/admin/views/scripts/catalogue/paniers.phtml +++ b/application/modules/admin/views/scripts/catalogue/paniers.phtml @@ -1,3 +1,35 @@ +<?php + echo $this->tag('div', + $this->tagAnchor($this->url(['action' => 'tester', + 'id_catalogue' => $this->catalogue->getId()]), + Class_Admin_Skin::current() + ->renderActionIconOn('test', + $this, + ['alt' => $this->_('Indexer les notices'), + 'class' => 'ico', + 'title' => $this->_('Indexer les notices du domaine "%s"', + $this->catalogue->getLibelle())]), + ['data-popup' => 'true']) + . + $this->tagAnchor($this->url(['action' => 'edit', + 'id_catalogue' => $this->catalogue->getId()]), + Class_Admin_Skin::current() + ->renderActionIconOn('edit', + $this, + ['alt' => $this->_('Modifier'), + 'class' => 'ico', + 'title' => $this->_('Modifier le domaine "%s"', + $this->catalogue->getLibelle())])) + . + $this->tagPreview($this->url(['module' => 'opac', + 'controller' => 'recherche', + 'action' => 'simple', + 'id_catalogue' => $this->catalogue->getId()], + null, true), + $this->_('Visualiser le domaine "%s" dans un nouvel onglet', $this->catalogue->getLibelle())), + ['class' => 'header_actions']); + +?> <ul> <?php diff --git a/application/modules/admin/views/scripts/catalogue/tester.phtml b/application/modules/admin/views/scripts/catalogue/tester.phtml index f38132fda15..d8ecc23ac93 100644 --- a/application/modules/admin/views/scripts/catalogue/tester.phtml +++ b/application/modules/admin/views/scripts/catalogue/tester.phtml @@ -10,46 +10,24 @@ if (!$this->notices) else { echo $this->ligneInfos($this->_('Notices trouvées'), $this->nb_notices); echo $this->ligneInfos($this->_('Avec vignettes en cache'), $this->avec_vignettes); - echo $this->ligneInfos($this->_('Temps d\'éxécution de la requête'), $this->temps_execution); } -if ($this->notices) { ?> - <br> - <table cellspacing="0" cellpadding="0"> - <tr class="soustitre"> - <td style="width:2%;"> </td> - <td style="width:60%"><?php echo $this->_('Titre'); ?></td> - <td style="width:38%"><?php echo $this->_('Auteur'); ?></td> - </tr> - <tr><td colspan="6" class="separ"></td></tr> -<?php - $ligne = 0; - foreach ($this->notices as $notice) - { - $ligne ++; - if ($ligne & 1) - $class="first"; - else - $class="second"; - echo '<tr class="' . $class . '">' . - '<td align="center" style="padding:3px 5px 3px 0px">'.$this->iconeSupport($notice->getTypeDoc()).'</td>' . - '<td>' . $notice->getTitrePrincipal() . '</td>'. - '<td>' . $notice->getAuteurPrincipal() . '</td> - </tr>'; - } - echo '<tr><td colspan="6" class="separ"></td></tr>'; - echo '</table>'; - echo '<p style="margin-top:1px;"><small>' . $this->_('Information : Affichage des 20 premières notices uniquement...') . '</small></p> '; -} ?> +if ($this->notices) { + echo $this->listeNotices_Tableau($this->notices, + ['liste_codes' => 'T;J;A;N']); +} - <br> -<?php + +echo $this->tag('p', + $this->_('Information : Affichage des 20 premières notices uniquement...')); + +if (!$this->isPopup()) echo $this->button((new Class_Entity()) - ->setText($this->_('Modifier le domaine ')) - ->setAttribs(['title' => $this->_('Modifier le domaine : %s', - $this->catalogue->getLibelle())]) - ->setUrl($this->url(['action' => 'edit', - 'id_catalogue' => $this->catalogue->getId()])) - ->setImage($this->tagImg(Class_Admin_Skin::current() - ->getIconUrl('buttons', 'configuration')))); + ->setText($this->_('Modifier le domaine ')) + ->setAttribs(['title' => $this->_('Modifier le domaine : %s', + $this->catalogue->getLibelle())]) + ->setUrl($this->url(['action' => 'edit', + 'id_catalogue' => $this->catalogue->getId()])) + ->setImage($this->tagImg(Class_Admin_Skin::current() + ->getIconUrl('buttons', 'configuration')))); diff --git a/tests/application/modules/admin/controllers/CatalogueControllerTest.php b/tests/application/modules/admin/controllers/CatalogueControllerTest.php index 4cd4b102993..4af3bf2b2f5 100644 --- a/tests/application/modules/admin/controllers/CatalogueControllerTest.php +++ b/tests/application/modules/admin/controllers/CatalogueControllerTest.php @@ -154,6 +154,9 @@ abstract class AdminCatalogueControllerTestCase extends AbstractControllerTestCa ->answers(10) ->whenCalled('fetchAll') + ->answers(null) + + ->whenCalled('query') ->answers(null); $this->_catalogue_adultes->setThesaurus('THEM123;GENR231'); @@ -546,7 +549,7 @@ class CatalogueControllerWithAModoBibWithRightAccesDomainesIndexTest extends Adm -class CatalogueControllerActionTesterNoIndexationTest extends AbstractControllerTestCase { +class CatalogueControllerActionTesterNoIndexationTest extends AdminCatalogueControllerTestCase { protected $_storm_default_to_volatile = true; @@ -566,17 +569,33 @@ class CatalogueControllerActionTesterNoIndexationTest extends AbstractController 'type_doc' => '', 'indexer' =>true]); - $this->dispatch('admin/catalogue/tester/id_catalogue/6', true); } -/** @test */ + + /** @test */ public function withNoCriteriaShouldDisplayNoIndexationPossible() { - $this->assertXPathContentContains('//p[@class="error"]','Le domaine ne ne peut pas être mis en favori utilisateur sans critères d\'indexation'); + $this->dispatch('admin/catalogue/tester/id_catalogue/6', true); + + $this->assertXPathContentContains('//p[@class="error"]','Le domaine ne peut pas être mis en favori utilisateur sans critères d\'indexation'); } + + /** @test */ + public function withBasketsShouldNotDisplayNoIndexationPossible() { + Class_Catalogue::find(6) + ->addPanierNotice($this->fixture('Class_PanierNotice', + ['id' => 9])) + ->assertSave(); + + $this->dispatch('admin/catalogue/tester/id_catalogue/6', true); + + $this->assertNotXPathContentContains('//p[@class="error"]','Le domaine ne peut pas'); + } } + + class CatalogueControllerActionTesterTest extends AbstractControllerTestCase { protected $_storm_default_to_volatile = true; @@ -627,6 +646,8 @@ class CatalogueControllerActionTesterTest extends AbstractControllerTestCase { class CatalogueControllerActionTesterWithEmptyDomainTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + protected function _loginHook($account) { $account->ROLE_LEVEL = ZendAfi_Acl_AdminControllerRoles::SUPER_ADMIN; } @@ -791,6 +812,18 @@ class CatalogueControllerEditCatalogueTest extends AdminCatalogueControllerTestC public function shouldContainsPopupLinkToTestAction() { $this->assertXPath('//a[contains(@href, "/tester/id_catalogue/6")][@data-popup]'); } + + + /** @test */ + public function pageShouldContainsLinkToBaskets() { + $this->assertXPath('//a[contains(@href, "/paniers/id_catalogue/6")]'); + } + + + /** @test */ + public function pageShouldContainsLinkToPreview() { + $this->assertXPath('//a[contains(@href, "/recherche/simple/id_catalogue/6")]'); + } } @@ -1306,6 +1339,24 @@ class CatalogueControllerPaniersHistoireTest extends AdminCatalogueControllerTes public function pageShouldContainsPanierPreview() { $this->assertXPath('//a[contains(@href, "recherche/simple/id_panier/8")]'); } + + + /** @test */ + public function shouldContainsPopupLinkToTestAction() { + $this->assertXPath('//a[contains(@href, "/tester/id_catalogue/100")][@data-popup]'); + } + + + /** @test */ + public function pageShouldContainsLinkToEdit() { + $this->assertXPath('//a[contains(@href, "/edit/id_catalogue/100")]'); + } + + + /** @test */ + public function pageShouldContainsLinkToPreview() { + $this->assertXPath('//a[contains(@href, "/recherche/simple/id_catalogue/100")]'); + } } -- GitLab