From 49d2d767d0fe0f251dd47dc83aa17ad6ac0f0d24 Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Mon, 24 Oct 2022 16:26:31 -0400 Subject: [PATCH] Submenus working for People, Person-Roles, External Identities, and External Identity Roles (CFM-192) --- app/resources/locales/en_US/information.po | 3 + app/src/Controller/StandardController.php | 2 + app/templates/EmailAddresses/fields-nav.inc | 2 +- .../ExternalIdentities/fields-nav.inc | 35 ++ .../ExternalIdentityRoles/columns.inc | 6 + .../ExternalIdentityRoles/fields-nav.inc | 35 ++ app/templates/PersonRoles/fields-nav.inc | 3 +- app/templates/Standard/add-edit-view.php | 13 +- app/templates/Standard/index.php | 10 +- app/templates/element/subnavigation.php | 381 +++++++++++++++--- app/webroot/css/co-base.css | 24 +- 11 files changed, 441 insertions(+), 73 deletions(-) create mode 100644 app/templates/ExternalIdentities/fields-nav.inc create mode 100644 app/templates/ExternalIdentityRoles/fields-nav.inc diff --git a/app/resources/locales/en_US/information.po b/app/resources/locales/en_US/information.po index dba961a1a..fa0fe170c 100644 --- a/app/resources/locales/en_US/information.po +++ b/app/resources/locales/en_US/information.po @@ -56,3 +56,6 @@ msgstr "Page {{page}} of {{pages}}, Viewing {{start}}-{{end}} of {{count}}" msgid "global.records.none" msgstr "There are no records to display." + +msgid "global.title.none" +msgstr "No title" diff --git a/app/src/Controller/StandardController.php b/app/src/Controller/StandardController.php index d28792885..43685c882 100644 --- a/app/src/Controller/StandardController.php +++ b/app/src/Controller/StandardController.php @@ -329,6 +329,8 @@ public function edit(string $id) { $this->set('vv_title', __d('operation', 'edit.ai', $table->generateDisplayField($obj))); $this->set('vv_supertitle', $table->generateDisplayField($obj)); + // Pass the display field also into subtitle for dealing with External IDs + $this->set('vv_subtitle', $table->generateDisplayField($obj)); } else { // Default view title is edit object display field $field = $table->getDisplayField(); diff --git a/app/templates/EmailAddresses/fields-nav.inc b/app/templates/EmailAddresses/fields-nav.inc index 157ea46fc..14b677975 100644 --- a/app/templates/EmailAddresses/fields-nav.inc +++ b/app/templates/EmailAddresses/fields-nav.inc @@ -30,6 +30,6 @@ $topLinks = []; $subnav = [ 'name' => 'person', - 'active' => 'attributes', + 'active' => 'attributes', // default for person. 'external identities' are special cased 'subActive' => 'email_addresses' ]; \ No newline at end of file diff --git a/app/templates/ExternalIdentities/fields-nav.inc b/app/templates/ExternalIdentities/fields-nav.inc new file mode 100644 index 000000000..569827598 --- /dev/null +++ b/app/templates/ExternalIdentities/fields-nav.inc @@ -0,0 +1,35 @@ + 'person', + 'active' => 'external_identities', + 'subActive' => 'properties' +]; \ No newline at end of file diff --git a/app/templates/ExternalIdentityRoles/columns.inc b/app/templates/ExternalIdentityRoles/columns.inc index 72d853f16..a911ae50b 100644 --- a/app/templates/ExternalIdentityRoles/columns.inc +++ b/app/templates/ExternalIdentityRoles/columns.inc @@ -44,6 +44,12 @@ $indexColumns = [ ] ]; +$subnav = [ + 'name' => 'person', + 'active' => 'external_identities', + 'subActive' => 'external_identity_roles' +]; + $bulkActions = [ // TODO: develop bulk actions. For now, use a placeholder. 'delete' => true diff --git a/app/templates/ExternalIdentityRoles/fields-nav.inc b/app/templates/ExternalIdentityRoles/fields-nav.inc new file mode 100644 index 000000000..9b766b90b --- /dev/null +++ b/app/templates/ExternalIdentityRoles/fields-nav.inc @@ -0,0 +1,35 @@ + 'person', + 'active' => 'external_identities', + 'subActive' => 'external_identity_roles' +]; \ No newline at end of file diff --git a/app/templates/PersonRoles/fields-nav.inc b/app/templates/PersonRoles/fields-nav.inc index 11932601d..e306f822c 100644 --- a/app/templates/PersonRoles/fields-nav.inc +++ b/app/templates/PersonRoles/fields-nav.inc @@ -30,5 +30,6 @@ $topLinks = []; $subnav = [ 'name' => 'person', - 'active' => 'person_roles' + 'active' => 'person_roles', + 'subActive' => 'properties' ]; \ No newline at end of file diff --git a/app/templates/Standard/add-edit-view.php b/app/templates/Standard/add-edit-view.php index ffae2843c..cce8353c9 100644 --- a/app/templates/Standard/add-edit-view.php +++ b/app/templates/Standard/add-edit-view.php @@ -74,7 +74,18 @@

-

+ request->getParam('controller') == 'PersonRoles' + || $this->request->getParam('controller') == 'ExternalIdentities' + || $this->request->getParam('controller') == 'ExternalIdentityRoles'): ?> +

+ +

+

-

+ +

+ +

+ diff --git a/app/templates/element/subnavigation.php b/app/templates/element/subnavigation.php index f30a37277..93b9088b8 100644 --- a/app/templates/element/subnavigation.php +++ b/app/templates/element/subnavigation.php @@ -24,38 +24,92 @@ * @since COmanage Registry v5.0.0 * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ +use Cake\View\Helper; $linkFilter = []; $curId = NULL; +$curController = $this->request->getParam('controller'); +$curAction = $this->request->getParam('action'); if(!empty($vv_primary_link) && !empty($this->request->getQuery($vv_primary_link))) { // This will work for most index views $curId = $this->request->getQuery($vv_primary_link); $linkFilter = [$vv_primary_link => $curId]; + // For top-level nav + if(!empty($vv_person_id)) { + $curId = $vv_person_id; + $linkFilter = ['person_id' => $vv_person_id]; + } } elseif (!empty($vv_obj)) { - // This will work for most edit views - // XXX we might produce the $vv_primary_link for edit views so this approach could be deprecated + // This will work for most top-level edit views + // XXX we might produce the $vv_primary_link for edit views so the approach below could be deprecated $curId = $vv_obj->id; + if(!empty($vv_person_id)) { + $curId = $vv_person_id; + } else if(!empty($vv_primary_link_id)) { $curId = $vv_primary_link_id; } + // For top-level nav if ($name == 'person') { $linkFilter = ['person_id' => $curId]; - } - if ($name == 'group') { + } 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; + +?> + + - + + + request->getQuery($vv_primary_link); + if($isPersonRole || $isExternalId) { + if($isExternalId && !empty($vv_ei_id)) { + $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 + print '

'; + if(!empty($vv_ei_name)) { + // We have an external identity name + print $vv_ei_name->full_name; + $linkFilter = ['external_identity_id' => $curId]; + } elseif(!empty($vv_person_role)) { + // We have a person role + print $vv_person_role; + $linkFilter = ['person_role_id' => $curId]; + } elseif(!empty($vv_obj)) { + // We are editing/viewing an object + if(!empty($vv_obj->title)) { + print $vv_obj->title; + } elseif (!empty($vv_subtitle)) { + print $vv_subtitle; + } else { + print print __d('information','global.title.none'); + } + // Set up $linkFilter for edit/view on Roles and External Identities + $curId = $vv_obj->id; + if($curController == 'PersonRoles') { + $linkFilter = ['person_role_id' => $curId]; + } + 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'); + } + print '

'; + } + ?> + + +
+

+ request->getQuery($vv_primary_link); + if(!empty($vv_obj)) { + $curId = $vv_obj->id; + } + $linkFilter = ['external_identity_role_id' => $curId]; + + if(!empty($vv_ei_role)) { + print $vv_ei_role; + } elseif(!empty($vv_obj->title)) { + print $vv_obj->title; + } else { + // As above, we shouldn't get here, but have a deafult in case. + print __d('information','global.title.none'); + } + ?> +

+ +
+ \ No newline at end of file diff --git a/app/webroot/css/co-base.css b/app/webroot/css/co-base.css index 99d944280..640734aa4 100644 --- a/app/webroot/css/co-base.css +++ b/app/webroot/css/co-base.css @@ -54,8 +54,8 @@ h2 { margin: 0; } h3 { - font-size: 1.6em; - line-height: 1.6em; + font-size: 1.4em; + line-height: 1.4em; margin: 0; } a { @@ -568,6 +568,26 @@ ul.form-list li.alert-banner .co-alert { .cm-subnav-links .nav-link.active { color: var(--cmg-color-gray-001); } +.cm-subnav-links ul.list-inline { + margin: 0.5em 0 0 0; + font-size: 0.9em; +} +.cm-subnav-links .list-inline-item { + margin: 0; +} +.cm-subnav-links .list-inline-item a.nav-link { + padding: 0 1.5em 0.5em 0; +} +#external-id-role { + border-top: 1px solid var(--cmg-color-lightgray-006); +} +#external-id-role h3 { + padding: 0.5rem 1rem; + background-color: var(--cmg-color-lightgray-003); +} +#external-id-role-nav { + margin-left: 1rem; +} /* INNER CONTENT - for non-table-based layouts */ #content { padding: 2rem;