From c8275c4aa3c8a269cf4e3e34220d3e62684d044b Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Tue, 11 Oct 2022 12:32:17 -0400 Subject: [PATCH] Submenus first commit: add submenus to People and Groups (CFM-192) --- app/resources/locales/en_US/menu.po | 3 + app/src/Controller/MVEAController.php | 12 +- app/src/Controller/StandardController.php | 7 + app/templates/AdHocAttributes/columns.inc | 6 + app/templates/AdHocAttributes/fields-nav.inc | 35 +++ app/templates/Addresses/columns.inc | 6 + app/templates/Addresses/fields-nav.inc | 35 +++ app/templates/EmailAddresses/columns.inc | 6 + app/templates/EmailAddresses/fields-nav.inc | 35 +++ app/templates/ExternalIdentities/columns.inc | 5 + app/templates/GroupMembers/columns.inc | 5 + .../{Groups => GroupMembers}/fields-nav.inc | 18 +- app/templates/GroupNestings/columns.inc | 5 + app/templates/GroupNestings/fields-nav.inc | 34 +++ app/templates/GroupOwners/columns.inc | 5 + app/templates/Identifiers/columns.inc | 16 +- app/templates/Identifiers/fields-nav.inc | 35 +++ app/templates/Names/columns.inc | 6 + app/templates/People/fields.inc | 113 -------- app/templates/PersonRoles/columns.inc | 5 + app/templates/Standard/add-edit-view.php | 37 ++- app/templates/Standard/index.php | 29 +- app/templates/TelephoneNumbers/columns.inc | 6 + app/templates/TelephoneNumbers/fields-nav.inc | 35 +++ app/templates/Urls/columns.inc | 6 + app/templates/Urls/fields-nav.inc | 35 +++ app/templates/element/datePicker.php | 26 ++ app/templates/element/subnavigation.php | 266 ++++++++++++++++++ app/webroot/css/co-base.css | 20 +- 29 files changed, 706 insertions(+), 146 deletions(-) create mode 100644 app/templates/AdHocAttributes/fields-nav.inc create mode 100644 app/templates/Addresses/fields-nav.inc create mode 100644 app/templates/EmailAddresses/fields-nav.inc rename app/templates/{Groups => GroupMembers}/fields-nav.inc (81%) create mode 100644 app/templates/GroupNestings/fields-nav.inc create mode 100644 app/templates/Identifiers/fields-nav.inc create mode 100644 app/templates/TelephoneNumbers/fields-nav.inc create mode 100644 app/templates/Urls/fields-nav.inc create mode 100644 app/templates/element/subnavigation.php diff --git a/app/resources/locales/en_US/menu.po b/app/resources/locales/en_US/menu.po index 2376b0bf2..f8884c6bc 100644 --- a/app/resources/locales/en_US/menu.po +++ b/app/resources/locales/en_US/menu.po @@ -24,6 +24,9 @@ # Menu Messages +msgid "co.Attributes" +msgstr "Attributes" + msgid "co.configuration" msgstr "Config" diff --git a/app/src/Controller/MVEAController.php b/app/src/Controller/MVEAController.php index 2f2323f9e..7a5fb97f0 100644 --- a/app/src/Controller/MVEAController.php +++ b/app/src/Controller/MVEAController.php @@ -81,7 +81,9 @@ public function beforeRender(\Cake\Event\EventInterface $event) { $this->set('vv_ei_id', $externalIdentity->id); // What's the primary name of the Person? - $this->set('vv_person_name', $Names->primaryName($externalIdentity->person_id)); + $personName = $Names->primaryName($externalIdentity->person_id); + $this->set('vv_person_name', $personName); + $this->set('vv_supertitle', $personName->full_name); $this->set('vv_person_id', $externalIdentity->person_id); break; case 'person_role_id': @@ -92,11 +94,15 @@ public function beforeRender(\Cake\Event\EventInterface $event) { $this->set('vv_person_role_id', $link->value); // Also set a name - $this->set('vv_person_name', $Names->primaryName($roleEntity->person_id)); + $personName = $Names->primaryName($roleEntity->person_id); + $this->set('vv_person_name', $personName); + $this->set('vv_supertitle', $personName->full_name); $this->set('vv_person_id', $roleEntity->person_id); break; case 'person_id': - $this->set('vv_person_name', $Names->primaryName((int)$link->value)); + $personName = $Names->primaryName((int)$link->value); + $this->set('vv_person_name', $personName); + $this->set('vv_supertitle', $personName->full_name); $this->set('vv_person_id', $link->value); break; default; diff --git a/app/src/Controller/StandardController.php b/app/src/Controller/StandardController.php index 4bf4fea62..d28792885 100644 --- a/app/src/Controller/StandardController.php +++ b/app/src/Controller/StandardController.php @@ -97,6 +97,12 @@ public function add() { // Default title is add new object $this->set('vv_title', __d('operation', 'add.a', __d('controller', $modelsName, [1]))); + + // Supertitle is normally the display name of the parent object when subnavigation exists. + // Set this here as the fallback default. This value is overriden in MVEAController to hold the + // name of the parent object, not the model name of the current object. + // TODO: set this to a better value for other kinds of child objects (e.g. Group member) + $this->set('vv_supertitle', __d('controller', $modelsName, [1])); // Let the view render $this->render('/Standard/add-edit-view'); @@ -322,6 +328,7 @@ public function edit(string $id) { // We don't use a trait for this since each table will implement different logic $this->set('vv_title', __d('operation', 'edit.ai', $table->generateDisplayField($obj))); + $this->set('vv_supertitle', $table->generateDisplayField($obj)); } else { // Default view title is edit object display field $field = $table->getDisplayField(); diff --git a/app/templates/AdHocAttributes/columns.inc b/app/templates/AdHocAttributes/columns.inc index 335fb303c..dd2f93b61 100644 --- a/app/templates/AdHocAttributes/columns.inc +++ b/app/templates/AdHocAttributes/columns.inc @@ -37,4 +37,10 @@ $indexColumns = [ $bulkActions = [ // TODO: develop bulk actions. For now, use a placeholder. 'delete' => true +]; + +$subnav = [ + 'name' => 'person', + 'active' => 'attributes', + 'subActive' => 'ad_hoc_attributes' ]; \ No newline at end of file diff --git a/app/templates/AdHocAttributes/fields-nav.inc b/app/templates/AdHocAttributes/fields-nav.inc new file mode 100644 index 000000000..8cddfe107 --- /dev/null +++ b/app/templates/AdHocAttributes/fields-nav.inc @@ -0,0 +1,35 @@ + 'person', + 'active' => 'attributes', + 'subActive' => 'ad_hoc_attributes' +]; \ No newline at end of file diff --git a/app/templates/Addresses/columns.inc b/app/templates/Addresses/columns.inc index 50ea05056..257f4b097 100644 --- a/app/templates/Addresses/columns.inc +++ b/app/templates/Addresses/columns.inc @@ -42,3 +42,9 @@ $bulkActions = [ // TODO: develop bulk actions. For now, use a placeholder. 'delete' => true ]; + +$subnav = [ + 'name' => 'person', + 'active' => 'attributes', + 'subActive' => 'addresses' +]; diff --git a/app/templates/Addresses/fields-nav.inc b/app/templates/Addresses/fields-nav.inc new file mode 100644 index 000000000..08574e5a4 --- /dev/null +++ b/app/templates/Addresses/fields-nav.inc @@ -0,0 +1,35 @@ + 'person', + 'active' => 'attributes', + 'subActive' => 'addresses' +]; \ No newline at end of file diff --git a/app/templates/EmailAddresses/columns.inc b/app/templates/EmailAddresses/columns.inc index 0af877b80..da915ca19 100644 --- a/app/templates/EmailAddresses/columns.inc +++ b/app/templates/EmailAddresses/columns.inc @@ -37,4 +37,10 @@ $indexColumns = [ $bulkActions = [ // TODO: develop bulk actions. For now, use a placeholder. 'delete' => true +]; + +$subnav = [ + 'name' => 'person', + 'active' => 'attributes', + 'subActive' => 'email_addresses' ]; \ No newline at end of file diff --git a/app/templates/EmailAddresses/fields-nav.inc b/app/templates/EmailAddresses/fields-nav.inc new file mode 100644 index 000000000..157ea46fc --- /dev/null +++ b/app/templates/EmailAddresses/fields-nav.inc @@ -0,0 +1,35 @@ + 'person', + 'active' => 'attributes', + 'subActive' => 'email_addresses' +]; \ No newline at end of file diff --git a/app/templates/ExternalIdentities/columns.inc b/app/templates/ExternalIdentities/columns.inc index d7482c7ee..9bdce03a2 100644 --- a/app/templates/ExternalIdentities/columns.inc +++ b/app/templates/ExternalIdentities/columns.inc @@ -40,4 +40,9 @@ $indexColumns = [ $bulkActions = [ // TODO: develop bulk actions. For now, use a placeholder. 'delete' => true +]; + +$subnav = [ + 'name' => 'person', + 'active' => 'external_identities' ]; \ No newline at end of file diff --git a/app/templates/GroupMembers/columns.inc b/app/templates/GroupMembers/columns.inc index b1d33928b..4faec634b 100644 --- a/app/templates/GroupMembers/columns.inc +++ b/app/templates/GroupMembers/columns.inc @@ -60,4 +60,9 @@ $indexColumns = [ $bulkActions = [ // TODO: develop bulk actions. For now, use a placeholder. 'delete' => true +]; + +$subnav = [ + 'name' => 'group', + 'active' => 'members' ]; \ No newline at end of file diff --git a/app/templates/Groups/fields-nav.inc b/app/templates/GroupMembers/fields-nav.inc similarity index 81% rename from app/templates/Groups/fields-nav.inc rename to app/templates/GroupMembers/fields-nav.inc index 38d21495f..1dba6bd0e 100644 --- a/app/templates/Groups/fields-nav.inc +++ b/app/templates/GroupMembers/fields-nav.inc @@ -1,6 +1,6 @@ 'sync', - 'order' => 'Default', - 'label' => __d('operation', 'reconcile'), - 'link' => [ - 'action' => 'reconcile' - ], - 'class' => '' - ] +// XXX: if CFM-218 (Make fields.inc configuration only) is accepted, move the contents of this file into fields.inc +$topLinks = []; + +$subnav = [ + 'name' => 'group', + 'active' => 'members' ]; \ No newline at end of file diff --git a/app/templates/GroupNestings/columns.inc b/app/templates/GroupNestings/columns.inc index 2fa1abbfb..014c4cec8 100644 --- a/app/templates/GroupNestings/columns.inc +++ b/app/templates/GroupNestings/columns.inc @@ -37,4 +37,9 @@ $indexColumns = [ $bulkActions = [ // TODO: develop bulk actions. For now, use a placeholder. 'delete' => true +]; + +$subnav = [ + 'name' => 'group', + 'active' => 'nestings' ]; \ No newline at end of file diff --git a/app/templates/GroupNestings/fields-nav.inc b/app/templates/GroupNestings/fields-nav.inc new file mode 100644 index 000000000..1374feaae --- /dev/null +++ b/app/templates/GroupNestings/fields-nav.inc @@ -0,0 +1,34 @@ + 'group', + 'active' => 'nestings' +]; \ No newline at end of file diff --git a/app/templates/GroupOwners/columns.inc b/app/templates/GroupOwners/columns.inc index e65333f78..efb861e28 100644 --- a/app/templates/GroupOwners/columns.inc +++ b/app/templates/GroupOwners/columns.inc @@ -39,4 +39,9 @@ $indexColumns = [ $bulkActions = [ // TODO: develop bulk actions. For now, use a placeholder. 'delete' => true +]; + +$subnav = [ + 'name' => 'group', + 'active' => 'owners' ]; \ No newline at end of file diff --git a/app/templates/Identifiers/columns.inc b/app/templates/Identifiers/columns.inc index 1eb1d552e..48c82927c 100644 --- a/app/templates/Identifiers/columns.inc +++ b/app/templates/Identifiers/columns.inc @@ -34,11 +34,6 @@ $indexColumns = [ ] ]; -$bulkActions = [ - // TODO: develop bulk actions. For now, use a placeholder. - 'delete' => true -]; - $indexActions = [ [ 'controller' => 'authentication_events', @@ -52,4 +47,15 @@ $indexActions = [ ]; } ] +]; + +$bulkActions = [ + // TODO: develop bulk actions. For now, use a placeholder. + 'delete' => true +]; + +$subnav = [ + 'name' => 'person', + 'active' => 'attributes', + 'subActive' => 'identifiers' ]; \ No newline at end of file diff --git a/app/templates/Identifiers/fields-nav.inc b/app/templates/Identifiers/fields-nav.inc new file mode 100644 index 000000000..bcacd714f --- /dev/null +++ b/app/templates/Identifiers/fields-nav.inc @@ -0,0 +1,35 @@ + 'person', + 'active' => 'attributes', + 'subActive' => 'identifiers' +]; \ No newline at end of file diff --git a/app/templates/Names/columns.inc b/app/templates/Names/columns.inc index 0e648e3d4..feeda0cd5 100644 --- a/app/templates/Names/columns.inc +++ b/app/templates/Names/columns.inc @@ -54,4 +54,10 @@ $rowActions = [ // TODO: develop bulk actions. For now, use a placeholder. $bulkActions = [ 'delete' => true +]; + +$subnav = [ + 'name' => 'person', + 'active' => 'attributes', + 'subActive' => 'names' ]; \ No newline at end of file diff --git a/app/templates/People/fields.inc b/app/templates/People/fields.inc index 3b81e76f6..4bdb5b69e 100644 --- a/app/templates/People/fields.inc +++ b/app/templates/People/fields.inc @@ -46,119 +46,6 @@ if($vv_action == 'add') { 'names.0.primary_name' => true ]; } elseif($vv_action == 'edit') { - // 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', - '?' => [ - 'person_id' => $vv_obj->id - ] - ], - ['class' => 'linkbutton'] - ); - - print $this->Html->link( - __d('controller', 'EmailAddresses', [99]), - [ 'controller' => 'email_addresses', - 'action' => 'index', - '?' => [ - 'person_id' => $vv_obj->id - ] - ], - ['class' => 'linkbutton'] - ); - - print $this->Html->link( - __d('controller', 'Identifiers', [99]), - [ 'controller' => 'identifiers', - 'action' => 'index', - '?' => [ - 'person_id' => $vv_obj->id - ] - ], - ['class' => 'linkbutton'] - ); - - print $this->Html->link( - __d('controller', 'PersonRoles', [99]), - [ 'controller' => 'person_roles', - 'action' => 'index', - '?' => [ - 'person_id' => $vv_obj->id - ] - ], - ['class' => 'linkbutton'] - ); - - print $this->Html->link( - __d('controller', 'HistoryRecords', [99]), - [ 'controller' => 'history_records', - 'action' => 'index', - '?' => [ - 'person_id' => $vv_obj->id - ] - ], - ['class' => 'linkbutton'] - ); - - print $this->Html->link( - __d('controller', 'AdHocAttributes', [99]), - [ 'controller' => 'ad_hoc_attributes', - 'action' => 'index', - '?' => [ - 'person_id' => $vv_obj->id - ] - ], - ['class' => 'linkbutton'] - ); - - print $this->Html->link( - __d('controller', 'Addresses', [99]), - [ 'controller' => 'addresses', - 'action' => 'index', - '?' => [ - 'person_id' => $vv_obj->id - ] - ], - ['class' => 'linkbutton'] - ); - - print $this->Html->link( - __d('controller', 'TelephoneNumbers', [99]), - [ 'controller' => 'telephone_numbers', - 'action' => 'index', - '?' => [ - 'person_id' => $vv_obj->id - ] - ], - ['class' => 'linkbutton'] - ); - - print $this->Html->link( - __d('controller', 'Urls', [99]), - [ 'controller' => 'urls', - 'action' => 'index', - '?' => [ - 'person_id' => $vv_obj->id - ] - ], - ['class' => 'linkbutton'] - ); - - print $this->Html->link( - __d('controller', 'ExternalIdentities', [99]), - [ 'controller' => 'external-identities', - 'action' => 'index', - '?' => [ - 'person_id' => $vv_obj->id - ] - ], - ['class' => 'linkbutton'] - ); - $a = $vv_obj->extract(['person_role_id', 'person_id']); } diff --git a/app/templates/PersonRoles/columns.inc b/app/templates/PersonRoles/columns.inc index 1637e09e7..17fc028ea 100644 --- a/app/templates/PersonRoles/columns.inc +++ b/app/templates/PersonRoles/columns.inc @@ -51,4 +51,9 @@ $indexColumns = [ $bulkActions = [ // TODO: develop bulk actions. For now, use a placeholder. 'delete' => true +]; + +$subnav = [ + 'name' => 'person', + 'active' => 'person_roles' ]; \ 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 abb41d9a4..ffae2843c 100644 --- a/app/templates/Standard/add-edit-view.php +++ b/app/templates/Standard/add-edit-view.php @@ -37,9 +37,10 @@ // If you're looking to set a custom $vv_title, you might be able to use // generateDisplayField() on the Table instead -// Include subnavigation structures on edit pages -// XXX: if CFM-218 (Make fields.inc configuration only) is accepted, move the contents of fields-nav.inc into fields.inc. -if($vv_action == 'edit') { +// Include subnavigation structures on add/edit/view pages +// XXX: if CFM-218 (Make fields.inc configuration only) is accepted, move the contents of fields-nav.inc into fields.inc +// When subnav exists, include on all Edit views and on Add/View for items with a parent. +if($vv_action == 'edit' || !empty($vv_bc_parent_obj) || !empty($vv_primary_link_id)) { if(file_exists(ROOT . DS . "templates" . DS . $modelsName . DS . "fields-nav.inc")) { include(ROOT . DS . "templates" . DS . $modelsName . DS . "fields-nav.inc"); } @@ -51,11 +52,30 @@ if(!empty($vv_primary_link) && !empty($this->request->getQuery($vv_primary_link))) { $linkFilter = [$vv_primary_link => $this->request->getQuery($vv_primary_link)]; } - ?> -
+ + + + + +
-

+ +

+ +

+
id; foreach(($topLinks ?? []) as $t) { - if($vv_permissions[ $t['link']['action'] ]) { + // TODO: fix the following test so that cross-model links can exist in top-links (e.g. History Records index) + //if($vv_permissions[ $t['link']['action'] ]) { // We need to inject $linkFilter, but not overwrite any existing query params if(!empty($t['link']['?'])) { $t['link']['?'] = array_merge($t['link']['?'], $linkFilter); @@ -77,7 +98,7 @@ 'url' => $this->Url->build($t['link']), 'label' => $t['label'], ]; - } + //} } // Delete diff --git a/app/templates/Standard/index.php b/app/templates/Standard/index.php index 25b49e8d9..0c06082d1 100644 --- a/app/templates/Standard/index.php +++ b/app/templates/Standard/index.php @@ -58,11 +58,30 @@ if(!empty($vv_primary_link) && !empty($this->request->getQuery($vv_primary_link))) { $linkFilter = [$vv_primary_link => $this->request->getQuery($vv_primary_link)]; } - ?> -
+ + + + + +
-

+ +

+ +

+
id; - // Insert actions as per the .inc file - // TODO: create an element or move this to MenuHelper so it can be used by topLinks as well as actions + // Insert actions as per the .inc file + // TODO: create an element or move this to MenuHelper so it can be used by topLinks as well as actions $actionOrderDefault = $this->Menu->getMenuOrder('Default'); foreach($rowActions as $a) { $ok = false; diff --git a/app/templates/TelephoneNumbers/columns.inc b/app/templates/TelephoneNumbers/columns.inc index a8916b276..55289a091 100644 --- a/app/templates/TelephoneNumbers/columns.inc +++ b/app/templates/TelephoneNumbers/columns.inc @@ -37,4 +37,10 @@ $indexColumns = [ $bulkActions = [ // TODO: develop bulk actions. For now, use a placeholder. 'delete' => true +]; + +$subnav = [ + 'name' => 'person', + 'active' => 'attributes', + 'subActive' => 'telephone_numbers' ]; \ No newline at end of file diff --git a/app/templates/TelephoneNumbers/fields-nav.inc b/app/templates/TelephoneNumbers/fields-nav.inc new file mode 100644 index 000000000..267ae0281 --- /dev/null +++ b/app/templates/TelephoneNumbers/fields-nav.inc @@ -0,0 +1,35 @@ + 'person', + 'active' => 'attributes', + 'subActive' => 'telephone_numbers' +]; \ No newline at end of file diff --git a/app/templates/Urls/columns.inc b/app/templates/Urls/columns.inc index f7a32778e..5790bff73 100644 --- a/app/templates/Urls/columns.inc +++ b/app/templates/Urls/columns.inc @@ -37,4 +37,10 @@ $indexColumns = [ $bulkActions = [ // TODO: develop bulk actions. For now, use a placeholder. 'delete' => true +]; + +$subnav = [ + 'name' => 'person', + 'active' => 'attributes', + 'subActive' => 'urls' ]; \ No newline at end of file diff --git a/app/templates/Urls/fields-nav.inc b/app/templates/Urls/fields-nav.inc new file mode 100644 index 000000000..8e2ef8f47 --- /dev/null +++ b/app/templates/Urls/fields-nav.inc @@ -0,0 +1,35 @@ + 'person', + 'active' => 'attributes', + 'subActive' => 'names' +]; \ No newline at end of file diff --git a/app/templates/element/datePicker.php b/app/templates/element/datePicker.php index e04bc9b0e..7d25f5d20 100644 --- a/app/templates/element/datePicker.php +++ b/app/templates/element/datePicker.php @@ -1,4 +1,30 @@ request->getQuery($vv_primary_link))) { + // This will work for most index views + $curId = $this->request->getQuery($vv_primary_link); + $linkFilter = [$vv_primary_link => $curId]; +} 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 + $curId = $vv_obj->id; + if(!empty($vv_primary_link_id)) { + $curId = $vv_primary_link_id; + } + if ($name == 'person') { + $linkFilter = ['person_id' => $curId]; + } + if ($name == 'group') { + $linkFilter = ['group_id' => $curId]; + } +} +?> + + + + + + \ No newline at end of file diff --git a/app/webroot/css/co-base.css b/app/webroot/css/co-base.css index 4d5eab282..99d944280 100644 --- a/app/webroot/css/co-base.css +++ b/app/webroot/css/co-base.css @@ -527,7 +527,7 @@ ul.form-list li.alert-banner .co-alert { font-size: 0.9em; margin-top: -1em; } -.titleNavContainer { +.pageTitleContainer { display: flex; justify-content: space-between; margin: 1em 0 0.5em; @@ -536,6 +536,9 @@ ul.form-list li.alert-banner .co-alert { .pageTitle { padding-bottom: 0.25em; } +.pageTitle h2 { + line-height: 1.2em; +} .pageTitle .deleted, .pageTitle .archived { background-color: var(--cmg-color-red-003); @@ -550,6 +553,21 @@ ul.form-list li.alert-banner .co-alert { .pageTitle .archived { background-color: var(--cmg-color-gray-003); } +/* SUBNAVIGATION & TABS */ +.supertitle { + padding: 1em 0; +} +#subnavigation nav { + padding: 0.5em 0; +} +.cm-subnav-tabs .nav-link { + text-transform: uppercase; + padding: 1em 1.5em; + color: var(--cmg-color-blue-001); +} +.cm-subnav-links .nav-link.active { + color: var(--cmg-color-gray-001); +} /* INNER CONTENT - for non-table-based layouts */ #content { padding: 2rem;