diff --git a/VERSIONS_HOTLINE/126937 b/VERSIONS_HOTLINE/126937 new file mode 100644 index 0000000000000000000000000000000000000000..044beb6c0d98f6590d835e0dce2a930233584324 --- /dev/null +++ b/VERSIONS_HOTLINE/126937 @@ -0,0 +1 @@ + - ticket #126937 : Magasin de thèmes : amélioration de l'affichage de la liste des prêts vide. \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/Abstract.php b/library/templates/Intonation/Library/View/Wrapper/Abstract.php index 1cb748f6f421008efd88aea297b67e51be130359..e9744ae38a3041815ca1ed3b2882570256566346 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Abstract.php +++ b/library/templates/Intonation/Library/View/Wrapper/Abstract.php @@ -97,6 +97,22 @@ abstract class Intonation_Library_View_Wrapper_Abstract { } + /** @return string */ + public function getPreviousItem() { + return ($rich_content = $this->getRichContent()) + ? $rich_content->getPreviousItem() + : ''; + } + + + /** @return string */ + public function getNextItem() { + return ($rich_content = $this->getRichContent()) + ? $rich_content->getNextItem() + : ''; + } + + public function inJsSearch() { $this->_in_js_search = true; return $this; @@ -135,6 +151,14 @@ abstract class Intonation_Library_View_Wrapper_Abstract { } + /** @return string */ + public function getRichContentActions() { + return ($rich_content = $this->getRichContent()) + ? $rich_content->getActions() + : ''; + } + + /** @return string */ abstract public function getMainTitle(); diff --git a/library/templates/Intonation/Library/View/Wrapper/RichContent/Abstract.php b/library/templates/Intonation/Library/View/Wrapper/RichContent/Abstract.php index 905370e73d3d217d0aea9d5122f2f954552518de..09fb489ac67575479c033c5fd4b9a6a35a6af34f 100644 --- a/library/templates/Intonation/Library/View/Wrapper/RichContent/Abstract.php +++ b/library/templates/Intonation/Library/View/Wrapper/RichContent/Abstract.php @@ -91,6 +91,20 @@ abstract class Intonation_Library_View_Wrapper_RichContent_Abstract { } + public function getPreviousItem() { + return ($navigation = $this->getNavigation()) + ? $navigation->getPreviousItem() + : null; + } + + + public function getNextItem() { + return ($navigation = $this->getNavigation()) + ? $navigation->getNextItem() + : null; + } + + abstract public function getNavigation(); abstract public function getActions(); diff --git a/library/templates/Intonation/Library/View/Wrapper/RichContent/Section.php b/library/templates/Intonation/Library/View/Wrapper/RichContent/Section.php index 7b5043ff3d82373f218b2e3f40c6eecb0ab72ebb..ab5ab59169d7555d9e6c7007e6177e345f97cfab 100644 --- a/library/templates/Intonation/Library/View/Wrapper/RichContent/Section.php +++ b/library/templates/Intonation/Library/View/Wrapper/RichContent/Section.php @@ -150,10 +150,21 @@ abstract class Intonation_Library_View_Wrapper_RichContent_Section { } - protected function _getJsCallback() { - return sprintf("if ($('.%s .jumbotron_section_content [data-ajax-content] > *').length) { $('.%s').removeClass('d-none text-black-50 disabled'); $('.loading_icon').parent().remove(); }", - $this->getClass(), - $this->getClass()); + protected function _getJsCallback($html = '') { + $js = ''; + if ($class = $this->getClass()) + $js = + sprintf('$(\'.loading_icon\').parent().remove(); + if ($(\'.%1$s .jumbotron_section_content [data-ajax-content] > *\').length) + return $(\'.%1$s\').removeClass(\'d-none text-black-50 disabled\');', + $class); + + if ($html) + $js .= sprintf('$(\'div.%s.wrapper_active:not(.hidde_content)\').parent().prepend(\'%s\');', + $class, + $html); + + return $js; } diff --git a/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Loans.php b/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Loans.php index c9f9747018f41cb21c55b21e1888cbf851774894..6763d7fe1f8758ffcebe0d93a6e6e0f5305bffd5 100644 --- a/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Loans.php +++ b/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Loans.php @@ -34,10 +34,15 @@ class Intonation_Library_View_Wrapper_User_RichContent_Loans extends Intonation_ if ($this->_content) return $this->_content; + $js = + $this->_getJsCallback($this->_view->tag('p', + $this->_('Pas de prêt en cours.'), + ['class' => 'empty_list ' . $this->getClass()])); + return $this->_content = $this->_view->renderAjax('abonne', 'ajax-loans', ['id' => $this->_model->getId()], - $this->_getJsCallback()); + $js); } diff --git a/library/templates/Intonation/View/Abonne/AjaxLoans.php b/library/templates/Intonation/View/Abonne/AjaxLoans.php index d3823d7bdbc1b401a701dd923bd25654f27a6a19..ee2bb9fe2907a8dfc2c47756e0b8a8d6de8e77fe 100644 --- a/library/templates/Intonation/View/Abonne/AjaxLoans.php +++ b/library/templates/Intonation/View/Abonne/AjaxLoans.php @@ -78,6 +78,6 @@ class Intonation_View_Abonne_AjaxLoans extends ZendAfi_View_Helper_BaseHelper { $this->view->tag('h3', $this->_('Historique des prêts')) . $history); - return $this->view->grid(implode($html)); + return $this->view->grid($html); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/Jumbotron.php b/library/templates/Intonation/View/Jumbotron.php index fc4ed39fec45c1203adda1e19cb979591469510a..087008c9d4da70335d504e7bcf2af5761eef06a1 100644 --- a/library/templates/Intonation/View/Jumbotron.php +++ b/library/templates/Intonation/View/Jumbotron.php @@ -23,14 +23,22 @@ class Intonation_View_Jumbotron extends ZendAfi_View_Helper_BaseHelper { protected + $_rich_content, + $_sections, $_element, $_current_url; public function jumbotron($element) { $this->_element = $element; + + if ( ! $this->_rich_content = $element->getRichContent()) + return ''; + $this->_current_url = $this->view->url(); + $this->_sections = $this->_rich_content->getSections(); + $content = $this->_renderContent(); $html = [$this->_renderHead(), @@ -62,31 +70,19 @@ class Intonation_View_Jumbotron extends ZendAfi_View_Helper_BaseHelper { $html [] = $this->_div(['class' => 'jumbotron_nav'], $this->_nav()); return $this->_div(['class' => 'bokeh_jumbotron'], - $this->view->grid(implode($html), + $this->view->grid($html, [], ['class' => 'justify-content-center'])); } protected function _getPreviousItem() { - if (!$rich_content = $this->_element->getRichContent()) - return; - - if (!$navigation = $rich_content->getNavigation()) - return; - - return $navigation->getPreviousItem(); + return $this->_element->getPreviousItem(); } protected function _getNextItem() { - if (!$rich_content = $this->_element->getRichContent()) - return; - - if (!$navigation = $rich_content->getNavigation()) - return; - - return $navigation->getNextItem(); + return $this->_element->getNextItem(); } @@ -106,34 +102,22 @@ class Intonation_View_Jumbotron extends ZendAfi_View_Helper_BaseHelper { protected function _actions() { - if (!$rich_content = $this->_element->getRichContent()) - return; - - return $rich_content->getActions(); + return $this->_element->getRichContentActions(); } protected function _getRowActions() { $html = $this->view->div(['class' => 'inspector_gadget'], ''); - - if (!$rich_content = $this->_element->getRichContent()) - return $html; - - return $rich_content->getRowActions() . $html; + return $this->_rich_content->getRowActions() . $html; } protected function _nav() { - if (!$rich_content = $this->_element->getRichContent()) - return; - - $sections = $rich_content->getSections(); - $html = array_map(function($item) { return $this->_renderNavItem($item); }, - $sections); + $this->_sections); return $this->_tag('ul', implode($html), @@ -163,18 +147,13 @@ class Intonation_View_Jumbotron extends ZendAfi_View_Helper_BaseHelper { protected function _renderContent() { - if (!$rich_content = $this->_element->getRichContent()) - return; - - $sections = $rich_content->getSections(); - $html = array_map(function($item) { return $this->_renderSection($item); }, - $sections); + $this->_sections); - $html = $this->_div(['class' => 'jumbotron_content'], $this->view->grid(implode($html))); + $html = $this->_div(['class' => 'jumbotron_content'], $this->view->grid($html)); return $this->view->grid($html, [], diff --git a/tests/scenarios/Templates/TemplatesAbonneTest.php b/tests/scenarios/Templates/TemplatesAbonneTest.php index e996753107ffe307dab40fc379637befe8a41867..1746c61243004ccac55a0fb27620daf819bcba2d 100644 --- a/tests/scenarios/Templates/TemplatesAbonneTest.php +++ b/tests/scenarios/Templates/TemplatesAbonneTest.php @@ -247,6 +247,11 @@ class TemplatesDispatchAbonneLoansTest extends TemplatesIntonationAccountTestCas $this->assertXPath('//div[@class="loading_icon spinner-border"]'); } + + /** @test */ + public function scriptShouldContainsNoLoanMessage() { + $this->assertXPathContentContains('//script', '$(\'div.user_loans.wrapper_active:not(.hidde_content)\').parent().prepend(\'<p class="empty_list user_loans">Pas de pr'); + } } diff --git a/tests/scenarios/Templates/TemplatesRecordsTest.php b/tests/scenarios/Templates/TemplatesRecordsTest.php index 1d9057b38039e4d099ee48abd486e66e894f8968..99890327dd086c8e17e16f0b60747dd1fdb5f7cf 100644 --- a/tests/scenarios/Templates/TemplatesRecordsTest.php +++ b/tests/scenarios/Templates/TemplatesRecordsTest.php @@ -371,6 +371,8 @@ 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();})'); + $this->assertXPathContentContains('//script', '.load("/noticeajax/author/id/1/id_profil/1", function() {$(\'.loading_icon\').parent().remove(); + if ($(\'.document_author .jumbotron_section_content [data-ajax-content] > *\').length) + return $(\'.document_author\').removeClass(\'d-none text-black-50 disabled\');initializePopups();setupAnchorsTarget();});'); } }