From ffae9e9ea2060246030c264286279be11245d84b Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Mon, 29 May 2017 15:23:59 +0200 Subject: [PATCH] dev #60900 move admin actions from lock to amdin menu --- .../admin/controllers/ProfilController.php | 2 +- .../ZendAfi/View/Helper/Admin/FrontNav.php | 17 +++++- library/ZendAfi/View/Helper/AdminTools.php | 13 +---- public/admin/skins/bokeh74/front_nav.css | 4 +- .../opac/controllers/IndexControllerTest.php | 58 ++++++++++++++++++- 5 files changed, 77 insertions(+), 17 deletions(-) diff --git a/application/modules/admin/controllers/ProfilController.php b/application/modules/admin/controllers/ProfilController.php index ab2ebd00a72..aa708869a83 100644 --- a/application/modules/admin/controllers/ProfilController.php +++ b/application/modules/admin/controllers/ProfilController.php @@ -441,7 +441,7 @@ class Admin_ProfilController extends ZendAfi_Controller_Action { public function moduleSortAction() { $this->getHelper('ViewRenderer')->setNoRender(); - if (!$profil = Class_Profil::getLoader()->find($this->_getParam('profil'))) + if (!$profil = Class_Profil::find($this->_getParam('profil'))) return; $profil->moveModuleOldDivPosNewDivPos($this->_getParam('fromDivision'), diff --git a/library/ZendAfi/View/Helper/Admin/FrontNav.php b/library/ZendAfi/View/Helper/Admin/FrontNav.php index 25528ae5046..4e9db5c0ad3 100644 --- a/library/ZendAfi/View/Helper/Admin/FrontNav.php +++ b/library/ZendAfi/View/Helper/Admin/FrontNav.php @@ -49,6 +49,11 @@ class ZendAfi_View_Helper_Admin_FrontNav extends ZendAfi_View_Helper_BaseHelper $this->_adminActions(), $this->_adminLinks()]; + return $this->_lify($entries); + } + + + protected function _lify($entries) { return array_map(function($entry) { return $this->_tag('li', $entry); @@ -72,7 +77,17 @@ class ZendAfi_View_Helper_Admin_FrontNav extends ZendAfi_View_Helper_BaseHelper protected function _adminActions() { - return ''; + $clear_cache_url = $this->view->absoluteUrl(['module' => 'admin', + 'controller' => 'index', + 'action' => 'clearcache']); + + $actions = [ $this->view->tagAnchor($clear_cache_url, + $this->_("Vider le cache de Bokeh")), + $this->view->tagAnchor('#', + $this->_('Activer déplacement des boites'), + ['onclick' => 'window.reactiveOpacBlocksSorting();return true;'])]; + + return $this->_tag('ul', implode($this->_lify($actions))); } diff --git a/library/ZendAfi/View/Helper/AdminTools.php b/library/ZendAfi/View/Helper/AdminTools.php index fcfd6717d35..b4bdddbe5dc 100644 --- a/library/ZendAfi/View/Helper/AdminTools.php +++ b/library/ZendAfi/View/Helper/AdminTools.php @@ -33,18 +33,7 @@ class ZendAfi_View_Helper_AdminTools extends ZendAfi_View_Helper_BaseHelper { 'class' => 'admin_tools_lock', 'onclick' => 'toggleMenuAdmin($(this));']); - $clear_cache_url = $this->view->absoluteUrl(['module' => 'admin', - 'controller' => 'index', - 'action' => 'clearcache']); - - $clear_cache = $this->_tag('button', - $this->_("Vider le cache de Bokeh"), - ['class' => 'clear_cache', - 'onclick' => sprintf('document.location.href = "%s"', $clear_cache_url), - 'style' => 'display: none']); - Class_ScriptLoader::getInstance() - ->addJQueryBackEnd(sprintf('$("#select_clef_profil").parent().prepend(\'%s\')', $lock)) - ->addJQueryBackEnd(sprintf('$("body").append(\'%s\')', $clear_cache)); + ->addJQueryBackEnd(sprintf('$("#select_clef_profil").parent().prepend(\'%s\')', $lock)); } } diff --git a/public/admin/skins/bokeh74/front_nav.css b/public/admin/skins/bokeh74/front_nav.css index 537ec4a3a2c..1cc293c29c6 100644 --- a/public/admin/skins/bokeh74/front_nav.css +++ b/public/admin/skins/bokeh74/front_nav.css @@ -18,11 +18,11 @@ } .menu_admin_front.hidden > div { - width: 0; + margin-left: -300px; } .menu_admin_front > button { - position: absolute; + margin: 0; white-space: nowrap; } diff --git a/tests/application/modules/opac/controllers/IndexControllerTest.php b/tests/application/modules/opac/controllers/IndexControllerTest.php index 9c47de6bf92..7821b2ef5e9 100644 --- a/tests/application/modules/opac/controllers/IndexControllerTest.php +++ b/tests/application/modules/opac/controllers/IndexControllerTest.php @@ -51,7 +51,6 @@ class IndexControllerSetupDomainTest extends AbstractControllerTestCase { } - class IndexControllerAsInviteTest extends AbstractControllerTestCase { protected function _loginHook($account) { $account->ROLE_LEVEL = ZendAfi_Acl_AdminControllerRoles::INVITE; @@ -78,6 +77,13 @@ class IndexControllerAsInviteTest extends AbstractControllerTestCase { $this->dispatch('/?id_profil=1'); $this->assertNotXPath('//a[contains(@href, "admin/profil/accueil/id_profil/1")]'); } + + + /** @test */ + public function menuAdminFrontShouldBeVisible() { + $this->dispatch('/'); + $this->assertNotXPath('//body/div[@class="menu_admin_front hidden"]'); + } } @@ -128,6 +134,12 @@ class IndexControllerAsAdminWithCssEditorAndNoHeaderCss extends IndexControllerA public function comboProfilCurrentProfilShouldBeOne() { $this->assertXPath('//div[@class="footer"]//select[@id="select_clef_profil"]//option[@value="1"][@selected="selected"]'); } + + + /** @test */ + public function menuAdminFrontShouldBeVisible() { + $this->assertXPath('//body/div[@class="menu_admin_front hidden"]'); + } } @@ -692,4 +704,48 @@ class IndexControllerStatusTest extends AbstractControllerTestCase { public function dateCreationShouldBeSet() { $this->assertNotNull($this->_json['headers']['creation_datetime'], $this->_json); } +} + + + +class IndexControllerWithBibAdminLoggedTest extends AbstractControllerTestCase { + protected + $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + $joe = $this->fixture('Class_Users', + ['id' => 23, + 'login' => 'Joe', + 'password' => 'unsupermotdepasse', + 'id_site' => 1, + 'role_level' => ZendAfi_Acl_AdminControllerRoles::MODO_BIB]); + ZendAfi_Auth::getInstance()->logUser($joe); + $this->dispatch('/'); + } + + + /** @test */ + public function menuAdminFrontShouldBeVisible() { + $this->assertXPath('//body/div[@class="menu_admin_front hidden"]'); + } + + + /** @test */ + public function frontNavCssShouldBeLoaded() { + $this->assertXPath('//link[contains(@href, "front_nav.css")]'); + } + + + /** @test */ + public function linkToClearCacheShouldBeInMenu() { + $this->assertXPath('//body/div//a[contains(@href, "/admin/index/clearcache")]'); + } + + + /** @test */ + public function linkToToggleWidgetMoveShouldBeInMenu() { + $this->assertXPathContentContains('//body/div//ul/li/ul/li/a', 'Activer déplacement des boites'); + } } \ No newline at end of file -- GitLab