From: Andrey Kutejko Date: Mon, 27 Oct 2014 21:59:18 +0000 (+0200) Subject: admin sidebar X-Git-Tag: 0.6~128 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=3c4013e139d20e0e1836f47b3e6c1399d8feb6a4;p=ipf.git admin sidebar --- diff --git a/ipf/admin/app.php b/ipf/admin/app.php index b87d0e3..96af519 100644 --- a/ipf/admin/app.php +++ b/ipf/admin/app.php @@ -1,5 +1,8 @@ appList() as $app) { + $components = array(); + foreach (IPF_Admin_App::applicationComponents($app) as $component) { + if ($component->isAccessible(array('view'), $request)) { + $component->request = $request; + $components[] = $component; + } + } + + if ($components) { + $app_list[] = (object)array( + 'name' => $app->getTitle(), + 'path' => $app->slug(), + 'components' => $components, + ); + } + } + return array( 'IPF_VER' => IPF::version(), 'ADMIN_MEDIA_URL' => IPF::get('static_url') . 'admin/', 'admin_title' => IPF::get('admin_title'), 'indexpage_url' => IPF::get('indexpage_url', '/'), + 'app_list' => $app_list, ); } @@ -72,12 +95,13 @@ class IPF_Admin_App extends IPF_Application if (count(array_diff($requiredPermissions, $component->getPerms($request)))) return false; - if ($request->user->is_superuser || !self::ArePermissionsEnabled()) + if ($request->user->is_superuser || !\IPF_Auth_App::ArePermissionsEnabled()) return true; - $authPermissions = \PFF\Arr($requiredPermissions) - ->map('sprintf', '%s|%s|%s', $component->app->slug(), $component->slug(), \PFF\Symbol::_()) - ->arr(); + $authPermissions = F::bind('array_map', + F::bind('sprintf', '%s|%s|%s', $component->app->slug(), $component->slug(), P::p()), + P::p()) + ->call($requiredPermissions); return $request->user->can($authPermissions); } diff --git a/ipf/admin/static/admin/css/base.css b/ipf/admin/static/admin/css/base.css index cf47a4e..6b15c6f 100644 --- a/ipf/admin/static/admin/css/base.css +++ b/ipf/admin/static/admin/css/base.css @@ -114,8 +114,20 @@ div.system-message { background: #ffc; margin: 10px; padding: 6px 8px; font-size div.system-message p.system-message-title { padding:4px 5px 4px 25px; margin:0; color:red; background:#ffc url(../img/icon_error.gif) 5px .3em no-repeat; } .description { font-size:12px; padding:5px 0 0 12px; } +/* + * Navigation + */ +.toggle-sidebar {display: none;} +.toggle-sidebar ~ label {display: inline-block; padding:0 8px 0 16px; font-size:18px; margin: 8px 0; font-weight:normal; color: #006a95; cursor: pointer; } + +.sidebar h3 {margin: 8px 0 0} +.sidebar ul {margin: 8px;padding: 0} +.sidebar li {list-style: none outside none; margin: 0; padding: 0} +.sidebar li ul {margin-left: 16px} + /* BREADCRUMBS */ -div.breadcrumbs { background:#AFAFAF url(../img/breadcrubms-bg.gif) left repeat-x; padding:2px 8px 3px 16px; font-size:11px; color:#444; border-top:1px solid #DCDCDC; border-bottom:1px solid #8C8C8C; text-align:left; } +.navigation { padding: 8px 16px; } +div.breadcrumbs { display: inline-block; font-size: 11px; color:#444; text-align:left; } /* ACTION ICONS */ .addlink { padding-left:12px; background:url(../img/icon_addlink.gif) 0 .2em no-repeat; } @@ -142,7 +154,7 @@ table#change-history tbody th { width:16em; } /* PAGE STRUCTURE */ #container { position:relative; width:100%; min-width:760px; padding:0; } #content { margin:10px 15px; } -#header { width:100%; } +.header { width:100%; height: 40px; } #content-main { float:left; width:100%; } #content-related { float:right; width:18em; position:relative; margin-right:-19em; } #footer { clear:both; padding:10px; } @@ -157,9 +169,10 @@ table#change-history tbody th { width:16em; } .dashboard #content { width:500px; } /* HEADER */ -#header { background:#BDBDBD url(../img/topbg.gif) left repeat-x; color:#565656; overflow:hidden; border-bottom:1px solid #8B8B8B;} -#header a:link, #header a:visited { color:#006A95; } -#header a:hover { text-decoration:underline; } +.header { background:#BDBDBD url(../img/topbg.gif) left repeat-x; color:#565656; overflow:hidden; border-bottom:1px solid #8B8B8B;} +.header a:link, .header a:visited { color:#006A95; } +.header a:hover { text-decoration:underline; } +#branding { display: inline-block; } #branding h1 { padding:0 16px; font-size:18px; margin:8px 0; font-weight:normal; } #branding h2 { padding:0 10px; font-size:14px; margin:-8px 0 8px 0; font-weight:normal; color:#ffc; } #user-tools { position:absolute; top:0; right:0; padding:8px 10px; font-size:11px; text-align:right; } @@ -182,3 +195,38 @@ table#change-history tbody th { width:16em; } .dashboard ul.actionlist { margin-left:0; } .dashboard ul.actionlist li { list-style-type:none; } +/* + * Sidebar + */ +body { + -webkit-transition: margin-left 0.3s ease; + -moz-transition: margin-left 0.3s ease; + transition: margin-left 0.3s ease; +} + +body.pushed {margin-left: 200px} + +.sidebar { + position: fixed; + left: -200px; + top: 0; + + margin: 0; + padding: 0; + width: 199px; + height: 100%; + overflow: auto; + + background: #f0f0f0; + border-right: 1px solid #999;1 + + -webkit-transition: left 0.3s ease; + -moz-transition: left 0.3s ease; + transition: left 0.3s ease; +} + +body.pushed .sidebar { + display: block; + left: 0; +} + diff --git a/ipf/admin/static/admin/js/admin.js b/ipf/admin/static/admin/js/admin.js index cf0225a..833048b 100644 --- a/ipf/admin/static/admin/js/admin.js +++ b/ipf/admin/static/admin/js/admin.js @@ -1,4 +1,9 @@ $(function(){ + $('.toggle-sidebar').on('change', function() { + $('body').toggleClass('pushed'); + return false; + }); + $('.dateinput').each(function(){ var opts = { dateFormat: $(this).data('format') || 'yy-mm-dd' diff --git a/ipf/admin/templates/admin/base.html b/ipf/admin/templates/admin/base.html index a487302..0f510b0 100644 --- a/ipf/admin/templates/admin/base.html +++ b/ipf/admin/templates/admin/base.html @@ -12,17 +12,53 @@ +
- + {block commonjs} diff --git a/ipf/admin/templates/admin/index.html b/ipf/admin/templates/admin/index.html index 50bfc1f..403518c 100644 --- a/ipf/admin/templates/admin/index.html +++ b/ipf/admin/templates/admin/index.html @@ -2,6 +2,9 @@ {block bodyclass}dashboard{/block} +{block sidebar_toggle}{/block} +{block navigation}{/block} + {block content}

{$page_title}

diff --git a/ipf/admin/views.php b/ipf/admin/views.php index d1bb7c8..729546a 100644 --- a/ipf/admin/views.php +++ b/ipf/admin/views.php @@ -4,26 +4,6 @@ function IPF_Admin_Views_Index($request, $match) { IPF_Admin_App::ensureUserIsStaff($request); - $apps = array(); - $app_list = new IPF_Template_ContextVars(); - foreach (IPF_Project::getInstance()->appList() as $app) { - $components = array(); - foreach (IPF_Admin_App::applicationComponents($app) as $component) { - if ($component->isAccessible(array('view'), $request)) { - $component->request = $request; - $components[] = $component; - } - } - - if ($components) { - $app_list[] = (object)array( - 'name' => $app->getTitle(), - 'path' => $app->slug(), - 'components' => $components, - ); - } - } - $admin_log = \PFF\Container::databaseQuery() ->from('admin_log') ->orderBy('created_at DESC') @@ -33,7 +13,6 @@ function IPF_Admin_Views_Index($request, $match) $context = array( 'page_title' => __('Site Administration'), - 'app_list' => $app_list, 'admin_log' => $admin_log, ); return IPF_Admin_App::RenderToResponse('admin/index.html', $context, $request);