Skip to content

Commit

Permalink
Clean up subnavigation logic and remove hard-coded links from Roles a…
Browse files Browse the repository at this point in the history
…nd External Identities (CFM-192)
  • Loading branch information
arlen committed Oct 24, 2022
1 parent 9dbb685 commit c3710f6
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 219 deletions.
112 changes: 0 additions & 112 deletions app/templates/ExternalIdentities/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -32,115 +32,3 @@ if($vv_action == 'add' || $vv_action == 'edit') {

print $this->Field->dateControl('date_of_birth', \App\Lib\Enum\DateTypeEnum::DateOnly);
}

// XXX This is a placeholder for canvas... maybe it should become a separate page
// rather than overload fields.inc?
print $this->Html->link(
__d('controller', 'Names', [99]),
[ 'controller' => 'names',
'action' => 'index',
'?' => [
'external_identity_id' => $vv_obj->id
]
],
['class' => 'linkbutton']
);

print $this->Html->link(
__d('controller', 'EmailAddresses', [99]),
[ 'controller' => 'email_addresses',
'action' => 'index',
'?' => [
'external_identity_id' => $vv_obj->id
]
],
['class' => 'linkbutton']
);

print $this->Html->link(
__d('controller', 'Identifiers', [99]),
[ 'controller' => 'identifiers',
'action' => 'index',
'?' => [
'external_identity_id' => $vv_obj->id
]
],
['class' => 'linkbutton']
);

print $this->Html->link(
__d('controller', 'ExternalIdentityRoles', [99]),
[ 'controller' => 'external_identity_roles',
'action' => 'index',
'?' => [
'external_identity_id' => $vv_obj->id
]
],
['class' => 'linkbutton']
);

print $this->Html->link(
__d('controller', 'HistoryRecords', [99]),
[ 'controller' => 'history_records',
'action' => 'index',
'?' => [
'external_identity_id' => $vv_obj->id
]
],
['class' => 'linkbutton']
);

print $this->Html->link(
__d('controller', 'AdHocAttributes', [99]),
[ 'controller' => 'ad_hoc_attributes',
'action' => 'index',
'?' => [
'external_identity_id' => $vv_obj->id
]
],
['class' => 'linkbutton']
);
print $this->Html->link(
__d('controller', 'Addresses', [99]),
[ 'controller' => 'addresses',
'action' => 'index',
'?' => [
'external_identity_id' => $vv_obj->id
]
],
['class' => 'linkbutton']
);

print $this->Html->link(
__d('controller', 'TelephoneNumbers', [99]),
[ 'controller' => 'telephone_numbers',
'action' => 'index',
'?' => [
'external_identity_id' => $vv_obj->id
]
],
['class' => 'linkbutton']
);

print $this->Html->link(
__d('controller', 'Urls', [99]),
[ 'controller' => 'urls',
'action' => 'index',
'?' => [
'external_identity_id' => $vv_obj->id
]
],
['class' => 'linkbutton']
);

print $this->Html->link(
__d('controller', 'Pronouns', [99]),
[ 'controller' => 'pronouns',
'action' => 'index',
'?' => [
'external_identity_id' => $vv_obj->id
]
],
['class' => 'linkbutton']
);
36 changes: 0 additions & 36 deletions app/templates/ExternalIdentityRoles/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -48,39 +48,3 @@ if($vv_action == 'add' || $vv_action == 'edit') {

print $this->Field->dateControl('valid_through');
}

// XXX This is a placeholder for canvas... maybe it should become a separate page
// rather than overload fields.inc?
print $this->Html->link(
__d('controller', 'AdHocAttributes', [99]),
[ 'controller' => 'ad_hoc_attributes',
'action' => 'index',
'?' => [
'external_identity_role_id' => $vv_obj->id
]
],
['class' => 'linkbutton']
);

print $this->Html->link(
__d('controller', 'Addresses', [99]),
[ 'controller' => 'addresses',
'action' => 'index',
'?' => [
'external_identity_role_id' => $vv_obj->id
]
],
['class' => 'linkbutton']
);

print $this->Html->link(
__d('controller', 'TelephoneNumbers', [99]),
[ 'controller' => 'telephone_numbers',
'action' => 'index',
'?' => [
'external_identity_role_id' => $vv_obj->id
]
],
['class' => 'linkbutton']
);
36 changes: 0 additions & 36 deletions app/templates/PersonRoles/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -61,39 +61,3 @@ if($vv_action == 'add' || $vv_action == 'edit') {

print $this->Field->dateControl('valid_through');
}

// XXX This is a placeholder for canvas... maybe it should become a separate page
// rather than overload fields.inc?
print $this->Html->link(
__d('controller', 'AdHocAttributes', [99]),
[ 'controller' => 'ad_hoc_attributes',
'action' => 'index',
'?' => [
'person_role_id' => $vv_obj->id
]
],
['class' => 'linkbutton']
);

print $this->Html->link(
__d('controller', 'Addresses', [99]),
[ 'controller' => 'addresses',
'action' => 'index',
'?' => [
'person_role_id' => $vv_obj->id
]
],
['class' => 'linkbutton']
);

print $this->Html->link(
__d('controller', 'TelephoneNumbers', [99]),
[ 'controller' => 'telephone_numbers',
'action' => 'index',
'?' => [
'person_role_id' => $vv_obj->id
]
],
['class' => 'linkbutton']
);
73 changes: 38 additions & 35 deletions app/templates/element/subnavigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
* @package registry
* @since COmanage Registry v5.0.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*
* The subnavigation is structured in first, second, and third level blocks.
* Only External Identity Roles have a third-level of navigation.
*
*/
use Cake\View\Helper;

Expand All @@ -32,7 +36,7 @@
$curAction = $this->request->getParam('action');

if(!empty($vv_primary_link) && !empty($this->request->getQuery($vv_primary_link))) {
// This will work for most index views
// This will work for most top-level index views
$curId = $this->request->getQuery($vv_primary_link);
$linkFilter = [$vv_primary_link => $curId];
// For top-level nav
Expand All @@ -46,46 +50,44 @@
$curId = $vv_obj->id;
if(!empty($vv_person_id)) {
$curId = $vv_person_id;
} else
if(!empty($vv_primary_link_id)) {
} elseif(!empty($vv_primary_link_id)) {
$curId = $vv_primary_link_id;
}
// For top-level nav
// For top-level nav while in edit pages.
if ($name == 'person') {
$linkFilter = ['person_id' => $curId];
} elseif ($name == 'group') {
$linkFilter = ['group_id' => $curId];
}
}

// Simplify our tests for roles and external identifiers (in Person subnav)
$isPersonRole = (
$vv_primary_link == 'person_role_id'
|| $vv_primary_link == 'person_role_id'
|| ($curController == 'PersonRoles' && ($curAction == 'edit' || $curAction == 'view'))
) ? true : false;

$isExternalIdRole = (
$vv_primary_link == 'external_identity_role_id'
|| ($curController == 'ExternalIdentityRoles' && ($curAction == 'edit' || $curAction == 'view'))
) ? true : false;

$isExternalId = (
$vv_primary_link == 'external_identity_id'
|| $vv_primary_link == 'external_identity_role_id'
|| ($curController == 'ExternalIdentities' && ($curAction == 'edit' || $curAction == 'view'))
|| ($curController == 'ExternalIdentityRoles' && ($curAction == 'edit' || $curAction == 'view'))
) ? true : false;

?>

<!-- Top-Level Subnavigation Tabs -->
<nav id="cm-<?= $name ?>-subnav-tabs" class="cm-subnav-tabs">
<ul class="nav nav-tabs">

<?php if ($name == 'person'): ?>
<!-- Person Subnavigation -->
<!-- Person Subnavigation -->
<?php
// Simplify our tests for roles and external identifiers
$isPersonRole = (
$vv_primary_link == 'person_role_id'
|| $vv_primary_link == 'person_role_id'
|| ($curController == 'PersonRoles' && ($curAction == 'edit' || $curAction == 'view'))
) ? true : false;

$isExternalIdRole = (
$vv_primary_link == 'external_identity_role_id'
|| ($curController == 'ExternalIdentityRoles' && ($curAction == 'edit' || $curAction == 'view'))
) ? true : false;

$isExternalId = (
$vv_primary_link == 'external_identity_id'
|| $vv_primary_link == 'external_identity_role_id'
|| ($curController == 'ExternalIdentities' && ($curAction == 'edit' || $curAction == 'view'))
|| ($curController == 'ExternalIdentityRoles' && ($curAction == 'edit' || $curAction == 'view'))
) ? true : false;

// Determine active tab. This logic is necessitated by MVEAs (that are displayed in multiple contexts).
$isPropertiesTab = ($active == 'properties') ? true : false;

Expand All @@ -109,7 +111,7 @@

<li class="nav-item">
<?php
$linkClass = ($isPropertiesTab) ? 'nav-link active' : 'nav-link';
$linkClass = $isPropertiesTab ? 'nav-link active' : 'nav-link';
print $this->Html->link(
__d('controller', 'Properties', [99]),
[ 'controller' => 'people',
Expand All @@ -122,7 +124,7 @@
</li>
<li class="nav-item">
<?php
$linkClass = ($isAttributesTab) ? 'nav-link active' : 'nav-link';
$linkClass = $isAttributesTab ? 'nav-link active' : 'nav-link';
print $this->Html->link(
__d('menu', 'Attributes', [99]),
[ 'controller' => 'names',
Expand All @@ -148,7 +150,7 @@
</li>
<li class="nav-item">
<?php
$linkClass = ($isExternalIdentitiesTab) ? 'nav-link active' : 'nav-link';
$linkClass = $isExternalIdentitiesTab ? 'nav-link active' : 'nav-link';
print $this->Html->link(
__d('controller', 'ExternalIdentities', [99]),
[ 'controller' => 'external-identities',
Expand All @@ -162,7 +164,7 @@
<?php endif; ?>

<?php if ($name == 'group'): ?>
<!-- Group Subnavigation -->
<!-- Group Subnavigation -->
<li class="nav-item">
<?php
$linkClass = ($active == 'properties') ? 'nav-link active' : 'nav-link';
Expand Down Expand Up @@ -228,7 +230,7 @@
$curId = $vv_ei_id;
}
// We display the role or external identity name above the subnav to show the hierarchy.
// Use this branch to also set the second-level $linkFilter
// We also use this structure to set the second-level $linkFilter
print '<h2>';
if(!empty($vv_ei_name)) {
// We have an external identity name
Expand All @@ -255,9 +257,6 @@
if($curController == 'ExternalIdentities') {
$linkFilter = ['external_identity_id' => $curId];
}
if($curController == 'ExternalIdentityRoles') {
$linkFilter = ['external_identity_role_id' => $curId];
}
} else {
// We shouldn't get here, but have a deafult in case.
print __d('information','global.title.none');
Expand Down Expand Up @@ -426,8 +425,9 @@
<?php endif; ?>
</ul>
</nav>

<?php if($isExternalIdRole): ?>
<!-- Third-level subnavigation links -->
<!-- Third-level subnavigation links - only for External Identity Roles -->
<div id="external-id-role">
<h3>
<?php
Expand All @@ -453,7 +453,10 @@
<li class="list-inline-item">
<?php
// Properties
$linkClass = ($subActive == 'properties') ? 'nav-link active' : 'nav-link';
$linkClass = (
$curController == 'ExternalIdentityRoles'
&& ($curAction == 'edit' || $curAction == 'view')
) ? 'nav-link active' : 'nav-link';
print $this->Html->link(
__d('controller', 'Properties', [99]),
[ 'controller' => 'external-identity-roles',
Expand Down

0 comments on commit c3710f6

Please sign in to comment.