From d04efb232c1421a8e2524198dd54e07b1e1d7498 Mon Sep 17 00:00:00 2001 From: iglocska Date: Fri, 6 Nov 2020 10:25:22 +0100 Subject: [PATCH] fix: [encryption keys] adding a key correctly returns the expected view elements - also some minor tweaks on the index - CRUD component now accepts a redirect parameter - as reported by cert.pl --- src/Controller/Component/CRUDComponent.php | 12 ++++++++++-- src/Controller/EncryptionKeysController.php | 2 +- templates/EncryptionKeys/index.php | 9 ++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Controller/Component/CRUDComponent.php b/src/Controller/Component/CRUDComponent.php index 900efa1..bf5247e 100644 --- a/src/Controller/Component/CRUDComponent.php +++ b/src/Controller/Component/CRUDComponent.php @@ -96,7 +96,11 @@ class CRUDComponent extends Component $this->Controller->render($params['displayOnSuccess']); return; } - $this->Controller->redirect(['action' => 'view', $data->id]); + if (empty($params['redirect'])) { + $this->Controller->redirect(['action' => 'view', $id]); + } else { + $this->Controller->redirect($params['redirect']); + } } } else { $validationMessage = $this->prepareValidationError($data); @@ -194,7 +198,11 @@ class CRUDComponent extends Component $this->Controller->restResponsePayload = $this->RestResponse->viewData($data, 'json'); } else { $this->Controller->Flash->success($message); - $this->Controller->redirect(['action' => 'view', $id]); + if (empty($params['redirect'])) { + $this->Controller->redirect(['action' => 'view', $id]); + } else { + $this->Controller->redirect($params['redirect']); + } } } else { $validationMessage = $this->prepareValidationError($data); diff --git a/src/Controller/EncryptionKeysController.php b/src/Controller/EncryptionKeysController.php index 4f52160..32c7d3b 100644 --- a/src/Controller/EncryptionKeysController.php +++ b/src/Controller/EncryptionKeysController.php @@ -37,7 +37,7 @@ class EncryptionKeysController extends AppController public function add() { - $this->CRUD->add(['displayOnSuccess' => 'add_success']); + $this->CRUD->add(['redirect' => $this->referer()]); if ($this->ParamHandler->isRest()) { return $this->restResponsePayload; } diff --git a/templates/EncryptionKeys/index.php b/templates/EncryptionKeys/index.php index 2d197fa..106b5ee 100644 --- a/templates/EncryptionKeys/index.php +++ b/templates/EncryptionKeys/index.php @@ -35,9 +35,9 @@ echo $this->element('genericElements/IndexTable/index_table', [ 'data_path' => 'id', ], [ - 'name' => __('Owner type'), - 'sort' => 'owner_type', - 'data_path' => 'owner_type', + 'name' => __('Type'), + 'sort' => 'type', + 'data_path' => 'type', ], [ 'name' => __('Owner ID'), @@ -64,8 +64,7 @@ echo $this->element('genericElements/IndexTable/index_table', [ ], [ 'name' => __('Key'), - 'data_path' => 'encryption_key', - 'privacy' => 1 + 'data_path' => 'encryption_key' ], ], 'title' => __('Encryption key Index'),