From cd871c6d4ffee09f20d445e0d72018b7e060b79a Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Wed, 5 Apr 2023 11:52:32 -0400 Subject: [PATCH 1/3] Move person canvas Add menu to the Person tab (CFM-260) --- app/templates/People/fields-nav.inc | 59 +++++++++++ app/templates/Standard/add-edit-view.php | 47 +-------- app/templates/element/personCanvas.php | 126 +++++++++++++++++++++++ app/templates/element/subnavigation.php | 89 ---------------- app/webroot/css/co-base.css | 6 ++ 5 files changed, 193 insertions(+), 134 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..28c52d2aa 100644 --- a/app/templates/People/fields-nav.inc +++ b/app/templates/People/fields-nav.inc @@ -41,6 +41,65 @@ $topLinks = [ 'class' => '' ] ]; + +// $addMenuLinks is 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. +$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' => 'person_roles', + 'action' => 'add', + 'icon' => 'emoji_people' + ], + [ + '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' + ] +]; $subnav = [ 'name' => 'person', diff --git a/app/templates/Standard/add-edit-view.php b/app/templates/Standard/add-edit-view.php index 3f84dd449..803acb082 100644 --- a/app/templates/Standard/add-edit-view.php +++ b/app/templates/Standard/add-edit-view.php @@ -79,52 +79,9 @@ 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..51721b8bc 100644 --- a/app/templates/element/subnavigation.php +++ b/app/templates/element/subnavigation.php @@ -98,95 +98,6 @@