Skip to content
Snippets Groups Projects
Commit 9c87c6e2 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

Merge branch 'hotline#135702_ajout_class_sur_horaire' into 'master'

hotline MT #135702 add openings hours to library wrapper description

See merge request !4104
parents 986cc1a2 a85e952d
Branches
Tags
1 merge request!4104hotline MT #135702 add openings hours to library wrapper description
Pipeline #13938 passed with stage
in 50 minutes and 54 seconds
- ticket #135702 : Magasin de thèmes : Il est maintenant possible d'afficher les ouvertures dans la description des bibliothèques. Par défaut la class library_opening_hours est hydraté par un d-none dans la configuration du thème.
\ No newline at end of file
......@@ -26,6 +26,17 @@ trait Trait_TemplateAware {
}
protected function _isBootstrapDNone($tag, $class) {
if ( ! $hydtratation = Class_Template::current()->hydrate(['class' => $class], $tag))
return false;
if ( ! isset($hydtratation['class']))
return false;
return false !== strpos($hydtratation['class'], 'd-none');
}
protected function _div($attributes=[], $content='') {
return $this->_view->div($attributes, $content);
}
......@@ -39,5 +50,4 @@ trait Trait_TemplateAware {
protected function _grid($html, $container_attribs=[], $row_attribs=[]) {
return $this->_view->grid($html, $container_attribs, $row_attribs);
}
}
......@@ -66,7 +66,7 @@ class ZendAfi_View_Helper_LibraryOpenings extends ZendAfi_View_Helper_BaseHelper
return ($label) ? $label : $this->_('Habituels');
};
return $this->_renderLabelled($default, $closure);
return $this->_renderLabelled($default, $closure, 'default_opening_hours');
}
......@@ -88,11 +88,11 @@ class ZendAfi_View_Helper_LibraryOpenings extends ZendAfi_View_Helper_BaseHelper
strtotime($first->getValidityEnd()));
};
return $this->_renderLabelled($openings, $callback);
return $this->_renderLabelled($openings, $callback, 'period_opening_hours');
}
protected function _renderLabelled($openings, $callback) {
protected function _renderLabelled($openings, $callback, $class) {
$content = $label = '';
$only_closures = true;
......@@ -106,14 +106,16 @@ class ZendAfi_View_Helper_LibraryOpenings extends ZendAfi_View_Helper_BaseHelper
$label = $this->_('Fermeture exceptionnelle');
return $this->_renderSection($callback($label),
$only_closures ? '' : $content );
$only_closures ? '' : $content ,
$class);
}
protected function _renderSection($label, $content) {
protected function _renderSection($label, $content, $class) {
return $this->_tag('li',
$this->_tag('h3', $label) .
($content ? $this->_tag('ul', $content) : ''));
($content ? $this->_tag('ul', $content) : ''),
['class' => $class]);
}
......@@ -126,7 +128,8 @@ class ZendAfi_View_Helper_LibraryOpenings extends ZendAfi_View_Helper_BaseHelper
'',
'Fermeture exceptionnelle',
'Fermetures exceptionnelles'),
$closure);
$closure,
'unexpected_closing_hours');
}
......@@ -139,11 +142,12 @@ class ZendAfi_View_Helper_LibraryOpenings extends ZendAfi_View_Helper_BaseHelper
'',
'Ouverture exceptionnelle',
'Ouvertures exceptionnelles'),
$exceptional);
$exceptional,
'unexpected_opening_hours');
}
protected function _renderSectionLabelled($label, $openings) {
protected function _renderSectionLabelled($label, $openings, $class) {
if (!$openings)
return '';
......@@ -152,7 +156,7 @@ class ZendAfi_View_Helper_LibraryOpenings extends ZendAfi_View_Helper_BaseHelper
$content .= $this->_tag('li',
(($item_label = $opening->getLabel()) ? $item_label . ' ': '') . $this->_renderOne($opening));
return $this->_renderSection($label, $content);
return $this->_renderSection($label, $content, $class);
}
......
......@@ -51,7 +51,7 @@ class ZendAfi_View_Helper_LibraryOpeningsAdmin
return ($label) ? $label : $this->_('Ouvertures habituelles');
};
return $this->_renderLabelled($default, $closure);
return $this->_renderLabelled($default, $closure, 'default_opening_hours');
}
......@@ -67,7 +67,7 @@ class ZendAfi_View_Helper_LibraryOpeningsAdmin
}
protected function _renderLabelled($openings, $closure) {
protected function _renderLabelled($openings, $closure, $class) {
$label = '';
foreach($openings as $opening)
$label = (!$label) ? $opening->getLabel() : $label;
......@@ -87,7 +87,7 @@ class ZendAfi_View_Helper_LibraryOpeningsAdmin
}
protected function _renderSectionLabelled($label, $openings) {
protected function _renderSectionLabelled($label, $openings, $class) {
$description = $this->_newTableDescription()
->prependColumn($this->_('Libellé'), 'label');
......
......@@ -302,6 +302,9 @@ class Intonation_Library_Settings extends Intonation_System_Abstract {
'div class collection_truncate_list' => 'col-12',
'div class websites_list_title' => 'col-12',
'div class websites_list_content' => 'col-12',
'div class library_horaire' => 'col-12',
'div class library_opening' => 'col-12',
'div class library_opening_hours' => 'col-12 d-none',
],
'icons_map_doc_types' => [],
......
......@@ -92,9 +92,19 @@ class Intonation_Library_View_Wrapper_Library extends Intonation_Library_View_Wr
protected function _renderOpening() {
return ($openings = $this->_model->getHoraire())
? $openings
: $this->_view->renderLibraryOpening($this->_model);
if ($openings = $this->_model->getHoraire())
return $this->_div(['class' => 'library_horaire'],
$openings);
$html = [$this->_div(['class' => 'library_opening'],
$this->_view->renderLibraryOpening($this->_model))];
$class = 'library_opening_hours';
if ( ! $this->_isBootstrapDNone('div', $class))
$html [] = $this->_div(['class' => $class],
$this->_view->libraryOpenings($this->_model));
return $this->_view->grid($html);
}
......
......@@ -88,7 +88,7 @@ class TemplatesLibraryWidgetWithCarouselThreeColumnsTest extends TemplatesLibrar
Class_Bib::setTimeSource($time);
ZendAfi_View_Helper_RenderLibraryOpening::setTimeSource($time);
$this->dispatch('/opac/index/index/id_profil/1', true);
$this->dispatch('/opac/index/index/id_profil/1');
}
......@@ -112,6 +112,13 @@ class TemplatesLibraryWidgetWithCarouselThreeColumnsTest extends TemplatesLibrar
}
/** @test */
public function firstCardShouldNotContainsOuvertMardiDixHeure() {
$this->assertNotXPathContentContains('//div[contains(@class, "card_Intonation_Library_View_Wrapper_Library")][1]//ul/li[@class="default_opening_hours"]',
'Mardi : 10h - 12h');
}
/** @test */
public function anchorEditLibraryShouldLinkToBibEditOne() {
$this->assertXPath('//div[contains(@class, "card_Intonation_Library_View_Wrapper_Library")][1]//a[contains(@class, "edit_library")][@href="/admin/bib/edit/id/1"]');
......@@ -655,3 +662,34 @@ class TemplatesWidgetLibraryWithOSMAndLinkToProfileTest extends TemplatesIntonat
$this->assertXPathContentContains('//div[contains(@class,"boite library")]//div[@class="card-title"]', 'Tataouine');
}
}
class TemplatesLibraryWidgetWithCarouselThreeColumnsAndOpeningHoursTest extends TemplatesLibraryTestCase {
public function setUp() {
parent::setUp();
$template_settings = $this->fixture(Class_Template_Settings::class,
['id' => 1,
'template' => 'INTONATION']);
$template_settings_instance = $template_settings->getSettingsInstance();
$template_settings_instance->setIntonationHydratingMapping([]);
$template_settings->setSettings(serialize($template_settings_instance->toArray()))->save();
$time = new TimeSourceForTest("2020-10-18 10:00:00");
Class_Bib::setTimeSource($time);
ZendAfi_View_Helper_RenderLibraryOpening::setTimeSource($time);
$this->dispatch('/opac/index/index/id_profil/1');
}
/** @test */
public function firstCardShouldContainsOuvertMardiDixHeure() {
$this->assertXPathContentContains('//div[contains(@class, "card_Intonation_Library_View_Wrapper_Library")][1]//ul/li[@class="default_opening_hours"]',
'Mardi : 10h - 12h');
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment