Skip to content

Move "Switch CO" link from Main Menu (CFM-157) #9

Merged
merged 3 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions app/templates/element/menuMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,6 @@
]
];

if(count($vv_available_cos) > 1) {
// More than one CO is available, so present the switcher
$menuItems[] = [
'controller' => 'cos',
'action' => 'select',
'permission' => null,
'icon' => 'transfer_within_a_station',
'label' => __d('menu', 'co.switch')
];
}

foreach($menuItems as $m) {
if(!isset($m['permission']) || $vv_menu_permissions[ $m['permission'] ]) {
$linkContent = '<em class="material-icons" aria-hidden="true">' . $m['icon'] . '</em>'
Expand Down
13 changes: 12 additions & 1 deletion app/templates/element/menuTop.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@
<em class="material-icons icon-adjust">person</em>
</a>
<!-- Account Dropdown -->
<div id="user-panel" class="dropdown-menu" aria-labelledby="user-panel-toggle">
<div id="user-panel" class="dropdown-menu <?= (count($vv_available_cos) > 1) ? ' with-co-switcher' : ''; ?>" aria-labelledby="user-panel-toggle">
<div id="logout-in-panel">
<?= $this->Html->link(__d('operation','logout') . ' <span class="fa fa-sign-out"></span>',
'/auth/logout/logout.php',
['escape' => false,
'id' => 'logout-in-panel-link',
'class' => 'btn']);
?>
</div>
Expand All @@ -49,6 +50,16 @@
<div id="user-panel-cn"><?= $vv_user['username']; ?></div>
<div id="user-panel-id"><!-- XXX identifier goes here --></div>
</div>
<?php if(count($vv_available_cos) > 1): // More than one CO is available, so present the switch button ?>
<div id="user-panel-switch-co">
<?= $this->Html->link(__d('menu','co.switch') . ' <em class="material-icons" aria-hidden="true">transfer_within_a_station</em>',
'/cos/select',
['escape' => false,
'id' => 'co-switch-link',
'class' => 'btn']);
?>
</div>
<?php endif; ?>
</div>
</li>
</ul>
Expand Down
13 changes: 8 additions & 5 deletions app/templates/layout/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
$controller_stripped = preg_replace('/[^a-zA-Z0-9\-_]/', '', strtolower($this->request->getParam('controller')));
$action_stripped = preg_replace('/[^a-zA-Z0-9\-_]/', '', strtolower($this->request->getParam('action')));
$bodyClasses = $controller_stripped . ' ' .$action_stripped;
$isCoSelectView = $controller_stripped == 'cos' && $action_stripped == 'select';
$isDashboard = $controller_stripped == 'dashboards' && $action_stripped == 'dashboard';

// add further body classes as needed
if(!empty($vv_user)) {
Expand All @@ -95,7 +97,7 @@
<!-- Primary layout -->
<div id="comanage-wrapper">
<div id="top-bar">
<?php if(!empty($vv_user) && !empty($vv_cur_co)): ?>
<?php if(!empty($vv_user) && !empty($vv_cur_co) && !$isCoSelectView): ?>
<div id="co-hamburger"><em class="material-icons">menu</em></div>
<?php endif; // vv_user ?>
<nav id="top-menu">
Expand All @@ -106,7 +108,9 @@
<header id="banner">
<div id="siteTitle">
<!-- XXX Sanitize $vv_cur_co['name'] -->
<?php if(!empty($vv_cur_co)): ?>
<?php if($isCoSelectView): // just print the name ?>
<?= __('registry.meta.registry') ?>
<?php elseif(!empty($vv_cur_co)): ?>
<?= $this->Html->link(
$vv_cur_co['name'],
['controller' => 'Dashboards',
Expand Down Expand Up @@ -136,7 +140,7 @@
</header>

<div id="main-wrapper">
<?php if(!empty($vv_user) && !empty($vv_cur_co)): ?>
<?php if(!empty($vv_user) && !empty($vv_cur_co) && !$isCoSelectView): ?>
<div id="navigation-drawer">
<nav id="navigation" aria-label="main menu">
<?= $this->element('menuMain'); ?>
Expand All @@ -147,8 +151,7 @@
<main id="main">
<div id="content">
<div id="content-inner">
<?php if(!(($controller_stripped == 'cos' && $action_stripped == 'select') ||
($controller_stripped == 'dashboards' && $action_stripped == 'dashboard'))): ?>
<?php if(!($isCoSelectView || $isDashboard)): ?>
<!-- insert breadcrumbs on all but the front page ("Select Collaborations")
and Dashboards (including the CO landing page) -->
<div id="breadcrumbs">
Expand Down
16 changes: 16 additions & 0 deletions app/webroot/css/co-base.css
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,22 @@ body.logged-in #top-menu {
#user-panel #panel-orgid {
margin-top: 0;
}
#user-panel.with-co-switcher {
padding-bottom: 0;
}
#user-panel #user-panel-switch-co {
clear: both;
text-align: center;
border-top: 1px solid var(--cmg-color-lightgray-006);
margin-top: 4em;
padding: 0;
}
#user-panel #co-switch-link {
text-transform: unset;
font-size: 1.1em;
display: block;
padding: 1em;
}
/* LOGIN & LOGOUT */
#login {
margin-top: -2px;
Expand Down