diff --git a/application/modules/admin/views/scripts/profil/menusindex.phtml b/application/modules/admin/views/scripts/profil/menusindex.phtml index 761796d9b35992416677df5a7b89a2be7b22d552..e2c6a4a28b894b8a665b742b7e7eb26ac34ddb81 100644 --- a/application/modules/admin/views/scripts/profil/menusindex.phtml +++ b/application/modules/admin/views/scripts/profil/menusindex.phtml @@ -1,67 +1,13 @@ -<?php echo $this->partial('profil/_profil_panel.phtml', - array('profil' => $this->profil)); ?> - - +<?php +Class_ScriptLoader::getInstance()->addSearchInputToContent($this->_('Filtrer les menus ')); +echo $this->partial('profil/_profil_panel.phtml', + ['profil' => $this->profil]); -<center> - <div align="center"><br\> - <?php - echo $this->Button_New((new Class_Entity()) +echo $this->Button_New((new Class_Entity()) ->setUrl($this->url(['module' => 'admin', 'controller' => 'widget', 'action' => 'add-menu'], null, true)) ->setText($this->_('Ajouter un menu'))); - ?> - </div> -</center> - - -<br /> -<table cellspacing="0" cellpadding="0"> - <tr class="soustitre"> - <td width="30px">Picto.</td> - <td>Libellé</td> - <td width="20px"> </td> - <td width="20px"> </td> - </tr> - <tr> - <td colspan="3" class="separ"></td> - </tr> - -<?php -$ligne=0; -foreach($this->menus as $id_menu => $menu) -{ - if ($ligne & 1) $class="first"; else $class="second"; - echo '<tr class="'.$class.'" style="height:30px">'; - echo '<td align="center">'; - echo '<img src="'.$this->path_img.$menu["picto"].'">'; - echo '</td>'; - echo '<td>'.$menu["libelle"].'</td>'; - echo '<td align="center">' . - $this->tagEditMenu($id_menu, - $this->profil->getId(), - null) . '</td>'; - - if($id_menu=="H") - echo '<td align="center"><a href="'.$this->url(['action' => 'duplicate-horizontal-menu', - 'id_profil' => $this->profil->getId() ]).'" - onclick="javascript:if(!confirm(\''.$this->traduire('Êtes vous sûr de vouloir dupliquer la configuration du menu horizontal à tous les autres profils ? Cela supprimera la configuration existante pour les autres profils').'\')) return false;" >'. - '<img src="'.URL_ADMIN_IMG.'ico/page_copy.png" alt="Dupliquer le menu horizontal" title="Dupliquer le menu horizontal à tous les autres profils" /></a>'; - - - else - echo '<td align="center"><a href="'.$this->url(array('action' => 'menusmaj', - 'id_profil' => $this->profil->getId(), - 'id_menu' => $id_menu, - 'mode' => 'delete')).'">' . - $this->boutonIco("type=del") . - '</a></td>'; - print('</tr>'); - $ligne ++ ; -} +echo $this->menus(); ?> - -</table> -<br /> diff --git a/library/Class/ScriptLoader.php b/library/Class/ScriptLoader.php index acfb2ad49a5098076d652a1ce1e49c79ecc34c4c..afce522a3e9a06361c0e1c418591a615db9fd693 100644 --- a/library/Class/ScriptLoader.php +++ b/library/Class/ScriptLoader.php @@ -808,7 +808,7 @@ class Class_ScriptLoader { return $this->_addSearchInput('.main > .modules', 'input_content_menu', $label, - 'table, thead, th , .form, .form *, center, center *, br, .bouton, a *, a, img, h1, h3, h3 + div , .error, h3 + div *, .soustitre, .soustitre *, tr *, #progressbar, #progressbar *'); + 'table, thead, th , .form, .form *, center, center *, br, .bouton, a *, a, img, h1, h3, h3 + div , .error, h3 + div *, .soustitre, .soustitre *, tr *, #progressbar, #progressbar *, button'); } @@ -816,7 +816,7 @@ class Class_ScriptLoader { return $this->_addSearchInput('.main > .left', 'input_search_menu', $label, - '.menuGaucheAdmin tr, .titre, img, table, tbody, td'); + '.menuGaucheAdmin tr, .titre, img, table, tbody, td, button'); } diff --git a/library/ZendAfi/View/Helper/Accueil/MenuVertical.php b/library/ZendAfi/View/Helper/Accueil/MenuVertical.php index fbb164aa98007c9e61b2e57f8ee6d8f76677971f..6667e2f3c01b1f736bb52d7bba8505d8e74f2b99 100644 --- a/library/ZendAfi/View/Helper/Accueil/MenuVertical.php +++ b/library/ZendAfi/View/Helper/Accueil/MenuVertical.php @@ -53,7 +53,7 @@ class ZendAfi_View_Helper_Accueil_MenuVertical extends ZendAfi_View_Helper_Accue : [Class_Profil::getCurrentProfil()->getId(), $menu]; if (!$profil = Class_profil::find($id_profil)) - return $this->retourErreur($this->translate()->_('Ce menu ne contient aucune entrée.')); + return $this->retourErreur($this->_('Ce menu ne contient aucune entrée.')); $this->_menu_id_profil = $id_profil; $this->_menu_id = $menu; diff --git a/library/ZendAfi/View/Helper/Admin/Menus.php b/library/ZendAfi/View/Helper/Admin/Menus.php new file mode 100644 index 0000000000000000000000000000000000000000..8513a05b257417c70f8ff127be064f32e5e84331 --- /dev/null +++ b/library/ZendAfi/View/Helper/Admin/Menus.php @@ -0,0 +1,105 @@ +<?php +/** + * Copyright (c) 2012-2017, 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 ZendAfi_View_Helper_Admin_Menus extends Zendafi_View_Helper_Basehelper { + protected $_profil; + + public function menus() { + $this->_profil = Class_Profil::getCurrentProfil(); + $datas = $this->_profil->getCfgMenusAsArray(); + $datas['H']['menus'] = (new Class_Systeme_MenuHorizontal($datas['H']['menus']))->asCfgProfil(); + $html = [$this->_renderNav($datas['H'])]; + unset($datas['H']); + + foreach($datas as $id => $params) { + $params['libelle'] .= $this->_tagDeleteMenu($id); + $html[] = $this->_renderMenu($id, $params); + } + + return $this->_tag('div', + implode($html), + ['class' => 'menus']); + } + + + protected function _renderNav($params) { + $params['libelle'] = $this->_tagDuplicateNav() . $params['libelle']; + return $this->_renderMenu('H', $params); + } + + + protected function _tagDuplicateNav() { + return $this->view->tagAnchor($this->view->url(['action' => 'duplicate-horizontal-menu']), + $this->view->tagImg(Class_Admin_Skin::current() + ->renderIconUrlOn('actions', + 'copy_module')), + ['onclick' => sprintf('if(!confirm(\'%s\'))return false;', + $this->_('Êtes vous sûr de vouloir dupliquer la configuration du menu horizontal à tous les autres profils ? Cela supprimera la configuration existante pour les autres profils')), + 'title' => $this->_('Dupliquer le menu horizontal à tous les autres profils')]); + } + + + protected function _tagDeleteMenu($id) { + return $this->view->tagAnchor($this->view->url(['action' => 'menusmaj', + 'mode' => 'delete', + 'id_menu' => $id]), + $this->view->tagImg(Class_Admin_Skin::current() + ->renderIconUrlOn('actions', + 'delete')), + ['onclick' => sprintf('if(!confirm(\'%s\'))return false;', + $this->_('Êtes vous sûr de vouloir supprimer le menu ?')), + 'title' => $this->_('Supprimer le menu')]); + } + + + protected function _renderMenu($id, $params) { + return $this->_tag('div', $this->_tag('h4', + $this->view->tagEditMenu($id, $this->_profil->getId()) . + $params['libelle']) + . $this->_renderChildren($params['menus'], $id)); + } + + + protected function _renderChildren($children, $parent) { + if(empty($children)) + return ''; + + $html = []; + foreach($children as $key => $child) { + if(isset($child['id_module'])) + $key = $child['id_module']; + + $entry = + $this->view->tagEditMenu($key, $this->_profil->getId(), $parent) . + $child['libelle']; + + if(isset($child['sous_menus']) && (!empty($child['sous_menus']))) { + $entry .= $this->_renderChildren($child['sous_menus'], $parent); + } + + $html[] = $this->_tag('li', $entry); + } + + return $this->_tag('ul', + implode($html)); + } +} diff --git a/library/ZendAfi/View/Helper/TagEditMenu.php b/library/ZendAfi/View/Helper/TagEditMenu.php index b1929bd48ceb27b4a64b584cbea83a5737ea69cf..d13d198438030d1cb1dd9316f16bb11988b0bfed 100644 --- a/library/ZendAfi/View/Helper/TagEditMenu.php +++ b/library/ZendAfi/View/Helper/TagEditMenu.php @@ -47,7 +47,8 @@ class ZendAfi_View_Helper_TagEditMenu extends ZendAfi_View_Helper_BaseHelper { $ico = 'edit'; $title = $this->_('Modifier l\'entrée : %s', $menu->getLabel()); - if(null !== $menu->getChildren()) { + if(($menu->getChildren() && is_array($menu->getChildren())) + || (null == $parent_id)) { $title = $this->_('Modifier le menu : %s', $menu->getLabel()); $ico = 'menu_configuration'; } diff --git a/public/admin/skins/bokeh74/form.css b/public/admin/skins/bokeh74/form.css index fa4f6b93c2ff80893bcf492a202a0e7b85c1bb15..a8a32b9d7e8d69c686b6f36e37a171a10a3981d6 100644 --- a/public/admin/skins/bokeh74/form.css +++ b/public/admin/skins/bokeh74/form.css @@ -83,4 +83,27 @@ z-index: 100; display: block; top: 0; -} \ No newline at end of file +} + +.admin-form #liste_picto_picto td { + width: 20px; +} + +.admin-form #liste_picto_picto td img { + width: 16px; + height: 16px; +} + +.admin-form table td { + border: none !important; +} + +.admin-form table td.gauche > *, +.admin-form table td.gauche { + text-align: left !important; +} + +.admin-form table td.droite > *, +.admin-form table td.droite { + text-align: right !important; +} diff --git a/public/admin/skins/bokeh74/global.css b/public/admin/skins/bokeh74/global.css index c443318cd3ad34c3eaef2a2b1a92381a1d468930..c8dd050dda301ab962d38ad1c18e25bfa1f0d819 100755 --- a/public/admin/skins/bokeh74/global.css +++ b/public/admin/skins/bokeh74/global.css @@ -62,6 +62,8 @@ td[id*="menu_item"] { background-color: var(--even-line-highlight); } +.modules .menus > div:hover, +.modules .menus > div li:hover, [class*=edit-multiple] .modules form tr:hover, .modules .profils ul li li:hover, .modules [class*="models"] tbody tr:hover, @@ -844,4 +846,30 @@ form .droite { .modules .bokeh-days > a { font-size: 1.1em; +} + +.modules .menus ul { + padding-left: 2em; +} + +.modules .menus > div img { + height: 16px; + width: 16px; +} + +.modules .menus > div { + display: inline-block; + width: 32%; + overflow: hidden; + vertical-align: top; +} + +.profils.form { + max-height: 15em; + overflow-y: auto; + overflow-x: hidden; +} + +.modules .menus h4 { + margin: 0.5em; } \ No newline at end of file diff --git a/public/admin/skins/bokeh74/jquery.css b/public/admin/skins/bokeh74/jquery.css index 65d5cb57a62615106cd8f98839727fa4ec2cfd4d..b0f420d9de91d6bcceaf02f7a49cdefa43feff4b 100644 --- a/public/admin/skins/bokeh74/jquery.css +++ b/public/admin/skins/bokeh74/jquery.css @@ -167,20 +167,6 @@ body .ui-state-active .ui-accordion-header-icon { transform: rotate(-90deg); } -body .ui-dialog table td { - border: none !important; -} - -body .ui-dialog table td.gauche *, -body .ui-dialog table td.gauche { - text-align: left !important; -} - -body .ui-dialog table td.droite *, -body .ui-dialog table td.droite { - text-align: right !important; -} - body .ui-front { z-index: 101; } \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/ProfilControllerTest.php b/tests/application/modules/admin/controllers/ProfilControllerTest.php index adb8fe9c2c6394aa4c6d7a4eaad0d316be06bb78..15dd576dab0d729776e79b977a2d0a19a7392930 100644 --- a/tests/application/modules/admin/controllers/ProfilControllerTest.php +++ b/tests/application/modules/admin/controllers/ProfilControllerTest.php @@ -684,22 +684,14 @@ class Admin_ProfilControllerProfilJeunesseTestMenusIndex extends Admin_ProfilCon ->whenCalled('findAllByZoneAndBib') ->answers(array($profil_portail, $this->profil_jeunesse, $profil_vide)); - $this->dispatch('/admin/profil/menusindex?id_profil=5'); - } - - - /** @test */ - public function menusindexPageShouldDisplayMenuVerticalAndHorizontal() { - $this->assertQueryContentContains("tr.second td", "Menu horizontal"); - $this->assertQueryContentContains("tr.first td", "Menu"); + $this->dispatch('/admin/profil/menusindex/id_profil/5'); } /** @test */ public function profilJeunessePanelShouldBeVisible() { $this->assertXPathContentContains("//div[contains(@class,'profils')]//ul//li//div", - "Profil Jeunesse", - $this->_response->getBody()); + "Profil Jeunesse"); } @@ -710,29 +702,29 @@ class Admin_ProfilControllerProfilJeunesseTestMenusIndex extends Admin_ProfilCon /** @test */ public function editMenuHorizontalLink() { - $this->assertXPath("//tr[@class='second']//td//a[contains(@href, 'admin/widget/edit-menu/id/H/id_profil/5')]"); + $this->assertXPath("//a[contains(@href, 'admin/widget/edit-menu/id/H/id_profil/5')]"); } /** @test */ public function duplicateHorizontalMenu() { - $this->assertXPath("//tr[@class='second']//td//a[contains(@href, 'admin/profil/duplicate-horizontal-menu/id_profil/5')]"); + $this->assertXPath("//a[contains(@href, 'admin/profil/duplicate-horizontal-menu/id_profil/5')]"); } /** @test */ public function cannotDeleteMenuHorizontalLink() { - $this->assertNotXPath("//tr[@class='second']//td//a[contains(@href, 'menusmaj/id_profil/5/id_menu/H/mode/delete')]"); + $this->assertNotXPath("//a[contains(@href, 'menusmaj/id_profil/5/id_menu/H/mode/delete')]"); } /** @test */ public function editMenuVerticalLink() { - $this->assertXPath("//tr[@class='first']//td//a[contains(@href, 'admin/widget/edit-menu/id/V/id_profil/5/backUrl')]"); + $this->assertXPath("//a[contains(@href, 'admin/widget/edit-menu/id/V/id_profil/5/backUrl')]"); } /** @test */ public function deleteMenuHorizontalLink() { - $this->assertXPath("//tr[@class='first']//td//a[contains(@href, 'menusmaj/id_profil/5/id_menu/V/mode/delete')]"); + $this->assertXPath("//a[contains(@href, 'menusmaj/id_profil/5/mode/delete/id_menu/V')]"); }