From 10113d578c2a4ac4fbf4f9d97b74ba095a9a92e2 Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Tue, 1 Feb 2022 21:50:59 -0500 Subject: [PATCH 1/2] Provide topLinks delete for edit view; also clean up some DOM elements to ensure HTML and WCAG validation (CMF-55) --- app/src/View/Helper/MenuHelper.php | 2 + app/templates/Standard/add-edit-view.php | 52 ++++++++++++++++-------- app/templates/Standard/index.php | 2 +- app/templates/element/dialog.php | 2 +- app/templates/element/menuAction.php | 6 +-- app/templates/layout/default.php | 2 +- app/webroot/css/co-responsive.css | 7 ++++ 7 files changed, 50 insertions(+), 23 deletions(-) diff --git a/app/src/View/Helper/MenuHelper.php b/app/src/View/Helper/MenuHelper.php index 5d6deb7d7..3ac9dd8b6 100644 --- a/app/src/View/Helper/MenuHelper.php +++ b/app/src/View/Helper/MenuHelper.php @@ -49,6 +49,7 @@ public function getMenuOrder($action) { } $order = array( + 'Add' => 3, // add_circle 'View' => 5, // visibility 'Edit' => 10, // edit 'Default' => 20, // link - default starting order for arbitrary action menu items @@ -72,6 +73,7 @@ public function getMenuIcon($action) { } $icon = array( + 'Add' => 'add_circle', 'View' => 'visibility', 'Edit' => 'edit', 'Default' => 'link', // default icon for arbitrary menu items diff --git a/app/templates/Standard/add-edit-view.php b/app/templates/Standard/add-edit-view.php index f16ce1ef4..ecdf6f547 100644 --- a/app/templates/Standard/add-edit-view.php +++ b/app/templates/Standard/add-edit-view.php @@ -41,6 +41,41 @@

+ id; + + // TODO: More actions in the config? Add them to $action_args['vv_actions'][] here. + + // Delete + if($vv_action != 'add' && !empty($vv_obj->id) && $vv_permissions['delete']) { + $actionPostBtnArray = ['action' => 'delete', $vv_obj->id]; + $actionUrl = $this->Url->build(['action' => 'delete', $vv_obj->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', [$vv_obj->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' => '' + ) + ); + } + + if(!empty($action_args['vv_actions'])) { + print ''; + } + ?> -id) && $vv_permissions['delete']) { - print '\n"; -} // By default, the form will POST to the current controller // Note we need to open the form for view so Cake will autopopulate values diff --git a/app/templates/Standard/index.php b/app/templates/Standard/index.php index 9c54117bf..3c622c505 100644 --- a/app/templates/Standard/index.php +++ b/app/templates/Standard/index.php @@ -323,7 +323,7 @@ function _column_key($modelsName, $c, $tz=null) { // Insert additional actions as per the .inc file if(!empty($indexActions)) { - +// TODO: create an element or move this to MenuHelper so it can be used by topLinks as well as indexActions // XXX this isn't quite the right test // if(isset($entity->status) && $entity->status == StatusEnum::Active) { $actionOrderDefault = $this->Menu->getMenuOrder('Default'); diff --git a/app/templates/element/dialog.php b/app/templates/element/dialog.php index 724441136..c8ef2923f 100644 --- a/app/templates/element/dialog.php +++ b/app/templates/element/dialog.php @@ -35,7 +35,7 @@