From 91b728634b69a72889d0da9295d6e63188800a85 Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Tue, 9 Mar 2021 11:37:38 +0100 Subject: [PATCH] hotline #128703 upgrade pnb actions links behavior to avoid popup issues --- VERSIONS_HOTLINE/128703 | 1 + .../scripts/bib-numerique/loan-book.phtml | 3 + .../ZendAfi/View/Helper/TagDilicomWidget.php | 6 +- public/opac/css/core.css | 4 + public/opac/js/subModal.js | 3 + .../TemplateDigitalResourcesTest.php | 105 ++++++++++++++++++ 6 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 VERSIONS_HOTLINE/128703 diff --git a/VERSIONS_HOTLINE/128703 b/VERSIONS_HOTLINE/128703 new file mode 100644 index 00000000000..a32858e3bd2 --- /dev/null +++ b/VERSIONS_HOTLINE/128703 @@ -0,0 +1 @@ + - ticket #128703 : Amélioration du comportement des liens d'emprunt et de consultation des ressources PNB. \ No newline at end of file diff --git a/application/modules/opac/views/scripts/bib-numerique/loan-book.phtml b/application/modules/opac/views/scripts/bib-numerique/loan-book.phtml index 002edf7c13e..a94ff7751ae 100644 --- a/application/modules/opac/views/scripts/bib-numerique/loan-book.phtml +++ b/application/modules/opac/views/scripts/bib-numerique/loan-book.phtml @@ -1,5 +1,8 @@ <?php +Class_ScriptLoader::getInstance() +->addOPACScript('subModal') +->addJQueryReady('initializeAjaxFormSubmit($("#pnb_devices"));'); $html = [$this->renderForm($this->form)]; diff --git a/library/ZendAfi/View/Helper/TagDilicomWidget.php b/library/ZendAfi/View/Helper/TagDilicomWidget.php index 10067764473..0ddd75efe01 100644 --- a/library/ZendAfi/View/Helper/TagDilicomWidget.php +++ b/library/ZendAfi/View/Helper/TagDilicomWidget.php @@ -78,7 +78,8 @@ class ZendAfi_View_Helper_TagDilicomWidget extends ZendAfi_View_Helper_BaseHelpe 'action' => $this->_getConsultBookAction(), 'id' => $this->_album->getId()], $this->_('Consulter le livre en ligne (depuis la médiathèque)'), - ['data-popup' => 'true']); + ['data-popup' => 'true', + 'data-disabled' => 1]); } @@ -126,7 +127,8 @@ class ZendAfi_View_Helper_TagDilicomWidget extends ZendAfi_View_Helper_BaseHelpe 'action' => $this->_getLoanBookAction(), 'id' => $this->_album->getId()], $this->_('Emprunter le livre au format EPUB'), - ['data-popup' => 'true']); + ['data-popup' => 'true', + 'data-disabled' => true]); if (!$this->_user) return $loanBookAnchor; diff --git a/public/opac/css/core.css b/public/opac/css/core.css index 965ae8cfe89..d78457c6c02 100644 --- a/public/opac/css/core.css +++ b/public/opac/css/core.css @@ -190,3 +190,7 @@ label.required:after { .dropdown-menu .dropdown-menu { position: unset !important; } + +[data-disabled] { + pointer-events: none !important; +} diff --git a/public/opac/js/subModal.js b/public/opac/js/subModal.js index 4c0bde278d9..057ed2c22ac 100644 --- a/public/opac/js/subModal.js +++ b/public/opac/js/subModal.js @@ -6,6 +6,9 @@ var on_open_listeners = []; window.initializePopups = function() { + $('[data-popup="true"][data-disabled], [data-popup="1"][data-disabled]') + .removeAttr('data-disabled'); + $('[data-popup="true"], [data-popup="1"]') .prop('onclick', null) .off('click') diff --git a/tests/scenarios/Templates/TemplateDigitalResourcesTest.php b/tests/scenarios/Templates/TemplateDigitalResourcesTest.php index 2c311125ff8..ae31c828753 100644 --- a/tests/scenarios/Templates/TemplateDigitalResourcesTest.php +++ b/tests/scenarios/Templates/TemplateDigitalResourcesTest.php @@ -20,6 +20,8 @@ */ +require_once 'tests/fixtures/DilicomFixtures.php'; + class TemplateDigitalResourcesDispatchTest extends AbstractControllerTestCase { protected $_storm_default_to_volatile = true; @@ -132,3 +134,106 @@ class TemplateDigitalResourcesMediaAndTrailerDispatchTest extends AbstractContro $this->assertXPathContentContains('//script', 'initializePopups();'); } } + + + + +abstract class TemplateDigitalResourcesDilicomTestCase extends AbstractControllerTestCase { + + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + + $this->_buildTemplateProfil(['id' => 9, + 'template' => 'MUSCLE']); + + $this->fixture('Class_Bib', + ['id' => 1, + 'libelle' => 'annecy', + 'gln' => '2222' + ]); + + $group = $this->fixture('Class_UserGroup', + ['id' => '20', + 'libelle' => 'Multimedia', + 'rights' => [Class_UserGroup::RIGHT_ACCES_PNB_DILICOM]]); + + $logged_user = $this->fixture('Class_Users', + ['id' => 6, + 'nom'=>'Pito', + 'login'=>'Chat', + 'password'=>'123456', + 'id_site' => 1, + 'idabon' => '12345', + 'user_groups' => [$group]]); + + $logged_user->beAbonneSIGB()->assertSave(); + ZendAfi_Auth::getInstance()->logUser($logged_user); + + $this->fixture('Class_Album', + ['id' => 34, + 'titre' => 'La Planète des chats', + 'type_doc_id' => Class_TypeDoc::LIVRE_NUM]); + } +} + + + + +class TemplateDigitalResourcesLoanBookAjaxTest extends TemplateDigitalResourcesDilicomTestCase { + + public function setUp() { + parent::setUp(); + $this->dispatch('bib-numerique/loan-book-ajax/id/34'); + } + + + /** @test */ + public function subModalJSShouldBeLoaded() { + $this->assertXPath('//script[contains(@src, "public/opac/js/subModal.js")]'); + } + + + /** @test */ + public function initializeAjaxFormSubmitShouldBePresent() { + $this->assertXPathContentContains('//script', 'initializeAjaxFormSubmit($("#pnb_devices"));'); + } +} + + + + +class TemplateDigitalResourcesDilicomItemTest extends TemplateDigitalResourcesDilicomTestCase { + + public function setUp() { + parent::setUp(); + + $this->fixture('Class_Notice', + ['id' => 123, + 'type_doc' => Class_TypeDoc::LIVRE_NUM]); + + $this->fixture('Class_Exemplaire', + ['id' => 8, + 'id_origine' => 3, + 'id_notice' => 123]); + + (new DilicomFixtures())->albumTotemThora(); + RessourcesNumeriquesFixtures::activateDilicom(); + + $this->dispatch('noticeajax/digital-resources/id_notice/123'); + } + + + /** @test */ + public function loanLinkShouldBeDisabled() { + $this->assertXPathContentContains('//a[@data-disabled]', 'Emprunter le livre au format EPUB'); + } + + + /** @test */ + public function consultLinkShouldBeDisabled() { + $this->assertXPathContentContains('//a[@data-disabled]', 'Consulter le livre en ligne'); + } +} \ No newline at end of file -- GitLab