From 16aec3e0eebf2baa0705a6cd2d44ed2c81f89be6 Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Wed, 5 Apr 2023 13:08:26 -0400 Subject: [PATCH] Build Person "Action" menu from $topLinks and move "Add" menu onto Person tab (CFM-260) (#87) * Move person canvas Add menu to the Person tab (CFM-260) * Remove "Person Role" from Add menu now that it is contextually connected only to the Person tab (CFM-260) * Ensure that the Person canvas menu link are built from $topLinks in config (CFM-260) --- app/templates/People/fields-nav.inc | 60 ++++++++++- app/templates/Standard/add-edit-view.php | 53 ++-------- app/templates/element/personCanvas.php | 126 +++++++++++++++++++++++ app/templates/element/subnavigation.php | 117 ++------------------- app/webroot/css/co-base.css | 6 ++ 5 files changed, 208 insertions(+), 154 deletions(-) create mode 100644 app/templates/element/personCanvas.php diff --git a/app/templates/People/fields-nav.inc b/app/templates/People/fields-nav.inc index cf904e33d..5ee314e2f 100644 --- a/app/templates/People/fields-nav.inc +++ b/app/templates/People/fields-nav.inc @@ -26,6 +26,8 @@ */ // XXX: if CFM-218 (Make fields.inc configuration only) is accepted, move the contents of this file into fields.inc + +// Output for $topLinks from this specific configuration is presented in the Person canvas "Actions" menu. $topLinks = [ [ 'icon' => 'history', @@ -37,8 +39,62 @@ $topLinks = [ '?' => [ 'person_id' => $vv_obj->id ] - ], - 'class' => '' + ] + ] +]; + +// $addMenuLinks is also given slightly different treatment from the typical $topLinks found in most views: +// it is a page-global menu used for adding MVEAs to the person canvas and is given special treatment in +// element/personCanvas.php. +$addMenuLinks = [ + [ + 'controller' => 'names', + 'action' => 'add', + 'icon' => 'account_box', + 'iconClass' => 'material-icons-outlined' + ], + [ + 'controller' => 'email_addresses', + 'action' => 'add', + 'icon' => 'email', + 'iconClass' => 'material-icons-outlined' + ], + [ + 'controller' => 'identifiers', + 'action' => 'add', + 'icon' => 'fingerprint' + ], + [ + 'controller' => 'ad_hoc_attributes', + 'action' => 'add', + 'icon' => 'check_box', + 'iconClass' => 'material-icons-outlined' + ], + [ + 'controller' => 'addresses', + 'action' => 'add', + 'icon' => 'contact_mail', + 'iconClass' => 'material-icons-outlined' + ], + [ + 'controller' => 'history_records', + 'action' => 'add', + 'icon' => 'history' + ], + [ + 'controller' => 'pronouns', + 'action' => 'add', + 'icon' => 'transgender' + ], + [ + 'controller' => 'telephone_numbers', + 'action' => 'add', + 'icon' => 'phone' + ], + [ + 'controller' => 'urls', + 'action' => 'add', + 'icon' => 'link' ] ]; diff --git a/app/templates/Standard/add-edit-view.php b/app/templates/Standard/add-edit-view.php index 3f84dd449..b1c2e2c3e 100644 --- a/app/templates/Standard/add-edit-view.php +++ b/app/templates/Standard/add-edit-view.php @@ -71,6 +71,10 @@ if(!empty($subnav)) { // Include the $flashArgs for the subnavigation element $subnav['flashArgs'] = $flashArgs; + if(!empty($topLinks) && ($modelsName == 'People' && $vv_action == 'edit')) { + // We are in Person canvas mode: pass along the top links for building the Actions menu. + $subnav['topLinks'] = $topLinks; + } // Generate the subnavigation title and tabs print $this->element('subnavigation', $subnav); } @@ -79,53 +83,10 @@ id; - } + // The person canvas has $addMenuLinks defined in templates/People/fields-nav.inc config. + print $this->element('personCanvas', ['vv_add_menu_links' => $addMenuLinks]); ?> -
- -
- element( - 'mveaJs', - [ - 'htmlId' => 'person-canvas-' . $attr . '-js', - 'parentId' => $objId, - 'mveaType' => $attr, - 'entityType' => 'person' - ] - ); - } - } - // XXX Add the DOB as its own special card. - ?> -
-
- +
diff --git a/app/templates/element/personCanvas.php b/app/templates/element/personCanvas.php new file mode 100644 index 000000000..dcdd4c987 --- /dev/null +++ b/app/templates/element/personCanvas.php @@ -0,0 +1,126 @@ +id; + if(!empty($vv_person_id)) { + $curId = $vv_person_id; + } elseif(!empty($vv_primary_link_id)) { + $curId = $vv_primary_link_id; + } + } + + // Build the Add menu + $action_args = array(); + $action_args['vv_attr_id'] = $curId; + $action_args['vv_actions_type'] = 'person-actions-add-menu'; + $action_args['vv_actions_title'] = __d('operation','add'); + $action_args['vv_actions_icon'] = 'add_circle'; + $action_args['vv_actions_class'] = 'person-actions-add-menu'; + $actionOrderDefault = $this->Menu->getMenuOrder('Default'); + $personAddMenuActions = $vv_add_menu_links; + foreach(($personAddMenuActions ?? []) as $a) { + $actionOrder = !empty($a['order']) ? $a['order'] : $actionOrderDefault++; + $actionIcon = !empty($a['icon']) ? $a['icon'] : $this->Menu->getMenuIcon('Default'); + $actionIconClass = !empty($a['iconClass']) ? $a['iconClass'] : ''; + $actionClass = !empty($a['class']) ? $a['class'] : ''; + $actionUrl = $this->Url->build( + [ + 'controller' => $a['controller'], + 'action' => $a['action'], + '?' => [ + 'person_id' => $curId + ] + ] + ); + $actionLabel = __d('controller', Cake\Utility\Inflector::camelize($a['controller']), [1]); + $action_args['vv_actions'][] = [ + 'order' => $actionOrder, + 'icon' => $actionIcon, + 'iconClass' => $actionIconClass, + 'url' => $actionUrl, + 'class' => $actionClass, + 'label' => $actionLabel + ]; + } +?> +
+ element('menuAction', $action_args) ?> +
+ + +id; + } +?> +
+ +
+ element( + 'mveaJs', + [ + 'htmlId' => 'person-canvas-' . $attr . '-js', + 'parentId' => $objId, + 'mveaType' => $attr, + 'entityType' => 'person' + ] + ); + } + } + // XXX Add the DOB as its own special card. + ?> +
+
\ No newline at end of file diff --git a/app/templates/element/subnavigation.php b/app/templates/element/subnavigation.php index 09a43ad79..34b0bec98 100644 --- a/app/templates/element/subnavigation.php +++ b/app/templates/element/subnavigation.php @@ -96,97 +96,8 @@
- +