From da768747ec5d08cf0436f67bd86c88d535617646 Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Tue, 13 Sep 2022 19:39:15 -0400 Subject: [PATCH] Add actions dropdown to People index (CFM-207) (#51) * Add actions dropdown to People index. Allow overriding of icon CSS class. (CFM-207) * Modify dropdown menu colors to improve contrast and link clarity. (CFM-207) --- app/src/Model/Table/PeopleTable.php | 13 ++++ app/templates/People/actions.inc | 103 +++++++++++++++++++++++++++ app/templates/Standard/index.php | 50 +------------ app/templates/element/menuAction.php | 12 +++- app/webroot/css/co-base.css | 8 ++- app/webroot/css/co-color.css | 1 + 6 files changed, 137 insertions(+), 50 deletions(-) create mode 100644 app/templates/People/actions.inc diff --git a/app/src/Model/Table/PeopleTable.php b/app/src/Model/Table/PeopleTable.php index d7288c949..e8fd6b365 100644 --- a/app/src/Model/Table/PeopleTable.php +++ b/app/src/Model/Table/PeopleTable.php @@ -139,6 +139,19 @@ public function initialize(array $config): void { 'table' => [ 'add' => ['platformAdmin', 'coAdmin'], 'index' => ['platformAdmin', 'coAdmin'] + ], + // Related models whose permissions we'll need, typically for table views + 'related' => [ + 'Addresses', + 'AdHocAttributes', + 'Names', + 'EmailAddresses', + 'ExternalIdentities', + 'HistoryRecords', + 'Identifiers', + 'PersonRoles', + 'TelephoneNumbers', + 'Urls' ] ]); } diff --git a/app/templates/People/actions.inc b/app/templates/People/actions.inc new file mode 100644 index 000000000..5d0cfa8d1 --- /dev/null +++ b/app/templates/People/actions.inc @@ -0,0 +1,103 @@ + 'names', + 'action' => 'index', + 'icon' => 'account_box', + 'iconClass' => 'material-icons-outlined', + 'type' => 'tab' + ], + [ + 'controller' => 'email_addresses', + 'action' => 'index', + 'icon' => 'email', + 'iconClass' => 'material-icons-outlined', + 'type' => 'tab' + ], + [ + 'controller' => 'identifiers', + 'action' => 'index', + 'icon' => 'fingerprint', + 'type' => 'tab', + 'class' => 'bottom-border' + ], + [ + 'controller' => 'person_roles', + 'action' => 'index', + 'icon' => 'emoji_people', + 'type' => 'tab' + ], + [ + 'controller' => 'external_identities', + 'action' => 'index', + 'icon' => 'system_update_alt', + 'type' => 'tab', + 'class' => 'bottom-border' + ], + [ + 'controller' => 'ad_hoc_attributes', + 'action' => 'index', + 'icon' => 'check_box', + 'iconClass' => 'material-icons-outlined', + 'type' => 'tab' + ], + [ + 'controller' => 'addresses', + 'action' => 'index', + 'icon' => 'contact_mail', + 'iconClass' => 'material-icons-outlined', + 'type' => 'tab' + ], + [ + 'controller' => 'history_records', + 'action' => 'index', + 'icon' => 'history', + 'type' => 'tab' + ], + [ + 'controller' => 'telephone_numbers', + 'action' => 'index', + 'icon' => 'phone', + 'type' => 'tab' + ], + [ + 'controller' => 'urls', + 'action' => 'index', + 'icon' => 'link', + 'type' => 'tab' + ] +]; diff --git a/app/templates/Standard/index.php b/app/templates/Standard/index.php index 3f8ce602a..656932ec9 100644 --- a/app/templates/Standard/index.php +++ b/app/templates/Standard/index.php @@ -237,30 +237,9 @@ function _column_key($modelsName, $c, $tz=null) { // Action list for command menu dropdown / button listing $action_args = array(); $action_args['vv_attr_id'] = $entity->id; - - // Edit / View - /* TODO: Keep as reference for now; ultimately remove. - * if($vv_permission_set[$entity->id]['edit']) { - $action_args['vv_actions'][] = array( - 'order' => $this->Menu->getMenuOrder('Edit'), - 'icon' => $this->Menu->getMenuIcon('Edit'), - 'url' => $this->Url->build(['action' => 'edit', $entity->id]), - 'label' => __d('operation', 'edit') - ); - } elseif($vv_permission_set[$entity->id]['view']) { - $action_args['vv_actions'][] = array( - 'order' => $this->Menu->getMenuOrder('View'), - 'icon' => $this->Menu->getMenuIcon('View'), - 'url' => $this->Url->build(['action' => 'view', $entity->id]), - 'label' => __d('operation', 'view') - ); - }*/ // 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 - // XXX this isn't quite the right test - // if(isset($entity->status) && $entity->status == StatusEnum::Active) { + // 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($actions as $a) { $ok = false; @@ -284,6 +263,7 @@ function _column_key($modelsName, $c, $tz=null) { if($ok) { $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 = ''; $actionLabel = ''; @@ -338,6 +318,7 @@ function _column_key($modelsName, $c, $tz=null) { $action_args['vv_actions'][] = array( 'order' => $actionOrder, 'icon' => $actionIcon, + 'iconClass' => $actionIconClass, 'url' => $actionUrl, 'label' => $actionLabel, 'class' => $actionClass, @@ -346,31 +327,6 @@ function _column_key($modelsName, $c, $tz=null) { } } -// } - - // Delete - /* TODO: Keep as reference for now - ultimately remove. - * if($vv_permission_set[$entity->id]['delete']) { - $actionPostBtnArray = ['action' => 'delete', $entity->id]; - $actionUrl = $this->Url->build(['action' => 'delete', $entity->id]); - $action_args['vv_actions'][] = array( - 'order' => $this->Menu->getMenuOrder('Delete'), - 'icon' => $this->Menu->getMenuIcon('Delete'), - 'url' => 'javascript:void(0);', - 'label' => __d('operation', 'delete'), - 'class' => 'deletebutton nospin', - 'onclick' => array( - 'dg_bd_txt' => __d('operation', 'delete.confirm', [$entity->id]), - 'dg_post_btn_array' => $actionPostBtnArray, - 'dg_url' => $actionUrl, - 'dg_conf_btn' => __d('operation', 'remove'), - 'dg_cancel_btn' => __d('operation', 'cancel'), - 'dg_title' => __d('operation', 'remove'), - 'dg_bd_txt_repl_str' => '' - ), - ); - }*/ - ?> diff --git a/app/templates/element/menuAction.php b/app/templates/element/menuAction.php index 80f732367..18fa989e1 100644 --- a/app/templates/element/menuAction.php +++ b/app/templates/element/menuAction.php @@ -64,7 +64,11 @@ class=""> - + + + + + @@ -85,7 +89,11 @@ class=""> - + + + + + diff --git a/app/webroot/css/co-base.css b/app/webroot/css/co-base.css index 858d47b69..0d2e3862c 100644 --- a/app/webroot/css/co-base.css +++ b/app/webroot/css/co-base.css @@ -751,12 +751,15 @@ a.action-menu-toggle { } .field-actions a.dropdown-item { padding: 0.5em 1em; - color: var(--cmg-color-gray-001); + color: var(--cmg-color-blue-002); } #main .field-actions a.dropdown-item:hover { color: var(--cmg-color-black); text-decoration: none; } +.dropdown-item { + background-color: var(--cmg-color-lightgray-011); +} .dropdown-item.active, .dropdown-item:active { background-color: var(--cmg-color-lightgray-004); @@ -764,6 +767,9 @@ a.action-menu-toggle { a.dropdown-item.deletebutton { color: var(--cmg-color-red-002); } +.dropdown-item.bottom-border { + border-bottom: 1px solid var(--cmg-color-lightgray-005); +} /* INDEX ACTION BULK EDIT */ .field-actions.top-links #bulk-edit-switch-container { padding: 0.5em 1em; diff --git a/app/webroot/css/co-color.css b/app/webroot/css/co-color.css index 1576ec0f0..38f2b6a9a 100644 --- a/app/webroot/css/co-color.css +++ b/app/webroot/css/co-color.css @@ -54,6 +54,7 @@ --cmg-color-lightgray-008: #bbb; /* border color */ --cmg-color-lightgray-009: #ededed; /* data-list background color */ --cmg-color-lightgray-010: #e8e8e8; /* co-grid background color */ + --cmg-color-lightgray-011: #fcfcfc; /* action dropdown menu background color */ /* Greens */ --cmg-color-green-001: #b4ffba; /* alert: success */