From 3201a8d9de64ea2e4494998ce4555b1a523776dd Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Tue, 3 May 2022 17:23:27 +0200 Subject: [PATCH] hotline #156384 add classes to library details tab contents --- VERSIONS_HOTLINE/156384 | 1 + .../templates/Intonation/Library/Settings.php | 4 ++- .../Wrapper/Library/RichContent/Details.php | 27 +++++++++---------- .../Templates/TemplatesLibraryTest.php | 9 ++++++- 4 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 VERSIONS_HOTLINE/156384 diff --git a/VERSIONS_HOTLINE/156384 b/VERSIONS_HOTLINE/156384 new file mode 100644 index 00000000000..4ab32d4b17b --- /dev/null +++ b/VERSIONS_HOTLINE/156384 @@ -0,0 +1 @@ + - correctif #156384 : Magasin de thèmes : Dans l'onglet Details de la fiche bibliothèque, nous avons ajouté les classes "library_details_custom_field" et "library_details_attribut" pour faciliter l'intégration graphique. \ No newline at end of file diff --git a/library/templates/Intonation/Library/Settings.php b/library/templates/Intonation/Library/Settings.php index 08285c03b63..7167a795b3a 100644 --- a/library/templates/Intonation/Library/Settings.php +++ b/library/templates/Intonation/Library/Settings.php @@ -334,7 +334,9 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'div class paginated_collection' => 'col-12 mt-3 list-group bg-transparent no_border', 'div class paginated_secondary_collection' => 'col-12 mt-3 list-group bg-transparent no_border', 'div class ajax_paginated_collection' => 'col-12', - 'div class paginated_collection_pager' => 'col' + 'div class paginated_collection_pager' => 'col', + 'div class library_details_attribut' => 'col-12', + 'div class library_details_custom_field' => 'col-12' ], 'icons_map_doc_types' => [], diff --git a/library/templates/Intonation/Library/View/Wrapper/Library/RichContent/Details.php b/library/templates/Intonation/Library/View/Wrapper/Library/RichContent/Details.php index 488dde3125e..5f1d3fb8473 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Library/RichContent/Details.php +++ b/library/templates/Intonation/Library/View/Wrapper/Library/RichContent/Details.php @@ -58,11 +58,11 @@ class Intonation_Library_View_Wrapper_Library_RichContent_Details extends Intona 'getAnnexe' => $this->_('Annexe'), 'getResetPassword' => $this->_('Comment modifier mon mot de passe')]; - $html = []; - + $attributs_html = []; foreach ($column_map as $attrib => $label) - $html = $this->_addAttributAsHtml($attrib, $label, $html); + $attributs_html = $this->_addAttributAsHtml($attrib, $label, $attributs_html); + $custom_fields_html = []; $count = 0; foreach($this->_model->getAllCustomFields()->getFieldValues() as $field) { if ($field->getLabel() === $this->_('Tags bibliothèque')) @@ -72,25 +72,22 @@ class Intonation_Library_View_Wrapper_Library_RichContent_Details extends Intona continue; $count++; - $html [] = $this->_renderBlock($this->_renderOptions($field, $count), - $field->getLabel(), - 'custom' . $count); + $custom_fields_html [] = + $this->_view->div(['class' => 'library_details_custom_field ' + . $this->_stripWord($field->getLabel())], + $this->_renderBlock($this->_renderOptions($field, $count), + $field->getLabel(), + 'custom' . $count)); } - $html = array_map(function($content) - { - return $this->_view->div(['class' => 'col-12'], - $content); - }, - $html); - - return $this->_view->grid(implode($html)); + return $this->_view->grid(implode(array_merge($attributs_html, + $custom_fields_html))); } protected function _addAttributAsHtml($attrib, $label, $html) { if ($value = $this->_model->$attrib()) - $html [] = $this->_view->div(['class' => 'col-12'], + $html [] = $this->_view->div(['class' => 'library_details_attribut ' . $this->_stripWord($label)], $this->_view->tag('h4', $label) . $this->_view->tag('p', diff --git a/tests/scenarios/Templates/TemplatesLibraryTest.php b/tests/scenarios/Templates/TemplatesLibraryTest.php index 8208a79ce3a..82b6940ae80 100644 --- a/tests/scenarios/Templates/TemplatesLibraryTest.php +++ b/tests/scenarios/Templates/TemplatesLibraryTest.php @@ -230,6 +230,7 @@ class TemplatesLibraryViewAnnecyTest extends TemplatesLibraryTestCase { 'model' => 'Bib']); Class_Bib::find(1) + ->setPret('C\'est génial vous pouvez emprunter') ->setCustomField('Services', ['Wifi', 'Restauration', 'l\'Médias']) ->setCustomField('Slogan', 'Vive le vélo') ->setCustomField('Fonds Spécifiques', 'La matériauthèque') @@ -245,9 +246,15 @@ class TemplatesLibraryViewAnnecyTest extends TemplatesLibraryTestCase { } + /** @test */ + public function pretTextShouldBeInDivClassLibraryDetailsPret() { + $this->assertXPathContentContains('//div[@class="library_details_attribut modalites_des_prets col-12"]/p', 'C\'est génial vous pouvez emprunter'); + } + + /** @test */ public function customOneLibraryBoxH4ShouldContainsServices() { - $this->assertXPathContentContains('//div[@class="custom1 library_box"]//h4', 'Services'); + $this->assertXPathContentContains('//div[@class="library_details_custom_field services col-12"]/div[@class="custom1 library_box"]//h4', 'Services'); } -- GitLab