From 932bd9d0eb10bd63b0f34c20b7682a65c00446fb Mon Sep 17 00:00:00 2001
From: efalcy <efalcy@afi-sa.fr>
Date: Wed, 20 Jan 2021 10:38:38 +0100
Subject: [PATCH] hotline MT #121123 : fix error on popup on PNB loan

---
 VERSIONS_HOTLINE/121123                         |  1 +
 .../templates/Intonation/View/RenderAjax.php    |  1 +
 .../Templates/TemplatesRecordsTest.php          | 14 +++++++++++++-
 tests/scenarios/Templates/TemplatesTest.php     | 17 -----------------
 4 files changed, 15 insertions(+), 18 deletions(-)
 create mode 100644 VERSIONS_HOTLINE/121123

diff --git a/VERSIONS_HOTLINE/121123 b/VERSIONS_HOTLINE/121123
new file mode 100644
index 00000000000..34f5193553c
--- /dev/null
+++ b/VERSIONS_HOTLINE/121123
@@ -0,0 +1 @@
+ - ticket #121123 : Magasin de thèmes : correction de la cinématique d'emprunt des documents PNB
\ No newline at end of file
diff --git a/library/templates/Intonation/View/RenderAjax.php b/library/templates/Intonation/View/RenderAjax.php
index e5d4391fdaa..c54e0a66f3c 100644
--- a/library/templates/Intonation/View/RenderAjax.php
+++ b/library/templates/Intonation/View/RenderAjax.php
@@ -28,6 +28,7 @@ class Intonation_View_RenderAjax extends ZendAfi_View_Helper_BaseHelper {
                         'action' => $action],
                        $params);
 
+    $js_callback .= 'initializePopups();setupAnchorsTarget()';
 
     if (($ig = Zend_Controller_Front::getInstance()
          ->getPlugin('ZendAfi_Controller_Plugin_InspectorGadget'))
diff --git a/tests/scenarios/Templates/TemplatesRecordsTest.php b/tests/scenarios/Templates/TemplatesRecordsTest.php
index 92c2e615b8f..1d9057b3803 100644
--- a/tests/scenarios/Templates/TemplatesRecordsTest.php
+++ b/tests/scenarios/Templates/TemplatesRecordsTest.php
@@ -361,4 +361,16 @@ class TemplateRecordsViewnoticeBadgesTest extends TemplateRecordsWithDescription
   public function badgeFacetGenreShouldHaveClassesBadgePrimary() {
     $this->assertXPath('//div[contains(@class, "badge-group")]//a[@class = "badge_tag record_facets record_facet_genre text-left badge badge-primary"]');
   }
-}
\ No newline at end of file
+}
+
+
+
+
+class TemplatesDispatchRecordItemsTest extends TemplatesRecordsWidgetTestCase {
+
+  /** @test */
+  public function shouldRenderAjaxLoadWithInitializePopupAndSetupAnchorTarget() {
+    $this->dispatch('/record/items/id/1/id_profil/1');
+    $this->assertXPathContentContains('//script', 'load("/noticeajax/author/id/1/id_profil/1", function() {if ($(\'.document_author .jumbotron_section_content [data-ajax-content] > *\').length) { $(\'.document_author\').removeClass(\'d-none text-black-50 disabled\'); $(\'.loading_icon\').parent().remove(); }initializePopups();setupAnchorsTarget();})');
+  }
+}
diff --git a/tests/scenarios/Templates/TemplatesTest.php b/tests/scenarios/Templates/TemplatesTest.php
index e4c45685230..faf10cddf1d 100644
--- a/tests/scenarios/Templates/TemplatesTest.php
+++ b/tests/scenarios/Templates/TemplatesTest.php
@@ -1559,23 +1559,6 @@ class TemplatesDispatchRecordAuthorTest extends TemplatesIntonationTestCase {
 
 
 
-class TemplatesDispatchRecordItemsTest extends TemplatesIntonationTestCase {
-
-  /** @test */
-  public function shouldRenderDescription() {
-    $record = $this->fixture('Class_Notice',
-                             ['id' => 456,
-                              'type_doc' => 8,
-                              'clef_oeuvre' => 'THE BOOK OF SOULS',
-                              'facettes' => 'G13 M12']);
-
-    $this->dispatch('/record/items/id/456/id_profil/72');
-    $this->assertXPath('//div');
-  }
-}
-
-
-
 
 class TemplatesNoticeajaxMediaDispatchTest extends TemplatesIntonationTestCase {
   public function setUp() {
-- 
GitLab