Commit 0d9574ca authored by Ghislain Loas's avatar Ghislain Loas
Browse files

hotline MT #140058 fix sub menu js to match new DOM

parent 783ff659
- ticket #140058 : Magasin de thèmes : Correction du fonctionnement des menus avec des sous menu.
\ No newline at end of file
<!DOCTYPE html>
<!--
/**
* Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-->
<html>
<head>
<meta charset="utf-8">
<title>QUnit tests</title>
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css">
<link rel="stylesheet" href="../../css/bootstrap.min.css">
<link rel="stylesheet" href="../../../../css/intonation.css">
<link rel="stylesheet" href="../../../../../../../../public/opac/css/core.css">
<script type="text/javascript" src="../../../../../../../../public/admin/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="../../../../../../../../public/admin/js/jquery-ui-1.12.1/jquery-ui.min.js"></script>
<script type="text/javascript" src="../../../popper.min.js"></script>
<script type="text/javascript" src="../bootstrap.min.js"></script>
<script src="http://code.jquery.com/qunit/qunit-1.13.0.js"></script>
<script src="dropdown_tests.js"></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<div>
<div class="boite">
<ul class="nav navbar-nav list-unstyled">
<li class="nav-item">
<a href="/" class="nav-link active_item active">Home</a>
</li>
<li class="nav-item dropdown">
<a href="#" id="6126059b06918" onclick="return false;" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Information</a>
<ul class="dropdown-menu list-unstyled" aria-labelledby="6126059b06918">
<li class="nav-item">
<a href="" class="nav-link">News</a>
</li>
<li class="nav-item dropdown">
<a href="#" id="6126059b11326" onclick="return false;" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Libraries</a>
<ul class="dropdown-menu list-unstyled" aria-labelledby="6126059b11326">
<li class="nav-item">
<a href="" class="nav-link">Valleiry</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<script src="../bootstrap_dropdown.js"></script>
</body>
</html>
/**
* Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
QUnit.module('dropdown_with_submenu');
test('Click on Information should display News', function() {
$('#6126059b06918').trigger('click');
deepEqual($('[aria-labelledby="6126059b06918"].show').length, 1, $('body'));
});
test('Click on Libraries should display Valleiry', function() {
$('#6126059b06918').trigger('click');
$('#6126059b11326').trigger('click');
deepEqual($('.has-child-dropdown-show [aria-labelledby="6126059b11326"].show').length, 1, $('body'));
});
......@@ -26,6 +26,12 @@ class Intonation_Library_View_Wrapper_MenuEntry extends Intonation_Library_View_
return $this->_model->getLabel();
}
public function isMenu() {
return $this->_model->isMenu();
}
public function getMainLink() {
return '';
}
......
......@@ -38,7 +38,9 @@ abstract class Intonation_View_Menu_Abstract extends ZendAfi_View_Helper_BaseHel
$html = '';
foreach ( $collection as $menu)
$html .= $this->_tag('li', $callback($menu), ['class' => 'nav-item']);
$html .= $this->_tag('li', $callback($menu), ['class' => 'nav-item'. (($menu->isMenu())
? ' dropdown'
: '')]);
return $this->_renderMenu($this->_navbarHeader() . $this->_navbarEntries($html),
['class' => implode(' ',
......
......@@ -37,10 +37,6 @@ class Intonation_View_RenderMenuEntry extends ZendAfi_View_Helper_BaseHelper {
$entry .= $this->_renderChildren($menu_entry, $id, $use_menu_layout);
if ($menu_entry->getChildren())
$entry = $this->_div(['class' => 'dropdown'],
$entry);
return $use_menu_layout
? $entry
: $this->_div(['class' => 'menu_entry'],
......@@ -80,7 +76,9 @@ class Intonation_View_RenderMenuEntry extends ZendAfi_View_Helper_BaseHelper {
$html[] = $this->_tag('li',
$this->_renderMenuEntry($menu_entry_child, $use_menu_layout),
['class' => 'nav-item']);
['class' => 'nav-item' . (($menu_entry_child->isMenu())
? ' dropdown'
: '')]);
}
return $this->_tag('ul',
......
<?php
/**
* Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class BootstrapDropdownTest extends PhantomJsTest {
protected $_test_path = ['library/templates/Intonation/Assets/Bootstrap/bootstrap-4.3.1-dist/js/tests/dropdown_tests.html'];
}
......@@ -135,7 +135,13 @@ class TemplatesMenuDispatchIndexTest extends TemplatesIntonationTestCase {
/** @test */
public function navDropdownAnchorShouldHaveOnclichReturnFalse() {
$this->assertXPath('//li[@class="nav-item"]//div[@class="dropdown"]/a[@onclick="return false;"]');
$this->assertXPath('//li[@class="nav-item dropdown"]/a[@onclick="return false;"]');
}
/** @test */
public function allNavItemShouldNotHaveDropdownClass() {
$this->assertXPath('//li[@class="nav-item"]');
}
}
......@@ -493,4 +499,34 @@ class TemplatesMenuNavWithLayoutTest extends TemplatesMenuTestCase {
public function homeShouldBeRenderInANavTag() {
$this->assertXPathContentContains('//footer//nav', 'Home');
}
}
class TemplatesMenuWithSubmenuTest extends TemplatesMenuTestCase {
public function setUp() {
parent::setUp();
$profile_patcher = (new Class_Template_ProfilePatcher(Class_Template::current()))
->setProfile(Class_Profil::find(7))
->addWidget(Intonation_Library_Widget_Nav_Definition::CODE,
Class_Profil::DIV_FOOTER,
['layout' => 'vertical',
'menu' => '7-' . $this->_menu_id]);
$this->dispatch('/index');
}
/** @test */
public function liShouldHaveClassNavItemDropdown() {
$this->assertXPath('//li[@class="nav-item dropdown"]/a[@onclick="return false;"]');
}
/** @test */
public function allNavItemShouldNotHaveDropdownClass() {
$this->assertXPath('//li[@class="nav-item dropdown"]//li[@class="nav-item"]/a');
}
}
\ No newline at end of file
Markdown is supported
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